Class: DNApi::App
- Includes:
- ComponentPossessor
- Defined in:
- lib/dnapi/app.rb
Instance Attribute Summary collapse
-
#branch ⇒ Object
Returns the value of attribute branch.
-
#bundled ⇒ Object
Returns the value of attribute bundled.
-
#database_name ⇒ Object
Returns the value of attribute database_name.
-
#deploy_action ⇒ Object
Returns the value of attribute deploy_action.
-
#deploy_key ⇒ Object
Returns the value of attribute deploy_key.
-
#migration_command ⇒ Object
Returns the value of attribute migration_command.
-
#name ⇒ Object
Returns the value of attribute name.
-
#newrelic ⇒ Object
Returns the value of attribute newrelic.
-
#repository_name ⇒ Object
Returns the value of attribute repository_name.
-
#revision ⇒ Object
Returns the value of attribute revision.
-
#run_deploy ⇒ Object
Returns the value of attribute run_deploy.
-
#run_migrations ⇒ Object
Returns the value of attribute run_migrations.
-
#type ⇒ Object
Returns the value of attribute type.
Attributes inherited from Struct
Instance Method Summary collapse
- #build_ebuild(attributes = {}) ⇒ Object
- #build_gem(attributes = {}) ⇒ Object
- #build_vhost(attributes = {}) ⇒ Object
- #bundled? ⇒ Boolean
- #domain_name ⇒ Object
- #domain_name=(value) ⇒ Object
- #gems_hash ⇒ Object
- #https? ⇒ Boolean
-
#initialize(attributes = {}) ⇒ App
constructor
A new instance of App.
- #jruby? ⇒ Boolean
- #newrelic? ⇒ Boolean
- #recipe_names ⇒ Object
- #recipes ⇒ Object
- #ssl_cert ⇒ Object
- #ssl_cert=(attributes = {}) ⇒ Object
- #to_legacy_hash ⇒ Object
- #vhost_legacy_array ⇒ Object
Methods included from ComponentPossessor
#add_component, #component, #component_group, #has_component?, included
Methods inherited from Struct
#==, #_many, _many, #_many_values, #_ones, _ones, #_ones_values, _umembers, belongs_to, from, #inspect, many, map, one, #to_hash, #umember_inspect, unserialized_member
Methods included from Test::Ext
#default_fauxture_name, #fixture, #generate, #generate_attributes, #pick
Constructor Details
#initialize(attributes = {}) ⇒ App
Returns a new instance of App.
12 13 14 15 16 17 18 19 20 21 |
# File 'lib/dnapi/app.rb', line 12 def initialize(attributes = {}) gem_attributes = attributes.delete(:gems) ebuild_names = attributes.delete(:ebuilds) super(attributes) gem_attributes.each {|attrs| build_gem(attrs) } if gem_attributes ebuild_names.each {|name| build_ebuild(:name => name) } if ebuild_names vhosts.each {|vhost| vhost.app = self } if vhosts end |
Instance Attribute Details
#branch ⇒ Object
Returns the value of attribute branch
2 3 4 |
# File 'lib/dnapi/app.rb', line 2 def branch @branch end |
#bundled ⇒ Object
Returns the value of attribute bundled
2 3 4 |
# File 'lib/dnapi/app.rb', line 2 def bundled @bundled end |
#database_name ⇒ Object
Returns the value of attribute database_name
2 3 4 |
# File 'lib/dnapi/app.rb', line 2 def database_name @database_name end |
#deploy_action ⇒ Object
Returns the value of attribute deploy_action
2 3 4 |
# File 'lib/dnapi/app.rb', line 2 def deploy_action @deploy_action end |
#deploy_key ⇒ Object
Returns the value of attribute deploy_key
2 3 4 |
# File 'lib/dnapi/app.rb', line 2 def deploy_key @deploy_key end |
#migration_command ⇒ Object
Returns the value of attribute migration_command
2 3 4 |
# File 'lib/dnapi/app.rb', line 2 def migration_command @migration_command end |
#name ⇒ Object
Returns the value of attribute name
2 3 4 |
# File 'lib/dnapi/app.rb', line 2 def name @name end |
#newrelic ⇒ Object
Returns the value of attribute newrelic
2 3 4 |
# File 'lib/dnapi/app.rb', line 2 def newrelic @newrelic end |
#repository_name ⇒ Object
Returns the value of attribute repository_name
2 3 4 |
# File 'lib/dnapi/app.rb', line 2 def repository_name @repository_name end |
#revision ⇒ Object
Returns the value of attribute revision
2 3 4 |
# File 'lib/dnapi/app.rb', line 2 def revision @revision end |
#run_deploy ⇒ Object
Returns the value of attribute run_deploy
2 3 4 |
# File 'lib/dnapi/app.rb', line 2 def run_deploy @run_deploy end |
#run_migrations ⇒ Object
Returns the value of attribute run_migrations
2 3 4 |
# File 'lib/dnapi/app.rb', line 2 def run_migrations @run_migrations end |
#type ⇒ Object
Returns the value of attribute type
2 3 4 |
# File 'lib/dnapi/app.rb', line 2 def type @type end |
Instance Method Details
#build_ebuild(attributes = {}) ⇒ Object
123 124 125 126 127 128 |
# File 'lib/dnapi/app.rb', line 123 def build_ebuild(attributes = {}) ebuild = EbuildDep.new(attributes) ebuild.app = self ebuilds << ebuild ebuild end |
#build_gem(attributes = {}) ⇒ Object
116 117 118 119 120 121 |
# File 'lib/dnapi/app.rb', line 116 def build_gem(attributes = {}) gem = GemDep.new(attributes) gem.app = self gems << gem gem end |
#build_vhost(attributes = {}) ⇒ Object
23 24 25 26 27 28 |
# File 'lib/dnapi/app.rb', line 23 def build_vhost(attributes = {}) vhost = VHost.new(attributes) vhost.app = self vhosts << vhost vhost end |
#bundled? ⇒ Boolean
58 59 60 |
# File 'lib/dnapi/app.rb', line 58 def bundled? !! bundled end |
#domain_name ⇒ Object
30 31 32 |
# File 'lib/dnapi/app.rb', line 30 def domain_name vhosts.map {|vhost| vhost.domain_name }.compact.first end |
#domain_name=(value) ⇒ Object
34 35 36 37 38 39 40 |
# File 'lib/dnapi/app.rb', line 34 def domain_name=(value) if vhosts.empty? build_vhost(:domain_name => value) else vhosts.first.domain_name = value end end |
#gems_hash ⇒ Object
98 99 100 101 102 |
# File 'lib/dnapi/app.rb', line 98 def gems_hash gems.map do |gem| gem.to_legacy_hash end end |
#https? ⇒ Boolean
54 55 56 |
# File 'lib/dnapi/app.rb', line 54 def https? vhosts.any? {|vhost| vhost.https? } end |
#jruby? ⇒ Boolean
108 109 110 |
# File 'lib/dnapi/app.rb', line 108 def jruby? environment.ruby_component.is_a?(DNApi::Components::JRuby) end |
#newrelic? ⇒ Boolean
62 63 64 |
# File 'lib/dnapi/app.rb', line 62 def newrelic? !! newrelic end |
#recipe_names ⇒ Object
112 113 114 |
# File 'lib/dnapi/app.rb', line 112 def recipe_names recipes.map {|r| r.name } end |
#recipes ⇒ Object
104 105 106 |
# File 'lib/dnapi/app.rb', line 104 def recipes Recipe.defaults + environment.stack.recipes end |
#ssl_cert ⇒ Object
42 43 44 |
# File 'lib/dnapi/app.rb', line 42 def ssl_cert vhosts.map {|vhost| vhost.ssl_cert }.compact.first end |
#ssl_cert=(attributes = {}) ⇒ Object
46 47 48 49 50 51 52 |
# File 'lib/dnapi/app.rb', line 46 def ssl_cert=(attributes = {}) if vhosts.empty? build_vhost.build_ssl_cert(attributes || {}) else vhosts.first.build_ssl_cert(attributes || {}) end end |
#to_legacy_hash ⇒ Object
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/dnapi/app.rb', line 66 def to_legacy_hash shared = %w( deploy_key repository_name type branch deploy_action migration_command revision run_deploy run_migrations ) data = to_hash.select {|k,v| shared.include?(k.to_s)} Hash[*data.flatten].merge( :newrelic => newrelic?, :vhosts => vhost_legacy_array, :recipes => recipe_names, :http_bind_port => 80, :https_bind_port => 443, :auth => {:active => false}, :services => [{ :resource => :mongrel, :mongrel_base_port => 5000, :mongrel_mem_limit => 150, :mongrel_instance_count => 3 }, { :resource => :memcached, :base_port => 11211, :mem_limit => 128 }] ) end |
#vhost_legacy_array ⇒ Object
92 93 94 95 96 |
# File 'lib/dnapi/app.rb', line 92 def vhost_legacy_array array = vhosts.map {|vhost| vhost.to_legacy_hash } vhosts.select {|vhost| vhost.https? }.inject(array) {|a,vhost| a.push(vhost.to_legacy_hash(true)) } if https? # legacy shit has 2 entries for an https vhost array end |