Class: OdaniaStaticPages::Config::Environment
- Inherits:
-
Object
- Object
- OdaniaStaticPages::Config::Environment
- Defined in:
- lib/odania_static_pages/config.rb
Instance Attribute Summary collapse
-
#deploy_module ⇒ Object
readonly
Returns the value of attribute deploy_module.
-
#deploy_type ⇒ Object
readonly
Returns the value of attribute deploy_type.
-
#notify ⇒ Object
readonly
Returns the value of attribute notify.
-
#output_path ⇒ Object
readonly
Returns the value of attribute output_path.
Class Method Summary collapse
Instance Method Summary collapse
- #do_notify(new_color, old_color) ⇒ Object
-
#initialize(output_path, deploy_type, deploy_module_config = {}, notify = 'echo Switched from OLD-COLOR to NEW-COLOR!') ⇒ Environment
constructor
A new instance of Environment.
- #to_h ⇒ Object
Constructor Details
#initialize(output_path, deploy_type, deploy_module_config = {}, notify = 'echo Switched from OLD-COLOR to NEW-COLOR!') ⇒ Environment
Returns a new instance of Environment.
106 107 108 109 110 111 112 |
# File 'lib/odania_static_pages/config.rb', line 106 def initialize(output_path, deploy_type, deploy_module_config={}, notify='echo Switched from OLD-COLOR to NEW-COLOR!') @output_path = output_path @deploy_type = deploy_type @notify = notify clazz_name = "OdaniaStaticPages::Config::Deploy::#{deploy_type}" @deploy_module = clazz_name.constantize.new deploy_module_config.symbolize_keys! end |
Instance Attribute Details
#deploy_module ⇒ Object (readonly)
Returns the value of attribute deploy_module.
104 105 106 |
# File 'lib/odania_static_pages/config.rb', line 104 def deploy_module @deploy_module end |
#deploy_type ⇒ Object (readonly)
Returns the value of attribute deploy_type.
104 105 106 |
# File 'lib/odania_static_pages/config.rb', line 104 def deploy_type @deploy_type end |
#notify ⇒ Object (readonly)
Returns the value of attribute notify.
104 105 106 |
# File 'lib/odania_static_pages/config.rb', line 104 def notify @notify end |
#output_path ⇒ Object (readonly)
Returns the value of attribute output_path.
104 105 106 |
# File 'lib/odania_static_pages/config.rb', line 104 def output_path @output_path end |
Class Method Details
.from_hash(data) ⇒ Object
123 124 125 |
# File 'lib/odania_static_pages/config.rb', line 123 def self.from_hash(data) Environment.new data['output_path'], data['deploy_type'], data['deploy_config'], data['notify'] end |
Instance Method Details
#do_notify(new_color, old_color) ⇒ Object
127 128 129 130 131 132 133 |
# File 'lib/odania_static_pages/config.rb', line 127 def do_notify(new_color, old_color) unless @notify.nil? replaced_notify = @notify.gsub('NEW-COLOR', new_color).gsub('OLD-COLOR', old_color) puts "Ececuting notify: #{replaced_notify}" puts `#{replaced_notify}` end end |
#to_h ⇒ Object
114 115 116 117 118 119 120 121 |
# File 'lib/odania_static_pages/config.rb', line 114 def to_h { output_path: @output_path, deploy_type: @deploy_type, notify: @notify, deploy_config: @deploy_module.to_h }.stringify_keys! end |