stash_core_api 0.1.6 → 0.1.7

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: eefa96b5608f5e886bec64e6bbecad120094e799c74c9e8c324ed58314174836
4
- data.tar.gz: 729a6906231d22ccefbd8b7573eb64e8a08a7c08a7f2d20198bcb9c667813b08
3
+ metadata.gz: f22254286614f429f6ab5fb80d4741b920ceb613aa7618648274d90d5ce134d4
4
+ data.tar.gz: 1b02ccd11503e2a3660ca503fc975dce8b3939f56e21b5ff92923b80fc2ff579
5
5
  SHA512:
6
- metadata.gz: b0c1cff131d164f24fb2e5b863385f1862e329cdac4f06ce89e5f80f3dcf23c879b1d75777c3869fc05048c622f42af34fb26f7ed582953b3ae48fa2ab2d557d
7
- data.tar.gz: 2effd106f6e9b8ea1623f524568d6f77dffa18b1af8756140f58a0774e6c54b97ffa9377965b6f6c075979169761917d81e9ca944d6f283ebccff78d807139b0
6
+ metadata.gz: 0cb5d9d289c22e5ad5fa4f6df3b198ad3e44396fc4fca154b92280b20ec794e640e052923449bb0292b631ae37418cf7a24f9b93efa4943aa00334a93e1c186a
7
+ data.tar.gz: 74b01fab544b852e884d97124431ca93f0a78a5abb30c69cf6fa1ffa252f618e5092bc691bf5812e7213d97592881f359107bb50a04367dbacfbe6906f53005d
data/.rubocop.yml ADDED
@@ -0,0 +1,14 @@
1
+ AllCops:
2
+ TargetRubyVersion: 2.4
3
+ DisplayCopNames: true
4
+
5
+ Metrics:
6
+ Enabled: false
7
+ Style/Documentation:
8
+ Enabled: false
9
+ Style/TrailingCommaInArguments:
10
+ EnforcedStyleForMultiline: consistent_comma
11
+ Style/TrailingCommaInArrayLiteral:
12
+ EnforcedStyleForMultiline: consistent_comma
13
+ Style/TrailingCommaInHashLiteral:
14
+ EnforcedStyleForMultiline: consistent_comma
data/.travis.yml CHANGED
@@ -1,5 +1,9 @@
1
1
  language: ruby
2
+ before_install:
3
+ - gem install bundler
2
4
  rvm:
3
- - 2.1
4
- - 2.2
5
- before_install: gem update bundler
5
+ - 2.4
6
+ - 2.5
7
+ - 2.6
8
+ matrix:
9
+ fast_finish: true
data/CHANGELOG.md CHANGED
@@ -1,6 +1,19 @@
1
1
  Change Log
2
2
  ==========
3
3
 
4
+ Version 1.1.7 *(2019-04-04)*
5
+ ----------------------------
6
+
7
+ * Bump gem dependencies
8
+ * Move development dependencies from gemspec to Gemfile
9
+ * Add bundler/gem_tasks
10
+ * Add rubocop + rubocop auto-correct
11
+
12
+ Version 1.1.6 *(2019-04-04)*
13
+ ----------------------------
14
+
15
+ * Add support for `commit/changes` and `compare/changes` endpoints
16
+
4
17
  Version 0.1.5 *(2018-01-11)*
5
18
  ----------------------------
6
19
 
data/Gemfile CHANGED
@@ -1,7 +1,13 @@
1
+ # frozen_string_literal: true
2
+
1
3
  source 'https://www.rubygems.org'
2
4
 
3
5
  gemspec
4
6
 
5
- group :development do
6
- gem 'kramdown'
7
- end
7
+ gem 'bundler', '~> 2.0'
8
+ gem 'kramdown'
9
+ gem 'rake', '~> 12.3'
10
+ gem 'rspec', '~> 3.8'
11
+ gem 'rubocop', '0.67.1'
12
+ gem 'webmock', '~> 3.5'
13
+ gem 'yard', '~> 0.9.11'
data/Rakefile CHANGED
@@ -1,11 +1,15 @@
1
- # encoding: utf-8
1
+ # frozen_string_literal: true
2
2
 
3
3
  require 'bundler/setup'
4
+ require 'bundler/gem_tasks'
4
5
 
5
6
  require 'rspec/core/rake_task'
6
7
  RSpec::Core::RakeTask.new
7
8
 
8
- task default: 'spec'
9
+ require 'rubocop/rake_task'
10
+ RuboCop::RakeTask.new
11
+
12
+ task default: %i[spec rubocop]
9
13
 
10
14
  begin
11
15
  require 'yard'
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'stash_core_api/commits'
2
4
  require 'stash_core_api/pull_requests'
3
5
  require 'stash_core_api/compare'
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'stash_core_api/api'
2
4
  require 'stash_core_api/utils'
3
5
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'stash_core_api/utils'
2
4
 
3
5
  module StashCoreAPI
@@ -18,7 +20,7 @@ module StashCoreAPI
18
20
  # @param withCounts [Boolean] optionally include the total number of
19
21
  # commits and total number of unique authors
20
22
  def commits(path: nil, since: nil, until_: nil, limit: nil,
21
- with_counts: nil)
23
+ with_counts: nil)
22
24
  endpoint = '/commits'
23
25
  if path || since || until_ || limit || with_counts
24
26
  endpoint = "#{endpoint}?"
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'stash_core_api/utils'
2
4
 
3
5
  module StashCoreAPI
@@ -26,4 +28,3 @@ module StashCoreAPI
26
28
  end
27
29
  end
28
30
  end
29
-
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module StashCoreAPI
2
4
  # Base class for all errors emanating from Stash.
3
5
  class Error < StandardError
@@ -32,8 +34,8 @@ module StashCoreAPI
32
34
  404 => StashCoreAPI::Error::NotFound,
33
35
  405 => StashCoreAPI::Error::MethodNotAllowed,
34
36
  409 => StashCoreAPI::Error::Conflict,
35
- 415 => StashCoreAPI::Error::UnsupportedMediaType
36
- }
37
+ 415 => StashCoreAPI::Error::UnsupportedMediaType,
38
+ }.freeze
37
39
 
38
40
  # Initializes a new Error object
39
41
  #
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'stash_core_api/utils'
2
4
 
3
5
  module StashCoreAPI
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'http'
2
4
  require 'json'
3
5
  require 'stash_core_api/error'
@@ -14,8 +16,8 @@ module StashCoreAPI
14
16
 
15
17
  def get
16
18
  response = HTTP
17
- .basic_auth(user: @client.user, pass: @client.pass)
18
- .get(req_url(@endpoint))
19
+ .basic_auth(user: @client.user, pass: @client.pass)
20
+ .get(req_url(@endpoint))
19
21
  process(response)
20
22
  end
21
23
 
@@ -26,13 +28,14 @@ module StashCoreAPI
26
28
  body = response.parse
27
29
 
28
30
  error = error(code, body)
29
- fail(error) if error
31
+ raise(error) if error
32
+
30
33
  body
31
34
  end
32
35
 
33
36
  def error(code, body)
34
37
  klass = StashCoreAPI::Error::ERRORS[code]
35
- klass.new(body) if klass
38
+ klass&.new(body)
36
39
  end
37
40
 
38
41
  def req_url(endpoint)
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'stash_core_api/request'
2
4
 
3
5
  module StashCoreAPI
@@ -11,7 +13,7 @@ module StashCoreAPI
11
13
 
12
14
  def sanitized_path(path)
13
15
  # strip out any leading '/' which will break the Stash API
14
- path.sub(/^\/*/, '')
16
+ path.sub(%r{^/*}, '')
15
17
  end
16
18
  end
17
19
  end
@@ -1,6 +1,5 @@
1
- # encoding: utf-8
1
+ # frozen_string_literal: true
2
2
 
3
- # StashCoreAPI module
4
3
  module StashCoreAPI
5
- VERSION = '0.1.6'
4
+ VERSION = '0.1.7'
6
5
  end
@@ -1,3 +1,4 @@
1
- # encoding: utf-8
1
+ # frozen_string_literal: true
2
+
2
3
  require 'stash_core_api/version'
3
4
  require 'stash_core_api/client'
data/spec/spec_helper.rb CHANGED
@@ -1,4 +1,4 @@
1
- # encoding: utf-8
1
+ # frozen_string_literal: true
2
2
 
3
3
  require 'rspec'
4
4
  require 'stash_core_api'
@@ -20,7 +20,7 @@ def base_path(client)
20
20
  end
21
21
 
22
22
  def fixture_path
23
- File.expand_path('../fixtures', __FILE__)
23
+ File.expand_path('fixtures', __dir__)
24
24
  end
25
25
 
26
26
  def fixture(file)
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  RSpec.describe StashCoreAPI::Client do
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  RSpec.describe StashCoreAPI::Client do
@@ -17,7 +19,7 @@ RSpec.describe StashCoreAPI::Client do
17
19
  endpoint = "/#{base_path(client)}/commits"
18
20
  stub_get(client, endpoint).to_return(
19
21
  body: fixture('commits.json'),
20
- headers: { 'Content-Type' => 'application/json' }
22
+ headers: { 'Content-Type' => 'application/json' },
21
23
  )
22
24
  commits = client.commits
23
25
  expect(commits['size']).to eq(25)
@@ -28,7 +30,7 @@ RSpec.describe StashCoreAPI::Client do
28
30
  endpoint = "/#{base_path(client)}/commits?limit=#{limit}"
29
31
  stub_get(client, endpoint).to_return(
30
32
  body: fixture('commits_with_limit.json'),
31
- headers: { 'Content-Type' => 'application/json' }
33
+ headers: { 'Content-Type' => 'application/json' },
32
34
  )
33
35
  commits = client.commits(limit: 2)
34
36
  expect(commits['size']).to eq(limit)
@@ -36,13 +38,13 @@ RSpec.describe StashCoreAPI::Client do
36
38
  end
37
39
 
38
40
  context 'with_count' do
39
- let(:count_keys) { %w( authorCount totalCount ) }
41
+ let(:count_keys) { %w[authorCount totalCount] }
40
42
 
41
43
  it 'does not include count keys if with_count is not set' do
42
44
  endpoint = "/#{base_path(client)}/commits"
43
45
  stub_get(client, endpoint).to_return(
44
46
  body: fixture('commits.json'),
45
- headers: { 'Content-Type' => 'application/json' }
47
+ headers: { 'Content-Type' => 'application/json' },
46
48
  )
47
49
  commits = client.commits
48
50
  expect(count_keys - commits.keys).to eq(count_keys)
@@ -52,7 +54,7 @@ RSpec.describe StashCoreAPI::Client do
52
54
  endpoint = "/#{base_path(client)}/commits?withCounts=true"
53
55
  stub_get(client, endpoint).to_return(
54
56
  body: fixture('commits_with_with_count.json'),
55
- headers: { 'Content-Type' => 'application/json' }
57
+ headers: { 'Content-Type' => 'application/json' },
56
58
  )
57
59
  commits = client.commits(with_counts: true)
58
60
  expect(count_keys - commits.keys).to be_empty
@@ -62,7 +64,7 @@ RSpec.describe StashCoreAPI::Client do
62
64
 
63
65
  describe '#commit_changes' do
64
66
  it 'should hit the approprate stash api with the given options' do
65
- endpoint = "/commits/083f66ba3c6/changes?limit=1"
67
+ endpoint = '/commits/083f66ba3c6/changes?limit=1'
66
68
  expect(client).to receive(:perform_get).with(endpoint)
67
69
  client.commit_changes('083f66ba3c6', limit: 1)
68
70
  end
@@ -72,10 +74,10 @@ RSpec.describe StashCoreAPI::Client do
72
74
  stub_get(client, endpoint).to_return(
73
75
  status: 404,
74
76
  body: fixture('commit_changes_bad_sha.json'),
75
- headers: { 'Content-Type' => 'application/json' }
77
+ headers: { 'Content-Type' => 'application/json' },
76
78
  )
77
79
  expect { client.commit_changes('083f66ba3c6') }.to raise_error(
78
- StashCoreAPI::Error::NotFound, 'Commit "083f66ba3c6" does not exist in this repository'
80
+ StashCoreAPI::Error::NotFound, 'Commit "083f66ba3c6" does not exist in this repository',
79
81
  )
80
82
  end
81
83
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  RSpec.describe StashCoreAPI::Client do
@@ -14,9 +16,9 @@ RSpec.describe StashCoreAPI::Client do
14
16
  describe '#compare' do
15
17
  describe '#changes' do
16
18
  it 'should hit the approprate stash api with the given options' do
17
- endpoint = "/compare/changes?from=a&to=b&fromRepo=c&limit=1"
19
+ endpoint = '/compare/changes?from=a&to=b&fromRepo=c&limit=1'
18
20
  expect(client).to receive(:perform_get).with(endpoint)
19
- changes = client.compare_changes('a', 'b', from_repo: 'c', limit: 1)
21
+ client.compare_changes('a', 'b', from_repo: 'c', limit: 1)
20
22
  end
21
23
 
22
24
  it 'should raise an error when the range is not valid' do
@@ -24,13 +26,12 @@ RSpec.describe StashCoreAPI::Client do
24
26
  stub_get(client, endpoint).to_return(
25
27
  status: 404,
26
28
  body: fixture('compare_changes_bad_range.json'),
27
- headers: { 'Content-Type' => 'application/json' }
29
+ headers: { 'Content-Type' => 'application/json' },
28
30
  )
29
31
  expect { client.compare_changes('c', 'd') }.to raise_error(
30
- StashCoreAPI::Error::NotFound, 'Object "c" does not exist in this repository'
32
+ StashCoreAPI::Error::NotFound, 'Object "c" does not exist in this repository',
31
33
  )
32
34
  end
33
35
  end
34
36
  end
35
37
  end
36
-
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  RSpec.describe StashCoreAPI::Error do
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  RSpec.describe StashCoreAPI::Client do
@@ -18,7 +20,7 @@ RSpec.describe StashCoreAPI::Client do
18
20
  it 'returns true if pr can be merged' do
19
21
  stub_get(client, endpoint).to_return(
20
22
  body: fixture('can_merge.json'),
21
- headers: { 'Content-Type' => 'application/json' }
23
+ headers: { 'Content-Type' => 'application/json' },
22
24
  )
23
25
  expect(client.can_merge?(pr_id)).to be true
24
26
  end
@@ -26,7 +28,7 @@ RSpec.describe StashCoreAPI::Client do
26
28
  it 'returns false if pr cannot be merged' do
27
29
  stub_get(client, endpoint).to_return(
28
30
  body: fixture('cannot_merge.json'),
29
- headers: { 'Content-Type' => 'application/json' }
31
+ headers: { 'Content-Type' => 'application/json' },
30
32
  )
31
33
  expect(client.can_merge?(pr_id)).to be false
32
34
  end
@@ -39,7 +41,7 @@ RSpec.describe StashCoreAPI::Client do
39
41
  it 'returns a JSON hash of body' do
40
42
  stub_get(client, endpoint).to_return(
41
43
  body: fixture('info.json'),
42
- headers: { 'Content-Type' => 'application/json' }
44
+ headers: { 'Content-Type' => 'application/json' },
43
45
  )
44
46
  expect(client.info(pr_id)).to eq(JSON.parse(fixture('info.json').read))
45
47
  end
@@ -47,12 +49,12 @@ RSpec.describe StashCoreAPI::Client do
47
49
  it 'returns expected keys in hash' do
48
50
  stub_get(client, endpoint).to_return(
49
51
  body: fixture('info.json'),
50
- headers: { 'Content-Type' => 'application/json' }
52
+ headers: { 'Content-Type' => 'application/json' },
51
53
  )
52
54
  info = client.info(pr_id)
53
- expected_keys = %w( id version title state open closed createdDate
55
+ expected_keys = %w[ id version title state open closed createdDate
54
56
  updatedDate fromRef toRef locked author reviewers
55
- participants link links )
57
+ participants link links ]
56
58
  expect(info.keys).to eq(expected_keys)
57
59
  end
58
60
 
@@ -60,7 +62,7 @@ RSpec.describe StashCoreAPI::Client do
60
62
  it 'matches id in JSON body' do
61
63
  stub_get(client, endpoint).to_return(
62
64
  body: fixture('info.json'),
63
- headers: { 'Content-Type' => 'application/json' }
65
+ headers: { 'Content-Type' => 'application/json' },
64
66
  )
65
67
  info = client.info(pr_id)
66
68
  expect(info['id']).to eq(pr_id)
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  RSpec.describe StashCoreAPI::Request do
@@ -19,7 +21,7 @@ RSpec.describe StashCoreAPI::Request do
19
21
  stub_get(client, endpoint).to_return(
20
22
  body: fixture('unauthorized_error.json'),
21
23
  status: 401,
22
- headers: { 'Content-Type' => 'application/json' }
24
+ headers: { 'Content-Type' => 'application/json' },
23
25
  )
24
26
  expect { request.get }.to raise_error(StashCoreAPI::Error::Unauthorized)
25
27
  end
@@ -1,4 +1,4 @@
1
- # encoding: utf-8
1
+ # frozen_string_literal: true
2
2
 
3
3
  require 'spec_helper'
4
4
  require 'stash_core_api'
@@ -1,6 +1,6 @@
1
- # -*- encoding: utf-8 -*-
1
+ # frozen_string_literal: true
2
2
 
3
- require File.expand_path('../lib/stash_core_api/version', __FILE__)
3
+ require File.expand_path('lib/stash_core_api/version', __dir__)
4
4
 
5
5
  Gem::Specification.new do |gem|
6
6
  gem.name = 'stash_core_api'
@@ -17,13 +17,5 @@ Gem::Specification.new do |gem|
17
17
  gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
18
18
  gem.require_paths = ['lib']
19
19
 
20
- gem.required_ruby_version = '>= 2.0'
21
-
22
- gem.add_dependency 'http', '~> 0.9.8'
23
-
24
- gem.add_development_dependency 'bundler', '~> 1.10'
25
- gem.add_development_dependency 'rake', '~> 10.4'
26
- gem.add_development_dependency 'rspec', '~> 3.4'
27
- gem.add_development_dependency 'webmock', '~> 1.22'
28
- gem.add_development_dependency 'yard', '~> 0.9.11'
20
+ gem.add_dependency 'http', '~> 2.2'
29
21
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: stash_core_api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.6
4
+ version: 0.1.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alyssa Pohahau
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-04-04 00:00:00.000000000 Z
11
+ date: 2019-04-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: http
@@ -16,84 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 0.9.8
19
+ version: '2.2'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: 0.9.8
27
- - !ruby/object:Gem::Dependency
28
- name: bundler
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - "~>"
32
- - !ruby/object:Gem::Version
33
- version: '1.10'
34
- type: :development
35
- prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - "~>"
39
- - !ruby/object:Gem::Version
40
- version: '1.10'
41
- - !ruby/object:Gem::Dependency
42
- name: rake
43
- requirement: !ruby/object:Gem::Requirement
44
- requirements:
45
- - - "~>"
46
- - !ruby/object:Gem::Version
47
- version: '10.4'
48
- type: :development
49
- prerelease: false
50
- version_requirements: !ruby/object:Gem::Requirement
51
- requirements:
52
- - - "~>"
53
- - !ruby/object:Gem::Version
54
- version: '10.4'
55
- - !ruby/object:Gem::Dependency
56
- name: rspec
57
- requirement: !ruby/object:Gem::Requirement
58
- requirements:
59
- - - "~>"
60
- - !ruby/object:Gem::Version
61
- version: '3.4'
62
- type: :development
63
- prerelease: false
64
- version_requirements: !ruby/object:Gem::Requirement
65
- requirements:
66
- - - "~>"
67
- - !ruby/object:Gem::Version
68
- version: '3.4'
69
- - !ruby/object:Gem::Dependency
70
- name: webmock
71
- requirement: !ruby/object:Gem::Requirement
72
- requirements:
73
- - - "~>"
74
- - !ruby/object:Gem::Version
75
- version: '1.22'
76
- type: :development
77
- prerelease: false
78
- version_requirements: !ruby/object:Gem::Requirement
79
- requirements:
80
- - - "~>"
81
- - !ruby/object:Gem::Version
82
- version: '1.22'
83
- - !ruby/object:Gem::Dependency
84
- name: yard
85
- requirement: !ruby/object:Gem::Requirement
86
- requirements:
87
- - - "~>"
88
- - !ruby/object:Gem::Version
89
- version: 0.9.11
90
- type: :development
91
- prerelease: false
92
- version_requirements: !ruby/object:Gem::Requirement
93
- requirements:
94
- - - "~>"
95
- - !ruby/object:Gem::Version
96
- version: 0.9.11
26
+ version: '2.2'
97
27
  description: Make basic auth requests to Stash Core REST API
98
28
  email: arp@squareup.com
99
29
  executables: []
@@ -101,6 +31,7 @@ extensions: []
101
31
  extra_rdoc_files: []
102
32
  files:
103
33
  - ".gitignore"
34
+ - ".rubocop.yml"
104
35
  - ".travis.yml"
105
36
  - CHANGELOG.md
106
37
  - CONTRIBUTING.md
@@ -149,7 +80,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
149
80
  requirements:
150
81
  - - ">="
151
82
  - !ruby/object:Gem::Version
152
- version: '2.0'
83
+ version: '0'
153
84
  required_rubygems_version: !ruby/object:Gem::Requirement
154
85
  requirements:
155
86
  - - ">="