one_sky 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +5 -0
- data/CHANGELOG +5 -0
- data/CREDITS +6 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +33 -0
- data/MIT-LICENSE +20 -0
- data/README.rdoc +77 -0
- data/Rakefile +13 -0
- data/lib/one_sky/project.rb +112 -0
- data/lib/one_sky/version.rb +3 -0
- data/lib/one_sky.rb +10 -0
- data/one_sky.gemspec +27 -0
- data/spec/data/en-us.po +21 -0
- data/spec/helpers.rb +11 -0
- data/spec/input_spec.rb +64 -0
- data/spec/output_spec.rb +35 -0
- data/spec/project_spec.rb +40 -0
- metadata +144 -0
data/CHANGELOG
ADDED
data/CREDITS
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
one_sky (0.0.1)
|
5
|
+
json (~> 1.4.6)
|
6
|
+
rest-client (~> 1.6.1)
|
7
|
+
|
8
|
+
GEM
|
9
|
+
remote: http://rubygems.org/
|
10
|
+
specs:
|
11
|
+
diff-lcs (1.1.2)
|
12
|
+
json (1.4.6)
|
13
|
+
mime-types (1.16)
|
14
|
+
rest-client (1.6.1)
|
15
|
+
mime-types (>= 1.16)
|
16
|
+
rspec (2.2.0)
|
17
|
+
rspec-core (~> 2.2)
|
18
|
+
rspec-expectations (~> 2.2)
|
19
|
+
rspec-mocks (~> 2.2)
|
20
|
+
rspec-core (2.2.1)
|
21
|
+
rspec-expectations (2.2.0)
|
22
|
+
diff-lcs (~> 1.1.2)
|
23
|
+
rspec-mocks (2.2.0)
|
24
|
+
|
25
|
+
PLATFORMS
|
26
|
+
ruby
|
27
|
+
|
28
|
+
DEPENDENCIES
|
29
|
+
bundler (~> 1.0.0)
|
30
|
+
json (~> 1.4.6)
|
31
|
+
one_sky!
|
32
|
+
rest-client (~> 1.6.1)
|
33
|
+
rspec (~> 2.2.0)
|
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2010-2011 {OneSky, Inc.}[link:http://www.oneskyapp.com]
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
ADDED
@@ -0,0 +1,77 @@
|
|
1
|
+
= OneSky: The Community-Powered Translation Service
|
2
|
+
|
3
|
+
OneSky[link:http://www.oneskyapp.com] is a new service that lets developers reach a global audience by easily enabling them to translate their websites and applications to different languages through the help of the community.
|
4
|
+
|
5
|
+
This gem is the basic interface to the RESTful API. It is used as the main building block for higher-level utilities and libraries such as the i18n-one_sky[link:http://rubygems.org/gems/i18n-one_sky] gem.
|
6
|
+
|
7
|
+
= Installing
|
8
|
+
|
9
|
+
Get from RubyGems.org by:
|
10
|
+
|
11
|
+
gem install one_sky
|
12
|
+
|
13
|
+
= Usage
|
14
|
+
|
15
|
+
Just the basic usage scenarios are shown here. See OneSky::Project for more available methods.
|
16
|
+
|
17
|
+
== Initialization
|
18
|
+
|
19
|
+
Provide the API key and secret which you can get from the web UI. Also provide the name of the project you created.
|
20
|
+
|
21
|
+
require 'one_sky'
|
22
|
+
|
23
|
+
client = OneSky::Project.new("my_api_key", "my_api_secret", "my_project")
|
24
|
+
|
25
|
+
== Submit a phrase for translation
|
26
|
+
|
27
|
+
Submit a string with no other parameters:
|
28
|
+
|
29
|
+
client.input("Hello World!")
|
30
|
+
|
31
|
+
You can also provide other parameters:
|
32
|
+
|
33
|
+
client.input("Hello World!", :string_key => "my_string_key", :context => "my_context", :page => "my_page")
|
34
|
+
|
35
|
+
== Get translated phrases
|
36
|
+
|
37
|
+
So you've submitted your phrases and your translators/users or the general OneSky[link:http://www.oneskyapp.com] community have kindly provided translations for them. It's time now to download those.
|
38
|
+
|
39
|
+
translations = client.output
|
40
|
+
|
41
|
+
=> {"Default"=>{"en-us"=>{"Hello World!"=>"Hello World!"}, "zh-cn"=>{"Hello World!"=>"\u4E16\u754C\u60A8\u597D\uFF01"}, "es-es"=>{"Hello World!"=>"Hola Mundo!"}}}
|
42
|
+
|
43
|
+
Let's pretty print that a bit:
|
44
|
+
|
45
|
+
translations["Default"].map { |k,v| puts "#{k}: #{v['Hello World!']}" }
|
46
|
+
|
47
|
+
en-us: Hello World!
|
48
|
+
zh-cn: 世界您好!
|
49
|
+
es-es: Hola Mundo!
|
50
|
+
|
51
|
+
== Provide a single sign-on (SSO) link for your translators
|
52
|
+
|
53
|
+
OneSky[link:http://www.oneskyapp.com] is all about community-powered translations. You can mark your project as public and any OneSky[link:http://www.oneskyapp.com] member translator can help in translating your phrases. Or if you mark it as private, only those you give access to can do so. For instance, you'd like your own website's user base to help you out. You can take a user's unique ID and bind it to OneSky:
|
54
|
+
|
55
|
+
client.get_sso_link("myapp/users/123456")
|
56
|
+
=> "http://rubyredtomatoes.oneskyapp.com/?time=1294020222&id=myapp/users/123456&data=3d56315499647c0419867283767aa270"
|
57
|
+
|
58
|
+
That user can then use the above link to automatically sign in to OneSky[link:http://www.oneskyapp.com] and start translating for you.
|
59
|
+
|
60
|
+
= Using with Rails
|
61
|
+
|
62
|
+
See the i18n-one_sky[link:http://rubygems.org/gems/i18n-one_sky] gem for Rails and I18n integration.
|
63
|
+
|
64
|
+
= History
|
65
|
+
|
66
|
+
See CHANGELOG[link:CHANGELOG.html]
|
67
|
+
|
68
|
+
= Credits
|
69
|
+
|
70
|
+
See CREDITS[link:CREDITS.html]
|
71
|
+
|
72
|
+
= License
|
73
|
+
|
74
|
+
Copyright 2010-2011 {OneSky, Inc.}[link:http://www.oneskyapp.com/]
|
75
|
+
|
76
|
+
Licensed under the {MIT License}[link:MIT-LICENSE.html].
|
77
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
require 'bundler'
|
2
|
+
Bundler::GemHelper.install_tasks
|
3
|
+
|
4
|
+
# = RDoc
|
5
|
+
require 'rake/rdoctask'
|
6
|
+
|
7
|
+
Rake::RDocTask.new do |t|
|
8
|
+
t.rdoc_dir = 'rdoc'
|
9
|
+
t.options << '--line-numbers' << '--inline-source' << '-A cattr_accessor=object'
|
10
|
+
t.options << '--charset' << 'utf-8'
|
11
|
+
t.rdoc_files.include('README.rdoc', 'MIT-LICENSE', 'CHANGELOG', 'CREDITS', 'lib/**/*.rb')
|
12
|
+
end
|
13
|
+
|
@@ -0,0 +1,112 @@
|
|
1
|
+
module OneSky
|
2
|
+
# This is the main class used to interact with the OneSky API and maps to a project on their web site.
|
3
|
+
class Project
|
4
|
+
attr_accessor :api_key, :api_secret, :name
|
5
|
+
|
6
|
+
# Provide the name of the project you created on the OneSky website. Also, the API key and secret shown there.
|
7
|
+
def initialize(api_key, api_secret, name)
|
8
|
+
raise ArgumentError, "api_key, api_secret, and name cannot be nil." unless [api_key, api_secret, name].all?
|
9
|
+
@api_key, @api_secret, @name = api_key, api_secret, name
|
10
|
+
end
|
11
|
+
|
12
|
+
# Returns details about the project.
|
13
|
+
def details
|
14
|
+
get("/details")["project"]
|
15
|
+
end
|
16
|
+
|
17
|
+
# Returns an array of available languages.
|
18
|
+
def languages
|
19
|
+
get("/languages")["languages"]
|
20
|
+
end
|
21
|
+
|
22
|
+
# Returns the SSO URL for the given unique_id
|
23
|
+
def get_sso_link(unique_id)
|
24
|
+
get("/sso/get-link", {:"unique-id" => unique_id})["url"]
|
25
|
+
end
|
26
|
+
|
27
|
+
# Submits a string for translation.
|
28
|
+
# Takes an optional hash of parameters, too:
|
29
|
+
# * :string_key
|
30
|
+
# * :context
|
31
|
+
# * :page
|
32
|
+
def input(string, options = {})
|
33
|
+
options = {:string => string}.merge(options)
|
34
|
+
post("/string/input", hash_to_params(options))
|
35
|
+
true
|
36
|
+
end
|
37
|
+
|
38
|
+
# Submits a bulk translation request.
|
39
|
+
# Parameters:
|
40
|
+
# * hashes - An array of hashes with mandatory key :string and optional keys (:string_key, :context)
|
41
|
+
# * An optional hash with keys:
|
42
|
+
# * :page
|
43
|
+
def input_bulk(hashes, options = {})
|
44
|
+
arrs = hashes.inject([[],[],[]]) do |o,e|
|
45
|
+
o[0] << e[:string]; o[1] << e[:string_key]; o[2] << e[:context]; o
|
46
|
+
end
|
47
|
+
|
48
|
+
post("/string/input-bulk", {:strings => arrs[0], :"string-keys" => arrs[1], :contexts => arrs[2]}.merge(options))
|
49
|
+
true
|
50
|
+
end
|
51
|
+
|
52
|
+
# Uploads a PO file for the given language.
|
53
|
+
# See #languages for a list of supported language codes.
|
54
|
+
# Takes an optional hash of parameters:
|
55
|
+
# * :page
|
56
|
+
def input_po(language, file_name, options = {})
|
57
|
+
response = post("/string/input-po", {:language => language, :file => File.new(file_name, "rb")}.merge(options), {})
|
58
|
+
true
|
59
|
+
end
|
60
|
+
|
61
|
+
alias_method :upload_po, :input_po
|
62
|
+
|
63
|
+
# Gets the strings with available translations.
|
64
|
+
# Takes these optional parameters, too:
|
65
|
+
# * :language
|
66
|
+
# * :page
|
67
|
+
# * :md5
|
68
|
+
#--
|
69
|
+
# ToDo: Probably need to expose MD5 response values for caching implementations.
|
70
|
+
#++
|
71
|
+
def output(options = {})
|
72
|
+
get("/string/output", hash_to_params(options))["translation"]
|
73
|
+
end
|
74
|
+
|
75
|
+
# Downloads the compiled MO file for the given language and saves it as file_name.
|
76
|
+
# See #languages for a list of supported language codes.
|
77
|
+
# Takes an optional hash of parameters:
|
78
|
+
# * :page
|
79
|
+
def output_mo(language, file_name, options = {})
|
80
|
+
response = get("/string/output-mo", {:language => language}.merge(options))
|
81
|
+
File.open(file_name, "w") { |f| f.print response }
|
82
|
+
true
|
83
|
+
end
|
84
|
+
|
85
|
+
alias_method :download_mo, :output_mo
|
86
|
+
|
87
|
+
protected
|
88
|
+
|
89
|
+
def hash_to_params(hash)
|
90
|
+
hash.inject({}) { |o, (k,v)| o[k.to_s.gsub("_", "-").to_sym] = v; o }
|
91
|
+
end
|
92
|
+
|
93
|
+
def get(path, params = {}, options = {:content_type => "text/plain; charset=UTF-8"})
|
94
|
+
params = {:"api-key" => @api_key, :"api-secret" => @api_secret, :"project" => @name}.merge(params)
|
95
|
+
parse_response(RestClient.get([API_ROOT_URL, path].join, {:params => params}.merge(options)))
|
96
|
+
end
|
97
|
+
|
98
|
+
def post(path, params = {}, options = {:content_type => "text/plain; charset=UTF-8"})
|
99
|
+
params = {:"api-key" => @api_key, :"api-secret" => @api_secret, :"project" => @name}.merge(params)
|
100
|
+
parse_response(RestClient.post([API_ROOT_URL, path].join, params.merge(options)))
|
101
|
+
end
|
102
|
+
|
103
|
+
def parse_response(response)
|
104
|
+
raise ApiHttpResponseError, "HTTP response status code: #{response.code.inspect}." unless response.code.eql?(200)
|
105
|
+
# Do not post-process response if it isn't JSON. (ie. Binary file returned from /output_mo.)
|
106
|
+
return response.body unless response.headers[:content_type] =~ /json/
|
107
|
+
response_hash = JSON.parse(response)
|
108
|
+
raise ApiError, response.body if response_hash.has_key?("response") and response_hash["response"] != "ok"
|
109
|
+
response_hash
|
110
|
+
end
|
111
|
+
end
|
112
|
+
end
|
data/lib/one_sky.rb
ADDED
data/one_sky.gemspec
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "one_sky/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "one_sky"
|
7
|
+
s.version = OneSky::VERSION
|
8
|
+
s.platform = Gem::Platform::RUBY
|
9
|
+
s.authors = ["Junjun Olympia"]
|
10
|
+
s.email = ["romeo.olympia@gmail.com"]
|
11
|
+
s.homepage = "http://rubygems.org/gems/one_sky"
|
12
|
+
s.summary = %q{Ruby interface to the OneSky REST API}
|
13
|
+
s.description = %q{OneSky is a community-powered translation service for web and mobile apps. This gem is the core interface to the REST API and is used by other specialty gems such the OneSky extension for I18n, i18n-one_sky.}
|
14
|
+
|
15
|
+
s.rubyforge_project = "one_sky"
|
16
|
+
|
17
|
+
s.add_dependency "json", "~> 1.4.6"
|
18
|
+
s.add_dependency "rest-client", "~> 1.6.1"
|
19
|
+
|
20
|
+
s.add_development_dependency "rspec", "~> 2.2.0"
|
21
|
+
s.add_development_dependency "bundler", "~> 1.0.0"
|
22
|
+
|
23
|
+
s.files = `git ls-files`.split("\n")
|
24
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
25
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
26
|
+
s.require_paths = ["lib"]
|
27
|
+
end
|
data/spec/data/en-us.po
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
msgid "This is the first line in the PO file."
|
2
|
+
msgstr ""
|
3
|
+
|
4
|
+
msgid "This is the second line in the PO file."
|
5
|
+
msgstr ""
|
6
|
+
|
7
|
+
msgid "And this is the last line in the PO file."
|
8
|
+
msgstr ""
|
9
|
+
|
10
|
+
msgid ""
|
11
|
+
"Project-Id-Version: rubysdkspec\n"
|
12
|
+
"POT-Creation-Date: 2010-12-16 19:29+0800\n"
|
13
|
+
"PO-Revision-Date: 2010-12-16 19:32+0800\n"
|
14
|
+
"Last-Translator: Junjun Olympia <romeo.olympia@gmail.com>\n"
|
15
|
+
"Language-Team: \n"
|
16
|
+
"MIME-Version: 1.0\n"
|
17
|
+
"Content-Type: text/plain; charset=UTF-8\n"
|
18
|
+
"Content-Transfer-Encoding: 8bit\n"
|
19
|
+
"X-Poedit-KeywordsList: _;gettext;gettext_noop\n"
|
20
|
+
"X-Poedit-Basepath: .\n"
|
21
|
+
|
data/spec/helpers.rb
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
$:.unshift File.expand_path('..', __FILE__)
|
2
|
+
$:.unshift File.expand_path('../../lib', __FILE__)
|
3
|
+
|
4
|
+
require 'one_sky'
|
5
|
+
|
6
|
+
module OneSkySpecHelpers
|
7
|
+
def create_project
|
8
|
+
raise "Please set environment variables: ONESKY_API_KEY, ONESKY_API_SECRET and ONESKY_SPEC_PROJ (default: rubysdkspec) before running spec." unless [ENV["ONESKY_API_KEY"], ENV["ONESKY_API_SECRET"]].all?
|
9
|
+
OneSky::Project.new(ENV["ONESKY_API_KEY"], ENV["ONESKY_API_SECRET"], ENV["ONESKY_SPEC_PROJ"] || "rubysdkspec")
|
10
|
+
end
|
11
|
+
end
|
data/spec/input_spec.rb
ADDED
@@ -0,0 +1,64 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
require 'helpers'
|
3
|
+
|
4
|
+
describe "Project" do
|
5
|
+
include OneSkySpecHelpers
|
6
|
+
|
7
|
+
before do
|
8
|
+
@project = create_project
|
9
|
+
end
|
10
|
+
|
11
|
+
describe "#input" do
|
12
|
+
# We use the spec description as the string sent to OneSky for translation.
|
13
|
+
# ToDo: Make this DRY.
|
14
|
+
it "returns true for a normal translate request." do
|
15
|
+
@project.input("input returns true for a normal translate request.").should be_true
|
16
|
+
end
|
17
|
+
|
18
|
+
it "returns true when non-latin characters are passed (こんにちは世界)." do
|
19
|
+
@project.input("input returns true when non-latin characters are passed (こんにちは世界).").should be_true
|
20
|
+
end
|
21
|
+
|
22
|
+
it "returns true when optional parameters are passed." do
|
23
|
+
@project.input("input returns true when optional parameters are passed.",
|
24
|
+
:string_key => "string key", :string_context => "string context", :page => "page").should be_true
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
describe "#input_bulk" do
|
29
|
+
it "returns true for a normal translate request." do
|
30
|
+
input = []
|
31
|
+
input << {:string => "input_bulk returns true for a normal translate request (A).", :string_key => "input_bulk.key.1.a", :context => "input_bulk.context.1.a"}
|
32
|
+
input << {:string => "input_bulk returns true for a normal translate request (B).", :string_key => "input_bulk.key.1.b", :context => "input_bulk.context.1.b"}
|
33
|
+
input << {:string => "input_bulk returns true for a normal translate request (C)." }
|
34
|
+
|
35
|
+
@project.input_bulk(input).should be_true
|
36
|
+
end
|
37
|
+
|
38
|
+
it "returns true when non-latin characters are passed (こんにちは世界)." do
|
39
|
+
input = []
|
40
|
+
input << {:string => "input_bulk returns true when non-latin characters are passed (こんにちは世界) (A).", :string_key => "input_bulk.key.2.a", :context => "input_bulk.context.2.a"}
|
41
|
+
input << {:string => "input_bulk returns true when non-latin characters are passed (こんにちは世界) (B).", :string_key => "input_bulk.key.2.b", :context => "input_bulk.context.2.b"}
|
42
|
+
input << {:string => "input_bulk returns true when non-latin characters are passed (こんにちは世界) (C)." }
|
43
|
+
|
44
|
+
@project.input_bulk(input).should be_true
|
45
|
+
end
|
46
|
+
|
47
|
+
it "returns true when optional parameters are passed." do
|
48
|
+
input = []
|
49
|
+
input << {:string => "input_bulk returns true when optional parameters are passed (A).", :string_key => "input_bulk.key.3.a", :context => "input_bulk.context.3.a"}
|
50
|
+
input << {:string => "input_bulk returns true when optional parameters are passed (B).", :string_key => "input_bulk.key.3.b", :context => "input_bulk.context.3.b"}
|
51
|
+
input << {:string => "input_bulk returns true when optional parameters are passed (C)." }
|
52
|
+
|
53
|
+
@project.input_bulk(input, {:page => "input_bulk.page.3"}).should be_true
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
describe "#input_po" do
|
58
|
+
it "returns true after uploading a file." do
|
59
|
+
file_name = "#{File.dirname(__FILE__)}/data/en-us.po"
|
60
|
+
@project.input_po("en-us", file_name).should be_true
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
data/spec/output_spec.rb
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
require 'helpers'
|
3
|
+
|
4
|
+
describe "Project" do
|
5
|
+
include OneSkySpecHelpers
|
6
|
+
|
7
|
+
before do
|
8
|
+
@project = create_project
|
9
|
+
end
|
10
|
+
|
11
|
+
describe "#output" do
|
12
|
+
it "returns a hash with a parent key called 'Default'" do
|
13
|
+
@project.output.has_key?("Default").should be_true
|
14
|
+
end
|
15
|
+
|
16
|
+
it "returns a hash with a parent key called 'Default' when optional parameters are passed." do
|
17
|
+
@project.output({:context => "Default"}).has_key?("Default").should be_true
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
describe "#output_mo" do
|
22
|
+
it "creates a file." do
|
23
|
+
file_name = "#{File.dirname(__FILE__)}/data/output.mo"
|
24
|
+
@project.output_mo("en-us", file_name)
|
25
|
+
File.exists?(file_name).should be_true
|
26
|
+
File.delete(file_name)
|
27
|
+
end
|
28
|
+
|
29
|
+
it "raises an error if an invalid language code is supplied." do
|
30
|
+
file_name = "#{File.dirname(__FILE__)}/data/output.2.mo"
|
31
|
+
lambda { @project.output_mo("en-xx", file_name) }.should raise_error
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
@@ -0,0 +1,40 @@
|
|
1
|
+
require 'helpers'
|
2
|
+
|
3
|
+
describe "Project" do
|
4
|
+
include OneSkySpecHelpers
|
5
|
+
|
6
|
+
it "raises an error when initialization values are nil." do
|
7
|
+
lambda { @project = OneSky::Project.new(nil, nil, nil) }.should raise_error ArgumentError
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
describe "Project" do
|
12
|
+
include OneSkySpecHelpers
|
13
|
+
|
14
|
+
before do
|
15
|
+
@project = create_project
|
16
|
+
end
|
17
|
+
|
18
|
+
it "raises an error when incorrect API credentials are passed." do
|
19
|
+
@project.api_secret = "wrong secret"
|
20
|
+
lambda { @project.details }.should raise_error OneSky::ApiError
|
21
|
+
end
|
22
|
+
|
23
|
+
describe "#details" do
|
24
|
+
it "returns project name among other things." do
|
25
|
+
@project.details["name"].should == @project.name
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
describe "#languages" do
|
30
|
+
it "returns an array." do
|
31
|
+
@project.languages.should be_an(Array)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
describe "#get_sso_link" do
|
36
|
+
it "returns a URL string." do
|
37
|
+
@project.get_sso_link("rspec_process").should match /^http.*$/
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
metadata
ADDED
@@ -0,0 +1,144 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: one_sky
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 0
|
7
|
+
- 0
|
8
|
+
- 1
|
9
|
+
version: 0.0.1
|
10
|
+
platform: ruby
|
11
|
+
authors:
|
12
|
+
- Junjun Olympia
|
13
|
+
autorequire:
|
14
|
+
bindir: bin
|
15
|
+
cert_chain: []
|
16
|
+
|
17
|
+
date: 2011-01-03 00:00:00 +08:00
|
18
|
+
default_executable:
|
19
|
+
dependencies:
|
20
|
+
- !ruby/object:Gem::Dependency
|
21
|
+
name: json
|
22
|
+
prerelease: false
|
23
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
24
|
+
none: false
|
25
|
+
requirements:
|
26
|
+
- - ~>
|
27
|
+
- !ruby/object:Gem::Version
|
28
|
+
segments:
|
29
|
+
- 1
|
30
|
+
- 4
|
31
|
+
- 6
|
32
|
+
version: 1.4.6
|
33
|
+
type: :runtime
|
34
|
+
version_requirements: *id001
|
35
|
+
- !ruby/object:Gem::Dependency
|
36
|
+
name: rest-client
|
37
|
+
prerelease: false
|
38
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
40
|
+
requirements:
|
41
|
+
- - ~>
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
segments:
|
44
|
+
- 1
|
45
|
+
- 6
|
46
|
+
- 1
|
47
|
+
version: 1.6.1
|
48
|
+
type: :runtime
|
49
|
+
version_requirements: *id002
|
50
|
+
- !ruby/object:Gem::Dependency
|
51
|
+
name: rspec
|
52
|
+
prerelease: false
|
53
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
54
|
+
none: false
|
55
|
+
requirements:
|
56
|
+
- - ~>
|
57
|
+
- !ruby/object:Gem::Version
|
58
|
+
segments:
|
59
|
+
- 2
|
60
|
+
- 2
|
61
|
+
- 0
|
62
|
+
version: 2.2.0
|
63
|
+
type: :development
|
64
|
+
version_requirements: *id003
|
65
|
+
- !ruby/object:Gem::Dependency
|
66
|
+
name: bundler
|
67
|
+
prerelease: false
|
68
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
69
|
+
none: false
|
70
|
+
requirements:
|
71
|
+
- - ~>
|
72
|
+
- !ruby/object:Gem::Version
|
73
|
+
segments:
|
74
|
+
- 1
|
75
|
+
- 0
|
76
|
+
- 0
|
77
|
+
version: 1.0.0
|
78
|
+
type: :development
|
79
|
+
version_requirements: *id004
|
80
|
+
description: OneSky is a community-powered translation service for web and mobile apps. This gem is the core interface to the REST API and is used by other specialty gems such the OneSky extension for I18n, i18n-one_sky.
|
81
|
+
email:
|
82
|
+
- romeo.olympia@gmail.com
|
83
|
+
executables: []
|
84
|
+
|
85
|
+
extensions: []
|
86
|
+
|
87
|
+
extra_rdoc_files: []
|
88
|
+
|
89
|
+
files:
|
90
|
+
- .gitignore
|
91
|
+
- CHANGELOG
|
92
|
+
- CREDITS
|
93
|
+
- Gemfile
|
94
|
+
- Gemfile.lock
|
95
|
+
- MIT-LICENSE
|
96
|
+
- README.rdoc
|
97
|
+
- Rakefile
|
98
|
+
- lib/one_sky.rb
|
99
|
+
- lib/one_sky/project.rb
|
100
|
+
- lib/one_sky/version.rb
|
101
|
+
- one_sky.gemspec
|
102
|
+
- spec/data/en-us.po
|
103
|
+
- spec/helpers.rb
|
104
|
+
- spec/input_spec.rb
|
105
|
+
- spec/output_spec.rb
|
106
|
+
- spec/project_spec.rb
|
107
|
+
has_rdoc: true
|
108
|
+
homepage: http://rubygems.org/gems/one_sky
|
109
|
+
licenses: []
|
110
|
+
|
111
|
+
post_install_message:
|
112
|
+
rdoc_options: []
|
113
|
+
|
114
|
+
require_paths:
|
115
|
+
- lib
|
116
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
117
|
+
none: false
|
118
|
+
requirements:
|
119
|
+
- - ">="
|
120
|
+
- !ruby/object:Gem::Version
|
121
|
+
segments:
|
122
|
+
- 0
|
123
|
+
version: "0"
|
124
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
125
|
+
none: false
|
126
|
+
requirements:
|
127
|
+
- - ">="
|
128
|
+
- !ruby/object:Gem::Version
|
129
|
+
segments:
|
130
|
+
- 0
|
131
|
+
version: "0"
|
132
|
+
requirements: []
|
133
|
+
|
134
|
+
rubyforge_project: one_sky
|
135
|
+
rubygems_version: 1.3.7
|
136
|
+
signing_key:
|
137
|
+
specification_version: 3
|
138
|
+
summary: Ruby interface to the OneSky REST API
|
139
|
+
test_files:
|
140
|
+
- spec/data/en-us.po
|
141
|
+
- spec/helpers.rb
|
142
|
+
- spec/input_spec.rb
|
143
|
+
- spec/output_spec.rb
|
144
|
+
- spec/project_spec.rb
|