Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
Browse files

move gem bins to exe/ and add console and setup

  • Loading branch information
indirect committed Jan 25, 2015
1 parent 3090326 commit ab3e21784c6c18702869c771fbe7ae23c82cc7c0
@@ -36,7 +36,8 @@ def run
: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 @@ def run
"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 @@ def run
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!(
@@ -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 )
@@ -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

This file was deleted.

@@ -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
@@ -0,0 +1,3 @@
#!/usr/bin/env ruby

require "<%= config[:namespaced_path] %>"
@@ -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"

13 comments on commit ab3e217

@sanemat

This comment has been minimized.

Copy link
Contributor

@sanemat sanemat replied Feb 11, 2015

@indirect
bundler v1.8.0 recommends moving from bin/my-command to exe/my-command? I think this is big change 😅

@sanemat

This comment has been minimized.

Copy link
Contributor

@sanemat sanemat replied Feb 11, 2015

sorry, I'll post this question to bundler mailing list 🙇

@indirect

This comment has been minimized.

Copy link
Member Author

@indirect indirect replied Feb 12, 2015

@sanemat it's a suggestion for new gems, not a suggestion to move your current binaries. old gems will keep working the way they always have. the reason is that rails, bundler, and the gem itself all want to use bin/ for scripts that are specific to the given repository, and rubygems bins are not usable directly. you could even create a bin/my-command for development if you want, while keeping the command that will ship inside your .gem file in exe/.

@sanemat

This comment has been minimized.

Copy link
Contributor

@sanemat sanemat replied Feb 12, 2015

@indirect thanks! I understand. I hope this to change log 😍

@bf4

This comment has been minimized.

Copy link

@bf4 bf4 replied Feb 19, 2015

@indirect

This comment has been minimized.

Copy link
Member Author

@indirect indirect replied Feb 19, 2015

@bf4 want to write about it for the Bundler blog? 😀

@bf4

This comment has been minimized.

Copy link

@bf4 bf4 replied Feb 19, 2015

@simi

This comment has been minimized.

Copy link
Contributor

@simi simi replied Feb 19, 2015

@indirect

This comment has been minimized.

Copy link
Member Author

@indirect indirect replied Feb 19, 2015

@bf4 you can send a pull request if you feel like you know what you'd like to say, or drop me an email to discuss if you'd like to talk about it first.

@bf4

This comment has been minimized.

Copy link

@bf4 bf4 replied Feb 19, 2015

I'll submit an outline for discussion.

@bf4

This comment has been minimized.

Copy link

@bf4 bf4 replied Feb 19, 2015

@schneems

This comment has been minimized.

Copy link
Contributor

@schneems schneems replied Oct 5, 2015

Maybe we can auto generate an exe dir and put a .gitkeep in there? Can we add some warnings or something? This change in behavior was a headscratcher for me, thought it had something to do with how I named my executable, or file permissions, or a number of other things. Took about an hour playing around with, until I finally tweeted out and someone pointed out the problem in the gemspec.

@indirect

This comment has been minimized.

Copy link
Member Author

@indirect indirect replied Oct 5, 2015

Please sign in to comment.
You can’t perform that action at this time.