Class: Dependabot::Bundler::FileUpdater::GemspecDependencyNameFinder
- Inherits:
-
Object
- Object
- Dependabot::Bundler::FileUpdater::GemspecDependencyNameFinder
- Defined in:
- lib/dependabot/bundler/file_updater/gemspec_dependency_name_finder.rb
Instance Attribute Summary collapse
-
#gemspec_content ⇒ Object
readonly
Returns the value of attribute gemspec_content.
Instance Method Summary collapse
-
#dependency_name ⇒ Object
rubocop:disable Security/Eval.
-
#initialize(gemspec_content:) ⇒ GemspecDependencyNameFinder
constructor
A new instance of GemspecDependencyNameFinder.
Constructor Details
#initialize(gemspec_content:) ⇒ GemspecDependencyNameFinder
Returns a new instance of GemspecDependencyNameFinder.
13 14 15 |
# File 'lib/dependabot/bundler/file_updater/gemspec_dependency_name_finder.rb', line 13 def initialize(gemspec_content:) @gemspec_content = gemspec_content end |
Instance Attribute Details
#gemspec_content ⇒ Object (readonly)
Returns the value of attribute gemspec_content.
11 12 13 |
# File 'lib/dependabot/bundler/file_updater/gemspec_dependency_name_finder.rb', line 11 def gemspec_content @gemspec_content end |
Instance Method Details
#dependency_name ⇒ Object
rubocop:disable Security/Eval
18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/dependabot/bundler/file_updater/gemspec_dependency_name_finder.rb', line 18 def dependency_name ast = Parser::CurrentRuby.parse(gemspec_content) dependency_name_node = find_dependency_name_node(ast) return unless dependency_name_node begin eval(dependency_name_node.children[2].loc.expression.source) rescue StandardError nil # If we can't evaluate the expression just return nil end end |