Class: Cukedep::Config
- Inherits:
-
Struct
- Object
- Struct
- Cukedep::Config
- Defined in:
- lib/cukedep/config.rb,
lib/cukedep/config.rb
Overview
Re-open the class for further customisation Configuration object for the Cukedep application.
Instance Attribute Summary collapse
-
#after_all_f_actions ⇒ Object
Returns the value of attribute after_all_f_actions.
-
#after_each_f_actions ⇒ Object
Returns the value of attribute after_each_f_actions.
-
#before_all_f_actions ⇒ Object
Returns the value of attribute before_all_f_actions.
-
#before_each_f_actions ⇒ Object
Returns the value of attribute before_each_f_actions.
-
#cucumber_args ⇒ Object
Returns the value of attribute cucumber_args.
-
#feature2id ⇒ Object
Returns the value of attribute feature2id.
-
#feature_encoding ⇒ Object
Returns the value of attribute feature_encoding.
-
#graph_file ⇒ Object
Returns the value of attribute graph_file.
-
#id2feature ⇒ Object
Returns the value of attribute id2feature.
-
#proj_dir ⇒ Object
Returns the value of attribute proj_dir.
-
#rake_file ⇒ Object
Returns the value of attribute rake_file.
Class Method Summary collapse
-
.default ⇒ Object
Factory method.
-
.empty_action_triplet ⇒ Object
Return Hash config for a no-op action triplet.
-
.file_action_attrs ⇒ Object
Purpose: get the list of attributes referencing a file action triplet.
-
.load_cfg(filename) ⇒ Object
Read the YAML file with specified name from the current working directory.
Instance Method Summary collapse
-
#write(filename) ⇒ Object
Save the Config object to a YAML file.
Instance Attribute Details
#after_all_f_actions ⇒ Object
Returns the value of attribute after_all_f_actions
9 10 11 |
# File 'lib/cukedep/config.rb', line 9 def after_all_f_actions @after_all_f_actions end |
#after_each_f_actions ⇒ Object
Returns the value of attribute after_each_f_actions
9 10 11 |
# File 'lib/cukedep/config.rb', line 9 def after_each_f_actions @after_each_f_actions end |
#before_all_f_actions ⇒ Object
Returns the value of attribute before_all_f_actions
9 10 11 |
# File 'lib/cukedep/config.rb', line 9 def before_all_f_actions @before_all_f_actions end |
#before_each_f_actions ⇒ Object
Returns the value of attribute before_each_f_actions
9 10 11 |
# File 'lib/cukedep/config.rb', line 9 def before_each_f_actions @before_each_f_actions end |
#cucumber_args ⇒ Object
Returns the value of attribute cucumber_args
9 10 11 |
# File 'lib/cukedep/config.rb', line 9 def cucumber_args @cucumber_args end |
#feature2id ⇒ Object
Returns the value of attribute feature2id
9 10 11 |
# File 'lib/cukedep/config.rb', line 9 def feature2id @feature2id end |
#feature_encoding ⇒ Object
Returns the value of attribute feature_encoding
9 10 11 |
# File 'lib/cukedep/config.rb', line 9 def feature_encoding @feature_encoding end |
#graph_file ⇒ Object
Returns the value of attribute graph_file
9 10 11 |
# File 'lib/cukedep/config.rb', line 9 def graph_file @graph_file end |
#id2feature ⇒ Object
Returns the value of attribute id2feature
9 10 11 |
# File 'lib/cukedep/config.rb', line 9 def id2feature @id2feature end |
#proj_dir ⇒ Object
Returns the value of attribute proj_dir
9 10 11 |
# File 'lib/cukedep/config.rb', line 9 def proj_dir @proj_dir end |
#rake_file ⇒ Object
Returns the value of attribute rake_file
9 10 11 |
# File 'lib/cukedep/config.rb', line 9 def rake_file @rake_file end |
Class Method Details
.default ⇒ Object
Factory method. Build a config object with default settings.
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/cukedep/config.rb', line 28 def self.default instance = Config.new( 'UTF-8', nil, FileMetaData.new('feature2id.csv'), FileMetaData.new('feature2id.csv'), FileMetaData.new('dependencies.dot'), 'cukedep.rake', [] ) file_action_attrs.each do |attr| instance[attr] = empty_action_triplet end return instance end |
.empty_action_triplet ⇒ Object
Return Hash config for a no-op action triplet.
72 73 74 75 76 77 78 79 80 81 |
# File 'lib/cukedep/config.rb', line 72 def self.empty_action_triplet { save_patterns: [], save_subdir: '', delete_patterns: [], delete_subdir: '', copy_patterns: [], copy_subdir: '' } end |
.file_action_attrs ⇒ Object
Purpose: get the list of attributes referencing a file action triplet.
62 63 64 65 66 67 68 69 |
# File 'lib/cukedep/config.rb', line 62 def self.file_action_attrs return %I[ before_all_f_actions before_each_f_actions after_each_f_actions after_all_f_actions ] end |
.load_cfg(filename) ⇒ Object
Read the YAML file with specified name from the current working directory. If that file does not exist, then return an instance with default values.
48 49 50 51 52 53 |
# File 'lib/cukedep/config.rb', line 48 def self.load_cfg(filename) # TODO: validation instance = File.exist?(filename) ? YAML.load_file(filename) : default return instance end |
Instance Method Details
#write(filename) ⇒ Object
Save the Config object to a YAML file.
56 57 58 |
# File 'lib/cukedep/config.rb', line 56 def write(filename) File.open(filename, 'w') { |f| YAML.dump(self, f) } end |