Class: Luban::Deployment::Configuration::Server
- Inherits:
-
SSHKit::Host
- Object
- SSHKit::Host
- Luban::Deployment::Configuration::Server
- Defined in:
- lib/luban/deployment/configuration/server.rb
Instance Attribute Summary collapse
-
#roles ⇒ Object
readonly
Returns the value of attribute roles.
Class Method Summary collapse
Instance Method Summary collapse
- #[](key) ⇒ Object (also: #fetch)
- #[]=(key, value) ⇒ Object (also: #set)
- #add_cronjob(cronjob) ⇒ Object (also: #cronjob=)
- #add_cronjobs(cronjobs) ⇒ Object (also: #cronjobs=)
- #add_properties(_properties) ⇒ Object
- #add_role(role) ⇒ Object
- #add_roles(roles) ⇒ Object (also: #roles=)
- #cronjobs ⇒ Object
- #has_role?(role) ⇒ Boolean
- #local? ⇒ Boolean
- #localhost? ⇒ Boolean
- #primary? ⇒ Boolean
- #properties ⇒ Object
Instance Attribute Details
#roles ⇒ Object (readonly)
Returns the value of attribute roles.
7 8 9 |
# File 'lib/luban/deployment/configuration/server.rb', line 7 def roles @roles end |
Class Method Details
Instance Method Details
#[](key) ⇒ Object Also known as: fetch
45 46 47 |
# File 'lib/luban/deployment/configuration/server.rb', line 45 def [](key) properties[key] end |
#[]=(key, value) ⇒ Object Also known as: set
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/luban/deployment/configuration/server.rb', line 50 def []=(key, value) if respond_to?("#{key}=") send("#{key}=", value) else pval = properties[key] if pval.is_a? Hash and value.is_a? Hash pval.merge!(value) elsif pval.is_a? Set and value.is_a? Set pval.merge(value) elsif pval.is_a? Array and value.is_a? Array pval.concat value else properties[key] = value end end end |
#add_cronjob(cronjob) ⇒ Object Also known as: cronjob=
85 86 87 |
# File 'lib/luban/deployment/configuration/server.rb', line 85 def add_cronjob(cronjob) cronjobs.add(cronjob) end |
#add_cronjobs(cronjobs) ⇒ Object Also known as: cronjobs=
80 81 82 |
# File 'lib/luban/deployment/configuration/server.rb', line 80 def add_cronjobs(cronjobs) cronjobs.each { |cronjob| add_cronjob(cronjob) } end |
#add_properties(_properties) ⇒ Object
68 69 70 |
# File 'lib/luban/deployment/configuration/server.rb', line 68 def add_properties(_properties) _properties.each { |k, v| self[k] = v } end |
#add_role(role) ⇒ Object
33 34 35 |
# File 'lib/luban/deployment/configuration/server.rb', line 33 def add_role(role) roles.add(role.to_sym) end |
#add_roles(roles) ⇒ Object Also known as: roles=
28 29 30 |
# File 'lib/luban/deployment/configuration/server.rb', line 28 def add_roles(roles) roles.each { |role| add_role(role) } end |
#cronjobs ⇒ Object
76 77 78 |
# File 'lib/luban/deployment/configuration/server.rb', line 76 def cronjobs self[:cronjobs] end |
#has_role?(role) ⇒ Boolean
37 38 39 |
# File 'lib/luban/deployment/configuration/server.rb', line 37 def has_role?(role) roles.include? role.to_sym end |
#local? ⇒ Boolean
16 17 18 |
# File 'lib/luban/deployment/configuration/server.rb', line 16 def local? super or (properties.has_key?(:local) ? properties[:local] : localhost?) end |
#localhost? ⇒ Boolean
20 21 22 |
# File 'lib/luban/deployment/configuration/server.rb', line 20 def localhost? hostname == 'localhost' or hostname == `hostname -f`.chomp end |
#primary? ⇒ Boolean
72 73 74 |
# File 'lib/luban/deployment/configuration/server.rb', line 72 def primary? self[:primary] end |
#properties ⇒ Object
41 42 43 |
# File 'lib/luban/deployment/configuration/server.rb', line 41 def properties @properties ||= { :roles => Set.new, :cronjobs => Set.new } end |