Class: OdaniaStaticPages::Config::Environment

Inherits:
Object
  • Object
show all
Defined in:
lib/odania_static_pages/config.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

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_moduleObject (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_typeObject (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

#notifyObject (readonly)

Returns the value of attribute notify.



104
105
106
# File 'lib/odania_static_pages/config.rb', line 104

def notify
  @notify
end

#output_pathObject (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_hObject



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