crowdin-api 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.
- data/README.md +39 -1
- data/lib/crowdin-api.rb +17 -8
- data/lib/crowdin-api/methods.rb +9 -7
- data/lib/crowdin-api/version.rb +1 -1
- metadata +2 -2
data/README.md
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
# Crowdin::API
|
2
2
|
|
3
3
|
The Crowdin Ruby Client is used to interact with the Crowdin API from Ruby.
|
4
|
+
|
4
5
|
For more about the Crowdin API see <http://crowdin.net/page/api>.
|
5
6
|
|
6
7
|
## Installation
|
@@ -81,10 +82,16 @@ crowdin.delete_file('strings.xml')
|
|
81
82
|
|
82
83
|
### Upload Translations
|
83
84
|
|
85
|
+
Documentation: <http://crowdin.net/page/api/upload-translation>
|
86
|
+
|
84
87
|
### Translation Status
|
85
88
|
|
89
|
+
Documentation: <http://crowdin.net/page/api/status>
|
90
|
+
|
86
91
|
### Project Info
|
87
92
|
|
93
|
+
Documentation: <http://crowdin.net/page/api/info>
|
94
|
+
|
88
95
|
### Download Translations
|
89
96
|
|
90
97
|
Documentation: <http://crowdin.net/page/api/download>
|
@@ -97,28 +104,59 @@ crowdin.download_translation('ru', :output => '/path/to/download/ru_RU.zip')
|
|
97
104
|
|
98
105
|
### Export Translations
|
99
106
|
|
107
|
+
Documentation: <http://crowdin.net/page/api/export>
|
108
|
+
|
100
109
|
### Account Projects
|
101
110
|
|
111
|
+
Documentation: <http://crowdin.net/page/api/get-projects>
|
112
|
+
|
102
113
|
### Create Project
|
103
114
|
|
115
|
+
Documentation: <http://crowdin.net/page/api/create-project>
|
116
|
+
|
104
117
|
### Edit Project
|
105
118
|
|
119
|
+
Documentation: <http://crowdin.net/page/api/edit-project>
|
120
|
+
|
106
121
|
### Delete Project
|
107
122
|
|
123
|
+
Documentation: <http://crowdin.net/page/api/delete-project>
|
124
|
+
|
108
125
|
### Create Directory
|
109
126
|
|
127
|
+
Documentation: <http://crowdin.net/page/api/add-directory>
|
128
|
+
|
110
129
|
### Delete Directory
|
111
130
|
|
131
|
+
Documentation: <http://crowdin.net/page/api/delete-directory>
|
132
|
+
|
112
133
|
### Download Glossary
|
113
134
|
|
135
|
+
Documentation: <http://crowdin.net/page/api/download-glossary>
|
136
|
+
|
114
137
|
### Upload Glossary
|
115
138
|
|
139
|
+
Documentation: <http://crowdin.net/page/api/upload-glossary>
|
140
|
+
|
116
141
|
### Download TM
|
117
142
|
|
143
|
+
Documentation: <http://crowdin.net/page/api/download-tm>
|
144
|
+
|
118
145
|
### Upload TM
|
119
146
|
|
120
|
-
|
147
|
+
Documentation: <http://crowdin.net/page/api/upload-tm>
|
148
|
+
|
149
|
+
### Supported Languages
|
150
|
+
|
151
|
+
Documentation: <http://crowdin.net/page/api/supported-languages>
|
152
|
+
|
153
|
+
|
154
|
+
## Supported Rubies
|
155
|
+
|
156
|
+
Tested with the following Ruby versions:
|
121
157
|
|
158
|
+
- MRI 1.9.3
|
159
|
+
- JRuby 1.7.0
|
122
160
|
|
123
161
|
## Contributing
|
124
162
|
|
data/lib/crowdin-api.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
|
+
require 'pp'
|
1
2
|
require 'logger'
|
2
|
-
require '
|
3
|
+
require 'json'
|
3
4
|
require 'rest-client'
|
4
5
|
|
5
6
|
require "crowdin-api/errors"
|
@@ -13,6 +14,13 @@ require "crowdin-api/version"
|
|
13
14
|
module Crowdin
|
14
15
|
class API
|
15
16
|
|
17
|
+
# Create a new API object using the given parameters.
|
18
|
+
#
|
19
|
+
# @param [String] api_key the authentication API key can be found on the project settings page
|
20
|
+
# @param [String] project_id the project identifier.
|
21
|
+
# @param [String] account_key the account API Key
|
22
|
+
# @param [String] base_url the url of the Crowdin API
|
23
|
+
#
|
16
24
|
def initialize(options = {})
|
17
25
|
@api_key = options.delete(:api_key)
|
18
26
|
@project_id = options.delete(:project_id)
|
@@ -24,10 +32,11 @@ module Crowdin
|
|
24
32
|
:params => {},
|
25
33
|
:key => @api_key,
|
26
34
|
:'account-key' => @account_key,
|
35
|
+
:json => true
|
27
36
|
}.merge(options)
|
28
37
|
|
29
38
|
options[:headers] = {
|
30
|
-
'Accept' => 'application/
|
39
|
+
'Accept' => 'application/json',
|
31
40
|
'User-Agent' => "crowdin-rb/#{Crowdin::API::VERSION}",
|
32
41
|
'X-Ruby-Version' => RUBY_VERSION,
|
33
42
|
'X-Ruby-Platform' => RUBY_PLATFORM
|
@@ -36,6 +45,7 @@ module Crowdin
|
|
36
45
|
options[:params] = {
|
37
46
|
:key => @api_key,
|
38
47
|
:'account-key' => @account_key,
|
48
|
+
:json => true
|
39
49
|
}.merge(options[:params])
|
40
50
|
|
41
51
|
@connection = RestClient::Resource.new(@base_url, options)
|
@@ -63,15 +73,14 @@ module Crowdin
|
|
63
73
|
file.close
|
64
74
|
return true
|
65
75
|
else
|
66
|
-
doc =
|
67
|
-
if doc.
|
68
|
-
code = doc
|
69
|
-
message = doc
|
76
|
+
doc = JSON.load(@response.body)
|
77
|
+
if doc.kind_of?(Hash) && doc['success'] == false
|
78
|
+
code = doc['error']['code']
|
79
|
+
message = doc['error']['message']
|
70
80
|
error = Crowdin::API::Errors::Error.new(code, message)
|
71
81
|
raise(error)
|
72
82
|
else
|
73
|
-
|
74
|
-
return @response
|
83
|
+
return doc
|
75
84
|
end
|
76
85
|
end
|
77
86
|
|
data/lib/crowdin-api/methods.rb
CHANGED
@@ -1,4 +1,9 @@
|
|
1
1
|
module Crowdin
|
2
|
+
# A wrapper and interface to the Crowdin api. Please visit the Crowdin developers
|
3
|
+
# site for a full explaination of what each of the Crowdin api methods
|
4
|
+
# expect and perform.
|
5
|
+
#
|
6
|
+
# http://crowdin.net/page/api
|
2
7
|
|
3
8
|
class API
|
4
9
|
|
@@ -236,25 +241,23 @@ module Crowdin
|
|
236
241
|
#
|
237
242
|
# GET http://api.crowdin.net/api/supported-languages
|
238
243
|
#
|
239
|
-
def supported_languages
|
244
|
+
def supported_languages
|
240
245
|
request(
|
241
246
|
:method => :get,
|
242
247
|
:path => "/api/supported-languages",
|
243
|
-
:query => { format => true },
|
244
248
|
)
|
245
249
|
end
|
246
250
|
|
247
|
-
# Track your Crowdin project translation progress by language.
|
251
|
+
# Track your Crowdin project translation progress by language.
|
248
252
|
#
|
249
253
|
# == Request
|
250
254
|
#
|
251
255
|
# POST http://api.crowdin.net/api/project/{project-identifier}/status?key={project-key}
|
252
256
|
#
|
253
|
-
def translations_status
|
257
|
+
def translations_status
|
254
258
|
request(
|
255
259
|
:method => :post,
|
256
260
|
:path => "/api/project/#{@project_id}/status",
|
257
|
-
:query => { format => true },
|
258
261
|
)
|
259
262
|
end
|
260
263
|
|
@@ -264,11 +267,10 @@ module Crowdin
|
|
264
267
|
#
|
265
268
|
# POST http://api.crowdin.net/api/project/{project-identifier}/info?key={project-key}
|
266
269
|
#
|
267
|
-
def project_info
|
270
|
+
def project_info
|
268
271
|
request(
|
269
272
|
:method => :post,
|
270
273
|
:path => "/api/project/#{@project_id}/info",
|
271
|
-
:query => { format => true },
|
272
274
|
)
|
273
275
|
end
|
274
276
|
|
data/lib/crowdin-api/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: crowdin-api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-10-04 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rest-client
|