Class: StaticSync::Config

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

Instance Method Summary collapse

Instance Method Details

#cacheObject



10
11
12
# File 'lib/static_sync/config.rb', line 10

def cache
  self.fetch('cache', {})
end

#gzipObject



36
37
38
# File 'lib/static_sync/config.rb', line 36

def gzip
  self.fetch('gzip', true)
end

#ignoredObject



40
41
42
# File 'lib/static_sync/config.rb', line 40

def ignored
  self['ignored']
end

#load(path = '.static') ⇒ Object



44
45
46
47
48
49
50
51
52
53
# File 'lib/static_sync/config.rb', line 44

def load(path = '.static')
  content = '{}'
  begin
    content = File.read(path)
  rescue
    # Loading config from file is not mandatory.
  end
  self.replace(YAML.load(ERB.new(content).result))
  self
end

#logObject



6
7
8
# File 'lib/static_sync/config.rb', line 6

def log
  self.fetch('log', true)
end

#remoteObject



14
15
16
# File 'lib/static_sync/config.rb', line 14

def remote
  self.fetch('remote', {})
end

#sourceObject



18
19
20
# File 'lib/static_sync/config.rb', line 18

def source
  self.fetch('local', {})['directory']
end

#storageObject



26
27
28
29
30
31
32
33
34
# File 'lib/static_sync/config.rb', line 26

def storage
  Fog::Storage.new({
    :persistent            => true,
    :provider              => self.remote['provider'],
    :region                => self.remote['region'],
    :aws_access_key_id     => self.remote['username'],
    :aws_secret_access_key => self.remote['password']
  })
end

#targetObject



22
23
24
# File 'lib/static_sync/config.rb', line 22

def target
  self.remote['directory']
end