Class: Dbhero::GdriveExporter
- Inherits:
-
Object
- Object
- Dbhero::GdriveExporter
- Defined in:
- lib/dbhero/gdrive_exporter.rb
Instance Attribute Summary collapse
-
#auth ⇒ Object
readonly
Returns the value of attribute auth.
-
#client ⇒ Object
readonly
Returns the value of attribute client.
-
#dataclip ⇒ Object
readonly
Returns the value of attribute dataclip.
-
#exported_file_url ⇒ Object
readonly
Returns the value of attribute exported_file_url.
-
#options ⇒ Object
Returns the value of attribute options.
-
#session ⇒ Object
readonly
Returns the value of attribute session.
-
#uploaded_file ⇒ Object
readonly
Returns the value of attribute uploaded_file.
Instance Method Summary collapse
- #export_clip_by_token(token) ⇒ Object
- #fetch_access_token!(code) ⇒ Object
-
#initialize(options = {}) ⇒ GdriveExporter
constructor
A new instance of GdriveExporter.
Constructor Details
#initialize(options = {}) ⇒ GdriveExporter
Returns a new instance of GdriveExporter.
7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/dbhero/gdrive_exporter.rb', line 7 def initialize = {} @client ||= ::Google::APIClient.new @options = @auth = @client. @auth.client_id = Dbhero.google_api_id @auth.client_secret = Dbhero.google_api_secret @auth.scope = "https://www.googleapis.com/auth/drive " + "https://spreadsheets.google.com/feeds/" @auth.redirect_uri = [:redirect_uri] end |
Instance Attribute Details
#auth ⇒ Object (readonly)
Returns the value of attribute auth.
4 5 6 |
# File 'lib/dbhero/gdrive_exporter.rb', line 4 def auth @auth end |
#client ⇒ Object (readonly)
Returns the value of attribute client.
4 5 6 |
# File 'lib/dbhero/gdrive_exporter.rb', line 4 def client @client end |
#dataclip ⇒ Object (readonly)
Returns the value of attribute dataclip.
4 5 6 |
# File 'lib/dbhero/gdrive_exporter.rb', line 4 def dataclip @dataclip end |
#exported_file_url ⇒ Object (readonly)
Returns the value of attribute exported_file_url.
4 5 6 |
# File 'lib/dbhero/gdrive_exporter.rb', line 4 def exported_file_url @exported_file_url end |
#options ⇒ Object
Returns the value of attribute options.
3 4 5 |
# File 'lib/dbhero/gdrive_exporter.rb', line 3 def @options end |
#session ⇒ Object (readonly)
Returns the value of attribute session.
4 5 6 |
# File 'lib/dbhero/gdrive_exporter.rb', line 4 def session @session end |
#uploaded_file ⇒ Object (readonly)
Returns the value of attribute uploaded_file.
4 5 6 |
# File 'lib/dbhero/gdrive_exporter.rb', line 4 def uploaded_file @uploaded_file end |
Instance Method Details
#export_clip_by_token(token) ⇒ Object
27 28 29 30 31 32 33 |
# File 'lib/dbhero/gdrive_exporter.rb', line 27 def export_clip_by_token token @dataclip ||= Dataclip.find_by token: token raise 'unable to find dataclip' unless @dataclip exported_file = find_or_create_spreadsheet! @exported_file_url = exported_file.human_url end |
#fetch_access_token!(code) ⇒ Object
21 22 23 24 25 |
# File 'lib/dbhero/gdrive_exporter.rb', line 21 def fetch_access_token! code @auth.code = code @auth.fetch_access_token! @session ||= GoogleDrive.login_with_oauth(@auth.access_token) end |