one_sky 2.0.1 → 2.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 +7 -0
- data/.travis.yml +9 -0
- data/CHANGELOG +2 -0
- data/Gemfile.lock +3 -3
- data/lib/one_sky/client.rb +1 -1
- data/lib/one_sky/translation.rb +17 -9
- data/lib/one_sky/version.rb +1 -1
- data/spec/live_spec.rb +7 -5
- data/spec/translation_spec.rb +18 -1
- metadata +45 -32
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: a26f82a2889f17e52b7eb2e29e5b14044636dbd2
|
4
|
+
data.tar.gz: 102ac67ec03058c57c8e3d7b1a4dd85daa34f284
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 0da077a007c4aac66d1ab9ddec40e5d44ac88cf3fa4e1426797f25cf1d79a69979d936ab5a6b388675b8d792a07751fbb2171c8cc535d3f32a50a0628efa6842
|
7
|
+
data.tar.gz: 462f54493da9fcd9137aad7dbaf80ed0ef3825e89ea7f833717ab3576cf5a9bdfe757dd3fda989d76841a06d6d0d10abe43bff63799221438dbc8e199cd4676d
|
data/.travis.yml
ADDED
data/CHANGELOG
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
one_sky (2.0.
|
4
|
+
one_sky (2.0.1)
|
5
5
|
json (>= 1.4.0)
|
6
6
|
rest-client (>= 1.4.0)
|
7
7
|
|
@@ -9,8 +9,8 @@ GEM
|
|
9
9
|
remote: http://rubygems.org/
|
10
10
|
specs:
|
11
11
|
diff-lcs (1.1.3)
|
12
|
-
json (1.
|
13
|
-
mime-types (
|
12
|
+
json (1.8.1)
|
13
|
+
mime-types (2.3)
|
14
14
|
rest-client (1.6.7)
|
15
15
|
mime-types (>= 1.16)
|
16
16
|
rspec (2.2.0)
|
data/lib/one_sky/client.rb
CHANGED
@@ -73,7 +73,7 @@ module OneSky
|
|
73
73
|
return response.body unless response.headers[:content_type] =~ /json/
|
74
74
|
response_hash = JSON.parse(response.body)
|
75
75
|
|
76
|
-
raise ApiError, response.body if response_hash.has_key?("response") and response_hash["response"] != "ok"
|
76
|
+
raise ApiError, response.body if response_hash.has_key?("response") and (response_hash["response"] != "ok" && response_hash["response"] != 'upload-in-progress')
|
77
77
|
response_hash
|
78
78
|
end
|
79
79
|
end
|
data/lib/one_sky/translation.rb
CHANGED
@@ -30,10 +30,18 @@ module OneSky
|
|
30
30
|
# Add new strings to be translated.
|
31
31
|
# expects a hash of {"string_key1" => "String 1", "string_key2" => "String 2"}
|
32
32
|
def input_phrases(phrases, options={})
|
33
|
-
strings = phrases.map do |string_key,
|
34
|
-
|
33
|
+
strings = phrases.map do |string_key, value|
|
34
|
+
if value.is_a? Array
|
35
|
+
output = []
|
36
|
+
value.each_with_index do |string, index|
|
37
|
+
output << {:string_key => string_key.to_s, :string => string, :context => index}
|
38
|
+
end
|
39
|
+
output
|
40
|
+
else
|
41
|
+
{:string_key => string_key.to_s, :string => value}
|
42
|
+
end
|
35
43
|
end
|
36
|
-
input_strings(strings, options)
|
44
|
+
input_strings(strings.flatten(1), options)
|
37
45
|
end
|
38
46
|
|
39
47
|
# Add translation to a string.
|
@@ -67,13 +75,13 @@ module OneSky
|
|
67
75
|
end
|
68
76
|
|
69
77
|
# Download strings and translations as string file. In RUBY_YAML format.
|
70
|
-
def download_yaml(locale)
|
71
|
-
download_file(locale, YAML_FORMAT)
|
78
|
+
def download_yaml(locale, options={})
|
79
|
+
download_file(options.merge(:locale => locale, :format => YAML_FORMAT))
|
72
80
|
end
|
73
81
|
|
74
82
|
# Download strings and translations as string file. In GNU_PO format.
|
75
|
-
def download_po(locale)
|
76
|
-
download_file(locale, PO_FORMAT)
|
83
|
+
def download_po(locale, options ={})
|
84
|
+
download_file(options.merge(:locale => locale, :format => PO_FORMAT))
|
77
85
|
end
|
78
86
|
|
79
87
|
protected
|
@@ -92,8 +100,8 @@ module OneSky
|
|
92
100
|
end
|
93
101
|
|
94
102
|
# Download strings and translations as string file.
|
95
|
-
def download_file(
|
96
|
-
get("string/download",
|
103
|
+
def download_file(options)
|
104
|
+
get("string/download", options)
|
97
105
|
end
|
98
106
|
|
99
107
|
def get(path, params={})
|
data/lib/one_sky/version.rb
CHANGED
data/spec/live_spec.rb
CHANGED
@@ -43,7 +43,7 @@ describe OneSky, :live => true do
|
|
43
43
|
locales.should be_an_instance_of Array
|
44
44
|
locales.should_not be_empty
|
45
45
|
en_us = locales.detect{|l| l["locale"] == english_locale }
|
46
|
-
en_us["name"]["eng"].should == "English
|
46
|
+
en_us["name"]["eng"].should == "English"
|
47
47
|
end
|
48
48
|
|
49
49
|
it "platform_types" do
|
@@ -51,7 +51,7 @@ describe OneSky, :live => true do
|
|
51
51
|
types.should be_an_instance_of Array
|
52
52
|
types.should_not be_empty
|
53
53
|
website = types.detect{|t| t["code"] == platform_code }
|
54
|
-
website.should == {"name" => "Website", "code" => platform_code}
|
54
|
+
website.should == {"name" => "Regular Website", "code" => platform_code}
|
55
55
|
end
|
56
56
|
|
57
57
|
it "get_sso_link" do
|
@@ -100,7 +100,7 @@ describe OneSky, :live => true do
|
|
100
100
|
locales.should be_an_instance_of Array
|
101
101
|
locales.should_not be_empty
|
102
102
|
en_us = locales.detect{|l| l["locale"] == english_locale }
|
103
|
-
en_us["name"]["eng"].should == "English
|
103
|
+
en_us["name"]["eng"].should == "English"
|
104
104
|
end
|
105
105
|
end
|
106
106
|
|
@@ -146,7 +146,7 @@ describe OneSky, :live => true do
|
|
146
146
|
it "output_for_locale" do
|
147
147
|
output = translation.output_for_locale(chinese_locale)
|
148
148
|
output.should be_an_instance_of Hash
|
149
|
-
|
149
|
+
|
150
150
|
output["Default"].keys.should == [chinese_locale]
|
151
151
|
output["Default"][chinese_locale].should have_key("test1")
|
152
152
|
end
|
@@ -165,9 +165,11 @@ describe OneSky, :live => true do
|
|
165
165
|
end
|
166
166
|
|
167
167
|
it "download_yaml" do
|
168
|
+
chinese_locale = "zh-CN"
|
169
|
+
|
168
170
|
yaml = translation.download_yaml(chinese_locale)
|
169
171
|
yaml.should be_an_instance_of String
|
170
|
-
|
172
|
+
|
171
173
|
hash = YAML.load(yaml)
|
172
174
|
hash.should be_an_instance_of Hash
|
173
175
|
|
data/spec/translation_spec.rb
CHANGED
@@ -21,7 +21,6 @@ describe OneSky::Translation do
|
|
21
21
|
[{:string => "test1"}, {:string => "test2"}]
|
22
22
|
}
|
23
23
|
|
24
|
-
|
25
24
|
context "with an array of strings" do
|
26
25
|
it "calls /string/input" do
|
27
26
|
client.should_receive(:post).with("string/input", :input => JSON.dump(hash_array), :"platform-id" => platform_id)
|
@@ -72,6 +71,19 @@ describe OneSky::Translation do
|
|
72
71
|
end
|
73
72
|
|
74
73
|
describe "input_phrases" do
|
74
|
+
let(:hash_string) {
|
75
|
+
{:test1 => "string1", :test2 => "string2", :array1 => ["first", "second"]}
|
76
|
+
}
|
77
|
+
|
78
|
+
let(:hash_output) {
|
79
|
+
[
|
80
|
+
{:string_key => "test1", :string => "string1"},
|
81
|
+
{:string_key => "test2", :string => "string2"},
|
82
|
+
{:string_key => "array1", :string => "first", :context => 0},
|
83
|
+
{:string_key => "array1", :string => "second", :context => 1},
|
84
|
+
]
|
85
|
+
}
|
86
|
+
|
75
87
|
it "defers to input_strings" do
|
76
88
|
translation.should_receive(:input_strings).with([{:string_key => "test1", :string => "Test 1"}], {})
|
77
89
|
translation.input_phrases("test1" => "Test 1")
|
@@ -82,6 +94,11 @@ describe OneSky::Translation do
|
|
82
94
|
translation.input_phrases({"test1" => "Test 1"}, :tag => "tagged")
|
83
95
|
end
|
84
96
|
|
97
|
+
it "transform an hash of strings" do
|
98
|
+
translation.should_receive(:input_strings).with(hash_output, {})
|
99
|
+
translation.input_phrases(hash_string)
|
100
|
+
end
|
101
|
+
|
85
102
|
end
|
86
103
|
|
87
104
|
describe "translate" do
|
metadata
CHANGED
@@ -1,8 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: one_sky
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0
|
5
|
-
prerelease:
|
4
|
+
version: 2.1.0
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Junjun Olympia
|
@@ -11,63 +10,78 @@ authors:
|
|
11
10
|
autorequire:
|
12
11
|
bindir: bin
|
13
12
|
cert_chain: []
|
14
|
-
date:
|
13
|
+
date: 2014-07-03 00:00:00.000000000 Z
|
15
14
|
dependencies:
|
16
15
|
- !ruby/object:Gem::Dependency
|
17
16
|
name: json
|
18
|
-
requirement:
|
19
|
-
none: false
|
17
|
+
requirement: !ruby/object:Gem::Requirement
|
20
18
|
requirements:
|
21
|
-
- -
|
19
|
+
- - ">="
|
22
20
|
- !ruby/object:Gem::Version
|
23
21
|
version: 1.4.0
|
24
22
|
type: :runtime
|
25
23
|
prerelease: false
|
26
|
-
version_requirements:
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
requirements:
|
26
|
+
- - ">="
|
27
|
+
- !ruby/object:Gem::Version
|
28
|
+
version: 1.4.0
|
27
29
|
- !ruby/object:Gem::Dependency
|
28
30
|
name: rest-client
|
29
|
-
requirement:
|
30
|
-
none: false
|
31
|
+
requirement: !ruby/object:Gem::Requirement
|
31
32
|
requirements:
|
32
|
-
- -
|
33
|
+
- - ">="
|
33
34
|
- !ruby/object:Gem::Version
|
34
35
|
version: 1.4.0
|
35
36
|
type: :runtime
|
36
37
|
prerelease: false
|
37
|
-
version_requirements:
|
38
|
+
version_requirements: !ruby/object:Gem::Requirement
|
39
|
+
requirements:
|
40
|
+
- - ">="
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
version: 1.4.0
|
38
43
|
- !ruby/object:Gem::Dependency
|
39
44
|
name: rspec
|
40
|
-
requirement:
|
41
|
-
none: false
|
45
|
+
requirement: !ruby/object:Gem::Requirement
|
42
46
|
requirements:
|
43
|
-
- - ~>
|
47
|
+
- - "~>"
|
44
48
|
- !ruby/object:Gem::Version
|
45
49
|
version: 2.2.0
|
46
50
|
type: :development
|
47
51
|
prerelease: false
|
48
|
-
version_requirements:
|
52
|
+
version_requirements: !ruby/object:Gem::Requirement
|
53
|
+
requirements:
|
54
|
+
- - "~>"
|
55
|
+
- !ruby/object:Gem::Version
|
56
|
+
version: 2.2.0
|
49
57
|
- !ruby/object:Gem::Dependency
|
50
58
|
name: bundler
|
51
|
-
requirement:
|
52
|
-
none: false
|
59
|
+
requirement: !ruby/object:Gem::Requirement
|
53
60
|
requirements:
|
54
|
-
- -
|
61
|
+
- - ">="
|
55
62
|
- !ruby/object:Gem::Version
|
56
63
|
version: 1.0.0
|
57
64
|
type: :development
|
58
65
|
prerelease: false
|
59
|
-
version_requirements:
|
66
|
+
version_requirements: !ruby/object:Gem::Requirement
|
67
|
+
requirements:
|
68
|
+
- - ">="
|
69
|
+
- !ruby/object:Gem::Version
|
70
|
+
version: 1.0.0
|
60
71
|
- !ruby/object:Gem::Dependency
|
61
72
|
name: time_freeze
|
62
|
-
requirement:
|
63
|
-
none: false
|
73
|
+
requirement: !ruby/object:Gem::Requirement
|
64
74
|
requirements:
|
65
|
-
- -
|
75
|
+
- - ">="
|
66
76
|
- !ruby/object:Gem::Version
|
67
77
|
version: '0'
|
68
78
|
type: :development
|
69
79
|
prerelease: false
|
70
|
-
version_requirements:
|
80
|
+
version_requirements: !ruby/object:Gem::Requirement
|
81
|
+
requirements:
|
82
|
+
- - ">="
|
83
|
+
- !ruby/object:Gem::Version
|
84
|
+
version: '0'
|
71
85
|
description: OneSky is a community-powered translation service for web and mobile
|
72
86
|
apps. This gem is the core interface to the REST API and is used by other specialty
|
73
87
|
gems such the OneSky extension for I18n, i18n-one_sky.
|
@@ -79,8 +93,9 @@ executables: []
|
|
79
93
|
extensions: []
|
80
94
|
extra_rdoc_files: []
|
81
95
|
files:
|
82
|
-
- .gitignore
|
83
|
-
- .rspec
|
96
|
+
- ".gitignore"
|
97
|
+
- ".rspec"
|
98
|
+
- ".travis.yml"
|
84
99
|
- CHANGELOG
|
85
100
|
- CREDITS
|
86
101
|
- Gemfile
|
@@ -107,27 +122,26 @@ files:
|
|
107
122
|
- spec/utility_spec.rb
|
108
123
|
homepage: http://developer.oneskyapp.com/
|
109
124
|
licenses: []
|
125
|
+
metadata: {}
|
110
126
|
post_install_message:
|
111
127
|
rdoc_options: []
|
112
128
|
require_paths:
|
113
129
|
- lib
|
114
130
|
required_ruby_version: !ruby/object:Gem::Requirement
|
115
|
-
none: false
|
116
131
|
requirements:
|
117
|
-
- -
|
132
|
+
- - ">="
|
118
133
|
- !ruby/object:Gem::Version
|
119
134
|
version: '0'
|
120
135
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
121
|
-
none: false
|
122
136
|
requirements:
|
123
|
-
- -
|
137
|
+
- - ">="
|
124
138
|
- !ruby/object:Gem::Version
|
125
139
|
version: '0'
|
126
140
|
requirements: []
|
127
141
|
rubyforge_project: one_sky
|
128
|
-
rubygems_version:
|
142
|
+
rubygems_version: 2.2.2
|
129
143
|
signing_key:
|
130
|
-
specification_version:
|
144
|
+
specification_version: 4
|
131
145
|
summary: Ruby interface to the OneSky REST API
|
132
146
|
test_files:
|
133
147
|
- spec/client_spec.rb
|
@@ -139,4 +153,3 @@ test_files:
|
|
139
153
|
- spec/spec_helper.rb
|
140
154
|
- spec/translation_spec.rb
|
141
155
|
- spec/utility_spec.rb
|
142
|
-
has_rdoc:
|