Class: MountainBerryFields

Inherits:
Object
  • Object
show all
Defined in:
lib/mountain_berry_fields.rb,
lib/mountain_berry_fields/test.rb,
lib/mountain_berry_fields/parser.rb,
lib/mountain_berry_fields/version.rb,
lib/mountain_berry_fields/evaluator.rb,
lib/mountain_berry_fields/interface.rb,
lib/mountain_berry_fields/rake_task.rb,
lib/mountain_berry_fields/test/always_fail.rb,
lib/mountain_berry_fields/test/always_pass.rb,
lib/mountain_berry_fields/command_line_interaction.rb

Overview

Ties everything together. It gets the file, passes it to the parser, passes the result to the evaluator, and writes the file. If anything goes wrong along the way, it declares the failure to the interaction

Defined Under Namespace

Modules: Interface Classes: CommandLineInteraction, Evaluator, Parser, RakeTask, Test

Constant Summary collapse

VERSION =
"1.0.3"

Instance Method Summary collapse

Constructor Details

#initialize(argv) ⇒ MountainBerryFields

Returns a new instance of MountainBerryFields.


17
18
19
20
# File 'lib/mountain_berry_fields.rb', line 17

def initialize(argv)
  self.argv = argv
  self.full_filename = File.expand_path filename if filename
end

Instance Method Details

#evaluatorObject


27
28
29
# File 'lib/mountain_berry_fields.rb', line 27

def evaluator
  @evaluator ||= evaluator_class.new parser.parse
end

#executeObject


22
23
24
25
# File 'lib/mountain_berry_fields.rb', line 22

def execute
  return false if missing_input_file? || invalid_filename? || nonexistent_file?
  execute!
end

#parserObject


31
32
33
34
35
# File 'lib/mountain_berry_fields.rb', line 31

def parser
  @parser ||= parser_class.new  file_class.read(full_filename),
                                visible:   evaluator_class.visible_commands,
                                invisible: evaluator_class.invisible_commands
end