Class: Smooster::Deploy::Setting

Inherits:
Object
  • Object
show all
Includes:
ActiveModel::Model, ActiveModel::Serializers::JSON
Defined in:
lib/smooster/deploy/setting.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Attribute Details

#formatblockObject

Returns the value of attribute formatblock.



7
8
9
# File 'lib/smooster/deploy/setting.rb', line 7

def formatblock
  @formatblock
end

#imagesObject

Returns the value of attribute images.



7
8
9
# File 'lib/smooster/deploy/setting.rb', line 7

def images
  @images
end

#rssObject

Returns the value of attribute rss.



7
8
9
# File 'lib/smooster/deploy/setting.rb', line 7

def rss
  @rss
end

Class Method Details

.read_configObject



9
10
11
12
13
# File 'lib/smooster/deploy/setting.rb', line 9

def self.read_config
  if File.exists?("#{Smooster::Application.instance.base_dir}/site_config.yml")
    YAML.load(File.read("#{Smooster::Application.instance.base_dir}/site_config.yml"))
  end
end

.uploadObject



15
16
17
18
19
20
21
22
23
24
# File 'lib/smooster/deploy/setting.rb', line 15

def self.upload
  begin
    response = RestClient.post "#{Smooster::Application.instance.api_url()}/#{Smooster::Application.instance.site_id()}/configure", {:configs => self.read_config}, {"Authorization" => 'Token token="'+ Smooster::Application.instance.api_key() +'"', "Accept" => 'application/vnd.smoosterid.v2'}
    data = JSON.parse(response)
  rescue => e
    Smooster::Application.instance.logger.error "Error settings!: #{e} / #{e.backtrace.inspect}"
    puts "The settings failed to be updated".colorize(:red)
  end

end