class GoldenChild::Configuration

Public Instance Methods

actual_root() click to toggle source

@return [Pathname] the directory in which “actual” results will be generated

# File lib/golden_child/configuration.rb, line 6
def actual_root
  golden_path + "actual"
end
add_content_filter(*patterns, &filter) click to toggle source

Add a filter for a given file pattern. Filters are useful for removing volatile information (like timestamps) from the files to be compared. NOTE: filters are currently not suitable for removing sensitive information, since they are only applied when diffing files. The files on disk are not filtered.

@param [Array<String, [#===]>] patterns Filename patterns that

determine which files this filter should be applied to. Strings are
treated as file glob patterns.

@yieldparam [String] file_content the contents of the file @yieldreturn [String] the filtered file contents

# File lib/golden_child/configuration.rb, line 52
def add_content_filter(*patterns, &filter)
  content_filters << BlockContentFilter.new(patterns, filter)
end
content_filters() click to toggle source

@return [Enumerable<BlockContentFilter>] the configured

content filters
# File lib/golden_child/configuration.rb, line 37
def content_filters
  @content_filters ||= []
end
env() click to toggle source

@return [Hash] The global, editable set of default env vars

# File lib/golden_child/configuration.rb, line 31
def env
  @env ||= {}
end
get_path_for_shortcode(code) click to toggle source

@param [String] code @return [String] path to the corresponding file @raise [UserError] if the shortcode is not found

TODO: Move this out of Configuration

# File lib/golden_child/configuration.rb, line 61
def get_path_for_shortcode(code)
  value = code[/\d+/].to_i
  state_transaction(read_only: true) do |store|
    store[:shortcode_map].invert.fetch(value) do
      fail UserError, "Shortcode not found: #{code}"
    end
  end
end
golden_path() click to toggle source

@return [Pathname] the root directory for everything GoldenChild does

# File lib/golden_child/configuration.rb, line 16
def golden_path
  Pathname("spec/golden")
end
master_root() click to toggle source

@return [Pathname] the base directory for gold master dirs

# File lib/golden_child/configuration.rb, line 11
def master_root
  golden_path + "master"
end
project_root() click to toggle source

@return [Pathname] the root directory of the current project

# File lib/golden_child/configuration.rb, line 21
def project_root
  @project_root ||= Pathname.pwd
end
project_root=(new_root) click to toggle source

@param [String, Pathname] new_root set the project root directory

# File lib/golden_child/configuration.rb, line 26
def project_root=(new_root)
  @project_root = Pathname(new_root).expand_path
end
state_transaction(read_only: false) { |store| ... } click to toggle source

@yield [YAML::Store]

TODO: Move this out of Configuration

# File lib/golden_child/configuration.rb, line 73
def state_transaction(read_only: false)
  config_dir = project_root + ".golden_child"
  mkpath config_dir unless config_dir.exist?
  state_db = config_dir + "state.yaml"
  store    = YAML::Store.new(state_db)
  store.transaction(read_only) do
    yield store
  end
end