ruby-lokalise-api 2.7.0 → 2.8.0

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
  SHA256:
3
- metadata.gz: 731873c8db739c3d8dfb50acdf3a953df1d5aeeebfae374abecef9a82a6768e2
4
- data.tar.gz: 8c9c3cd03e0044afb2c7b35c13f2a76639313808752a0646a7038563ea9bb80d
3
+ metadata.gz: 8e19a20b1d025fd711703a9176f3379e9434b91715db88098a6c25aff8e24fa3
4
+ data.tar.gz: afbe4d805b7d97b19fb0105e34815e5a8ce49e36d1fe7b497bea8405d826d44e
5
5
  SHA512:
6
- metadata.gz: c366018086577a01348cb54c46c28637be5132b3139e4226a2a21e28e75fe8d271db4c54f59b5e7c540aff9c70199c6d928abfd3fa4e8a26eb05ad56cd176653
7
- data.tar.gz: a4dc54cefa1e39df9cc26cca452e4210c9f7d4288b9d083da6fd52194760efec083b0a7bfbca19ab315d7072161b2d01c3712ea8b15b1022b880a21bfd863a99
6
+ metadata.gz: 60df98ac6b8065743bd760e4979b94264da22eeebde08f8b199889dada4d591e7491becb64f09684371a97e7da4a4bb7dfa2cdefb590eca754c2bf7ed1684e1a
7
+ data.tar.gz: a22de056ac53851456ac434cd3ecec0c8622d19d5a18b37a658c9d6bb71108ae41106868b54297fc569d8f517b4759156d48ccdea93df3abd43a389ab3e3a9f5
data/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # Changelog
2
2
 
3
+ ## 2.8.0 (13-Nov-19)
4
+
5
+ * Added methods to [merge branches](https://lokalise.com/api2docs/curl/#transition-merge-a-branch-post):
6
+ + `branch.merge params`
7
+ + `client.merge_branch project_id, branch_id, params`
8
+
3
9
  ## 2.7.0 (30-Oct-19)
4
10
 
5
11
  * Added [`Branch` endpoint](https://lokalise.co/api2docs/curl/#resource-branches)
data/README.md CHANGED
@@ -206,6 +206,13 @@ If you are using [project branching feature](https://docs.lokalise.com/en/articl
206
206
  ## Updated branch
207
207
  ```
208
208
 
209
+ Alternatively:
210
+
211
+ ```ruby
212
+ branch = @client.branch('project_id', 'branch_id')
213
+ branch.update params
214
+ ```
215
+
209
216
  #### Delete branch
210
217
 
211
218
  [Doc](https://lokalise.com/api2docs/curl/#transition-delete-a-branch-delete)
@@ -218,6 +225,33 @@ If you are using [project branching feature](https://docs.lokalise.com/en/articl
218
225
  ## Hash with the project's id and "branch_deleted"=>true
219
226
  ```
220
227
 
228
+ Alternatively:
229
+
230
+ ```ruby
231
+ branch = @client.branch('project_id', 'branch_id')
232
+ branch.destroy
233
+ ```
234
+
235
+ #### Merge branch
236
+
237
+ [Doc](https://lokalise.com/api2docs/curl/#transition-merge-a-branch-post)
238
+
239
+ ```ruby
240
+ @client.merge_branch(project_id, branch_id, params) # Input:
241
+ ## project_id (string, required)
242
+ ## branch_id (string or integer, required)
243
+ ## params (hash)
244
+ # Output:
245
+ ## Hash with the project's id, "branch_merged"=>true, and branch attributes
246
+ ```
247
+
248
+ Alternatively:
249
+
250
+ ```ruby
251
+ branch = @client.branch('project_id', 'branch_id')
252
+ branch.merge params
253
+ ```
254
+
221
255
  ### Comments
222
256
 
223
257
  [Comments attributes](https://lokalise.com/api2docs/curl/#resource-comments)
@@ -3,10 +3,22 @@ module Lokalise
3
3
  class Branch < Base
4
4
  supports :update, :destroy
5
5
 
6
+ def merge(params = {})
7
+ self.class.merge @client, self.class.endpoint(project_id, branch_id, :merge), params
8
+ end
9
+
6
10
  class << self
7
- def endpoint(project_id, branch_id = nil)
8
- path_from projects: project_id,
9
- branches: branch_id
11
+ def merge(client, path, params, *_args)
12
+ post(path, client, params)['content']
13
+ end
14
+
15
+ def endpoint(project_id, branch_id = nil, action = nil)
16
+ params = {projects: project_id,
17
+ branches: branch_id}
18
+
19
+ params[:merge] = '' if action == :merge
20
+
21
+ path_from params
10
22
  end
11
23
  end
12
24
  end
@@ -50,5 +50,16 @@ module Lokalise
50
50
  def destroy_branch(project_id, branch_id)
51
51
  c_r Lokalise::Resources::Branch, :destroy, [project_id, branch_id]
52
52
  end
53
+
54
+ # Merges a branch in the project
55
+ #
56
+ # @see https://lokalise.com/api2docs/curl/#transition-merge-a-branch-post
57
+ # @return [Hash]
58
+ # @param project_id [String]
59
+ # @param branch_id [String, Integer]
60
+ # @param params [Hash]
61
+ def merge_branch(project_id, branch_id, params = {})
62
+ c_r Lokalise::Resources::Branch, :merge, [project_id, branch_id, :merge], params
63
+ end
53
64
  end
54
65
  end
@@ -1,3 +1,3 @@
1
1
  module Lokalise
2
- VERSION = '2.7.0'.freeze
2
+ VERSION = '2.8.0'.freeze
3
3
  end
@@ -63,7 +63,45 @@ RSpec.describe Lokalise::Client do
63
63
  expect(response['branch_deleted']).to eq(true)
64
64
  end
65
65
 
66
+ specify '#merge_branch' do
67
+ branch = VCR.use_cassette('create_branch_to_merge') do
68
+ test_client.create_branch project_id, name: 'merge-me'
69
+ end
70
+
71
+ expect(branch.name).to eq('merge-me')
72
+
73
+ branch_id = branch.branch_id
74
+
75
+ response = VCR.use_cassette('merge_branch') do
76
+ test_client.merge_branch project_id, branch_id, force_conflict_resolve_using: 'master'
77
+ end
78
+
79
+ expect(response['project_id']).to eq(project_id)
80
+ expect(response['branch_merged']).to eq(true)
81
+ expect(response['branch']['branch_id']).to eq(branch_id)
82
+ expect(response['branch']['name']).to eq(branch.name)
83
+ end
84
+
66
85
  context 'branch chained methods' do
86
+ it 'should support merge' do
87
+ branch = VCR.use_cassette('create_branch_to_merge2') do
88
+ test_client.create_branch project_id, name: 'merge-me-plz'
89
+ end
90
+
91
+ expect(branch.name).to eq('merge-me-plz')
92
+
93
+ branch_id = branch.branch_id
94
+
95
+ response = VCR.use_cassette('merge_branch_chained') do
96
+ branch.merge force_conflict_resolve_using: 'master'
97
+ end
98
+
99
+ expect(response['project_id']).to eq(project_id)
100
+ expect(response['branch_merged']).to eq(true)
101
+ expect(response['branch']['branch_id']).to eq(branch_id)
102
+ expect(response['branch']['name']).to eq(branch.name)
103
+ end
104
+
67
105
  it 'should support update and destroy' do
68
106
  branch = VCR.use_cassette('create_another_branch') do
69
107
  test_client.create_branch project_id, name: 'ruby-second-branch'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby-lokalise-api
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.7.0
4
+ version: 2.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ilya Bodrov
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-10-30 00:00:00.000000000 Z
11
+ date: 2019-11-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: addressable