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.



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

def initialize(target)
  @target = target
  set_config_paths
end

Instance Attribute Details

#base_pathObject (readonly)

Returns the value of attribute base_path.



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

def base_path
  @base_path
end

#config_fileObject (readonly)

Returns the value of attribute config_file.



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

def config_file
  @config_file
end

#config_pathObject (readonly)

Returns the value of attribute config_path.



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

def config_path
  @config_path
end

#config_rootObject (readonly)

Returns the value of attribute config_root.



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

def config_root
  @config_root
end

#stage_config_fileObject (readonly)

Returns the value of attribute stage_config_file.



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

def stage_config_file
  @stage_config_file
end

#stage_config_pathObject (readonly)

Returns the value of attribute stage_config_path.



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

def stage_config_path
  @stage_config_path
end

#stage_templates_pathObject (readonly)

Returns the value of attribute stage_templates_path.



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

def stage_templates_path
  @stage_templates_path
end

#targetObject (readonly)

Returns the value of attribute target.



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

def target
  @target
end

#templates_pathObject (readonly)

Returns the value of attribute templates_path.



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

def templates_path
  @templates_path
end

Class Method Details

.application(target) ⇒ Object



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

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

.default_templates_pathsObject



86
87
88
89
# File 'lib/luban/deployment/helpers/configuration.rb', line 86

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



91
92
93
94
# File 'lib/luban/deployment/helpers/configuration.rb', line 91

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



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

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

Instance Method Details

#deployfileObject



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

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

#find_template_file(file_name) ⇒ Object



170
171
172
173
# File 'lib/luban/deployment/helpers/configuration.rb', line 170

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



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

def load_configuration
  load_general_configuration
  load_stage_configuration
end

#load_general_configurationObject



155
156
157
# File 'lib/luban/deployment/helpers/configuration.rb', line 155

def load_general_configuration
  target.load_configuration_file(config_file)
end

#load_stage_configurationObject



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

def load_stage_configuration
  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
  target.load_configuration_file(stage_config_file)
end

#stagefileObject



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

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