Class: FileParser
- Inherits:
-
Object
- Object
- FileParser
- Defined in:
- lib/file_parser.rb
Overview
Parses code in a file
Constant Summary collapse
- RUNNABLE_TAG =
:runnable
Instance Attribute Summary collapse
-
#clazz ⇒ Object
readonly
Returns the value of attribute clazz.
-
#initialize_method ⇒ Object
readonly
Returns the value of attribute initialize_method.
-
#run_method ⇒ Object
readonly
Returns the value of attribute run_method.
-
#runnable_methods ⇒ Object
readonly
Returns the value of attribute runnable_methods.
Class Method Summary collapse
-
.select_runnable_tags(yard_object) ⇒ Array(YARD::Tags::Tag)
Select all @runnable tags from of specified object.
Instance Method Summary collapse
-
#initialize(file_path) ⇒ FileParser
constructor
Parse file with #YARD::CLI::Stats.
Constructor Details
#initialize(file_path) ⇒ FileParser
Parse file with #YARD::CLI::Stats
16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/file_parser.rb', line 16 def initialize(file_path) raise RubyFireCLIError "Cannot find file #{file_path}" unless File.exist?(file_path) code = YARD::CLI::Stats.new code.run(file_path) @all_objects = code.all_objects runnable_classes = list_classes(:runnable) raise RubyFireCLIError, 'At least one runnable Class should be specified in file' if runnable_classes.count != 1 @clazz = runnable_classes.first all_methods = list_methods(:all, clazz) @runnable_methods = list_methods(:runnable, clazz) @initialize_method = all_methods.find { |m| m.name == :initialize } @run_method = all_methods.find { |m| m.name == :run } end |
Instance Attribute Details
#clazz ⇒ Object (readonly)
Returns the value of attribute clazz.
8 9 10 |
# File 'lib/file_parser.rb', line 8 def clazz @clazz end |
#initialize_method ⇒ Object (readonly)
Returns the value of attribute initialize_method.
8 9 10 |
# File 'lib/file_parser.rb', line 8 def initialize_method @initialize_method end |
#run_method ⇒ Object (readonly)
Returns the value of attribute run_method.
8 9 10 |
# File 'lib/file_parser.rb', line 8 def run_method @run_method end |
#runnable_methods ⇒ Object (readonly)
Returns the value of attribute runnable_methods.
8 9 10 |
# File 'lib/file_parser.rb', line 8 def runnable_methods @runnable_methods end |
Class Method Details
.select_runnable_tags(yard_object) ⇒ Array(YARD::Tags::Tag)
Select all @runnable tags from of specified object
34 35 36 |
# File 'lib/file_parser.rb', line 34 def self.(yard_object) yard_object..select { |t| t.tag_name == RUNNABLE_TAG.to_s } end |