transync 1.1.1 → 1.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 53afd1b65e808cfce2e81eec433f2503ecc48e50
4
- data.tar.gz: f82b54ece69a6a9517e1926cca8b960325e99f31
3
+ metadata.gz: 49efb85a09f9890df8eba832d04c506230170c66
4
+ data.tar.gz: 7c49b7c23956526668d1dac41e33bc4fae6f5054
5
5
  SHA512:
6
- metadata.gz: adde07a797914699e9de74366856e41daff5cd4569c533aa6af8c1ecb95067e62f2e63f5f53b3bb405c85ba3f1117cf5bf30998672ec6014bcfb67781d3e186c
7
- data.tar.gz: d124defa8261d27de9f511354fbe9f364233900acd74b5b18022a9eebdfb932deded157856f95bac16a553042c2d76e1d40a7e76e433d82e85109349c6dd7173
6
+ metadata.gz: 5414c79018b18062005a39dbd9c439189fdc86e5c0870b8d5c2e6023e61379cfea363c50de03e0df1a7520c69c557fdaba91163be43cf8062ec0281768cfdb76
7
+ data.tar.gz: 6f3aa8575a1905f67f8597169d8d66c160c490c1038da9fbc5cd006e7895a33a419b4e4c35af1c5856ac9f57f8d8f50c90887d94ca7f28f582077d389db12e22
@@ -1,3 +1,4 @@
1
+ require 'colorize'
1
2
  require_relative '../transync_config'
2
3
 
3
4
  class GdocTransReader
@@ -5,8 +6,8 @@ class GdocTransReader
5
6
 
6
7
  # file represents tab in spreadsheet
7
8
  def initialize(file)
8
- @worksheet = TransyncConfig::WORKSHEETS.detect{ |w| w.title == file }
9
- abort("#{file} tab is not defined in GDoc") if @worksheet.nil?
9
+ @worksheet = TransyncConfig.worksheets.detect{ |w| w.title == file }
10
+ abort("\u{2717} '#{file}' tab is not defined in GDoc".colorize(:red)) if @worksheet.nil?
10
11
  end
11
12
 
12
13
  def translations(language)
@@ -22,7 +22,9 @@ module Transync
22
22
  TransyncConfig::CONFIG['FILES'].each do |file|
23
23
  xliff_files = XliffTransReader.new(PATH, file, TransyncConfig::CONFIG['LANGUAGES'])
24
24
  puts "\u{2713} '#{file}' have all the keys for all languages in XLIFF files.".colorize(:green) if xliff_files.valid?
25
+ end
25
26
 
27
+ TransyncConfig::CONFIG['FILES'].each do |file|
26
28
  TransyncConfig::CONFIG['LANGUAGES'].each do |language|
27
29
  trans_sync = TranslationSync.new(PATH, 'test', file)
28
30
 
@@ -32,7 +34,6 @@ module Transync
32
34
  puts "\u{2717} '#{file}.#{language}' XLIFF is NOT in sync with GDoc. See diff!".colorize(:red)
33
35
  end
34
36
  end
35
-
36
37
  puts '----------'
37
38
  end
38
39
  end
@@ -1,3 +1,5 @@
1
+ require 'colorize'
2
+
1
3
  class Init
2
4
 
3
5
  def initialize(path)
@@ -7,10 +9,10 @@ class Init
7
9
 
8
10
  def run
9
11
  @config['FILES'].each do |file|
10
- worksheet = TransyncConfig::WORKSHEETS.detect{ |s| s.title == file }
12
+ worksheet = TransyncConfig.worksheets.detect{ |s| s.title == file }
11
13
  if worksheet.nil?
12
- worksheet = TransyncConfig::SPREADSHEET.add_worksheet(file)
13
- p "Adding #{file} worksheet to spreadsheet with first row (key and languages)"
14
+ worksheet = TransyncConfig.spreadsheet.add_worksheet(file)
15
+ puts "\u{2713} adding '#{file}' worksheet to spreadsheet with first row (key and languages)".colorize(:green)
14
16
  end
15
17
 
16
18
  worksheet[1, 1] = 'Key'
@@ -21,9 +23,9 @@ class Init
21
23
  end
22
24
 
23
25
  # re-init spreadsheet after new worksheets were created
24
- TransyncConfig.init_spreadsheet
26
+ TransyncConfig.re_init
25
27
  sync = TranslationSync.new(@path, 'x2g')
26
- sync.run('x2g', nil)
28
+ sync.run('x2g')
27
29
  end
28
30
 
29
31
  end
@@ -17,16 +17,17 @@ class TranslationSync
17
17
  xliff_files = XliffTransReader.new(@path, file, @config['LANGUAGES'])
18
18
  abort('Fix your Xliff translations by hand or run transync update!') unless xliff_files.valid?
19
19
 
20
+ gdoc_trans_reader = GdocTransReader.new(file)
21
+ gdoc_trans_writer = GdocTransWriter.new(gdoc_trans_reader.worksheet)
22
+ xliff_trans_writer = XliffTransWriter.new(@path, file)
23
+
20
24
  @config['LANGUAGES'].each do |language|
21
25
  trans_sync = TranslationSync.new(@path, direction, file)
22
26
  trans_hash = trans_sync.sync(language, direction)
23
27
 
24
28
  if direction == 'x2g'
25
- gdoc_trans_reader = GdocTransReader.new(file)
26
- gdoc_trans_writer = GdocTransWriter.new(gdoc_trans_reader.worksheet)
27
29
  gdoc_trans_writer.write(trans_hash)
28
30
  else
29
- xliff_trans_writer = XliffTransWriter.new(@path, file)
30
31
  xliff_trans_writer.write(trans_hash)
31
32
  end
32
33
  end
@@ -8,6 +8,9 @@ module TransyncConfig
8
8
  WORKSHEET_COLUMNS = { key: 1 }
9
9
  START_ROW = 2
10
10
 
11
+ @spreadsheet = nil
12
+ @worksheets = nil
13
+
11
14
  def self.init_spreadsheet
12
15
  session = GoogleDrive.login(CONFIG['GDOC']['email'], CONFIG['GDOC']['password'])
13
16
  spreadsheet = session.spreadsheet_by_key(CONFIG['GDOC']['key'])
@@ -16,18 +19,33 @@ module TransyncConfig
16
19
  return spreadsheet, worksheets
17
20
  end
18
21
 
22
+ # This gets executed automatically when module is evaluated (required?)
19
23
  begin
20
24
  CONFIG = YAML.load(File.open('transync.yml'))
21
- SPREADSHEET, WORKSHEETS = TransyncConfig.init_spreadsheet
25
+ @spreadsheet, @worksheets = TransyncConfig.init_spreadsheet
26
+
27
+ # populate languages dynamically from settings yaml file
28
+ CONFIG['LANGUAGES'].each_with_index do |language, index|
29
+ key = language
30
+ value = index + 2
31
+ WORKSHEET_COLUMNS[key.to_sym] = value
32
+ end
22
33
  rescue => e
23
34
  p e.message
24
35
  exit(1)
25
36
  end
26
37
 
27
- # populate languages dynamically from settings yaml file
28
- CONFIG['LANGUAGES'].each_with_index do |language, index|
29
- key = language
30
- value = index + 2
31
- WORKSHEET_COLUMNS[key.to_sym] = value
38
+ # used for init command after we create new tabs
39
+ def self.re_init
40
+ @spreadsheet, @worksheets = TransyncConfig.init_spreadsheet
41
+ end
42
+
43
+ def self.worksheets
44
+ @worksheets
32
45
  end
46
+
47
+ def self.spreadsheet
48
+ @spreadsheet
49
+ end
50
+
33
51
  end
@@ -1,3 +1,3 @@
1
1
  module Transync
2
- VERSION = '1.1.1'
2
+ VERSION = '1.1.2'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: transync
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.1
4
+ version: 1.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - zigomir