Class: Urbane::Generator
- Inherits:
-
Object
- Object
- Urbane::Generator
- Defined in:
- lib/urbane.rb
Constant Summary collapse
- GENERATORS =
{ :json => lambda{|content| JSON.pretty_generate(content)}, :yaml => lambda{|content| content.to_yaml}, :xml => lambda do |content| builder = Nokogiri::XML::Builder.new(:encoding => 'UTF-8') do |xml| xml.send('resource-bundle', 'xmlns' => '', 'xmlns:xsi' => 'http://www.w3.org/2001/XMLSchema-instance') do content.each do |key, translation| xml.resource(translation, 'key' => key) end end end builder.to_xml(:indent => 2, :encoding => 'UTF-8') end, :apple_strings => lambda do |content| output = "" content.each do |key, translation| output << "\"#{key}\" = \"#{translation}\";\n" end output end }
Instance Method Summary collapse
- #google_spreadsheet_url ⇒ Object
-
#initialize(options) ⇒ Generator
constructor
A new instance of Generator.
- #run ⇒ Object
Constructor Details
#initialize(options) ⇒ Generator
Returns a new instance of Generator.
34 35 36 37 38 39 40 41 42 |
# File 'lib/urbane.rb', line 34 def initialize() @target_dir = [:target_dir] @spreadsheet_id = [:spreadsheet_id] @file_name_for_translation_file = [:file_name] @language_locale_map = [:languages] @languages = @language_locale_map.keys @fallback_language = [:fallback_language] @format = [:format] || :json end |
Instance Method Details
#google_spreadsheet_url ⇒ Object
54 55 56 |
# File 'lib/urbane.rb', line 54 def google_spreadsheet_url "http://spreadsheets.google.com/feeds/worksheets/#{@spreadsheet_id}/public/values/?alt=json" end |
#run ⇒ Object
44 45 46 47 48 49 50 51 52 |
# File 'lib/urbane.rb', line 44 def run @text_ids = {} @languages.each do |language| @text_ids[language] = {} end process_spreadsheet write_files end |