Class: Luban::Deployment::Helpers::Configuration::Finder

Inherits:
Object
  • Object
show all
Defined in:
lib/luban/deployment/helpers/configuration.rb

Direct Known Subclasses

Application, Project

Defined Under Namespace

Classes: Application, Project

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(target) ⇒ Finder

Returns a new instance of Finder.



144
145
146
147
# File 'lib/luban/deployment/helpers/configuration.rb', line 144

def initialize(target)
  @target = target
  set_config_paths
end

Instance Attribute Details

#base_pathObject (readonly)

Returns the value of attribute base_path.



135
136
137
# File 'lib/luban/deployment/helpers/configuration.rb', line 135

def base_path
  @base_path
end

#config_fileObject (readonly)

Returns the value of attribute config_file.



137
138
139
# File 'lib/luban/deployment/helpers/configuration.rb', line 137

def config_file
  @config_file
end

#config_pathObject (readonly)

Returns the value of attribute config_path.



138
139
140
# File 'lib/luban/deployment/helpers/configuration.rb', line 138

def config_path
  @config_path
end

#config_rootObject (readonly)

Returns the value of attribute config_root.



136
137
138
# File 'lib/luban/deployment/helpers/configuration.rb', line 136

def config_root
  @config_root
end

#stage_config_fileObject (readonly)

Returns the value of attribute stage_config_file.



140
141
142
# File 'lib/luban/deployment/helpers/configuration.rb', line 140

def stage_config_file
  @stage_config_file
end

#stage_config_pathObject (readonly)

Returns the value of attribute stage_config_path.



141
142
143
# File 'lib/luban/deployment/helpers/configuration.rb', line 141

def stage_config_path
  @stage_config_path
end

#stage_templates_pathObject (readonly)

Returns the value of attribute stage_templates_path.



142
143
144
# File 'lib/luban/deployment/helpers/configuration.rb', line 142

def stage_templates_path
  @stage_templates_path
end

#targetObject (readonly)

Returns the value of attribute target.



134
135
136
# File 'lib/luban/deployment/helpers/configuration.rb', line 134

def target
  @target
end

#templates_pathObject (readonly)

Returns the value of attribute templates_path.



139
140
141
# File 'lib/luban/deployment/helpers/configuration.rb', line 139

def templates_path
  @templates_path
end

Class Method Details

.application(target) ⇒ Object



132
# File 'lib/luban/deployment/helpers/configuration.rb', line 132

def self.application(target); Application.new(target); end

.default_templates_pathsObject



88
89
90
91
# File 'lib/luban/deployment/helpers/configuration.rb', line 88

def self.default_templates_paths
  @default_templates_paths ||= 
    [Pathname.new(File.join(File.dirname(__FILE__), '..', 'templates')).realpath]
end

.find_default_template_file(file_name) ⇒ Object



93
94
95
96
# File 'lib/luban/deployment/helpers/configuration.rb', line 93

def self.find_default_template_file(file_name)
  path = default_templates_paths.find { |p| p.join(file_name).file? }
  return path.join(file_name) unless path.nil?
end

.project(target) ⇒ Object



131
# File 'lib/luban/deployment/helpers/configuration.rb', line 131

def self.project(target); Project.new(target); end

Instance Method Details

#deployfileObject



149
# File 'lib/luban/deployment/helpers/configuration.rb', line 149

def deployfile; @deployfile ||= 'deploy.rb';   end

#find_template_file(file_name) ⇒ Object



172
173
174
175
# File 'lib/luban/deployment/helpers/configuration.rb', line 172

def find_template_file(file_name)
  return file_path if (file_path = stage_templates_path.join(file_name)).file?
  return file_path if (file_path = templates_path.join(file_name)).file?
end

#load_configurationObject



152
153
154
155
# File 'lib/luban/deployment/helpers/configuration.rb', line 152

def load_configuration
  load_general_configuration
  load_stage_configuration
end

#load_general_configurationObject



157
158
159
# File 'lib/luban/deployment/helpers/configuration.rb', line 157

def load_general_configuration
  target.load_configuration_file(config_file)
end

#load_stage_configurationObject



161
162
163
164
165
166
167
168
169
170
# File 'lib/luban/deployment/helpers/configuration.rb', line 161

def load_stage_configuration
  target.load_configuration_file(stage_config_file)
  if File.directory?(stage_config_path)
    ["*.rb", "{packages}/**/*.rb"].each do |pattern|
      Dir[stage_config_path.join(pattern)].each do |file|
        target.load_configuration_file(file)
      end
    end
  end
end

#stagefileObject



150
# File 'lib/luban/deployment/helpers/configuration.rb', line 150

def stagefile;  @stagefile  ||= "#{target.stage}.rb"; end