Module: Siteleaf

Defined in:
lib/siteleaf.rb,
lib/siteleaf/job.rb,
lib/siteleaf/file.rb,
lib/siteleaf/page.rb,
lib/siteleaf/role.rb,
lib/siteleaf/site.rb,
lib/siteleaf/user.rb,
lib/siteleaf/client.rb,
lib/siteleaf/entity.rb,
lib/siteleaf/content.rb,
lib/siteleaf/version.rb,
lib/siteleaf/document.rb,
lib/siteleaf/git_hash.rb,
lib/siteleaf/collection.rb,
lib/siteleaf/source_file.rb

Defined Under Namespace

Modules: GitHash Classes: Client, Collection, Content, Document, Entity, File, Job, Page, Role, Site, SourceFile, User

Constant Summary collapse

VERSION =
"2.2.1"

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.api_baseObject

Returns the value of attribute api_base.



31
32
33
# File 'lib/siteleaf.rb', line 31

def api_base
  @api_base
end

.api_keyObject

Returns the value of attribute api_key.



31
32
33
# File 'lib/siteleaf.rb', line 31

def api_key
  @api_key
end

.api_secretObject

Returns the value of attribute api_secret.



31
32
33
# File 'lib/siteleaf.rb', line 31

def api_secret
  @api_secret
end

.api_versionObject

Returns the value of attribute api_version.



31
32
33
# File 'lib/siteleaf.rb', line 31

def api_version
  @api_version
end

Class Method Details

.api_url(url = '') ⇒ Object



34
35
36
# File 'lib/siteleaf.rb', line 34

def self.api_url(url = '')
  ::File.join(@api_base, @api_version, url)
end

.load_settings(file = self.settings_file) ⇒ Object



42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/siteleaf.rb', line 42

def self.load_settings(file = self.settings_file)
  if ::File.exist?(file)
    settings = ::File.open(file) { |f| YAML.load(f) }
    
    [:api_key, :api_secret, :api_base, :api_version].each do |key|
      self.send "#{key}=", settings[key.to_s] if settings.has_key?(key.to_s)
    end
      
    symbolized_settings = Hash.new
    settings.each{|k,v| symbolized_settings[k.to_sym] = v}
    
    symbolized_settings
  end
rescue 
  nil
end

.save_settings(settings, file = self.settings_file) ⇒ Object



59
60
61
62
63
64
65
66
# File 'lib/siteleaf.rb', line 59

def self.save_settings(settings, file = self.settings_file)
  stringified_settings = Hash.new
  settings.each{|k,v| stringified_settings[k.to_s] = v}
  
  ::File.open(file, 'w') { |f| f.write stringified_settings.to_yaml }
  
  settings
end

.settings_fileObject



38
39
40
# File 'lib/siteleaf.rb', line 38

def self.settings_file
  ::File.expand_path('~/.siteleaf.yml')
end