Class: SourcedConfig::Locale::GSheetsClient
- Inherits:
-
Object
- Object
- SourcedConfig::Locale::GSheetsClient
- Defined in:
- lib/sourced_config/locale/g_sheets_client.rb
Instance Attribute Summary collapse
-
#url ⇒ Object
readonly
Returns the value of attribute url.
Instance Method Summary collapse
-
#initialize(url) ⇒ GSheetsClient
constructor
A new instance of GSheetsClient.
- #load(locale) ⇒ Object
Constructor Details
#initialize(url) ⇒ GSheetsClient
Returns a new instance of GSheetsClient.
8 9 10 |
# File 'lib/sourced_config/locale/g_sheets_client.rb', line 8 def initialize(url) @url = url end |
Instance Attribute Details
#url ⇒ Object (readonly)
Returns the value of attribute url.
12 13 14 |
# File 'lib/sourced_config/locale/g_sheets_client.rb', line 12 def url @url end |
Instance Method Details
#load(locale) ⇒ Object
14 15 16 17 18 19 20 21 22 23 |
# File 'lib/sourced_config/locale/g_sheets_client.rb', line 14 def load(locale) Rails.logger.debug { "[locale - #{locale}] Strings read (as UTF-8) from remote URL #{url}" } content = get_content parse_body(content.body.force_encoding("UTF-8")).reduce({}) do |memo, row| parse_item(row, memo) end rescue => e Rails.logger.error "[locale - #{locale}] Could not fetch TSV doc directly from Google Spreadsheets: #{e.}" {} end |