Skip to content
This repository has been archived by the owner on Apr 14, 2021. It is now read-only.
Permalink
Browse files
move gem bins to exe/ and add console and setup
  • Loading branch information
indirect committed Jan 26, 2015
1 parent 3090326 commit ab3e217
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 10 deletions.
@@ -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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@sanemat
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@indirect
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@bf4
Copy link

@bf4 bf4 commented on ab3e217 Feb 19, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@indirect
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@bf4
Copy link

@bf4 bf4 commented on ab3e217 Feb 19, 2015 via email

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@simi
Copy link
Member

@simi simi commented on ab3e217 Feb 19, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@indirect
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@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
Copy link

@bf4 bf4 commented on ab3e217 Feb 19, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll submit an outline for discussion.

@bf4
Copy link

@bf4 bf4 commented on ab3e217 Feb 19, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@schneems
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
Copy link
Member Author

@indirect indirect commented on ab3e217 Oct 5, 2015 via email

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.