Class: AppBuilder::Config
- Inherits:
-
Object
- Object
- AppBuilder::Config
- Defined in:
- lib/app_builder/config.rb
Constant Summary collapse
- VALID_OPTIONS =
[ :build_id, :project_name, :remote_repository, :branch, :revision, :src_base_url, :manifest_base_url, :remote_src_path, :remote_manifest_path, :manifest_template_path, :resource_host, :ssh_user, :identity_file, :logger, ].freeze
- PARAMETERS =
[ :working_path, :repo_path, :archive_path, :build_path, :builded_src_path, :builded_manifest_path, :revision_path, :src_url, :manifest_url, :remote_app_home, ].concat(VALID_OPTIONS).freeze
Instance Method Summary collapse
- #archive_path ⇒ Object
- #build_name ⇒ Object
- #build_path ⇒ Object
- #builded_manifest_path ⇒ Object
- #builded_src_path ⇒ Object
-
#initialize(options = {}) ⇒ Config
constructor
A new instance of Config.
- #manifest_name ⇒ Object
- #manifest_url ⇒ Object
- #merge(params) ⇒ Object
- #remote_app_home ⇒ Object
- #repo_path ⇒ Object
- #reset ⇒ Object
- #revision_path ⇒ Object
- #src_url ⇒ Object
- #working_path ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Config
Returns a new instance of Config.
35 36 37 38 |
# File 'lib/app_builder/config.rb', line 35 def initialize( = {}) reset merge() end |
Instance Method Details
#archive_path ⇒ Object
63 64 65 |
# File 'lib/app_builder/config.rb', line 63 def archive_path File.join(working_path, "archive", build_id) end |
#build_name ⇒ Object
47 48 49 |
# File 'lib/app_builder/config.rb', line 47 def build_name "#{build_id}.tar.gz" end |
#build_path ⇒ Object
67 68 69 |
# File 'lib/app_builder/config.rb', line 67 def build_path File.join(working_path, "build", build_id) end |
#builded_manifest_path ⇒ Object
75 76 77 |
# File 'lib/app_builder/config.rb', line 75 def builded_manifest_path File.join(build_path, manifest_name) end |
#builded_src_path ⇒ Object
71 72 73 |
# File 'lib/app_builder/config.rb', line 71 def builded_src_path File.join(build_path, build_name) end |
#manifest_name ⇒ Object
51 52 53 |
# File 'lib/app_builder/config.rb', line 51 def manifest_name "#{build_id}.yml" end |
#manifest_url ⇒ Object
87 88 89 |
# File 'lib/app_builder/config.rb', line 87 def manifest_url File.join(manifest_base_url, manifest_name) end |
#merge(params) ⇒ Object
40 41 42 43 44 45 |
# File 'lib/app_builder/config.rb', line 40 def merge(params) params.each do |key, value| self.send("#{key}=", value) end self end |
#remote_app_home ⇒ Object
91 92 93 |
# File 'lib/app_builder/config.rb', line 91 def remote_app_home File.join("/var/www", project_name) end |
#repo_path ⇒ Object
59 60 61 |
# File 'lib/app_builder/config.rb', line 59 def repo_path File.join(working_path, "repo") end |
#reset ⇒ Object
95 96 97 98 99 100 101 102 103 104 105 |
# File 'lib/app_builder/config.rb', line 95 def reset @build_id = Time.now.strftime("%Y%m%d%H%M%S") @project_name = File.basename(`git rev-parse --show-toplevel`.chomp) @remote_repository = `git remote get-url origin`.chomp @branch = ENV.fetch("TARGET_BRANCH", "master") @revision = `git rev-parse #{branch}`.chomp @manifest_template_path = File.("template/manifest.yml.erb", __dir__) @ssh_user = ENV.fetch("USER", nil) @identity_file = "~/.ssh/id_rsa" @logger = Logger.new(STDOUT) end |
#revision_path ⇒ Object
79 80 81 |
# File 'lib/app_builder/config.rb', line 79 def revision_path File.join(archive_path, "revision.yml") end |
#src_url ⇒ Object
83 84 85 |
# File 'lib/app_builder/config.rb', line 83 def src_url File.join(src_base_url, build_name) end |
#working_path ⇒ Object
55 56 57 |
# File 'lib/app_builder/config.rb', line 55 def working_path File.join("/var/tmp", project_name) end |