Class: Databasion::GoogleLoader

Inherits:
Object
  • Object
show all
Defined in:
lib/databasion/google_loader.rb

Constant Summary collapse

@@session =
nil
@@environment_sheet =
'Environments'
@@table_def =
'table'
@@field_def =
'field'
@@type_def =
'type'
@@index_def =
'index'
@@ignore_def =
'ignore'

Class Method Summary collapse

Class Method Details

.configObject



28
29
30
31
# File 'lib/databasion/google_loader.rb', line 28

def self.config
  config?
  @@config
end

.config=(data) ⇒ Object



24
25
26
# File 'lib/databasion/google_loader.rb', line 24

def self.config=(data)
  @@config = data
end

.config?Boolean

Returns:

  • (Boolean)

Raises:



19
20
21
22
# File 'lib/databasion/google_loader.rb', line 19

def self.config?
  raise GoogleLoaderError, 'GoogleLoader cannot load without a config.' unless defined?(@@config)
  true
end

.environment_sheetObject



41
42
43
# File 'lib/databasion/google_loader.rb', line 41

def self.environment_sheet
  @@environment_sheet
end

.environment_sheet=(environment) ⇒ Object



37
38
39
# File 'lib/databasion/google_loader.rb', line 37

def self.environment_sheet=(environment)
  @@environment_sheet = environment
end

.loginObject



45
46
47
48
49
50
51
# File 'lib/databasion/google_loader.rb', line 45

def self.
  begin
    @@session = GoogleSpreadsheet.(@@config['login']['username'], @@config['login']['password'])
  rescue
    raise GoogleLoaderError, "Couldn't log into Google."
  end
end

.run(opts = nil) ⇒ Object



53
54
55
56
57
58
59
60
# File 'lib/databasion/google_loader.rb', line 53

def self.run(opts=nil)
  @@environment = opts[:env]
  config?
  
  process.each do |data_hash|
    Databasion::YamlBuilder.run(data_hash, @@config, opts)
  end
end

.run_version(opts = nil) ⇒ Object



62
63
64
65
66
# File 'lib/databasion/google_loader.rb', line 62

def self.run_version(opts=nil)
  config?
   if session.nil?
  fetch_environment_version(opts)
end

.sessionObject



33
34
35
# File 'lib/databasion/google_loader.rb', line 33

def self.session
  @@session
end