Class: Jeweler::GemSpecHelper
- Inherits:
-
Object
- Object
- Jeweler::GemSpecHelper
- Defined in:
- lib/jeweler/gemspec.rb
Instance Attribute Summary collapse
-
#base_dir ⇒ Object
Returns the value of attribute base_dir.
-
#spec ⇒ Object
Returns the value of attribute spec.
Instance Method Summary collapse
-
#initialize(spec, base_dir = nil) {|spec| ... } ⇒ GemSpecHelper
constructor
A new instance of GemSpecHelper.
- #parse ⇒ Object
- #path ⇒ Object
- #valid? ⇒ Boolean
- #write ⇒ Object
Constructor Details
#initialize(spec, base_dir = nil) {|spec| ... } ⇒ GemSpecHelper
Returns a new instance of GemSpecHelper.
7 8 9 10 11 12 |
# File 'lib/jeweler/gemspec.rb', line 7 def initialize(spec, base_dir = nil) self.spec = spec self.base_dir = base_dir || '' yield spec if block_given? end |
Instance Attribute Details
#base_dir ⇒ Object
Returns the value of attribute base_dir.
5 6 7 |
# File 'lib/jeweler/gemspec.rb', line 5 def base_dir @base_dir end |
#spec ⇒ Object
Returns the value of attribute spec.
5 6 7 |
# File 'lib/jeweler/gemspec.rb', line 5 def spec @spec end |
Instance Method Details
#parse ⇒ Object
35 36 37 38 |
# File 'lib/jeweler/gemspec.rb', line 35 def parse data = File.read(path) Thread.new { eval("$SAFE = 3\n#{data}", binding, path) }.join end |
#path ⇒ Object
29 30 31 32 33 |
# File 'lib/jeweler/gemspec.rb', line 29 def path denormalized_path = File.join(@base_dir, "#{@spec.name}.gemspec") absolute_path = File.(denormalized_path) absolute_path.gsub(Dir.getwd + File::SEPARATOR, '') end |
#valid? ⇒ Boolean
14 15 16 17 18 19 20 21 |
# File 'lib/jeweler/gemspec.rb', line 14 def valid? begin parse true rescue false end end |
#write ⇒ Object
23 24 25 26 27 |
# File 'lib/jeweler/gemspec.rb', line 23 def write File.open(path, 'w') do |f| f.write @spec.to_ruby end end |