Module: Comodule::Deployment::Base::InstanceMethods
- Defined in:
- lib/comodule/deployment/base.rb
Instance Method Summary collapse
- #aws_config_path ⇒ Object
- #common_config_dir ⇒ Object
- #common_config_path ⇒ Object
- #common_secret_config_dir ⇒ Object
- #common_secret_config_path ⇒ Object
- #config ⇒ Object
- #config_copy ⇒ Object
- #config_dir ⇒ Object
- #config_path ⇒ Object
- #file_copy(dir) ⇒ Object
- #file_path(*path) ⇒ Object
- #git_dir ⇒ Object
- #name ⇒ Object
- #platform_dir ⇒ Object
- #platform_root ⇒ Object
- #project_name ⇒ Object
- #project_root ⇒ Object
- #secret_config_dir ⇒ Object
- #secret_config_path ⇒ Object
- #test_dir ⇒ Object
- #tmp_dir ⇒ Object
- #tmp_project_dir ⇒ Object
- #tmp_projects_dir ⇒ Object
Instance Method Details
#aws_config_path ⇒ Object
92 93 94 |
# File 'lib/comodule/deployment/base.rb', line 92 def aws_config_path @aws_config_path ||= File.join(platform_root, 'aws_config.yml') end |
#common_config_dir ⇒ Object
104 105 106 |
# File 'lib/comodule/deployment/base.rb', line 104 def common_config_dir @common_config_dir ||= File.join(platform_root, 'config') end |
#common_config_path ⇒ Object
112 113 114 |
# File 'lib/comodule/deployment/base.rb', line 112 def common_config_path @common_config_path ||= File.join(platform_root, 'config.yml') end |
#common_secret_config_dir ⇒ Object
108 109 110 |
# File 'lib/comodule/deployment/base.rb', line 108 def common_secret_config_dir @common_secret_config_dir ||= File.join(platform_root, 'secret_config') end |
#common_secret_config_path ⇒ Object
116 117 118 |
# File 'lib/comodule/deployment/base.rb', line 116 def common_secret_config_path @common_secret_config_path ||= File.join(platform_root, 'secret_config.yml') end |
#config ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/comodule/deployment/base.rb', line 12 def config return @config if @config @config = ::Comodule::ConfigSupport::Config.new @config += yaml_to_config(aws_config_path) if File.file?(aws_config_path) @config += yaml_to_config(common_config_path) if File.file?(common_config_path) @config += yaml_to_config(config_path) @config += yaml_to_config(common_secret_config_path) if File.file?(common_secret_config_path) @config += yaml_to_config(secret_config_path) if File.file?(secret_config_path) if @config.config_files @config.config_files.each do |extend_path| path = File.join(platform_root, extend_path) @config += yaml_to_config(path) if File.file?(path) end end @config.platform_name = @name @config end |
#config_copy ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/comodule/deployment/base.rb', line 36 def config_copy return unless config.cp rm_rf File.join(test_dir, 'file_copy') if test? count = 0 count += file_copy(common_config_dir) count += file_copy(common_secret_config_dir) count += file_copy(config_dir) count += file_copy(secret_config_dir) return count end |
#config_dir ⇒ Object
96 97 98 |
# File 'lib/comodule/deployment/base.rb', line 96 def config_dir @config_dir ||= File.join(platform_dir, 'config') end |
#config_path ⇒ Object
120 121 122 |
# File 'lib/comodule/deployment/base.rb', line 120 def config_path @config_path ||= File.join(platform_dir, 'config.yml') end |
#file_copy(dir) ⇒ Object
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 |
# File 'lib/comodule/deployment/base.rb', line 51 def file_copy(dir) count = 0 paths = Dir.glob(File.join(dir, '**', '*')) order = config.cp.to_hash order.each do |key, path_head_list| [path_head_list].flatten.each do |path_head| wanted = %r|^#{File.join(dir, key.to_s)}| paths.each do |file_path| next unless File.file?(file_path) next unless file_path =~ wanted path_tail = file_path.sub(wanted, '') path = File.join(path_head, path_tail) path = File.join(test_dir, 'file_copy', path) if test? dirname, filename = File.split(path) be_dir(dirname) if file_path =~ /\.erb$/ File.open(path.sub(/\.erb$/, ''), 'w') do |file| file.write render(file_path) end else FileUtils.cp file_path, "#{dirname}/" end count += 1 end end end count end |
#file_path(*path) ⇒ Object
152 153 154 155 156 157 158 159 |
# File 'lib/comodule/deployment/base.rb', line 152 def file_path(*path) path = File.join(*path) if path =~ %r|^platform/(.*)| File.join(platform_root, $1) else File.join(platform_dir, path) end end |
#git_dir ⇒ Object
148 149 150 |
# File 'lib/comodule/deployment/base.rb', line 148 def git_dir @git_dir ||= File.join(project_root, '.git') end |
#name ⇒ Object
165 166 167 |
# File 'lib/comodule/deployment/base.rb', line 165 def name @name end |
#platform_dir ⇒ Object
161 162 163 |
# File 'lib/comodule/deployment/base.rb', line 161 def platform_dir @platform_dir ||= File.join(platform_root, name) end |
#platform_root ⇒ Object
182 183 184 |
# File 'lib/comodule/deployment/base.rb', line 182 def platform_root @platform_root ||= File.join(project_root, 'platform') end |
#project_name ⇒ Object
144 145 146 |
# File 'lib/comodule/deployment/base.rb', line 144 def project_name File.basename project_root end |
#project_root ⇒ Object
173 174 175 176 177 178 179 180 |
# File 'lib/comodule/deployment/base.rb', line 173 def project_root @project_root ||= if defined?(Rails) Rails.root else Dir.getwd end end |
#secret_config_dir ⇒ Object
100 101 102 |
# File 'lib/comodule/deployment/base.rb', line 100 def secret_config_dir @secret_config_dir ||= File.join(platform_dir, 'secret_config') end |
#secret_config_path ⇒ Object
124 125 126 |
# File 'lib/comodule/deployment/base.rb', line 124 def secret_config_path @secret_config_path ||= File.join(platform_dir, 'secret_config.yml') end |
#test_dir ⇒ Object
132 133 134 |
# File 'lib/comodule/deployment/base.rb', line 132 def test_dir @test_dir ||= be_dir(File.join(platform_dir, 'test')) end |
#tmp_dir ⇒ Object
128 129 130 |
# File 'lib/comodule/deployment/base.rb', line 128 def tmp_dir @tmp_dir ||= be_dir(File.join(platform_dir, 'tmp')) end |
#tmp_project_dir ⇒ Object
140 141 142 |
# File 'lib/comodule/deployment/base.rb', line 140 def tmp_project_dir @tmp_project_dir ||= be_dir(File.join(tmp_projects_dir, project_name)) end |
#tmp_projects_dir ⇒ Object
136 137 138 |
# File 'lib/comodule/deployment/base.rb', line 136 def tmp_projects_dir @tmp_projects_dir ||= be_dir(File.join(tmp_dir, 'projects')) end |