smartling_xcode 0.1.5 → 0.1.6

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: fd8109b6538b3512dfecf179841422d88d788d31
4
- data.tar.gz: b1ee650d51f1dde4cd9e41f45e5d409fc3225f14
3
+ metadata.gz: ac0f92fc6ca6cfe0e3d5a53537ee75a73de59907
4
+ data.tar.gz: b51eb2b809d3603b0605562ae4f99ab3dfd95bca
5
5
  SHA512:
6
- metadata.gz: a45eb744de29013ba281a183ccdb89595027a502be0ec50e060a0bc8dc3d575f23a5ffdad345c046acf02a5f9ea88a55695a404bf4b3c2791e8a6ee219787f3a
7
- data.tar.gz: cc1dff99bc4a14d35090958e26d73e758c3cfd931f9a5af245ec18a5b8af7433def339c3097320c4f8ebf07628b4537770a79d439c56a338c5a916057cffae2a
6
+ metadata.gz: 2f7eed95202dc8d3c0300518e3951acf462273b56da5b78563cefe7a8f647c97ebdfd4875130ac75b697a95aa84d7f403654621b113b078e95d5a93403f67cca
7
+ data.tar.gz: 2a6b48f94b520dfb83706527584c869356fdcb0514bd9630c6048570f8b31c68b1d93ba357abae84a44ba1dab6b440e84528fc100fd0aeec83c1c2e689942618
data/bin/smartling_xcode CHANGED
@@ -19,7 +19,7 @@ ARGV.each do |arg|
19
19
  sl.sandbox = true
20
20
 
21
21
  # Commands
22
- when 'init', 'extract', 'push' then command = arg
22
+ when 'init', 'extract', 'push', 'getversion' then command = arg
23
23
 
24
24
  else
25
25
  if command.nil?
@@ -28,7 +28,7 @@ ARGV.each do |arg|
28
28
  sl.version = arg
29
29
  version_is_next = false
30
30
  else
31
- sl.project_path = arg
31
+ sl.projectPath = arg
32
32
  end
33
33
  end
34
34
  end
@@ -29,5 +29,11 @@ module SmartlingXcode
29
29
  api.pushStringsFromFiles(files, @version)
30
30
  puts "\nYour files are now available in the Files section of your Smartling project."
31
31
  end
32
+
33
+ def getversion
34
+ project = Xcodeproj::Project.find(@projectPath)
35
+ @version = project.getVersion
36
+ puts "Version #{@version} will be used."
37
+ end
32
38
  end
33
39
  end
@@ -75,7 +75,6 @@ module SmartlingXcode
75
75
  end
76
76
 
77
77
  def pushStringsFromFiles(files, version)
78
- sl = fileApi()
79
78
  files.each do |f|
80
79
 
81
80
  # Check if file exists
@@ -84,29 +83,58 @@ module SmartlingXcode
84
83
  next
85
84
  end
86
85
 
87
- # Check if file contains at least one string
88
- file = File.open(f)
89
- line = file.read.scrub.tr("\000", '').gsub(/\s+/, "")
90
- if !line.include?('=')
91
- puts "No strings in #{f}"
92
- next
86
+ if f.to_s.end_with?(".strings")
87
+ pushStringsFile(f, version)
88
+ elsif
89
+ pushStringsdictFile(f, version)
90
+ end
91
+ end
92
+ end
93
+
94
+ def pushStringsFile(f, version)
95
+ sl = fileApi()
96
+
97
+ # Check if file contains at least one string
98
+ file = File.open(f)
99
+ line = file.read.scrub.tr("\000", '').gsub(/\s+/, "")
100
+ if !line.include?('=')
101
+ puts "No strings in #{f}"
102
+ return
103
+ end
104
+
105
+ remote_path = "/#{version}/#{f.to_s.split('/').last}"
106
+
107
+ # Upload
108
+ begin
109
+ res = sl.upload(f.to_s, remote_path, "ios", {:authorize => true})
110
+ if res
111
+ puts "Uploaded #{res['stringCount']} strings from #{f}"
112
+ end
113
+ rescue Exception => e
114
+ puts "⚠️ Upload failed for #{f}"
115
+ if e.message
116
+ puts e.message
93
117
  end
118
+ end
119
+ end
94
120
 
95
- remote_path = "/#{version}/#{f.to_s.split('/').last}"
96
-
97
- # Upload
98
- begin
99
- res = sl.upload(f.to_s, remote_path, "ios", {:authorize => true})
100
- if res
101
- puts "Uploaded #{res['stringCount']} strings from #{f}"
102
- end
103
- rescue Exception => e
104
- puts "⚠️ Upload failed for #{f}"
105
- if e.message
106
- puts e.message
107
- end
121
+ def pushStringsdictFile(f, version)
122
+ sl = fileApi()
123
+ remote_path = "/#{version}/#{f.to_s.split('/').last}"
124
+
125
+ # Upload
126
+ begin
127
+ res = sl.upload(f.to_s, remote_path, "stringsdict", {:authorize => true})
128
+ if res
129
+ puts "Uploaded #{f}"
130
+ end
131
+ rescue Exception => e
132
+ puts "⚠️ Upload failed for #{f}"
133
+ if e.message
134
+ puts e.message
108
135
  end
109
136
  end
110
137
  end
138
+
111
139
  end
112
140
  end
@@ -1,5 +1,5 @@
1
1
  module SmartlingXcode
2
- VERSION = "0.1.5"
2
+ VERSION = "0.1.6"
3
3
  USAGE = <<ENDUSAGE
4
4
  Smartling utility to extract strings from an Xcode project
5
5
  and add them to a Smartling project.
@@ -7,11 +7,17 @@ module Xcodeproj
7
7
  def self.find(path)
8
8
  # Get .xcodeproj path
9
9
  if path.nil?
10
- project_file = Dir.entries('./').select {|f| f.end_with?(".xcodeproj") }.first
11
- path = "./#{project_file}"
10
+ path = './'
12
11
  end
13
12
 
14
- if !path.nil? && File.exist?(path)
13
+ if File.exist?(path)
14
+ if !path.end_with?(".xcodeproj")
15
+ project_file = Dir.entries(path).select {|f| f.end_with?(".xcodeproj") }.first
16
+ path = "#{path}/#{project_file}".gsub("//", "/")
17
+ end
18
+
19
+ puts "Using project #{path}"
20
+
15
21
  # Open project
16
22
  begin
17
23
  return Xcodeproj::Project.open(path)
@@ -46,9 +52,9 @@ module Xcodeproj
46
52
  strings_files.push(output_path)
47
53
  end
48
54
 
49
- # Loop on .strings files
55
+ # Loop on .strings and .stringsdict files
50
56
  self.files.select{|f|
51
- f.path.end_with?(".strings") && Project.fromBase(f.path)
57
+ Project.fromBase(f.path) && f.path.end_with?(".strings", ".stringsdict")
52
58
  }.each do |f|
53
59
  strings_files.push(f.real_path)
54
60
  end
@@ -57,11 +63,12 @@ module Xcodeproj
57
63
  end
58
64
 
59
65
  def getVersion
66
+ puts "Looking for an app version number to use for the strings files upload..."
60
67
  versions = []
61
68
  self.files.select{|f| f.path.end_with?(".plist")}.each do |f|
62
69
  contents = Xcodeproj::Plist.read_from_path(f.real_path)
63
70
  if contents['CFBundleShortVersionString']
64
- versions.push({:version => contents['CFBundleShortVersionString'], :file => f.path})
71
+ versions.push({:version => contents['CFBundleShortVersionString'], :file => f.hierarchy_path})
65
72
  end
66
73
  end
67
74
 
@@ -71,13 +78,16 @@ module Xcodeproj
71
78
  version = STDIN.gets.chomp
72
79
  return version
73
80
  when 1
74
- return versions.first[:version]
81
+ file = versions.first
82
+ version = file[:version]
83
+ puts "Using #{version} found in #{file[:file]}"
84
+ return version
75
85
  else
76
- puts "Multiple Info.plist files found."
86
+ puts "Multiple Info.plist files found. Please select which version number to use:"
77
87
  versions.each_with_index do |v, i|
78
88
  puts "#{i}. #{v[:version]} from #{v[:file]}"
79
89
  end
80
- puts "Please select which version number to use:"
90
+ puts "Selection: "
81
91
  choice = nil
82
92
  while choice.nil?
83
93
  choice = STDIN.gets.chomp.to_i
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: smartling_xcode
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.5
4
+ version: 0.1.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Emilien Huet
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-11-30 00:00:00.000000000 Z
11
+ date: 2017-03-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: xcodeproj