Class: Tumbler::GemspecHelper
- Inherits:
-
Object
- Object
- Tumbler::GemspecHelper
- Defined in:
- lib/tumbler/gemspec_helper.rb
Instance Method Summary collapse
- #bin_files ⇒ Object
- #date ⇒ Object
- #files(test = nil) ⇒ Object
- #git_files ⇒ Object
-
#initialize(manager = nil) ⇒ GemspecHelper
constructor
A new instance of GemspecHelper.
- #inject_dependencies(gemspec) ⇒ Object
- #name ⇒ Object
- #version ⇒ Object
Constructor Details
#initialize(manager = nil) ⇒ GemspecHelper
Returns a new instance of GemspecHelper.
3 4 5 6 7 8 9 |
# File 'lib/tumbler/gemspec_helper.rb', line 3 def initialize(manager = nil) unless manager root = File.(File.dirname(Callsite.parse(caller).find{|c| c.filename =~ /\.gemspec$/}.filename)) manager = Tumbler.load(root) end @manager = manager end |
Instance Method Details
#bin_files ⇒ Object
27 28 29 |
# File 'lib/tumbler/gemspec_helper.rb', line 27 def bin_files git_files.select{|f| f[/^bin\//] }.map{|f| f[/bin\/(.*)/, 1]} end |
#date ⇒ Object
38 39 40 |
# File 'lib/tumbler/gemspec_helper.rb', line 38 def date Time.new.strftime("%Y-%m-%d") end |
#files(test = nil) ⇒ Object
23 24 25 |
# File 'lib/tumbler/gemspec_helper.rb', line 23 def files(test = nil) git_files.select{|f| test.nil? or f.index(test) } end |
#git_files ⇒ Object
19 20 21 |
# File 'lib/tumbler/gemspec_helper.rb', line 19 def git_files @git_files ||= Dir.chdir(@manager.base) { `git ls-files`.split("\n") } end |
#inject_dependencies(gemspec) ⇒ Object
31 32 33 34 35 36 |
# File 'lib/tumbler/gemspec_helper.rb', line 31 def inject_dependencies(gemspec) @manager.bundler.dependencies.each do |dep| gemspec.add_runtime_dependency(dep.name, *dep.requirements_list) if dep.groups.include?(:default) gemspec.add_development_dependency(dep.name, *dep.requirements_list) if dep.groups.include?(:development) end end |
#name ⇒ Object
15 16 17 |
# File 'lib/tumbler/gemspec_helper.rb', line 15 def name @manager.name end |
#version ⇒ Object
11 12 13 |
# File 'lib/tumbler/gemspec_helper.rb', line 11 def version @manager.version.to_s end |