Class: Databasion::GoogleLoader
- Inherits:
-
Object
- Object
- Databasion::GoogleLoader
- 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
- .config ⇒ Object
- .config=(data) ⇒ Object
- .config? ⇒ Boolean
- .environment_sheet ⇒ Object
- .environment_sheet=(environment) ⇒ Object
- .login ⇒ Object
- .run(opts = nil) ⇒ Object
- .run_version(opts = nil) ⇒ Object
- .session ⇒ Object
Class Method Details
.config ⇒ Object
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
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_sheet ⇒ Object
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 |
.login ⇒ Object
45 46 47 48 49 50 51 |
# File 'lib/databasion/google_loader.rb', line 45 def self.login begin @@session = GoogleSpreadsheet.login(@@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? login 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? login if session.nil? fetch_environment_version(opts) end |
.session ⇒ Object
33 34 35 |
# File 'lib/databasion/google_loader.rb', line 33 def self.session @@session end |