summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHomu <homu@barosl.com>2016-01-24 09:32:26 +0900
committerHomu <homu@barosl.com>2016-01-24 09:32:26 +0900
commit0ae330ede86905a17bb940b686d45e19b79f7e41 (patch)
treeabd1fff98256323a716e687be84963a11722162a
parentd36d0129d18e409f5ccb9758d2383a6c8d184f7e (diff)
parent95d65d5870da321d78505612a325d81f19b23d9a (diff)
downloadbundler-0ae330ede86905a17bb940b686d45e19b79f7e41.tar.gz
Auto merge of #4225 - christhekeele:bundle-gem-with-exe, r=indirect
Use 'bundle gem --exe' as primary option name, in addition to '--bin'. This furthers the v1.8 transition of conventionally using the `exe/` folder for bins, leaving the `bin/` folder for binstubs, by allowing the flag that auto-generates a starter file in the `exe/` folder to logically be referred to as `--exe`. This is a follow-up on the discussion at bundler/bundler-features#105.
-rw-r--r--lib/bundler/cli.rb2
-rw-r--r--lib/bundler/cli/gem.rb4
-rw-r--r--man/bundle-gem.ronn10
-rw-r--r--spec/commands/newgem_spec.rb18
4 files changed, 25 insertions, 9 deletions
diff --git a/lib/bundler/cli.rb b/lib/bundler/cli.rb
index d97503435d..477224e4e9 100644
--- a/lib/bundler/cli.rb
+++ b/lib/bundler/cli.rb
@@ -358,7 +358,7 @@ module Bundler
end
desc "gem GEM [OPTIONS]", "Creates a skeleton for creating a rubygem"
- method_option :bin, :type => :boolean, :default => false, :aliases => "-b", :desc => "Generate a binary for your library."
+ method_option :exe, :type => :boolean, :default => false, :aliases => ["--bin", "-b"], :desc => "Generate a binary executable for your library."
method_option :coc, :type => :boolean, :desc => "Generate a code of conduct file. Set a default with `bundle config gem.coc true`."
method_option :edit, :type => :string, :aliases => "-e", :required => false, :banner => "EDITOR",
:lazy_default => [ENV["BUNDLER_EDITOR"], ENV["VISUAL"], ENV["EDITOR"]].find {|e| !e.nil? && !e.empty? },
diff --git a/lib/bundler/cli/gem.rb b/lib/bundler/cli/gem.rb
index ca90f274c5..96d5a6849a 100644
--- a/lib/bundler/cli/gem.rb
+++ b/lib/bundler/cli/gem.rb
@@ -42,7 +42,7 @@ module Bundler
:email => git_user_email.empty? ? "TODO: Write your email address" : git_user_email,
:test => options[:test],
:ext => options[:ext],
- :bin => options[:bin],
+ :exe => options[:exe],
:bundler_version => bundler_dependency_version
}
ensure_safe_gem_name(name, constant_array)
@@ -109,7 +109,7 @@ module Bundler
templates.merge!("CODE_OF_CONDUCT.md.tt" => "CODE_OF_CONDUCT.md")
end
- templates.merge!("exe/newgem.tt" => "exe/#{name}") if options[:bin]
+ templates.merge!("exe/newgem.tt" => "exe/#{name}") if config[:exe]
if options[:ext]
templates.merge!(
diff --git a/man/bundle-gem.ronn b/man/bundle-gem.ronn
index 769e5263f5..8e57189f83 100644
--- a/man/bundle-gem.ronn
+++ b/man/bundle-gem.ronn
@@ -24,13 +24,13 @@ configuration file using the following names:
## OPTIONS
-* `-b` or `--bin`:
- Specify that Bundler should create a binary (as `exe/GEM_NAME`) in the
- generated rubygem project. This binary will also be added to the
+* `--exe` or `-b` or `--bin`:
+ Specify that Bundler should create a binary executable (as `exe/GEM_NAME`)
+ in the generated rubygem project. This binary will also be added to the
`GEM_NAME.gemspec` manifest. This behavior is disabled by default.
-* `--no-bin`:
- Do not create a binary (overrides `--bin` specified in the global config).
+* `--no-exe`:
+ Do not create a binary (overrides `--exe` specified in the global config).
* `--coc`:
Add a `CODE_OF_CONDUCT.md` file to the root of the generated project. If
diff --git a/spec/commands/newgem_spec.rb b/spec/commands/newgem_spec.rb
index 6cd8f86dd8..732097dacc 100644
--- a/spec/commands/newgem_spec.rb
+++ b/spec/commands/newgem_spec.rb
@@ -253,6 +253,22 @@ describe "bundle gem" do
end
end
+ context "--exe parameter set" do
+ before do
+ reset!
+ in_app_root
+ bundle "gem #{gem_name} --exe"
+ end
+
+ it "builds exe skeleton" do
+ expect(bundled_app("test_gem/exe/test_gem")).to exist
+ end
+
+ it "requires 'test-gem'" do
+ expect(bundled_app("test_gem/exe/test_gem").read).to match(/require "test_gem"/)
+ end
+ end
+
context "--bin parameter set" do
before do
reset!
@@ -260,7 +276,7 @@ describe "bundle gem" do
bundle "gem #{gem_name} --bin"
end
- it "builds bin skeleton" do
+ it "builds exe skeleton" do
expect(bundled_app("test_gem/exe/test_gem")).to exist
end