Class: Cukedep::Config

Inherits:
Struct
  • Object
show all
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

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#after_all_f_actionsObject

Returns the value of attribute after_all_f_actions

Returns:

  • (Object)

    the current value of 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_actionsObject

Returns the value of attribute after_each_f_actions

Returns:

  • (Object)

    the current value of 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_actionsObject

Returns the value of attribute before_all_f_actions

Returns:

  • (Object)

    the current value of 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_actionsObject

Returns the value of attribute before_each_f_actions

Returns:

  • (Object)

    the current value of 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_argsObject

Returns the value of attribute cucumber_args

Returns:

  • (Object)

    the current value of cucumber_args



9
10
11
# File 'lib/cukedep/config.rb', line 9

def cucumber_args
  @cucumber_args
end

#feature2idObject

Returns the value of attribute feature2id

Returns:

  • (Object)

    the current value of feature2id



9
10
11
# File 'lib/cukedep/config.rb', line 9

def feature2id
  @feature2id
end

#feature_encodingObject

Returns the value of attribute feature_encoding

Returns:

  • (Object)

    the current value of feature_encoding



9
10
11
# File 'lib/cukedep/config.rb', line 9

def feature_encoding
  @feature_encoding
end

#graph_fileObject

Returns the value of attribute graph_file

Returns:

  • (Object)

    the current value of graph_file



9
10
11
# File 'lib/cukedep/config.rb', line 9

def graph_file
  @graph_file
end

#id2featureObject

Returns the value of attribute id2feature

Returns:

  • (Object)

    the current value of id2feature



9
10
11
# File 'lib/cukedep/config.rb', line 9

def id2feature
  @id2feature
end

#proj_dirObject

Returns the value of attribute proj_dir

Returns:

  • (Object)

    the current value of proj_dir



9
10
11
# File 'lib/cukedep/config.rb', line 9

def proj_dir
  @proj_dir
end

#rake_fileObject

Returns the value of attribute rake_file

Returns:

  • (Object)

    the current value of rake_file



9
10
11
# File 'lib/cukedep/config.rb', line 9

def rake_file
  @rake_file
end

Class Method Details

.defaultObject

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_tripletObject

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_attrsObject

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