Class: Mire::Analyzer
- Inherits:
-
Object
- Object
- Mire::Analyzer
- Includes:
- ConfigurationMethods
- Defined in:
- lib/mire/analyzer.rb
Overview
analyze all ruby files in a folder and find there usage
Constant Summary collapse
- BLACKLIST =
%i(lambda new inspect to_i to_a [] []= * | ! != !~ % & + -@ / < << <= <=> == === =~ > >= - __callee__ __send__ initialize method_missing)
- CALLBACKS =
%i(after_commit after_create after_destroy after_save after_update after_validation before_commit before_create before_destroy before_save before_update before_validation)
- BLOCKS =
%i(task)
- FILE =
'.mire_analysis.yml'
Instance Attribute Summary collapse
-
#methods ⇒ Object
readonly
Returns the value of attribute methods.
Instance Method Summary collapse
-
#initialize(files: nil) ⇒ Analyzer
constructor
A new instance of Analyzer.
- #run ⇒ Object
- #save ⇒ Object
Methods included from ConfigurationMethods
#configuration, #excluded_file?
Constructor Details
#initialize(files: nil) ⇒ Analyzer
Returns a new instance of Analyzer.
20 21 22 23 24 |
# File 'lib/mire/analyzer.rb', line 20 def initialize(files: nil) @namespace = [] @methods = {} @files = files || Dir['**/*.{rb,haml}'] end |
Instance Attribute Details
#methods ⇒ Object (readonly)
Returns the value of attribute methods.
6 7 8 |
# File 'lib/mire/analyzer.rb', line 6 def methods @methods end |
Instance Method Details
#run ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/mire/analyzer.rb', line 26 def run = ProgressBar.create(total: @files.count) @files.each do |file| @method = nil next if excluded_file?(file) @filename = file case file_type(file) when :haml parse_haml_file(file) when :rb parse_file(file) end @filename = nil .increment end self end |
#save ⇒ Object
44 45 46 |
# File 'lib/mire/analyzer.rb', line 44 def save IO.write(FILE, @methods.to_yaml) end |