-
-
Save franckverrot/1008733 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Gem::Specification.new do |s| | |
# totally generic | |
version_file = Dir['lib/*/{*/,}version.rb'].first | |
s.name = version_file.split('/')[1..-2].join('-') | |
s.files = `git ls-files`.split("\n") | |
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n") | |
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) } | |
s.authors = `git shortlog -sn`.scan(/[^\d\s].*/) | |
s.email = `git shortlog -sne`.scan(/[^<]+@[^>]+/) | |
s.require_paths = ["lib"] | |
# generic, but you might want to change it | |
github_user = `git config github.user`.strip | |
s.homepage = "http://github.com/#{github_user}/#{s.name}" | |
fail "`git config github.users` not set" if github_user.empty? | |
# let's figure out the version | |
wrapper = Module.new | |
wrapper.module_eval File.read(version_file) | |
wrapper.constants.map { |n| wrapper.const_get(n) }.each do |c| | |
if c.const_defined? :VERSION | |
s.version = c::VERSION | |
elsif nested = c.constants.detect { |n| c.const_get(n).const_defined? :VERSION } | |
s.version = nested::VERSION | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment