crowdin-api 0.2.5 → 0.2.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 693786452e672ae92ccdcd344dfe689f89e47f8e
4
- data.tar.gz: 74b8e38462eb8d882d5391733b57cb521b9698ee
3
+ metadata.gz: dbac2dab8ad43628ad23b1369afb7c5cc6cafa8d
4
+ data.tar.gz: a89f46c9ed748831cb731ba2eecb8292109daae5
5
5
  SHA512:
6
- metadata.gz: fbe9a4eaeec9ae33a0be109454eb1f3bea728ce175156972b3a83b729849d4dadec23752d9908997fd748b8095fc8525a28b1e0a5543b9d122fe29839bf527d7
7
- data.tar.gz: 36c455a22e4c8f52895d8de9efa325d9caafc1994b8709c5a6515004e0a88bb5a52358bf86731128ec6551eec00f047d44546d3961bb10e093dfee5ca2a92278
6
+ metadata.gz: 20cd87fd0b6bf70d5891fc2816b42d888593fec66af1f2cfa7f6232a7435a24e8f6caf0101a59135574d8215dad6b9b26e7e6e72b7ad1977bfa9fefcb3fbca2d
7
+ data.tar.gz: 27d29910c7a2cceb615f9242fd7faefe51c16fb8b4ca586bf3a46a7b2654790dc6ee272faabf10413e14fd372f7be2a6234e1e36c0e2c7797891a72be04ddd35
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --require spec_helper
data/Gemfile CHANGED
@@ -1,5 +1,11 @@
1
1
  source 'https://rubygems.org'
2
+ gemspec
2
3
 
3
4
  # Specify your gem's dependencies in crowdin-api.gemspec
4
5
  # gem 'rest-client', :git => 'git://github.com/rest-client/rest-client.git'
5
6
  gem 'rest-client'
7
+
8
+ group :test do
9
+ gem 'webmock'
10
+ gem 'sinatra'
11
+ end
data/LICENSE CHANGED
@@ -1,22 +1,21 @@
1
- Copyright (c) 2012-2014 Anton Maminov
1
+ The MIT License (MIT)
2
2
 
3
- MIT License
3
+ Copyright (c) 2012-2014 Anton Maminov
4
4
 
5
- Permission is hereby granted, free of charge, to any person obtaining
6
- a copy of this software and associated documentation files (the
7
- "Software"), to deal in the Software without restriction, including
8
- without limitation the rights to use, copy, modify, merge, publish,
9
- distribute, sublicense, and/or sell copies of the Software, and to
10
- permit persons to whom the Software is furnished to do so, subject to
11
- the following conditions:
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
12
11
 
13
- The above copyright notice and this permission notice shall be
14
- included in all copies or substantial portions of the Software.
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
15
14
 
16
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
data/README.md CHANGED
@@ -28,14 +28,22 @@ $ gem install crowdin-api
28
28
 
29
29
  Start by creating a connection to Crowdin with your credentials:
30
30
 
31
+ Please note that almost all API calls require the `Project Identifier` and `Project API Key`.
32
+
31
33
  ```ruby
32
34
  require 'crowdin-api'
33
35
  require 'logger'
34
36
 
35
- crowdin = Crowdin::API.new(api_key: API_KEY, project_id: PROJECT_ID, account_key: ACCOUNT_KEY)
37
+ crowdin = Crowdin::API.new(api_key: API_KEY, project_id: PROJECT_ID)
36
38
  crowdin.log = Logger.new $stderr
37
39
  ```
38
40
 
41
+ As well there are several API methods (`get_projects`, `create_project`) that require `User API Key` instead of regular `Project API Key`.
42
+
43
+ ```ruby
44
+ crowdin = Crowdin::API.new(account_key: ACCOUNT_KEY)
45
+ ```
46
+
39
47
  Now you can make requests to the api.
40
48
 
41
49
  ### Add File
@@ -47,17 +55,18 @@ Documentation: <https://crowdin.com/page/api/add-file>.
47
55
  First parameter is array of files that should be added to Crowdin project.
48
56
  Every file is hash:
49
57
  * `:dest` - file name with path in Crowdin project (required)
50
- * `:source` - uploaded file (required)
51
- * `:title` - title for uploaded file (optional)
58
+ * `:source` - file that should be added (required)
59
+ * `:title` - string that defines title for uploaded file (optional)
52
60
  * `:export_pattern` - string that defines name of resulted file (optional)
53
61
 
62
+ **NOTE!** 20 files max are allowed to upload per one time file transfer.
54
63
 
55
64
  ```ruby
56
65
  crowdin.add_file(
57
66
  files = [
58
- { :dest => '/directory/array.xml', :source => 'array.xml', :export_pattern => '/values-%two_letters_code%/%original_file_name%' },
59
- { :dest => 'strings.xml', :source => 'strings.xml', :title => 'Texts in Application' }
60
- ], :type => 'android')
67
+ { dest: '/directory/array.xml', source: 'array.xml', export_pattern: '/values-%two_letters_code%/%original_file_name%' },
68
+ { dest: 'strings.xml', source: 'strings.xml', title: 'Texts in Application' }
69
+ ], type: 'android')
61
70
  ```
62
71
 
63
72
  ### Update File
@@ -73,6 +82,8 @@ Every file is hash:
73
82
  * `:title` - title for uploaded file (optional)
74
83
  * `:export_pattern` - string that defines name of resulted file (optional)
75
84
 
85
+ **NOTE!** 20 files max are allowed to upload per one time file transfer.
86
+
76
87
  ```ruby
77
88
  crowdin.update_file(
78
89
  files = [
@@ -112,9 +123,28 @@ Documentation: <https://crowdin.com/page/api/delete-directory>
112
123
  crowdin.delete_directory('dirname')
113
124
  ```
114
125
 
126
+ ### Change Directory
127
+
128
+ Rename or change directory attributes.
129
+
130
+ Documentation: <https://crowdin.com/page/api/change-directory>
131
+
132
+ First parameter `name` - full directory path that should be modified (e.g. /MainPage/AboutUs) (required)
133
+
134
+ Optional params:
135
+ * `:new_name` - new directory name
136
+ * `:title` - new directory title to be displayed in Crowdin UI
137
+ * `:export_pattern` - new direcrory export pattern. Is used to create directory name and path in resulted translations bundle.
138
+
139
+ When renaming directory the path can not be changed (it means `new_name` parameter can not contain path, name only).
140
+
141
+ ```ruby
142
+ crowdin.change_directory('/MainPage/AboutUs', new_name: 'AboutCompany')
143
+ ```
144
+
115
145
  ### Upload Translations
116
146
 
117
- Upload translations made in a third party software or previously made translations.
147
+ Upload existing translations to your Crowdin project.
118
148
 
119
149
  Documentation: <https://crowdin.com/page/api/upload-translation>
120
150
 
@@ -132,6 +162,8 @@ Optional params:
132
162
  * `:import_eq_suggestions` - defines whether to add translation if it is equal to source string at Crowdin (default: false)
133
163
  * `:auto_approve_imported` - mark uploaded translations as approved (default: false)
134
164
 
165
+ **NOTE!** 20 files max are allowed to upload per one time file transfer.
166
+
135
167
  ```ruby
136
168
  crowdin.upload_translation(
137
169
  files = [
@@ -179,6 +211,11 @@ crowdin.project_info
179
211
 
180
212
  Build ZIP archive with the latest translations.
181
213
 
214
+ **Note!** This method can be invoked only once per 30 minutes (there is no such restriction for organization plans).
215
+
216
+ Also API call will be ignored if there were no changes in the project since previous export.
217
+ You can see whether ZIP archive with latest translations was actually build by status attribute (`built` or `skipped`) returned in response.
218
+
182
219
  Documentation: <https://crowdin.com/page/api/export>
183
220
 
184
221
  ```ruby
@@ -187,10 +224,23 @@ crowdin.export_translations
187
224
 
188
225
  ### Account Projects
189
226
 
227
+ Get Crowdin Project details.
228
+
229
+ **Important:** This API method requires `Account API Key`. This key can not be found on your profile pages.
230
+
190
231
  Documentation: <https://crowdin.com/page/api/get-projects>
191
232
 
233
+ ```ruby
234
+ crowdin = Crowdin::API.new(account_key: ACCOUNT_KEY)
235
+ crowdin.get_projects(login = 'YourCrowdinAccount')
236
+ ```
237
+
192
238
  ### Create Project
193
239
 
240
+ Create Crowdin project.
241
+
242
+ **Important:** This API method requires `Account API Key`. This key can not be found on your profile pages.
243
+
194
244
  Documentation: <https://crowdin.com/page/api/create-project>
195
245
 
196
246
  ### Edit Project
@@ -240,6 +290,6 @@ Tested with the following Ruby versions:
240
290
 
241
291
  Author: Anton Maminov (anton.maminov@gmail.com)
242
292
 
243
- Copyright: 2012-2014 [crowdin.com](https://crowdin.com/)
293
+ Copyright: 2012-2015 [crowdin.com](https://crowdin.com/)
244
294
 
245
295
  This library is distributed under the MIT license. Please see the LICENSE file.
data/crowdin-api.gemspec CHANGED
@@ -17,4 +17,5 @@ Gem::Specification.new do |gem|
17
17
  gem.require_paths = ['lib']
18
18
 
19
19
  gem.add_dependency 'rest-client', '>= 1.7.0'
20
+ gem.add_development_dependency 'rspec'
20
21
  end
@@ -13,7 +13,8 @@ PROJECT_ID = 'rubytestapi'
13
13
  crowdin = Crowdin::API.new(api_key: API_KEY, project_id: PROJECT_ID, base_url: 'https://api.crowdin.com')
14
14
  crowdin.log = Logger.new $stderr
15
15
 
16
- pp crowdin.project_info
16
+ pp crowdin.supported_languages
17
+ #pp crowdin.project_info
17
18
 
18
19
  # crowdin.add_directory('test')
19
20
  # file = { :dest => '/test.txt', :source => 'test.txt', :export_pattern => '/%three_letters_code%/%original_file_name%' }
@@ -3,7 +3,7 @@ module Crowdin
3
3
  # site for a full explaination of what each of the Crowdin api methods
4
4
  # expect and perform.
5
5
  #
6
- # http://crowdin.com/page/api
6
+ # https://crowdin.com/page/api
7
7
 
8
8
  class API
9
9
 
@@ -12,7 +12,7 @@ module Crowdin
12
12
  # == Parameters
13
13
  #
14
14
  # files - Array of files that should be added to Crowdin project.
15
- # file is a Hash {:dest, :source, :title, :export_pattern}
15
+ # file is a Hash { :dest, :source, :title, :export_pattern }
16
16
  # * :dest - file name with path in Crowdin project (required)
17
17
  # * :source - path for uploaded file (required)
18
18
  # * :title - title in Crowdin UI (optional)
@@ -23,18 +23,18 @@ module Crowdin
23
23
  # POST https://api.crowdin.com/api/project/{project-identifier}/add-file?key={project-key}
24
24
  #
25
25
  def add_file(files, params = {})
26
- params[:files] = Hash[files.map{ |f| [
26
+ params[:files] = Hash[files.map { |f| [
27
27
  f[:dest] || raise(ArgumentError, "'`:dest`' is required"),
28
28
  ::File.open(f[:source] || raise(ArgumentError, "'`:source` is required'"))
29
29
  ] }]
30
30
 
31
- params[:titles] = Hash[files.map{ |f| [f[:dest], f[:title]] }]
32
- params[:titles].delete_if{ |k, v| v.nil? }
31
+ params[:titles] = Hash[files.map { |f| [f[:dest], f[:title]] }]
32
+ params[:titles].delete_if { |k, v| v.nil? }
33
33
 
34
- params[:export_patterns] = Hash[files.map{ |f| [f[:dest], f[:export_pattern]] }]
35
- params[:export_patterns].delete_if{ |k, v| v.nil? }
34
+ params[:export_patterns] = Hash[files.map { |f| [f[:dest], f[:export_pattern]] }]
35
+ params[:export_patterns].delete_if { |k, v| v.nil? }
36
36
 
37
- params.delete_if{ |k, v| v.to_s.empty? }
37
+ params.delete_if { |k, v| v.to_s.empty? }
38
38
 
39
39
  request(
40
40
  :method => :post,
@@ -48,7 +48,7 @@ module Crowdin
48
48
  # == Parameters
49
49
  #
50
50
  # files - Array of files that should be updated in Crowdin project.
51
- # file is a Hash {:dest, :source}
51
+ # file is a Hash { :dest, :source }
52
52
  # * :dest - file name with path in Crowdin project (required)
53
53
  # * :source - path for uploaded file (required)
54
54
  # * :title - title in Crowdin UI (optional)
@@ -59,7 +59,7 @@ module Crowdin
59
59
  # POST https://api.crowdin.com/api/project/{project-identifier}/update-file?key={project-key}
60
60
  #
61
61
  def update_file(files, params = {})
62
- params[:files] = Hash[files.map{ |f|
62
+ params[:files] = Hash[files.map { |f|
63
63
  dest = f[:dest] || raise(ArgumentError, "'`:dest` is required'")
64
64
  source = ::File.open(f[:source] || raise(ArgumentError, "'`:source` is required'"))
65
65
  source.define_singleton_method(:original_filename) do
@@ -68,13 +68,13 @@ module Crowdin
68
68
  [dest, source]
69
69
  }]
70
70
 
71
- params[:titles] = Hash[files.map{ |f| [f[:dest], f[:title]] }]
72
- params[:titles].delete_if{ |k, v| v.nil? }
71
+ params[:titles] = Hash[files.map { |f| [f[:dest], f[:title]] }]
72
+ params[:titles].delete_if { |k, v| v.nil? }
73
73
 
74
- params[:export_patterns] = Hash[files.map{ |f| [f[:dest], f[:export_pattern]] }]
75
- params[:export_patterns].delete_if{ |k, v| v.nil? }
74
+ params[:export_patterns] = Hash[files.map { |f| [f[:dest], f[:export_pattern]] }]
75
+ params[:export_patterns].delete_if { |k, v| v.nil? }
76
76
 
77
- params.delete_if{ |k, v| v.to_s.empty? }
77
+ params.delete_if { |k, v| v.to_s.empty? }
78
78
 
79
79
  request(
80
80
  :method => :post,
@@ -88,7 +88,7 @@ module Crowdin
88
88
  # == Parameters
89
89
  #
90
90
  # files - Array of files that should be added to Crowdin project.
91
- # file is a Hash {:dest, :source}
91
+ # file is a Hash { :dest, :source }
92
92
  # * :dest - file name with path in Crowdin project (required)
93
93
  # * :source - path for uploaded file (required)
94
94
  #
@@ -102,7 +102,7 @@ module Crowdin
102
102
  # POST https://api.crowdin.com/api/project/{project-identifier}/upload-translation?key={project-key}
103
103
  #
104
104
  def upload_translation(files, language, params = {})
105
- params[:files] = Hash[files.map{ |f| [
105
+ params[:files] = Hash[files.map { |f| [
106
106
  f[:dest] || raise(ArgumentError, "`:dest` is required"),
107
107
  ::File.open(f[:source] || raise(ArgumentError, "`:source` is required"))
108
108
  ] }]
@@ -117,6 +117,7 @@ module Crowdin
117
117
  end
118
118
 
119
119
  # Download ZIP file with translations. You can choose the language of translation you need or download all of them at once.
120
+ #
120
121
  # Note: If you would like to download the most recent translations you may want to use export API method before downloading.
121
122
  #
122
123
  # == Request
@@ -193,6 +194,32 @@ module Crowdin
193
194
  end
194
195
 
195
196
 
197
+ # Rename or change directory attributes.
198
+ #
199
+ # == Parameters
200
+ #
201
+ # name - Full directory path that should be modified (e.g. /MainPage/AboutUs).
202
+ #
203
+ # Optional:
204
+ # * :new_name - new directory name (not contain path, name only)
205
+ # * :title - new directory title to be displayed in Crowdin UI
206
+ # * :export_pattern - new directory export pattern
207
+ #
208
+ # == Request
209
+ #
210
+ # POST https://api.crowdin.com/api/project/{project-identifier}/change-directory?key={project-key}
211
+ #
212
+ def change_directory(name, params = {})
213
+ params[:name] = name
214
+
215
+ request(
216
+ :method => :post,
217
+ :path => "/api/project/#{@project_id}/change-directory",
218
+ :query => params,
219
+ )
220
+ end
221
+
222
+
196
223
  # Delete file from Crowdin project. All the translations will be lost without ability to restore them.
197
224
  #
198
225
  # == Request
@@ -235,7 +262,10 @@ module Crowdin
235
262
  )
236
263
  end
237
264
 
238
- # Build ZIP archive with the latest translations. Please note that this method can be invoked only every 30 minutes. Also API call will be ignored if there were no any changes in project since last export.
265
+ # Build ZIP archive with the latest translations.
266
+ #
267
+ # Please note that this method can be invoked only every 30 minutes.
268
+ # Also API call will be ignored if there were no any changes in project since last export.
239
269
  #
240
270
  # == Request
241
271
  #
@@ -253,12 +283,12 @@ module Crowdin
253
283
  #
254
284
  # == Request
255
285
  #
256
- # GET https://api.crowdin.com/api/supported-languages
286
+ # GET https://api.crowdin.com/api/project/{project-identifier}/supported-languages?key={project-key}
257
287
  #
258
288
  def supported_languages
259
289
  request(
260
290
  :method => :get,
261
- :path => "/api/supported-languages",
291
+ :path => "/api/project/#{@project_id}/supported-languages",
262
292
  )
263
293
  end
264
294
 
@@ -289,7 +319,7 @@ module Crowdin
289
319
  end
290
320
 
291
321
  # Create new Crowdin project.
292
- # Important: The API method requires Account API Key. This key can not be found on your profile pages, please contact us to obtain API key for your account.
322
+ # Important: The API method requires Account API Key. This key can not be found on your profile pages.
293
323
  #
294
324
  # == Request
295
325
  #
@@ -331,10 +361,11 @@ module Crowdin
331
361
  end
332
362
 
333
363
  # Get Crowdin Project details.
364
+ # Important: The API method requires Account API Key. This key can not be found on your profile pages.
334
365
  #
335
366
  # == Request
336
367
  #
337
- # GET https://api.crowdin.com/api/account/get-projects?key={account-key}
368
+ # GET https://api.crowdin.com/api/account/get-projects?account-key={account-key}
338
369
  #
339
370
  def get_projects(login)
340
371
  request(
@@ -1,5 +1,5 @@
1
1
  module Crowdin
2
2
  class API
3
- VERSION = "0.2.5"
3
+ VERSION = "0.2.6"
4
4
  end
5
5
  end
@@ -0,0 +1,16 @@
1
+ require 'spec_helper'
2
+ require 'crowdin-api'
3
+
4
+ describe Crowdin::API do
5
+ before(:each) do
6
+ @crowdin_client = Crowdin::API.new
7
+ end
8
+
9
+ it 'should have a version' do
10
+ expect(Crowdin::API::VERSION).to eq('0.2.5')
11
+ end
12
+
13
+ it 'should get a list of supported languages' do
14
+ expect(@crowdin_client.supported_languages).to eq([{}])
15
+ end
16
+ end
@@ -0,0 +1,11 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'External request' do
4
+ it 'should call crowdin api' do
5
+ uri = URI('https://api.crowdin.com//api/project/123/supported-languages')
6
+
7
+ response = JSON.load(Net::HTTP.get(uri))
8
+
9
+ expect(response).to eq([{}])
10
+ end
11
+ end
@@ -0,0 +1,101 @@
1
+ # This file was generated by the `rspec --init` command. Conventionally, all
2
+ # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
3
+ # The generated `.rspec` file contains `--require spec_helper` which will cause this
4
+ # file to always be loaded, without a need to explicitly require it in any files.
5
+ #
6
+ # Given that it is always loaded, you are encouraged to keep this file as
7
+ # light-weight as possible. Requiring heavyweight dependencies from this file
8
+ # will add to the boot time of your test suite on EVERY test run, even for an
9
+ # individual file that may not need all of that loaded. Instead, consider making
10
+ # a separate helper file that requires the additional dependencies and performs
11
+ # the additional setup, and require it from the spec files that actually need it.
12
+ #
13
+ # The `.rspec` file also contains a few flags that are not defaults but that
14
+ # users commonly want.
15
+ #
16
+ # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
17
+
18
+ require 'json'
19
+
20
+ require 'webmock/rspec'
21
+ WebMock.disable_net_connect!(allow_localhost: true)
22
+
23
+ require 'support/fake_crowdin'
24
+
25
+ RSpec.configure do |config|
26
+ # rspec-expectations config goes here. You can use an alternate
27
+ # assertion/expectation library such as wrong or the stdlib/minitest
28
+ # assertions if you prefer.
29
+ config.expect_with :rspec do |expectations|
30
+ # This option will default to `true` in RSpec 4. It makes the `description`
31
+ # and `failure_message` of custom matchers include text for helper methods
32
+ # defined using `chain`, e.g.:
33
+ # be_bigger_than(2).and_smaller_than(4).description
34
+ # # => "be bigger than 2 and smaller than 4"
35
+ # ...rather than:
36
+ # # => "be bigger than 2"
37
+ expectations.include_chain_clauses_in_custom_matcher_descriptions = true
38
+ end
39
+
40
+ # rspec-mocks config goes here. You can use an alternate test double
41
+ # library (such as bogus or mocha) by changing the `mock_with` option here.
42
+ config.mock_with :rspec do |mocks|
43
+ # Prevents you from mocking or stubbing a method that does not exist on
44
+ # a real object. This is generally recommended, and will default to
45
+ # `true` in RSpec 4.
46
+ mocks.verify_partial_doubles = true
47
+ end
48
+
49
+ config.before(:each) do
50
+ stub_request(:any, /api.crowdin.com/).to_rack(FakeCrowdin)
51
+ end
52
+
53
+ # The settings below are suggested to provide a good initial experience
54
+ # with RSpec, but feel free to customize to your heart's content.
55
+ =begin
56
+ # These two settings work together to allow you to limit a spec run
57
+ # to individual examples or groups you care about by tagging them with
58
+ # `:focus` metadata. When nothing is tagged with `:focus`, all examples
59
+ # get run.
60
+ config.filter_run :focus
61
+ config.run_all_when_everything_filtered = true
62
+
63
+ # Limits the available syntax to the non-monkey patched syntax that is recommended.
64
+ # For more details, see:
65
+ # - http://myronmars.to/n/dev-blog/2012/06/rspecs-new-expectation-syntax
66
+ # - http://teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
67
+ # - http://myronmars.to/n/dev-blog/2014/05/notable-changes-in-rspec-3#new__config_option_to_disable_rspeccore_monkey_patching
68
+ config.disable_monkey_patching!
69
+
70
+ # This setting enables warnings. It's recommended, but in some cases may
71
+ # be too noisy due to issues in dependencies.
72
+ config.warnings = true
73
+
74
+ # Many RSpec users commonly either run the entire suite or an individual
75
+ # file, and it's useful to allow more verbose output when running an
76
+ # individual spec file.
77
+ if config.files_to_run.one?
78
+ # Use the documentation formatter for detailed output,
79
+ # unless a formatter has already been configured
80
+ # (e.g. via a command-line flag).
81
+ config.default_formatter = 'doc'
82
+ end
83
+
84
+ # Print the 10 slowest examples and example groups at the
85
+ # end of the spec run, to help surface which specs are running
86
+ # particularly slow.
87
+ config.profile_examples = 10
88
+
89
+ # Run specs in random order to surface order dependencies. If you find an
90
+ # order dependency and want to debug it, you can fix the order by providing
91
+ # the seed, which is printed after each run.
92
+ # --seed 1234
93
+ config.order = :random
94
+
95
+ # Seed global randomization in this process using the `--seed` CLI option.
96
+ # Setting this allows you to use `--seed` to deterministically reproduce
97
+ # test failures related to randomization by passing the same `--seed` value
98
+ # as the one that triggered the failure.
99
+ Kernel.srand config.seed
100
+ =end
101
+ end
@@ -0,0 +1,19 @@
1
+ require 'sinatra/base'
2
+
3
+ class FakeCrowdin < Sinatra::Base
4
+ get '/api/project/:project_identifier/supported-languages' do
5
+ json_response 200, 'supported-languages.json'
6
+ end
7
+
8
+ get '/api/project/supported-languages' do
9
+ json_response 200, 'supported-languages.json'
10
+ end
11
+
12
+ private
13
+
14
+ def json_response(response_code, file_name)
15
+ content_type :json
16
+ status response_code
17
+ File.open(File.dirname(__FILE__) + '/fixtures/' + file_name, 'rb').read
18
+ end
19
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: crowdin-api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.5
4
+ version: 0.2.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Crowdin
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-08-27 00:00:00.000000000 Z
11
+ date: 2015-02-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rest-client
@@ -24,6 +24,20 @@ dependencies:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: 1.7.0
27
+ - !ruby/object:Gem::Dependency
28
+ name: rspec
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
27
41
  description: Ruby Client for the Crowdin API
28
42
  email:
29
43
  - support@crowdin.net
@@ -31,6 +45,7 @@ executables: []
31
45
  extensions: []
32
46
  extra_rdoc_files: []
33
47
  files:
48
+ - ".rspec"
34
49
  - Gemfile
35
50
  - LICENSE
36
51
  - README.md
@@ -42,6 +57,11 @@ files:
42
57
  - lib/crowdin-api/errors.rb
43
58
  - lib/crowdin-api/methods.rb
44
59
  - lib/crowdin-api/version.rb
60
+ - spec/crowdin-api_spec.rb
61
+ - spec/features/external_request_spec.rb
62
+ - spec/spec_helper.rb
63
+ - spec/support/fake_crowdin.rb
64
+ - spec/support/fixtures/supported-languages.json
45
65
  homepage: https://github.com/crowdin/crowdin-api/
46
66
  licenses:
47
67
  - MIT
@@ -62,8 +82,13 @@ required_rubygems_version: !ruby/object:Gem::Requirement
62
82
  version: '0'
63
83
  requirements: []
64
84
  rubyforge_project:
65
- rubygems_version: 2.2.2
85
+ rubygems_version: 2.4.5
66
86
  signing_key:
67
87
  specification_version: 4
68
88
  summary: Client library to manage translations on Crowdin
69
- test_files: []
89
+ test_files:
90
+ - spec/crowdin-api_spec.rb
91
+ - spec/features/external_request_spec.rb
92
+ - spec/spec_helper.rb
93
+ - spec/support/fake_crowdin.rb
94
+ - spec/support/fixtures/supported-languages.json