Class: Roodi::Core::Runner
- Inherits:
-
Object
- Object
- Roodi::Core::Runner
- Defined in:
- lib/roodi/core/runner.rb
Constant Summary collapse
- DEFAULT_CONFIG =
File.join(File.dirname(__FILE__), "..", "..", "..", "roodi.yml")
Instance Attribute Summary collapse
-
#config ⇒ Object
writeonly
Sets the attribute config.
Instance Method Summary collapse
- #check(filename, content) ⇒ Object
- #check_content(content, filename = "dummy-file.rb") ⇒ Object
- #check_file(filename) ⇒ Object
- #errors ⇒ Object
-
#initialize(*checks) ⇒ Runner
constructor
A new instance of Runner.
- #print(filename, content) ⇒ Object
- #print_content(content) ⇒ Object
- #print_file(filename) ⇒ Object
Constructor Details
#initialize(*checks) ⇒ Runner
Returns a new instance of Runner.
15 16 17 18 19 |
# File 'lib/roodi/core/runner.rb', line 15 def initialize(*checks) @config = DEFAULT_CONFIG @checks = checks unless checks.empty? @parser = Parser.new end |
Instance Attribute Details
#config=(value) ⇒ Object (writeonly)
Sets the attribute config
13 14 15 |
# File 'lib/roodi/core/runner.rb', line 13 def config=(value) @config = value end |
Instance Method Details
#check(filename, content) ⇒ Object
21 22 23 24 25 26 27 28 |
# File 'lib/roodi/core/runner.rb', line 21 def check(filename, content) @checks ||= load_checks @checker ||= CheckingVisitor.new(@checks) @checks.each {|check| check.start_file(filename)} node = parse(filename, content) node.accept(@checker) if node @checks.each {|check| check.end_file(filename)} end |
#check_content(content, filename = "dummy-file.rb") ⇒ Object
30 31 32 |
# File 'lib/roodi/core/runner.rb', line 30 def check_content(content, filename = "dummy-file.rb") check(filename, content) end |
#check_file(filename) ⇒ Object
34 35 36 |
# File 'lib/roodi/core/runner.rb', line 34 def check_file(filename) check(filename, File.read(filename)) end |
#errors ⇒ Object
52 53 54 55 56 |
# File 'lib/roodi/core/runner.rb', line 52 def errors @checks ||= [] all_errors = @checks.collect {|check| check.errors} all_errors.flatten end |
#print(filename, content) ⇒ Object
38 39 40 41 42 |
# File 'lib/roodi/core/runner.rb', line 38 def print(filename, content) node = @parser.parse(content, filename) puts "Line: #{node.line}" pp node end |
#print_content(content) ⇒ Object
44 45 46 |
# File 'lib/roodi/core/runner.rb', line 44 def print_content(content) print("dummy-file.rb", content) end |
#print_file(filename) ⇒ Object
48 49 50 |
# File 'lib/roodi/core/runner.rb', line 48 def print_file(filename) print(filename, File.read(filename)) end |