Class: Gemologist::AbstractGemfile
- Inherits:
-
Object
- Object
- Gemologist::AbstractGemfile
- Defined in:
- lib/gemologist/abstract_gemfile.rb
Instance Attribute Summary collapse
-
#path ⇒ Object
readonly
Returns the value of attribute path.
Instance Method Summary collapse
- #dependencies ⇒ Object
- #find_dependency(name) ⇒ Object
-
#initialize(path) ⇒ AbstractGemfile
constructor
A new instance of AbstractGemfile.
- #rewrite! ⇒ Object
- #save ⇒ Object
Constructor Details
#initialize(path) ⇒ AbstractGemfile
Returns a new instance of AbstractGemfile.
9 10 11 |
# File 'lib/gemologist/abstract_gemfile.rb', line 9 def initialize(path) @path = path end |
Instance Attribute Details
#path ⇒ Object (readonly)
Returns the value of attribute path.
7 8 9 |
# File 'lib/gemologist/abstract_gemfile.rb', line 7 def path @path end |
Instance Method Details
#dependencies ⇒ Object
17 18 19 20 21 22 |
# File 'lib/gemologist/abstract_gemfile.rb', line 17 def dependencies @dependencies ||= ast.each_node.with_object([]) do |node, dependencies| next unless dependency_class.valid_node?(node) dependencies << dependency_class.new(node, source_rewriter) end end |
#find_dependency(name) ⇒ Object
13 14 15 |
# File 'lib/gemologist/abstract_gemfile.rb', line 13 def find_dependency(name) dependencies.find { |dep| dep.name == name } end |
#rewrite! ⇒ Object
29 30 31 32 |
# File 'lib/gemologist/abstract_gemfile.rb', line 29 def rewrite! Gemologist::UI.deprecate("#{self.class.name}##{__method__}", replacement: '#save') save end |
#save ⇒ Object
24 25 26 27 |
# File 'lib/gemologist/abstract_gemfile.rb', line 24 def save rewritten_source = source_rewriter.process File.write(path, rewritten_source) end |