Class: Tumbler::GemspecHelper

Inherits:
Object
  • Object
show all
Defined in:
lib/tumbler/gemspec_helper.rb

Instance Method Summary collapse

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.expand_path(File.dirname(Callsite.parse(caller).find{|c| c.filename =~ /\.gemspec$/}.filename))
    manager = Tumbler.load(root)
  end
  @manager = manager
end

Instance Method Details

#bin_filesObject



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

#dateObject



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_filesObject



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

#nameObject



15
16
17
# File 'lib/tumbler/gemspec_helper.rb', line 15

def name
  @manager.name
end

#versionObject



11
12
13
# File 'lib/tumbler/gemspec_helper.rb', line 11

def version
  @manager.version.to_s
end