strings_updater 0.1.1 → 0.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.
@@ -0,0 +1,18 @@
1
+ class AndroidStringsUpdater < StringsUpdater
2
+ def begin_document
3
+ @document = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<resources>\n"
4
+ end
5
+
6
+ def end_document
7
+ @document += "</resources>"
8
+ end
9
+
10
+ def add_translation(key, to)
11
+ @document += " <stringname=\"#{key}\">#{to}</string>\n"
12
+ end
13
+
14
+
15
+ def add_comment(comment)
16
+ @document += "\n <!-- #{comment} -->\n\n"
17
+ end
18
+ end
@@ -0,0 +1,13 @@
1
+ class IosStringsUpdater < StringsUpdater
2
+ def begin_document
3
+ @document = "\nFile generated by Strings Updater v0.1\nMore info: https://github.com/artur-gurgul/strings_updater\n\n\n"
4
+ end
5
+
6
+ def add_translation(key, to)
7
+ @document += "\"#{key}\" = \"#{to};\n"
8
+ end
9
+
10
+ def add_comment(comment)
11
+ @document += "\n// #{comment}\n\n"
12
+ end
13
+ end
@@ -1,8 +1,4 @@
1
1
 
2
- #THIS IS TRIVIAL CODE WITHOUT LICENCE
3
- # depends: google_drive, inifile
4
- #!/usr/bin/env ruby
5
-
6
2
  require "inifile"
7
3
  require 'google_drive'
8
4
 
@@ -11,10 +7,6 @@ class StringsUpdater
11
7
  "./"
12
8
  end
13
9
 
14
- def temp_catalog_name
15
- "temp_proj"
16
- end
17
-
18
10
  def read_settings
19
11
  config = IniFile.load "#{Dir.home}/.aplist/cred.cfg", :parameter => ":", :comment => ';'
20
12
 
@@ -22,40 +14,57 @@ class StringsUpdater
22
14
  @user_password = config["user"]["password"]
23
15
  end
24
16
 
25
- def get_plist_with_document_id(document_id)
17
+ def get_document_id(document_id, col)
26
18
 
27
19
  read_settings
28
20
 
29
21
  session = GoogleDrive.login(@user_name, @user_password)
30
22
  @ws = session.spreadsheet_by_key(document_id).worksheets[0]
31
23
 
32
- plist = "\nFile generated Strings Updater v0.1\nMore info: https://github.com/artur-gurgul/strings_updater\n\n\n"
24
+ @document = ""
25
+ begin_document
26
+
33
27
  i = 2
34
28
  while true
35
29
 
36
30
 
37
31
  break if @ws[i, 1] == "."
38
32
 
39
- plist += "\n//#{@ws[i, 1]}\n\n" if @ws[i, 1] != ""
33
+ add_comment @ws[i, 1] if @ws[i, 1] != ""
34
+
35
+ if @ws[i, 2] != ""
36
+ key = @ws[i, 2].downcase.scan(/[a-z]+/)[0..2].join "_"
37
+
38
+ add_translation key, @ws[i, col]
39
+ end
40
40
 
41
- plist += "\"#{@ws[i, 2]}\" = \"#{@ws[i, 3]};\n" if @ws[i, 2] != ""
42
41
  i += 1
43
42
  end
44
- plist
43
+
44
+ end_document
45
+
46
+ @document
47
+
45
48
  end
46
49
 
47
- def push_project(project_url,output_path,spread_id, branch_name)
50
+ def push_project(project_url,output_path,spread_id, branch_name, folder_name, col)
48
51
  Dir.chdir working_dictionary
52
+ proj_path = working_dictionary + folder_name
53
+
54
+ puts "updating..."
55
+ if File.exist? folder_name
56
+ Dir.chdir folder_name
57
+ `git pull origin #{branch_name}`
58
+ else
59
+ `git clone #{project_url} #{folder_name}`
60
+ Dir.chdir folder_name
61
+ # exit(-1) if $?.exitstatus != 0
62
+ end
49
63
 
50
- puts "cloning..."
51
- `git clone #{project_url} #{temp_catalog_name}`
52
- exit(-1) if $?.exitstatus != 0
53
-
54
- proj_path = working_dictionary + temp_catalog_name
55
- Dir.chdir proj_path
64
+ `git checkout #{branch_name}`
56
65
 
57
66
  puts "downloading google document..."
58
- plist = get_plist_with_document_id(spread_id)
67
+ plist = get_document_id(spread_id, col)
59
68
 
60
69
  f = File.new(output_path, "w")
61
70
  f.write(plist)
@@ -66,11 +75,25 @@ class StringsUpdater
66
75
  `git push origin #{branch_name}`
67
76
  exit(-1) if $?.exitstatus != 0
68
77
 
69
- puts "cleaning ..."
70
- Dir.chdir working_dictionary
71
- `rm -rf #{proj_path}`
72
78
  puts "DONE"
73
79
  end
80
+
81
+ # callbacks
82
+ def begin_document
83
+
84
+ end
85
+
86
+ def end_document
87
+
88
+ end
89
+
90
+ def add_translation(key, to)
91
+
92
+ end
93
+
94
+ def add_comment(comment)
95
+
96
+ end
74
97
  end
75
98
 
76
99
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: strings_updater
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -49,7 +49,9 @@ executables: []
49
49
  extensions: []
50
50
  extra_rdoc_files: []
51
51
  files:
52
- - lib/StringsUpdater.rb
52
+ - lib/strings_updater.rb
53
+ - lib/android_strings_updater.rb
54
+ - lib/ios_strings_updater.rb
53
55
  homepage: https://github.com/artur-gurgul/plist_updater
54
56
  licenses: []
55
57
  post_install_message: