Class: Calcifer::Finders::ModuleNameFinder
- Inherits:
-
Object
- Object
- Calcifer::Finders::ModuleNameFinder
- Defined in:
- lib/calcifer/finders/module_name_finder.rb
Constant Summary collapse
- MODULE_REGEX =
/^(module)\s\w+/.freeze
- CLASS_REGEX =
/^(class)\s\w+/.freeze
- ONE_LINE_CLASS_REGEX =
/^(class)\s\w+\s<\s\w+;\s(end)/.freeze
Instance Attribute Summary collapse
-
#modules ⇒ Object
readonly
Returns the value of attribute modules.
Instance Method Summary collapse
- #execute ⇒ Object
-
#initialize(file) ⇒ ModuleNameFinder
constructor
A new instance of ModuleNameFinder.
Constructor Details
#initialize(file) ⇒ ModuleNameFinder
Returns a new instance of ModuleNameFinder.
11 12 13 14 |
# File 'lib/calcifer/finders/module_name_finder.rb', line 11 def initialize(file) @file = file @module_name = [] end |
Instance Attribute Details
#modules ⇒ Object (readonly)
Returns the value of attribute modules.
9 10 11 |
# File 'lib/calcifer/finders/module_name_finder.rb', line 9 def modules @modules end |
Instance Method Details
#execute ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/calcifer/finders/module_name_finder.rb', line 16 def execute return unless @file @file.readlines.each do |line| next if one_line_class_definition?(line) if module_definition?(line) @module_name << line.gsub('module', '').strip elsif class_definition?(line) @module_name << line.gsub('class', '').gsub(/<(.*)/, '').strip break end end mount_module_name end |