Class: Poesie::Exporter
- Inherits:
-
Object
- Object
- Poesie::Exporter
- Defined in:
- lib/exporter.rb
Instance Method Summary collapse
-
#initialize(api_token, project_id) ⇒ Exporter
constructor
A new instance of Exporter.
-
#run(lang) ⇒ Object
Use the POEditor API to download the terms for a given language, then call a block to post-process those terms (exported as a JSON structure).
Constructor Details
#initialize(api_token, project_id) ⇒ Exporter
Returns a new instance of Exporter.
10 11 12 13 |
# File 'lib/exporter.rb', line 10 def initialize(api_token, project_id) @api_token = api_token @project_id = project_id end |
Instance Method Details
#run(lang) ⇒ Object
Use the POEditor API to download the terms for a given language, then call a block to post-process those terms (exported as a JSON structure)
24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/exporter.rb', line 24 def run(lang) Log::info(' - Generating export...') uri = generate_export_uri(lang) Log::info(' - Downloading exported file...') json_string = Net::HTTP.get(URI(uri)) json = JSON.parse(json_string) terms = json.sort { |item1, item2| item1['term'] <=> item2['term'] } if block_given? Log::info(' - Processing generated strings...') yield terms end end |