spearly-sdk-ruby 0.2.3 → 0.2.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 90991a87fed739d937f83ef33aa5f18075a3dbe8f2c7d53c53326bf417aa188a
4
- data.tar.gz: 02da248080a263211686303a3ba6fce31ed6cb2a3b280e53b1aa3350c94f30da
3
+ metadata.gz: 67814c681befa771a269e339b41cd446c68bdc242dd3a61900c3a1f507165167
4
+ data.tar.gz: ae7c1f34d649ebc34c0bd8ec4d1e468542c5c7c13bbf351fc0c9e3c294010996
5
5
  SHA512:
6
- metadata.gz: 6023e00a6a9964f2219f0f5776e0b9848b535686c60ac8ec2db4d20dce690a4a7b616109cb8f859ee6c34a8be2f13ec3cc59fa9b2b19fbb8418a302ae2e2f00a
7
- data.tar.gz: 9d83e00abdcca65131a8e3af7b7817509fe274373af37bd7c21b7e3db1772c9753b7792836ee2831dc5f8e526316ade8ed8cdfe7b6752d87cdadb3a19af8dd3e
6
+ metadata.gz: b5e943c498662cd93bcaaa2a5db68e5f16129a337860f8f35637a3d4056bcda54684a5f542201017ac1642ca9dab50549a77324d5d1c7c0354178eaa92b9c88c
7
+ data.tar.gz: a7fff0b9890ee300d37a958cfd714057d5684dbd534fb05e7a8cd24b6f7f59c1e45fd084ab64a457da3fcbf5c2a51c437e7d11704174db4fb00b1db30040e855
data/CHANGELOG.md CHANGED
@@ -1,10 +1,14 @@
1
+ ## [0.2.3] - 2021-06-18
2
+
3
+ - Raise `Spearly::Auth::AuthorizationError` and `Spearly::Auth::ServerError` from `Spearly::Auth::User` and `Spearly::Auth::Token`
4
+
1
5
  ## [0.2.2] - 2021-06-11
2
6
 
3
- - Updates README and gem specs
7
+ - Updates `README` and gem specs
4
8
 
5
9
  ## [0.2.1] - 2021-05-31
6
10
 
7
- - Initialize Spearly::Auth::User with bearer token
11
+ - Initialize `Spearly::Auth::User` with bearer token
8
12
 
9
13
  ## [0.2.0] - 2021-05-31
10
14
 
data/README.md CHANGED
@@ -7,26 +7,42 @@ Spearly SDK for Ruby.
7
7
  Add this line to your application's `Gemfile`:
8
8
 
9
9
  ```ruby
10
- gem 'spearly-sdk-ruby', '~> 0.2.2', require: 'spearly'
10
+ gem 'spearly-sdk-ruby', '~> x.y.z', require: 'spearly'
11
11
  ```
12
12
 
13
13
  And then execute:
14
14
  ```sh
15
- $ bundle install
15
+ bundle install
16
16
  ```
17
17
 
18
- Or install it yourself as:
18
+ Or install it manually:
19
19
  ```sh
20
- $ gem install spearly-sdk-ruby
20
+ gem install spearly-sdk-ruby
21
21
  ```
22
22
 
23
23
  ## Publish
24
+ ### Increment version
25
+ ```sh
26
+ vim lib/spearly/version.rb
27
+ ```
28
+
24
29
  ### Build
25
30
  ```sh
26
- $ rake build
31
+ rake build
27
32
  ```
28
33
 
29
34
  ### Push to RubyGems
30
35
  ```sh
31
- $ gem push pkg/spearly-sdk-ruby-x.y.z.gem
36
+ new_version=$(ruby -e "require 'spearly/version'; puts Spearly::VERSION")
37
+
38
+ gem push pkg/spearly-sdk-ruby-$new_version.gem
39
+ ```
40
+
41
+ ## Contribute
42
+ ### New version commit
43
+ ```sh
44
+ new_version=$(ruby -e "require 'spearly/version'; puts Spearly::VERSION")
45
+
46
+ git commit -m "v$new_version"
47
+ git tag -a v$new_version -m "Release $new_version"
32
48
  ```
@@ -12,6 +12,8 @@ module Spearly
12
12
 
13
13
  def method_missing(name, *args)
14
14
  @client.send(name, *args)
15
+ rescue Signet::AuthorizationError
16
+ raise Spearly::Auth::AuthorizationError
15
17
  end
16
18
 
17
19
  private
@@ -13,18 +13,16 @@ module Spearly
13
13
  def spearly_token
14
14
  @spearly_token ||= begin
15
15
  token = Spearly::Auth::Token.new(request.authorization)
16
- token.info
17
16
 
18
- token
17
+ token.info ? token : nil
19
18
  end
20
19
  end
21
20
 
22
21
  def spearly_user
23
22
  @spearly_user ||= begin
24
23
  user = Spearly::Auth::User.new(request.authorization)
25
- user.find
26
24
 
27
- user
25
+ user.find ? user : nil
28
26
  end
29
27
  end
30
28
  end
@@ -25,12 +25,7 @@ module Spearly
25
25
  nil,
26
26
  'Authorization' => @token)
27
27
 
28
- case res.status
29
- when 401
30
- raise Spearly::Auth::AuthorizationError
31
- when 500
32
- raise Spearly::Auth::ServerError
33
- end
28
+ return unless res.status == 200
34
29
 
35
30
  @attributes = JSON.parse(res.body)
36
31
  end
@@ -25,12 +25,7 @@ module Spearly
25
25
  nil,
26
26
  'Authorization' => @token)
27
27
 
28
- case res.status
29
- when 401
30
- raise Spearly::Auth::AuthorizationError
31
- when 500
32
- raise Spearly::Auth::ServerError
33
- end
28
+ return unless res.status == 200
34
29
 
35
30
  @attributes = JSON.parse(res.body)['user']
36
31
  end
@@ -44,12 +39,7 @@ module Spearly
44
39
  nil,
45
40
  'Authorization' => @token)
46
41
 
47
- case res.status
48
- when 401
49
- raise Spearly::Auth::AuthorizationError
50
- when 500
51
- raise Spearly::Auth::ServerError
52
- end
42
+ return [] unless res.status == 200
53
43
 
54
44
  team_hashes = JSON.parse(res.body)['teams']
55
45
 
@@ -67,12 +57,7 @@ module Spearly
67
57
  nil,
68
58
  'Authorization' => @token)
69
59
 
70
- case res.status
71
- when 401
72
- raise Spearly::Auth::AuthorizationError
73
- when 500
74
- raise Spearly::Auth::ServerError
75
- end
60
+ return [] unless res.status == 200
76
61
 
77
62
  oauth_user_hashes = JSON.parse(res.body)['oauth_users']
78
63
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Spearly
4
- VERSION = '0.2.3'
4
+ VERSION = '0.2.4'
5
5
  end
data/spearly.gemspec CHANGED
@@ -13,7 +13,7 @@ Gem::Specification.new do |gem|
13
13
  gem.required_ruby_version = Gem::Requirement.new('>= 2.7.2')
14
14
  gem.metadata['homepage_uri'] = gem.homepage
15
15
  gem.metadata['source_code_uri'] = 'https://github.com/unimal-jp/spearly-sdk-ruby'
16
- gem.metadata['changelog_uri'] = 'https://github.com/unimal-jp/spearly-sdk-ruby/CHANGELOG.md'
16
+ gem.metadata['changelog_uri'] = "https://github.com/unimal-jp/spearly-sdk-ruby/blob/#{Spearly::VERSION}/CHANGELOG.md"
17
17
 
18
18
  gem.files = `git ls-files`.split("\n")
19
19
  gem.executables = 'spearly'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: spearly-sdk-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.3
4
+ version: 0.2.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Spearly
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-06-18 00:00:00.000000000 Z
11
+ date: 2021-07-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -166,7 +166,7 @@ licenses: []
166
166
  metadata:
167
167
  homepage_uri: https://github.com/unimal-jp/spearly-sdk-ruby
168
168
  source_code_uri: https://github.com/unimal-jp/spearly-sdk-ruby
169
- changelog_uri: https://github.com/unimal-jp/spearly-sdk-ruby/CHANGELOG.md
169
+ changelog_uri: https://github.com/unimal-jp/spearly-sdk-ruby/blob/0.2.4/CHANGELOG.md
170
170
  post_install_message:
171
171
  rdoc_options: []
172
172
  require_paths: