Class: GemfileLocker::GemfileProcessor
- Inherits:
-
Object
- Object
- GemfileLocker::GemfileProcessor
- Defined in:
- lib/gemfile_locker/gemfile_processor.rb
Defined Under Namespace
Classes: Rewriter
Instance Attribute Summary collapse
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
Instance Method Summary collapse
- #call(string) ⇒ Object
-
#initialize(options = {}) ⇒ GemfileProcessor
constructor
A new instance of GemfileProcessor.
- #process_gem(_name, _data) ⇒ Object
- #skip_gem?(gem_entry) ⇒ Boolean
Constructor Details
#initialize(options = {}) ⇒ GemfileProcessor
Returns a new instance of GemfileProcessor.
23 24 25 |
# File 'lib/gemfile_locker/gemfile_processor.rb', line 23 def initialize( = {}) = end |
Instance Attribute Details
#options ⇒ Object (readonly)
Returns the value of attribute options.
21 22 23 |
# File 'lib/gemfile_locker/gemfile_processor.rb', line 21 def end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
21 22 23 |
# File 'lib/gemfile_locker/gemfile_processor.rb', line 21 def path @path end |
Instance Method Details
#call(string) ⇒ Object
27 28 29 30 31 32 33 34 35 |
# File 'lib/gemfile_locker/gemfile_processor.rb', line 27 def call(string) buffer = Parser::Source::Buffer.new('(Gemfile)') buffer.source = string parser = Parser::CurrentRuby.new ast = parser.parse(buffer) Rewriter.new.rewrite(buffer, ast) do |gem_entry| process_gem(gem_entry) unless skip_gem?(gem_entry) end end |
#process_gem(_name, _data) ⇒ Object
45 46 47 |
# File 'lib/gemfile_locker/gemfile_processor.rb', line 45 def process_gem(_name, _data) raise 'Abstract method' end |
#skip_gem?(gem_entry) ⇒ Boolean
37 38 39 40 41 42 43 |
# File 'lib/gemfile_locker/gemfile_processor.rb', line 37 def skip_gem?(gem_entry) if [:only] ![:only].include?(gem_entry.name) elsif [:except] [:except].include?(gem_entry.name) end end |