Class: Init
- Inherits:
-
Object
- Object
- Init
- Defined in:
- lib/transync/sync/init.rb
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
Instance Method Summary collapse
-
#initialize(path) ⇒ Init
constructor
A new instance of Init.
- #run ⇒ Object
Constructor Details
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
6 7 8 |
# File 'lib/transync/sync/init.rb', line 6 def config @config end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
6 7 8 |
# File 'lib/transync/sync/init.rb', line 6 def path @path end |
Instance Method Details
#run ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/transync/sync/init.rb', line 14 def run # first we want to add all the files to spreadsheet as worksheets (tabs) # add_worksheet(title, max_rows = 100, max_cols = 20) session = GoogleDrive.login(@gdoc_access['email'], @gdoc_access['password']) spreadsheet = session.spreadsheet_by_key(@gdoc_access['key']) @config['FILES'].each do |file| worksheet = spreadsheet.worksheets.select { |s| s.title == file }.first if worksheet.nil? worksheet = spreadsheet.add_worksheet(file) p "Adding #{file} worksheet to spreadsheet with first row (key and languages)" end worksheet[1, 1] = 'Key' @config['LANGUAGES'].each_with_index do |language, index| worksheet[1, index + 2] = language.upcase end worksheet.save end # now sync all our keys and translations to gdoc # this won't work if local files are not 'clean'. # to make them clean run test and update first! x2g = Xliff2GdocMain.new(path) x2g.run end |