diff options
author | Andre Arko <andre@arko.net> | 2015-01-24 20:14:25 -0800 |
---|---|---|
committer | Andre Arko <andre@arko.net> | 2015-01-25 23:30:18 -0800 |
commit | ab3e21784c6c18702869c771fbe7ae23c82cc7c0 (patch) | |
tree | a9d44d74600128ba68f2b5d91b6276d607b3d388 | |
parent | 30903263a4ff69275f4075742dc2ab928de31167 (diff) | |
download | bundler-ab3e21784c6c18702869c771fbe7ae23c82cc7c0.tar.gz |
move gem bins to exe/ and add console and setup
-rw-r--r-- | lib/bundler/cli/gem.rb | 9 | ||||
-rw-r--r-- | lib/bundler/templates/newgem/README.md.tt | 6 | ||||
-rw-r--r-- | lib/bundler/templates/newgem/bin/console.tt | 14 | ||||
-rw-r--r-- | lib/bundler/templates/newgem/bin/newgem.tt | 3 | ||||
-rw-r--r-- | lib/bundler/templates/newgem/bin/setup.tt | 7 | ||||
-rw-r--r-- | lib/bundler/templates/newgem/exe/newgem.tt | 3 | ||||
-rw-r--r-- | lib/bundler/templates/newgem/newgem.gemspec.tt | 8 |
7 files changed, 40 insertions, 10 deletions
diff --git a/lib/bundler/cli/gem.rb b/lib/bundler/cli/gem.rb index 2bb0b53ae2..78b7da5253 100644 --- a/lib/bundler/cli/gem.rb +++ b/lib/bundler/cli/gem.rb @@ -36,7 +36,8 @@ module Bundler :author => git_user_name.empty? ? "TODO: Write your name" : git_user_name, :email => git_user_email.empty? ? "TODO: Write your email address" : git_user_email, :test => options[:test], - :ext => options[:ext] + :ext => options[:ext], + :bin => options[:bin] } templates = { @@ -46,7 +47,9 @@ module Bundler "lib/newgem/version.rb.tt" => "lib/#{namespaced_path}/version.rb", "newgem.gemspec.tt" => "#{name}.gemspec", "Rakefile.tt" => "Rakefile", - "README.md.tt" => "README.md" + "README.md.tt" => "README.md", + "bin/console.tt" => "bin/console", + "bin/setup.tt" => "bin/setup" } if ask_and_set(:coc, "Do you want to include a code of conduct in gems you generate?", @@ -85,7 +88,7 @@ module Bundler end end - templates.merge!("bin/newgem.tt" => "bin/#{name}") if options[:bin] + templates.merge!("exe/newgem.tt" => "exe/#{name}") if options[:bin] if options[:ext] templates.merge!( diff --git a/lib/bundler/templates/newgem/README.md.tt b/lib/bundler/templates/newgem/README.md.tt index 1a8737eb39..d1d5dc47ca 100644 --- a/lib/bundler/templates/newgem/README.md.tt +++ b/lib/bundler/templates/newgem/README.md.tt @@ -24,6 +24,12 @@ Or install it yourself as: TODO: Write usage instructions here +## Development + +After checking out the repo, run `bin/setup` to install dependencies. Then, run `bin/console` for an interactive prompt that will allow you to experiment. <% if config[:bin] %>Run `bundle exec <%= config[:name] %>` to use the code located in this directory, ignoring other installed copies of this gem.<% end %> + +To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release` to create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org). + ## Contributing 1. Fork it ( https://github.com/[my-github-username]/<%=config[:name]%>/fork ) diff --git a/lib/bundler/templates/newgem/bin/console.tt b/lib/bundler/templates/newgem/bin/console.tt new file mode 100644 index 0000000000..f402bd639e --- /dev/null +++ b/lib/bundler/templates/newgem/bin/console.tt @@ -0,0 +1,14 @@ +#!/usr/bin/env ruby + +require "bundler/setup" +require "<%= config[:namespaced_path] %>" + +# You can add fixtures and/or initialization code here to make experimenting +# with your gem easier. You can also use a different console, if you like. + +# (If you use this, don't forget to add pry to your Gemfile!) +# require "pry" +# Pry.start + +require "irb" +IRB.start diff --git a/lib/bundler/templates/newgem/bin/newgem.tt b/lib/bundler/templates/newgem/bin/newgem.tt deleted file mode 100644 index a005298815..0000000000 --- a/lib/bundler/templates/newgem/bin/newgem.tt +++ /dev/null @@ -1,3 +0,0 @@ -#!/usr/bin/env ruby - -require '<%= config[:namespaced_path] %>' diff --git a/lib/bundler/templates/newgem/bin/setup.tt b/lib/bundler/templates/newgem/bin/setup.tt new file mode 100644 index 0000000000..b65ed50ff1 --- /dev/null +++ b/lib/bundler/templates/newgem/bin/setup.tt @@ -0,0 +1,7 @@ +#!/bin/bash +set -euo pipefail +IFS=$'\n\t' + +bundle install + +# Do any other automated setup that you need to do here diff --git a/lib/bundler/templates/newgem/exe/newgem.tt b/lib/bundler/templates/newgem/exe/newgem.tt new file mode 100644 index 0000000000..a8339bb79f --- /dev/null +++ b/lib/bundler/templates/newgem/exe/newgem.tt @@ -0,0 +1,3 @@ +#!/usr/bin/env ruby + +require "<%= config[:namespaced_path] %>" diff --git a/lib/bundler/templates/newgem/newgem.gemspec.tt b/lib/bundler/templates/newgem/newgem.gemspec.tt index de80065b2f..efc08c9544 100644 --- a/lib/bundler/templates/newgem/newgem.gemspec.tt +++ b/lib/bundler/templates/newgem/newgem.gemspec.tt @@ -13,17 +13,17 @@ Gem::Specification.new do |spec| spec.metadata['allowed_push_host'] = "TODO: Set to 'http://mygemserver.com' to prevent pushes to rubygems.org, or delete to allow pushes to any server." end -<%- if config[:ext] -%> - spec.extensions = ["ext/<%=config[:underscored_name]%>/extconf.rb"] -<%- end -%> spec.summary = %q{TODO: Write a short summary, because Rubygems requires one.} spec.description = %q{TODO: Write a longer description or delete this line.} spec.homepage = "TODO: Put your gem's website or public repo URL here." spec.license = "MIT" spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) } - spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) } + spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) } spec.require_paths = ["lib"] +<%- if config[:ext] -%> + spec.extensions = ["ext/<%=config[:underscored_name]%>/extconf.rb"] +<%- end -%> spec.add_development_dependency "bundler", "~> <%= Bundler::VERSION.split(".")[0..1].join(".") %>" spec.add_development_dependency "rake", "~> 10.0" |