Class: Kamaze::Project::Tools::Gemspec::Reader
- Inherits:
-
BaseTool
- Object
- Observable
- BaseTool
- Kamaze::Project::Tools::Gemspec::Reader
- Defined in:
- lib/kamaze/project/tools/gemspec/reader.rb
Overview
Read gemspec
file
Retrieve Gem::Specification
through read
method.
Defined Under Namespace
Classes: Decorator
Instance Attribute Summary collapse
- #gem_name ⇒ String
- #observer_peers ⇒ Hash|nil included from Concern::Observable readonly protected
-
#project ⇒ Object|Kamaze::Project
Get project.
Instance Method Summary collapse
- #mutable_attributes ⇒ Object
- #pwd ⇒ Pathname
-
#read(type = nil) ⇒ Gem::Specification|Object
Read gemspec (as given
type
). - #setup ⇒ Object protected
-
#spec ⇒ Gem::Specification|Object
protected
Read sepc file.
-
#spec_file ⇒ Pathname
Get (gem)spec file path.
Constructor Details
This class inherits a constructor from Kamaze::Project::Tools::BaseTool
Instance Attribute Details
#gem_name ⇒ String
22 23 24 |
# File 'lib/kamaze/project/tools/gemspec/reader.rb', line 22 def gem_name @gem_name end |
#observer_peers ⇒ Hash|nil (readonly, protected) Originally defined in module Concern::Observable
Instance Method Details
#mutable_attributes ⇒ Object
27 28 29 |
# File 'lib/kamaze/project/tools/gemspec/reader.rb', line 27 def mutable_attributes [:project, :gem_name] end |
#pwd ⇒ Pathname
32 33 34 |
# File 'lib/kamaze/project/tools/gemspec/reader.rb', line 32 def pwd Pathname.new(Dir.pwd) end |
#read(type = nil) ⇒ Gem::Specification|Object
Read gemspec (as given type
)
Return Gem::Specification
or given type
43 44 45 |
# File 'lib/kamaze/project/tools/gemspec/reader.rb', line 43 def read(type = nil) type ? Decorator.new(spec).to(type) : spec end |
#setup ⇒ Object (protected)
63 64 65 |
# File 'lib/kamaze/project/tools/gemspec/reader.rb', line 63 def setup @gem_name ||= project.name end |
#spec ⇒ Gem::Specification|Object (protected)
Read sepc file.
71 72 73 74 75 76 77 |
# File 'lib/kamaze/project/tools/gemspec/reader.rb', line 71 def spec Dir.chdir(pwd) do return Gem::Specification.new unless spec_file.file? eval(self.spec_file.read, binding, self.spec_file.to_s) # rubocop:disable Security/Eval end end |