glogin 0.14.1 → 0.14.2

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: 43ce4ccebe57a06bb860c407b9e96dc939932f952aa2a6c4951a64f79a5f34c7
4
- data.tar.gz: 65854ae4920a4ff27bd67bcf7cf34d8222be36398639bd82b013fa73b94700a5
3
+ metadata.gz: 56ba569dbb60a5e6e480c86cf2b5e103c6bd42d695e57d16bfc9b94a9b819526
4
+ data.tar.gz: 4cd694c79226b6a7946caf4adac29ea10326f7944f89facb7b578c2ea1bc9034
5
5
  SHA512:
6
- metadata.gz: c36870984ff3f36eb946b5bbb5273bc4f3633332651bd180196d1b172c7782248583285a0e3c9ae499205d45b6a45bb6e19910b7fb6ca8a455b0b2af8934c457
7
- data.tar.gz: 456ef6a6e5329d490d2195c58d3c8c007e23f6326f4535d362b04898451009926a5226baa384342b8dd889f6e00c17b8ef595d85e7a0e0fd5fa4a06c69324642
6
+ metadata.gz: 37236f4de0ef6c6984c450cf03c0c6a79f51564911d3cf8a35408158d57153bfbda6c966cb0f5aa678e96c4482f89142d189f1d5054efd5b4c10227a01aa75d3
7
+ data.tar.gz: 0f3a77248cd9c7ec6c925693ee125b8a34b86fd1def5d3f7e4bf45265d4a7ae46bf36b628444ce669e8da164116d57c88af6fb953e803520f6209bb3f066b954
data/Gemfile CHANGED
@@ -28,7 +28,7 @@ gem 'minitest', '5.21.2', require: false
28
28
  gem 'rake', '13.1.0', require: false
29
29
  gem 'rdoc', '6.6.1', require: false
30
30
  gem 'rspec-rails', '6.1.0', require: false
31
- gem 'rubocop', '1.60.1', require: false
31
+ gem 'rubocop', '1.60.2', require: false
32
32
  gem 'rubocop-rspec', '2.26.1', require: false
33
33
  gem 'simplecov', '0.22.0', require: false
34
34
  gem 'webmock', '3.19.1', require: false
data/lib/glogin/cookie.rb CHANGED
@@ -78,10 +78,12 @@ module GLogin
78
78
 
79
79
  # Open
80
80
  class Open
81
+ attr_reader :id, :login, :avatar_url, :bearer
82
+
81
83
  # Here comes the JSON you receive from Auth.user().
82
84
  #
83
85
  # The JSON is a Hash where every key is a string. When the class is instantiated,
84
- # its methods +id+, +login+, and +avatar_url+ may be used to retrieve
86
+ # its methods `id`, `login`, and `avatar_url` may be used to retrieve
85
87
  # the data inside the JSON, but this is not what this class is mainly about.
86
88
  #
87
89
  # The method +to_s+ returns an encrypted cookie string, that may be
@@ -89,39 +91,24 @@ module GLogin
89
91
  def initialize(json, secret, context = '')
90
92
  raise 'JSON can\'t be nil' if json.nil?
91
93
  raise 'JSON must contain "id" key' if json['id'].nil?
92
- raise 'JSON must contain "login" key' if json['login'].nil?
93
- raise 'JSON must contain "avatar_url" key' if json['avatar_url'].nil?
94
- raise 'JSON must contain "bearer" key' if json['bearer'].nil?
95
- @json = json
94
+ @id = json['id']
95
+ @login = json['login'] || ''
96
+ @avatar_url = json['avatar_url'] || ''
97
+ @bearer = json['bearer'] || ''
96
98
  raise 'Secret can\'t be nil' if secret.nil?
97
99
  @secret = secret
98
100
  raise 'Context can\'t be nil' if context.nil?
99
101
  @context = context.to_s
100
102
  end
101
103
 
102
- # GitHub id of the authenticated user
103
- def id
104
- @json['id']
105
- end
106
-
107
- # GitHub login name of the authenticated user
108
- def login
109
- @json['login']
110
- end
111
-
112
- # GitHub avatar URL of the authenticated user
113
- def avatar_url
114
- @json['avatar_url']
115
- end
116
-
117
104
  # Returns the text you should drop back to the user as a cookie.
118
105
  def to_s
119
106
  Codec.new(@secret).encrypt(
120
107
  [
121
- id,
122
- login,
123
- avatar_url,
124
- @json['bearer'],
108
+ @id,
109
+ @login,
110
+ @avatar_url,
111
+ @bearer,
125
112
  @context
126
113
  ].join(GLogin::SPLIT)
127
114
  )
@@ -26,5 +26,5 @@
26
26
  # Copyright:: Copyright (c) 2017-2024 Yegor Bugayenko
27
27
  # License:: MIT
28
28
  module GLogin
29
- VERSION = '0.14.1'
29
+ VERSION = '0.14.2'
30
30
  end
@@ -94,7 +94,7 @@ class TestCookie < Minitest::Test
94
94
  assert_raises GLogin::Codec::DecodingError do
95
95
  GLogin::Cookie::Closed.new(
96
96
  GLogin::Cookie::Open.new(
97
- JSON.parse('{"login":"x","avatar_url":"x","id":"999","bearer":""}'),
97
+ JSON.parse('{"login":"x","avatar_url":"x","id":"","bearer":""}'),
98
98
  secret,
99
99
  'context-1'
100
100
  ).to_s,
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: glogin
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.14.1
4
+ version: 0.14.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yegor Bugayenko
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-01-22 00:00:00.000000000 Z
11
+ date: 2024-01-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: base58