Class: Luban::Deployment::Helpers::Configuration::Finder
- Inherits:
-
Object
- Object
- Luban::Deployment::Helpers::Configuration::Finder
- Defined in:
- lib/luban/deployment/helpers/configuration.rb
Direct Known Subclasses
Defined Under Namespace
Classes: Application, Project
Instance Attribute Summary collapse
-
#base_path ⇒ Object
readonly
Returns the value of attribute base_path.
-
#config_file ⇒ Object
readonly
Returns the value of attribute config_file.
-
#config_path ⇒ Object
readonly
Returns the value of attribute config_path.
-
#config_root ⇒ Object
readonly
Returns the value of attribute config_root.
-
#stage_config_file ⇒ Object
readonly
Returns the value of attribute stage_config_file.
-
#stage_config_path ⇒ Object
readonly
Returns the value of attribute stage_config_path.
-
#stage_templates_path ⇒ Object
readonly
Returns the value of attribute stage_templates_path.
-
#target ⇒ Object
readonly
Returns the value of attribute target.
-
#templates_path ⇒ Object
readonly
Returns the value of attribute templates_path.
Class Method Summary collapse
- .application(target) ⇒ Object
- .default_templates_paths ⇒ Object
- .find_default_template_file(file_name) ⇒ Object
- .project(target) ⇒ Object
Instance Method Summary collapse
- #deployfile ⇒ Object
- #find_template_file(file_name) ⇒ Object
-
#initialize(target) ⇒ Finder
constructor
A new instance of Finder.
- #load_configuration ⇒ Object
- #load_general_configuration ⇒ Object
- #load_stage_configuration ⇒ Object
- #stagefile ⇒ Object
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_path ⇒ Object (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_file ⇒ Object (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_path ⇒ Object (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_root ⇒ Object (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_file ⇒ Object (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_path ⇒ Object (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_path ⇒ Object (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 |
#target ⇒ Object (readonly)
Returns the value of attribute target.
132 133 134 |
# File 'lib/luban/deployment/helpers/configuration.rb', line 132 def target @target end |
#templates_path ⇒ Object (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_paths ⇒ Object
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 |
Instance Method Details
#deployfile ⇒ Object
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_configuration ⇒ Object
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_configuration ⇒ Object
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_configuration ⇒ Object
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 |
#stagefile ⇒ Object
148 |
# File 'lib/luban/deployment/helpers/configuration.rb', line 148 def stagefile; @stagefile ||= "#{target.stage}.rb"; end |