Module: Googletastic

Defined in:
lib/googletastic.rb

Defined Under Namespace

Modules: Analytics, Helpers, Mixins, PrettyPrint, Sync Classes: AccessRule, Album, AppEngine, Apps, Attendee, Base, Calendar, Comment, Document, Event, Form, Group, Head, Image, Person, Row, Spreadsheet, Table, Thumbnail, Worksheet

Constant Summary collapse

VERSION =

:stopdoc:

'0.0.5.2'

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.clientsObject

Returns the value of attribute clients.



64
65
66
# File 'lib/googletastic.rb', line 64

def clients
  @clients
end

.keysObject

Returns the value of attribute keys.



64
65
66
# File 'lib/googletastic.rb', line 64

def keys
  @keys
end

.optionsObject

Returns the value of attribute options.



64
65
66
# File 'lib/googletastic.rb', line 64

def options
  @options
end

Class Method Details

.[](value) ⇒ Object



96
97
98
# File 'lib/googletastic.rb', line 96

def self.[](value)
  self.options_for(value)
end

.client_for(model) ⇒ Object



74
75
76
77
78
79
80
81
# File 'lib/googletastic.rb', line 74

def self.client_for(model)
  self.clients ||= {}
  model = model.to_sym
  return self.clients[model] if self.clients.has_key?(model)
 client = ("GData::Client::#{model.to_s.camelize}").constantize.new(:source => credentials[:application])
 client.clientlogin(credentials[:username], credentials[:password], nil, nil, nil, credentials[:account_type])	  
 self.clients[model] = client
end

.credentialsObject



66
67
68
69
70
71
72
# File 'lib/googletastic.rb', line 66

def self.credentials
  return self.keys if self.keys
  
  config_file = "#{RAILS_ROOT}/config/gdata.yml"
  raise "Sorry, you must have #{config_file}" unless File.exists?(config_file)
  self.keys = YAML.load_file(config_file).symbolize_keys
end

.options_for(klass, value = {}) ⇒ Object



83
84
85
86
87
88
89
90
91
92
93
94
# File 'lib/googletastic.rb', line 83

def self.options_for(klass, value = {})
  self.options ||= {}
  klass = klass.is_a?(Class) ? klass : klass.class
  name = klass.to_s.underscore.downcase.to_sym
  if value and !value.blank?
    value.symbolize_keys!
    self.options[name] = value
  else
    self.options[name] ||= {}
  end
  self.options[name]
end