Class: Guard::Guardfile::Evaluator
- Inherits:
-
Object
- Object
- Guard::Guardfile::Evaluator
- Defined in:
- lib/guard/guardfile/evaluator.rb
Overview
This class is responsible for evaluating the Guardfile. It delegates to Guard::Dsl for the actual objects generation from the Guardfile content.
Defined Under Namespace
Classes: NoCustomGuardfile, NoGuardfileError
Constant Summary collapse
- DEFAULT_GUARDFILES =
%w( guardfile.rb Guardfile ~/.Guardfile ).freeze
- EVALUATOR_OPTIONS =
%i[guardfile inline].freeze
Instance Attribute Summary collapse
-
#guardfile_path ⇒ Object
readonly
Returns the value of attribute guardfile_path.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
- #custom? ⇒ Boolean
-
#evaluate ⇒ Object
Evaluates the DSL methods in the
Guardfile
. - #guardfile_contents ⇒ Object
-
#guardfile_include?(plugin_name) ⇒ Boolean
Tests if the current
Guardfile
contains a specific Guard plugin. -
#initialize(options = {}) ⇒ Evaluator
constructor
Initializes a new Guard::Guardfile::Evaluator object.
- #inline? ⇒ Boolean
Constructor Details
#initialize(options = {}) ⇒ Evaluator
Initializes a new Guard::Guardfile::Evaluator object.
content of a valid Guardfile
42 43 44 45 46 |
# File 'lib/guard/guardfile/evaluator.rb', line 42 def initialize( = {}) @guardfile_path = nil @options = Options.new(.slice(*Guard::Guardfile::Evaluator::EVALUATOR_OPTIONS)) @dsl = Dsl.new end |
Instance Attribute Details
#guardfile_path ⇒ Object (readonly)
Returns the value of attribute guardfile_path.
25 26 27 |
# File 'lib/guard/guardfile/evaluator.rb', line 25 def guardfile_path @guardfile_path end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
25 26 27 |
# File 'lib/guard/guardfile/evaluator.rb', line 25 def @options end |
Instance Method Details
#custom? ⇒ Boolean
77 78 79 |
# File 'lib/guard/guardfile/evaluator.rb', line 77 def custom? !![:guardfile] end |
#evaluate ⇒ Object
Evaluates the DSL methods in the Guardfile
.
52 53 54 55 56 57 |
# File 'lib/guard/guardfile/evaluator.rb', line 52 def evaluate @evaluate ||= begin dsl.evaluate(guardfile_contents, guardfile_path || "", 1) dsl.result end end |
#guardfile_contents ⇒ Object
85 86 87 88 89 90 91 |
# File 'lib/guard/guardfile/evaluator.rb', line 85 def guardfile_contents @guardfile_contents ||= begin _use_inline || _use_custom || _use_default [@contents, _user_config].compact.join("\n") end end |
#guardfile_include?(plugin_name) ⇒ Boolean
Tests if the current Guardfile
contains a specific Guard plugin.
plugin
File.read('Guardfile') => "guard :rspec"
Guard::Guardfile::Evaluator.new.guardfile_include?('rspec') => true
73 74 75 |
# File 'lib/guard/guardfile/evaluator.rb', line 73 def guardfile_include?(plugin_name) evaluate.plugin_names.include?(plugin_name.to_sym) end |
#inline? ⇒ Boolean
81 82 83 |
# File 'lib/guard/guardfile/evaluator.rb', line 81 def inline? !![:inline] end |