Class: CI::ConfigHelper
- Inherits:
-
Object
- Object
- CI::ConfigHelper
- Defined in:
- lib/source/helpers.rb
Overview
Helper for setting up environment dependent config files for CI. It expects to find ERB templates for config files in rails-root/config/ci/ which it renders with the rails_root and ci_env variables.
Defined Under Namespace
Classes: ConfigTemplate
Constant Summary collapse
- DEFAULT_CONFIG_PATHS =
%W[ config/environments/test.rb ]
Instance Attribute Summary collapse
-
#ci_env ⇒ Object
readonly
Returns the value of attribute ci_env.
-
#rails_root ⇒ Object
readonly
Returns the value of attribute rails_root.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(rails_root, ci_env, config_paths) ⇒ ConfigHelper
constructor
A new instance of ConfigHelper.
- #setup! ⇒ Object
- #setup_configs! ⇒ Object
- #setup_environment! ⇒ Object
Constructor Details
#initialize(rails_root, ci_env, config_paths) ⇒ ConfigHelper
Returns a new instance of ConfigHelper.
38 39 40 41 42 |
# File 'lib/source/helpers.rb', line 38 def initialize(rails_root, ci_env, config_paths) @rails_root = rails_root @ci_env = ci_env @config_paths = config_paths end |
Instance Attribute Details
#ci_env ⇒ Object (readonly)
Returns the value of attribute ci_env.
9 10 11 |
# File 'lib/source/helpers.rb', line 9 def ci_env @ci_env end |
#rails_root ⇒ Object (readonly)
Returns the value of attribute rails_root.
9 10 11 |
# File 'lib/source/helpers.rb', line 9 def rails_root @rails_root end |
Class Method Details
.setup!(rails_root, ci_env, config_paths = DEFAULT_CONFIG_PATHS) ⇒ Object
15 16 17 |
# File 'lib/source/helpers.rb', line 15 def self.setup!(rails_root, ci_env, config_paths=DEFAULT_CONFIG_PATHS) new(rails_root, ci_env, config_paths).setup! end |
Instance Method Details
#setup! ⇒ Object
44 45 46 47 |
# File 'lib/source/helpers.rb', line 44 def setup! setup_configs! setup_environment! end |
#setup_configs! ⇒ Object
60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/source/helpers.rb', line 60 def setup_configs! find_config_templates.each do |template| result = ConfigTemplate.new(template, ) file_name = destination_config(template) File.open(file_name, 'w') do |f| f.write(result) end puts "~> Generated: #{file_name}" puts result end end |
#setup_environment! ⇒ Object
49 50 51 52 53 54 55 56 57 58 |
# File 'lib/source/helpers.rb', line 49 def setup_environment! return if 'test' == ci_env @config_paths.each do |path| test_config = File.join(rails_root, path) env_config = destination_config_path(path) FileUtils.ln_sf(test_config, env_config) end end |