getlocal 0.0.3 → 0.0.4

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: 44e9e1d11b5c82afee354f10b3fe469a0fcc525c
4
- data.tar.gz: 26a6f3c96f71412bca49fcb0b446f0958d2432bc
3
+ metadata.gz: 87a35bed0fc83dee63f750eca7f030ec2b9c3358
4
+ data.tar.gz: aa2294ec8f166678697fef0b41107ac48c4591fe
5
5
  SHA512:
6
- metadata.gz: c0df3b44d0e9f5d7375915bac6ed510a4a16784cdae47e4da02c1a21b8a3d9cc636498b0d1d41e5586ad6557eb104c7bb7cc0e6137c2c23a706d7487543a26e2
7
- data.tar.gz: 1be269374a4fc4b01c1c4ade918dd96e1925ab61e7abc542b00a3195bdffdb1b3a57f862ef38f96bc003dc8c7c1df01fecd392c44a01e6c4490a7f779a44e63e
6
+ metadata.gz: 25b7ae479b6a1f180c072bebc32d3adea867714e7d00bf4ba498fe8e193cc94a982df3e60dde267e6ae0734aa45e9d78a37022984ce99b970b2a96ecc3ef5cc3
7
+ data.tar.gz: 4c1e5bf5862f18407b340995b5bb27065af472a8953581f6257d897bcc943fdd8f2f1bbd5f276bbf24786d724dda77ac4f5b871c6cc563dc72d4e3c610076884
data/lib/getlocal/cli.rb CHANGED
@@ -3,7 +3,7 @@
3
3
  require 'zip'
4
4
  require 'thread'
5
5
  require 'io/console'
6
-
6
+
7
7
  require 'thor'
8
8
  require 'httmultiparty'
9
9
 
@@ -17,17 +17,18 @@ module Getlocal
17
17
 
18
18
  method_option :user, :required => true, :aliases => "-u"
19
19
  method_option :password, :aliases => "-p"
20
+ method_option :timeout, :aliases => "-t"
20
21
  desc "fetch [PROJECT]", "Used to fetch the latest localisations"
21
22
  def fetch(project)
22
-
23
+
23
24
  # Check if we are in the right place
24
25
  if Dir.glob('*.lproj').empty?
25
26
  puts "Wrong directory please select the directory that contains the .lproj folders"
26
27
  return
27
28
  end
28
-
29
+
29
30
  username = options[:user]
30
-
31
+
31
32
  # Check if we need to ask for a password
32
33
  if options[:password]
33
34
  password = options[:password]
@@ -36,7 +37,7 @@ module Getlocal
36
37
  password = STDIN.noecho(&:gets).chomp
37
38
  puts ""
38
39
  end
39
-
40
+
40
41
  if !options[:verbose] then
41
42
  Thread.new do
42
43
  #set up spinner
@@ -49,15 +50,22 @@ module Getlocal
49
50
  end
50
51
  end
51
52
  end
52
-
53
+
53
54
  auth = {:username => username, :password => password}
54
-
55
+
55
56
  puts "Fetching the zip. This may take a while" if options[:verbose]
56
-
57
+
57
58
  zipfile = Tempfile.new("file")
58
-
59
+
60
+ if options[:timeout] then
61
+ timeout == options[:timeout]
62
+ else
63
+ timeout == 600
64
+ end
65
+
59
66
  begin
60
- response = HTTParty.get("https://api.getlocalization.com/#{project}/api/translations/zip/", :basic_auth => auth, :timeout => 600)
67
+
68
+ response = HTTParty.get("https://api.getlocalization.com/#{project}/api/translations/zip/", :basic_auth => auth, :timeout => timeout)
61
69
  rescue
62
70
  puts "Oh no, somthing fucked up."
63
71
  return
@@ -76,19 +84,19 @@ module Getlocal
76
84
  ensure
77
85
  zipfile.close
78
86
  end
79
-
87
+
80
88
  puts "Extracting the zip" if options[:verbose]
81
89
  Zip::File.open(zipfile.path) do |zipFile|
82
90
  # Handle entries one by one
83
91
  zipFile.each do |entry|
84
92
  # Extract to correct location
85
93
  pathComponents = entry.name.split("/")
86
-
94
+
87
95
  destFolder = pathComponents[0] + '.lproj'
88
96
  destFile = pathComponents[1]
89
-
97
+
90
98
  destPath = destFolder + '/' + destFile
91
-
99
+
92
100
  if Dir.exists?(destFolder)
93
101
  puts "Extracting #{destFile} to #{destPath}" if options[:verbose]
94
102
  File.delete(destPath) if File.exist?(destPath)
@@ -96,18 +104,18 @@ module Getlocal
96
104
  else
97
105
  puts destFolder + " folder not found. Couldn't import " + destFile if options[:verbose]
98
106
  end
99
-
107
+
100
108
  end
101
109
  end
102
-
110
+
103
111
  end
104
-
112
+
105
113
  method_option :user, :required => true, :aliases => "-u"
106
114
  method_option :password, :aliases => "-p"
107
115
  desc "update [PROJECT]", "Used to send the latest localisations to get localization"
108
116
  def update(project)
109
117
  username = options[:user]
110
-
118
+
111
119
  # Check if we need to ask for a password
112
120
  if options[:password]
113
121
  password = options[:password]
@@ -116,7 +124,7 @@ module Getlocal
116
124
  password = STDIN.noecho(&:gets).chomp
117
125
  puts ""
118
126
  end
119
-
127
+
120
128
  if !options[:verbose] then
121
129
  Thread.new do
122
130
  #set up spinner
@@ -129,12 +137,12 @@ module Getlocal
129
137
  end
130
138
  end
131
139
  end
132
-
140
+
133
141
  auth = {:username => username, :password => password}
134
-
142
+
135
143
  puts "Requesting the list of master files" if options[:verbose]
136
144
  response = HTTParty.get("https://api.getlocalization.com/#{project}/api/list-master/json/", :basic_auth => auth)
137
-
145
+
138
146
  if response.code == 200 then
139
147
  parsedResponse = JSON.parse(response.body)
140
148
  if parsedResponse['success'] == "1"
@@ -148,14 +156,14 @@ module Getlocal
148
156
  puts "couldn't fetch list of master files"
149
157
  return
150
158
  end
151
-
159
+
152
160
  Dir.glob("Base.lproj/*.strings") do |stringFilePath|
153
-
161
+
154
162
  alreadyExists = currentMasterFiles.include?(stringFilePath.gsub("Base.lproj/", ""))
155
-
163
+
156
164
  body = {"file" => File.new(stringFilePath)}
157
-
158
-
165
+
166
+
159
167
  if alreadyExists
160
168
  # Update master
161
169
  puts "Updateing " + stringFilePath if options[:verbose]
@@ -165,11 +173,11 @@ module Getlocal
165
173
  puts "Creating " + stringFilePath if options[:verbose]
166
174
  response = HTTMultiParty.post("https://api.getlocalization.com/#{project}/api/create-master/ios/en/", :basic_auth => auth, :query => body)
167
175
  end
168
-
176
+
169
177
  puts "Upload complete with responce code #{response.code}" if options[:verbose]
170
178
  puts "" if options[:verbose]
171
179
  end
172
-
180
+
173
181
  end
174
182
  end
175
- end
183
+ end
@@ -1,3 +1,3 @@
1
1
  module Getlocal
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: getlocal
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Benjamin Briggs
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-07-22 00:00:00.000000000 Z
11
+ date: 2015-01-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler