class Figs::Application
Constants
- FIGS_ENV_PREFIX
Attributes
path[W]
stage[W]
Public Class Methods
new(options = {})
click to toggle source
# File lib/figs/application.rb, line 17 def initialize(options = {}) @figsfile = options[:file] @stage = options[:stage] load_path end
Public Instance Methods
configuration()
click to toggle source
# File lib/figs/application.rb, line 59 def configuration global_configuration.merge(stage_configuration) end
each(&block)
click to toggle source
# File lib/figs/application.rb, line 75 def each(&block) configuration.each(&block) end
env()
click to toggle source
# File lib/figs/application.rb, line 71 def env Figs::ENV end
figsfile()
click to toggle source
# File lib/figs/application.rb, line 47 def figsfile (@figsfile || default_figsfile) end
flattened_filenames(filenames)
click to toggle source
# File lib/figs/application.rb, line 27 def flattened_filenames(filenames) Figs::DirectoryFlattener.flattened_filenames(filenames) end
load()
click to toggle source
# File lib/figs/application.rb, line 63 def load each do |key, value| set(key, value) unless skip?(key) end ensure Figs::GitHandler.clear_temp_files end
load_path()
click to toggle source
# File lib/figs/application.rb, line 31 def load_path if figsfile["method"].eql? "git" @path = path_from_git(figsfile["repo"], flattened_filenames(figsfile["locations"])) else @path = flattened_filenames(figsfile["locations"]) end end
locations()
click to toggle source
# File lib/figs/application.rb, line 23 def locations figsfile["locations"] end
path()
click to toggle source
# File lib/figs/application.rb, line 51 def path (@path || default_path) end
path_from_git(git_path, filenames = nil)
click to toggle source
# File lib/figs/application.rb, line 39 def path_from_git(git_path, filenames = nil) if(locations.is_a?(Array)) Figs::GitHandler.location(git_path, filenames) else Figs::GitHandler.location(git_path, @stage) end end
stage()
click to toggle source
# File lib/figs/application.rb, line 55 def stage (@stage || default_stage).to_s end
Private Instance Methods
default_figsfile()
click to toggle source
# File lib/figs/application.rb, line 89 def default_figsfile raise NotImplementedError end
default_path()
click to toggle source
# File lib/figs/application.rb, line 81 def default_path raise NotImplementedError end
default_stage()
click to toggle source
# File lib/figs/application.rb, line 85 def default_stage "test" end
global_configuration()
click to toggle source
# File lib/figs/application.rb, line 107 def global_configuration raw_configuration.reject { |key, value| key.to_s.eql?(stage) && value.is_a?(Hash) } end
non_string_configuration!(value)
click to toggle source
# File lib/figs/application.rb, line 125 def non_string_configuration!(value) warn "WARNING: Use strings for Fig configuration. #{value.inspect} was converted to #{value.to_s.inspect}." end
parse(paths)
click to toggle source
# File lib/figs/application.rb, line 101 def parse(paths) parse = {} paths.is_a?(Array) ? paths.each { |path| parse.merge!(parse_path(path)) } : parse.merge!(parse_path(paths)) parse end
parse_path(path)
click to toggle source
# File lib/figs/application.rb, line 97 def parse_path(path) File.exist?(path) && YAML.load(ERB.new(File.read(path)).result) || {} end
raw_configuration()
click to toggle source
# File lib/figs/application.rb, line 93 def raw_configuration (@parsed ||= Hash.new { |hash, path| hash[path] = parse(path) })[path] end
set(key, value)
click to toggle source
# File lib/figs/application.rb, line 115 def set(key, value) # FigsFigs::ENV.set_array(key, value) unless !value.is_a?(Array) Figs::ENV[key] = value Figs::ENV[FIGS_ENV_PREFIX + key.to_s] = value end
skip?(key)
click to toggle source
# File lib/figs/application.rb, line 121 def skip?(key) Figs::ENV.key?(key.to_s) && !Figs::ENV.key?(FIGS_ENV_PREFIX + key.to_s) end
stage_configuration()
click to toggle source
# File lib/figs/application.rb, line 111 def stage_configuration raw_configuration.fetch(stage) { {} } end