Class: Conjure::Service::RailsCodebase
- Inherits:
-
Object
- Object
- Conjure::Service::RailsCodebase
- Defined in:
- lib/conjure/service/rails_codebase.rb
Instance Method Summary collapse
- #configure_database ⇒ Object
- #configure_logs ⇒ Object
- #database ⇒ Object
- #database_name ⇒ Object
- #database_yml ⇒ Object
- #gem_names ⇒ Object
-
#initialize(host, github_url, branch, app_name, rails_environment) ⇒ RailsCodebase
constructor
A new instance of RailsCodebase.
- #install ⇒ Object
- #repository_link ⇒ Object
- #volume ⇒ Object
Constructor Details
#initialize(host, github_url, branch, app_name, rails_environment) ⇒ RailsCodebase
4 5 6 7 8 9 10 |
# File 'lib/conjure/service/rails_codebase.rb', line 4 def initialize(host, github_url, branch, app_name, rails_environment) @github_url = github_url @branch = branch @app_name = app_name @rails_environment = rails_environment @host = host end |
Instance Method Details
#configure_database ⇒ Object
44 45 46 47 |
# File 'lib/conjure/service/rails_codebase.rb', line 44 def configure_database Conjure.log "[ repo] Generating database.yml" volume.write "config/database.yml", database_yml end |
#configure_logs ⇒ Object
49 50 51 52 53 |
# File 'lib/conjure/service/rails_codebase.rb', line 49 def configure_logs Conjure.log "[ repo] Configuring application logger" setup = 'Rails.logger = Logger.new "#{Rails.root}/log/#{Rails.env}.log"' volume.write "config/initializers/z_conjure_logger.rb", setup end |
#database ⇒ Object
63 64 65 |
# File 'lib/conjure/service/rails_codebase.rb', line 63 def database @database ||= Database.new :docker_host => @host, :codebase => self end |
#database_name ⇒ Object
55 56 57 |
# File 'lib/conjure/service/rails_codebase.rb', line 55 def database_name "#{@app_name}_#{@rails_environment}" end |
#database_yml ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/conjure/service/rails_codebase.rb', line 12 def database_yml { @rails_environment => { "adapter" => database.adapter_name, "database" => database.name, "encoding" => "utf8", "host" => database.ip_address, "username" => "root", "template" => "template0", } }.to_yaml end |
#gem_names ⇒ Object
59 60 61 |
# File 'lib/conjure/service/rails_codebase.rb', line 59 def gem_names volume.read("Gemfile").scan(/gem ['"]([^'"]+)['"]/).flatten end |
#install ⇒ Object
25 26 27 28 29 |
# File 'lib/conjure/service/rails_codebase.rb', line 25 def install repository_link.update configure_database configure_logs end |
#repository_link ⇒ Object
31 32 33 34 35 36 37 38 |
# File 'lib/conjure/service/rails_codebase.rb', line 31 def repository_link @repository_link ||= RepositoryLink.new( :volume => volume, :branch => @branch, :origin_url => @github_url, :public_key => Conjure.config.file_contents(:public_key_file).gsub("\n", "\\n"), ) end |
#volume ⇒ Object
40 41 42 |
# File 'lib/conjure/service/rails_codebase.rb', line 40 def volume @volume ||= Volume.new(:docker_host => @host, :host_path => "/rails_app", :container_path => "/#{@app_name}") end |