Class: Figs::Application

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/figs/application.rb

Constant Summary collapse

FIGS_ENV_PREFIX =
"_FIGS_"

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Application

Returns a new instance of Application.



17
18
19
20
21
# File 'lib/figs/application.rb', line 17

def initialize(options = {})
  @figsfile = options[:file]
  @stage = options[:stage]
  load_path
end

Instance Attribute Details

#pathObject



51
52
53
# File 'lib/figs/application.rb', line 51

def path
  (@path || default_path)
end

#stageObject



55
56
57
# File 'lib/figs/application.rb', line 55

def stage
  (@stage || default_stage).to_s
end

Instance Method Details

#configurationObject



59
60
61
# File 'lib/figs/application.rb', line 59

def configuration
  global_configuration.merge(stage_configuration)
end

#each(&block) ⇒ Object



75
76
77
# File 'lib/figs/application.rb', line 75

def each(&block)
  configuration.each(&block)
end

#envObject



71
72
73
# File 'lib/figs/application.rb', line 71

def env
  Figs::ENV
end

#figsfileObject



47
48
49
# File 'lib/figs/application.rb', line 47

def figsfile
  (@figsfile || default_figsfile)
end

#flattened_filenames(filenames) ⇒ Object



27
28
29
# File 'lib/figs/application.rb', line 27

def flattened_filenames(filenames)
  Figs::DirectoryFlattener.flattened_filenames(filenames)
end

#loadObject



63
64
65
66
67
68
69
# 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_pathObject



31
32
33
34
35
36
37
# 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

#locationsObject



23
24
25
# File 'lib/figs/application.rb', line 23

def locations
  figsfile["locations"]
end

#path_from_git(git_path, filenames = nil) ⇒ Object



39
40
41
42
43
44
45
# 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