Class: Bricolage::SpreadsheetDataSource::SpreadsheetTask::S3ExportAction
- Inherits:
-
Action
- Object
- Action
- Bricolage::SpreadsheetDataSource::SpreadsheetTask::S3ExportAction
- Defined in:
- lib/bricolage/spreadsheetdatasource.rb
Instance Attribute Summary collapse
-
#dest_ds ⇒ Object
readonly
Returns the value of attribute dest_ds.
-
#dest_file ⇒ Object
readonly
Returns the value of attribute dest_file.
-
#gzip ⇒ Object
readonly
Returns the value of attribute gzip.
-
#range ⇒ Object
readonly
Returns the value of attribute range.
-
#sheet_id ⇒ Object
readonly
Returns the value of attribute sheet_id.
Instance Method Summary collapse
- #format ⇒ Object
-
#initialize(sheet_id, range, format, value_render_option, dest_ds, dest_file, gzip) ⇒ S3ExportAction
constructor
A new instance of S3ExportAction.
- #run ⇒ Object
- #source ⇒ Object
- #url_encoded_range ⇒ Object
- #value_render_option ⇒ Object
Constructor Details
#initialize(sheet_id, range, format, value_render_option, dest_ds, dest_file, gzip) ⇒ S3ExportAction
Returns a new instance of S3ExportAction.
76 77 78 79 80 81 82 83 84 |
# File 'lib/bricolage/spreadsheetdatasource.rb', line 76 def initialize(sheet_id, range, format, value_render_option, dest_ds, dest_file, gzip) @sheet_id = sheet_id @range = range @format = format @value_render_option = value_render_option @dest_ds = dest_ds @dest_file = dest_file @gzip = gzip end |
Instance Attribute Details
#dest_ds ⇒ Object (readonly)
Returns the value of attribute dest_ds.
86 87 88 |
# File 'lib/bricolage/spreadsheetdatasource.rb', line 86 def dest_ds @dest_ds end |
#dest_file ⇒ Object (readonly)
Returns the value of attribute dest_file.
86 87 88 |
# File 'lib/bricolage/spreadsheetdatasource.rb', line 86 def dest_file @dest_file end |
#gzip ⇒ Object (readonly)
Returns the value of attribute gzip.
86 87 88 |
# File 'lib/bricolage/spreadsheetdatasource.rb', line 86 def gzip @gzip end |
#range ⇒ Object (readonly)
Returns the value of attribute range.
86 87 88 |
# File 'lib/bricolage/spreadsheetdatasource.rb', line 86 def range @range end |
#sheet_id ⇒ Object (readonly)
Returns the value of attribute sheet_id.
86 87 88 |
# File 'lib/bricolage/spreadsheetdatasource.rb', line 86 def sheet_id @sheet_id end |
Instance Method Details
#format ⇒ Object
96 97 98 |
# File 'lib/bricolage/spreadsheetdatasource.rb', line 96 def format @format.downcase end |
#run ⇒ Object
107 108 109 110 111 112 113 114 115 116 117 |
# File 'lib/bricolage/spreadsheetdatasource.rb', line 107 def run ds.logger.info source rows = ds.formatted_rows(sheet_id, range, format, value_render_option: value_render_option) Tempfile.open do |f| f = Zlib::GzipWriter.wrap(f) if gzip f.write rows.to_a.join("\n") f.close # flush dest_ds.object(dest_file).upload_file(f.path) end nil end |
#source ⇒ Object
100 101 102 103 104 105 |
# File 'lib/bricolage/spreadsheetdatasource.rb', line 100 def source <<~SOURCE "GET https://sheets.googleapis.com/v4/spreadsheets/#{sheet_id}/values/#{url_encoded_range}" "PUT s3://#{dest_ds.bucket_name}/#{dest_ds.prefix}/#{dest_file}" SOURCE end |
#url_encoded_range ⇒ Object
88 89 90 |
# File 'lib/bricolage/spreadsheetdatasource.rb', line 88 def url_encoded_range @url_encoded_range ||= URI.encode(range) end |
#value_render_option ⇒ Object
92 93 94 |
# File 'lib/bricolage/spreadsheetdatasource.rb', line 92 def value_render_option @value_render_option&.upcase end |