Class: RailsParser::Parsers::Rails::ConfigParser

Inherits:
SexpProcessor
  • Object
show all
Defined in:
lib/rails_parser/parsers/rails/config_parser.rb

Overview

Gemfile Parser

The class inspects an application.rb config file and extracts the options

It works like this: parser = ApplicationConfigParser.new parser.parse(“/path/to/application.rb”) parser.application_name #=> “Foobar”

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfigParser

Returns a new instance of ConfigParser.



17
18
19
20
21
# File 'lib/rails_parser/parsers/rails/config_parser.rb', line 17

def initialize
  super
  self.auto_shift_type = true
  @config_options = {}
end

Instance Attribute Details

#config_optionsObject (readonly)

Returns the value of attribute config_options.



15
16
17
# File 'lib/rails_parser/parsers/rails/config_parser.rb', line 15

def config_options
  @config_options
end

Instance Method Details

#process_attrasgn(exp) ⇒ Object



23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/rails_parser/parsers/rails/config_parser.rb', line 23

def process_attrasgn(exp)
  object = exp.shift
  variable = exp.shift
  value = exp.shift
  
  ap object
  
  variable = variable[0...-1].to_sym
  value = value[1][1]
  @config_options[variable] = value
  exp
end

#process_op_asgn2(exp) ⇒ Object



36
37
38
# File 'lib/rails_parser/parsers/rails/config_parser.rb', line 36

def process_op_asgn2(exp)
  ap exp
end