getlocal 0.0.5 → 0.1.0

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: 32fad14425e0c9d1ac334b685859a7d4e5eccb65
4
- data.tar.gz: ef7b2325fd7435f3a15d4c4bae23c52683028ef7
3
+ metadata.gz: e958e892452a0d3f63f2694a9c2521c8c1d907eb
4
+ data.tar.gz: 761bf80f42ad3a85aed5c34a4bf31c54b153e0d0
5
5
  SHA512:
6
- metadata.gz: 4efd1312b6b38dcf7c481ecc79e8c4a39c941f4271c73d40832c2d94acd8bd4228761427729c3cf714c4e34fa0bc00f43c36d30dc878745a74825e82f5e53a77
7
- data.tar.gz: 85bb53071266fbbe905b16df4d62e32c24f63c11e833ab38b271defd53b0b3f88a53b6932e15be5ed2449b4866b99a5eae97647d1731142d8d9ceef42f63d287
6
+ metadata.gz: 0079e0e27d6637e97452b92e2033c81134fa10cf57e28a1bb807df52ec9567a5f20cb36abf4f5f2d754d575648348c2685ebb229e5b21b2b11d295c6e76469de
7
+ data.tar.gz: 0506c7f248f276eb7c4de6a2bcf11c6aabf945f3822ef844bc6b741d9bd4008663aa1c9a0b195def4623173b9dd126c21546408d1b5b30a015cbf1ee36641bc4
@@ -20,10 +20,11 @@ Gem::Specification.new do |spec|
20
20
 
21
21
  spec.add_development_dependency "bundler", "~> 1.6"
22
22
  spec.add_development_dependency "rake", '~> 10.3'
23
-
23
+
24
24
  spec.add_dependency "thor", '~> 0.19'
25
25
  spec.add_dependency "json", '~> 1.8'
26
26
  spec.add_dependency "httmultiparty", '~> 0.3'
27
27
  spec.add_dependency "rubyzip", '~> 1.1'
28
-
28
+ spec.add_dependency "powerbar", '~> 1.0'
29
+
29
30
  end
@@ -6,6 +6,7 @@ require 'io/console'
6
6
 
7
7
  require 'thor'
8
8
  require 'httmultiparty'
9
+ require 'powerbar'
9
10
 
10
11
  require 'getlocal'
11
12
 
@@ -38,68 +39,78 @@ module Getlocal
38
39
  puts ""
39
40
  end
40
41
 
41
- if !options[:verbose] then
42
- Thread.new do
43
- #set up spinner
44
- glyphs = ['|', '/', '-', "\\"]
45
- while true
46
- glyphs.each do |g|
47
- print "\r#{g}"
48
- sleep 0.15
49
- end
50
- end
51
- end
52
- end
42
+ p = PowerBar.new
53
43
 
54
44
  auth = {:username => username, :password => password}
55
45
 
56
- puts "Fetching the zip. This may take a while" if options[:verbose]
46
+ # Find all the languages we support
47
+ supportedLanguages = []
48
+ Dir.glob("*.lproj") do |filePath|
49
+ f = File.basename(filePath, ".*")
50
+ supportedLanguages << f unless f == "Base"
51
+ end
57
52
 
58
- zipfile = Tempfile.new("file")
53
+ puts "Fetching localisations for" if options[:verbose]
54
+ puts "" if options[:verbose]
59
55
 
60
- begin
61
- response = HTTParty.get("https://api.getlocalization.com/#{project}/api/translations/zip/", :basic_auth => auth, :timeout => options[:timeout])
62
- rescue
63
- puts "Oh no, somthing fucked up."
64
- return
65
- else
66
- if response.code == 200
67
- puts "Zip downloaded" if options[:verbose]
68
- zipfile.binmode # This might not be necessary depending on the zip file
69
- zipfile.write(response.body)
70
- elsif response.code == 401
71
- puts "The username or password are invailed"
72
- return
73
- else
74
- puts "Bad response. Close but no cigar."
75
- return
76
- end
77
- ensure
78
- zipfile.close
79
- end
56
+ total = Dir.glob("Base.lproj/*.strings").count * supportedLanguages.count
57
+ current = 0
58
+
59
+ # Loop through the string files we have localy
60
+ Dir.glob("Base.lproj/*.strings") do |stringFilePath|
80
61
 
81
- puts "Extracting the zip" if options[:verbose]
82
- Zip::File.open(zipfile.path) do |zipFile|
83
- # Handle entries one by one
84
- zipFile.each do |entry|
85
- # Extract to correct location
86
- pathComponents = entry.name.split("/")
62
+ fileName = File.basename(stringFilePath)
63
+ puts "-- #{fileName} --" if options[:verbose]
64
+ puts "" if options[:verbose]
87
65
 
88
- destFolder = pathComponents[0] + '.lproj'
89
- destFile = pathComponents[1]
66
+ # Request the translations for each supported language
67
+ supportedLanguages.each do |lang|
90
68
 
91
- destPath = destFolder + '/' + destFile
69
+ current = current.next
70
+ p.show(:msg => 'Fetching Translation', :done => current, :total => total) unless options[:verbose]
92
71
 
93
- if Dir.exists?(destFolder)
94
- puts "Extracting #{destFile} to #{destPath}" if options[:verbose]
95
- File.delete(destPath) if File.exist?(destPath)
96
- entry.extract(destPath)
72
+ tempfile = Tempfile.new("file")
73
+
74
+ puts "Fetching #{lang} for #{fileName}." if options[:verbose]
75
+ begin
76
+ response = HTTParty.get("https://api.getlocalization.com/#{project}/api/translations/file/#{fileName}/#{lang}/", :basic_auth => auth, :timeout => options[:timeout])
77
+ rescue
78
+ puts "Oh no, somthing fucked up."
79
+ return
97
80
  else
98
- puts destFolder + " folder not found. Couldn't import " + destFile if options[:verbose]
81
+ if response.code == 200
82
+ puts "File downloaded" if options[:verbose]
83
+ tempfile.binmode # This might not be necessary depending on the zip file
84
+ tempfile.write(response.body)
85
+
86
+
87
+ destFolder = lang + ".lproj"
88
+ destFile = fileName
89
+
90
+ destPath = destFolder + '/' + destFile
91
+
92
+ puts "moveing translations to #{destPath}" if options[:verbose]
93
+
94
+ if Dir.exists?(destFolder)
95
+ File.delete(destPath) if File.exist?(destPath)
96
+ FileUtils.mv(tempfile.path, destPath)
97
+ else
98
+ puts destFolder + " folder not found. Couldn't import " + destFile if options[:verbose]
99
+ end
100
+ elsif response.code == 401
101
+ puts "The username or password are invailed"
102
+ return
103
+ else
104
+ puts "Bad response. Close but no cigar."
105
+ puts "Sorry couldn't get #{lang} translations this time."
106
+ end
107
+ ensure
108
+ tempfile.close
99
109
  end
100
-
110
+ puts "" if options[:verbose]
101
111
  end
102
-
112
+ puts "" if options[:verbose]
113
+ puts "" if options[:verbose]
103
114
  end
104
115
 
105
116
  end
@@ -157,7 +168,6 @@ module Getlocal
157
168
 
158
169
  body = {"file" => File.new(stringFilePath)}
159
170
 
160
-
161
171
  if alreadyExists
162
172
  # Update master
163
173
  puts "Updateing " + stringFilePath if options[:verbose]
@@ -1,3 +1,3 @@
1
1
  module Getlocal
2
- VERSION = "0.0.5"
2
+ VERSION = "0.1.0"
3
3
  end
metadata CHANGED
@@ -1,99 +1,113 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: getlocal
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Benjamin Briggs
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-01-23 00:00:00.000000000 Z
11
+ date: 2015-02-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ~>
18
18
  - !ruby/object:Gem::Version
19
19
  version: '1.6'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - "~>"
24
+ - - ~>
25
25
  - !ruby/object:Gem::Version
26
26
  version: '1.6'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - "~>"
31
+ - - ~>
32
32
  - !ruby/object:Gem::Version
33
33
  version: '10.3'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - "~>"
38
+ - - ~>
39
39
  - !ruby/object:Gem::Version
40
40
  version: '10.3'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: thor
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - "~>"
45
+ - - ~>
46
46
  - !ruby/object:Gem::Version
47
47
  version: '0.19'
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - "~>"
52
+ - - ~>
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0.19'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: json
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - "~>"
59
+ - - ~>
60
60
  - !ruby/object:Gem::Version
61
61
  version: '1.8'
62
62
  type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - "~>"
66
+ - - ~>
67
67
  - !ruby/object:Gem::Version
68
68
  version: '1.8'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: httmultiparty
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - "~>"
73
+ - - ~>
74
74
  - !ruby/object:Gem::Version
75
75
  version: '0.3'
76
76
  type: :runtime
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - "~>"
80
+ - - ~>
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0.3'
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: rubyzip
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
- - - "~>"
87
+ - - ~>
88
88
  - !ruby/object:Gem::Version
89
89
  version: '1.1'
90
90
  type: :runtime
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
- - - "~>"
94
+ - - ~>
95
95
  - !ruby/object:Gem::Version
96
96
  version: '1.1'
97
+ - !ruby/object:Gem::Dependency
98
+ name: powerbar
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ~>
102
+ - !ruby/object:Gem::Version
103
+ version: '1.0'
104
+ type: :runtime
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ~>
109
+ - !ruby/object:Gem::Version
110
+ version: '1.0'
97
111
  description: This is a in house tool developed by Palringo to help interface with
98
112
  the GetLocaization API
99
113
  email:
@@ -103,7 +117,7 @@ executables:
103
117
  extensions: []
104
118
  extra_rdoc_files: []
105
119
  files:
106
- - ".gitignore"
120
+ - .gitignore
107
121
  - Gemfile
108
122
  - LICENSE.txt
109
123
  - README.md
@@ -123,17 +137,17 @@ require_paths:
123
137
  - lib
124
138
  required_ruby_version: !ruby/object:Gem::Requirement
125
139
  requirements:
126
- - - ">="
140
+ - - '>='
127
141
  - !ruby/object:Gem::Version
128
142
  version: '0'
129
143
  required_rubygems_version: !ruby/object:Gem::Requirement
130
144
  requirements:
131
- - - ">="
145
+ - - '>='
132
146
  - !ruby/object:Gem::Version
133
147
  version: '0'
134
148
  requirements: []
135
149
  rubyforge_project:
136
- rubygems_version: 2.2.2
150
+ rubygems_version: 2.4.5
137
151
  signing_key:
138
152
  specification_version: 4
139
153
  summary: A simple tool to make keeping GetLocalisation up to date