arena 0.2.0 → 0.2.1
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 +4 -4
- data/.rubocop_todo.yml +15 -1
- data/lib/arena/client.rb +6 -5
- data/lib/arena/version.rb +1 -1
- data/test/cassettes/Arena/channel/handles_a_400_error_that_returns_nil.yml +36 -0
- data/test/lib/arena/api_test.rb +10 -2
- metadata +7 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: eb1d546f2e81fba83aacb5950d9fe25fe4fc9907d7cf1224ee3ce82bbab0d33b
|
|
4
|
+
data.tar.gz: 4202eac01621ce84c36a681e0d266dce58cf9bb209e519f24f2b18399cf0fe84
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 0f80bcf522f69df14235daa04aafb0d04f9f71387ba9e1791ae61c5970742fa33e23575a1e181c0144482f2c64cf3006bc4dac493d54e92d5c6692d987670ee8
|
|
7
|
+
data.tar.gz: 00c436b76d931c6e5f01b47aa55206660afa94ccc47279371e6e10b61a48add35d6de6b9ed9eec450cf1c22111c5055dc26d3bcf340c4722e1c3fa9261b41653
|
data/.rubocop_todo.yml
CHANGED
|
@@ -1,11 +1,17 @@
|
|
|
1
1
|
# This configuration was generated by
|
|
2
2
|
# `rubocop --auto-gen-config`
|
|
3
|
-
# on 2025-10-
|
|
3
|
+
# on 2025-10-13 18:03:06 UTC using RuboCop version 1.81.1.
|
|
4
4
|
# The point is for the user to remove these configuration records
|
|
5
5
|
# one by one as the offenses are removed from the code base.
|
|
6
6
|
# Note that changes in the inspected code, or installation of new
|
|
7
7
|
# versions of RuboCop, may require this file to be generated again.
|
|
8
8
|
|
|
9
|
+
# Offense count: 1
|
|
10
|
+
# Configuration parameters: AllowComments, AllowNil.
|
|
11
|
+
Lint/SuppressedException:
|
|
12
|
+
Exclude:
|
|
13
|
+
- 'lib/arena/client.rb'
|
|
14
|
+
|
|
9
15
|
# Offense count: 2
|
|
10
16
|
# Configuration parameters: Mode, AllowedMethods, AllowedPatterns, AllowBangMethods, WaywardPredicates.
|
|
11
17
|
# AllowedMethods: call
|
|
@@ -47,3 +53,11 @@ Style/MissingRespondToMissing:
|
|
|
47
53
|
- 'lib/arena/cache/adaptor/null.rb'
|
|
48
54
|
- 'lib/arena/cache/adaptor/padrino.rb'
|
|
49
55
|
- 'lib/arena/cache/adaptor/rails.rb'
|
|
56
|
+
|
|
57
|
+
# Offense count: 1
|
|
58
|
+
# This cop supports unsafe autocorrection (--autocorrect-all).
|
|
59
|
+
# Configuration parameters: ConvertCodeThatCanStartToReturnNil, AllowedMethods, MaxChainLength.
|
|
60
|
+
# AllowedMethods: present?, blank?, presence, try, try!
|
|
61
|
+
Style/SafeNavigation:
|
|
62
|
+
Exclude:
|
|
63
|
+
- 'lib/arena/client.rb'
|
data/lib/arena/client.rb
CHANGED
|
@@ -44,10 +44,14 @@ module Arena
|
|
|
44
44
|
response.code != 200
|
|
45
45
|
end
|
|
46
46
|
|
|
47
|
-
def
|
|
47
|
+
def error_message_from_json(response)
|
|
48
48
|
"#{response['code']}: #{response['message']} - #{response['description']}"
|
|
49
49
|
end
|
|
50
50
|
|
|
51
|
+
def error_message(response)
|
|
52
|
+
"#{response.code}: #{response.body && response.body.length.positive? ? response.body : 'Unexpected Error'}"
|
|
53
|
+
end
|
|
54
|
+
|
|
51
55
|
def request(method, path, options)
|
|
52
56
|
response = self.class.send(method, "https://#{@base_domain}/#{@api_version}#{path}", options)
|
|
53
57
|
|
|
@@ -55,13 +59,10 @@ module Arena
|
|
|
55
59
|
begin
|
|
56
60
|
JSON.parse(response.body)
|
|
57
61
|
rescue JSON::ParserError, TypeError
|
|
58
|
-
nil
|
|
59
62
|
end
|
|
60
|
-
else
|
|
61
|
-
response.body
|
|
62
63
|
end
|
|
63
64
|
|
|
64
|
-
raise Arena::Error,
|
|
65
|
+
raise Arena::Error, parsed ? error_message_from_json(parsed) : error_message(response) if error?(response)
|
|
65
66
|
|
|
66
67
|
parsed
|
|
67
68
|
end
|
data/lib/arena/version.rb
CHANGED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
---
|
|
2
|
+
http_interactions:
|
|
3
|
+
- request:
|
|
4
|
+
method: get
|
|
5
|
+
uri: https://api.are.na/v2/channels/delightfully-absurd
|
|
6
|
+
body:
|
|
7
|
+
encoding: US-ASCII
|
|
8
|
+
string: ''
|
|
9
|
+
headers:
|
|
10
|
+
Accept-Encoding:
|
|
11
|
+
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
|
12
|
+
Accept:
|
|
13
|
+
- "*/*"
|
|
14
|
+
User-Agent:
|
|
15
|
+
- Ruby
|
|
16
|
+
response:
|
|
17
|
+
status:
|
|
18
|
+
code: 403
|
|
19
|
+
message: OK
|
|
20
|
+
headers:
|
|
21
|
+
Date:
|
|
22
|
+
- Sat, 11 Oct 2025 20:29:37 GMT
|
|
23
|
+
Content-Type:
|
|
24
|
+
- text/plain; charset=utf-8
|
|
25
|
+
Transfer-Encoding:
|
|
26
|
+
- chunked
|
|
27
|
+
Cache-Control:
|
|
28
|
+
- max-age=604800, private
|
|
29
|
+
Server:
|
|
30
|
+
- cloudflare
|
|
31
|
+
Vary:
|
|
32
|
+
- Origin
|
|
33
|
+
Via:
|
|
34
|
+
- 2.0 heroku-router
|
|
35
|
+
recorded_at: Sat, 11 Oct 2025 20:29:37 GMT
|
|
36
|
+
recorded_with: VCR 6.3.1
|
data/test/lib/arena/api_test.rb
CHANGED
|
@@ -9,16 +9,24 @@ describe Arena do
|
|
|
9
9
|
end
|
|
10
10
|
|
|
11
11
|
it 'handles a 403 error' do
|
|
12
|
-
assert_raises
|
|
12
|
+
error = assert_raises Arena::Error do
|
|
13
13
|
Arena.channel('delightfully-absurd')
|
|
14
14
|
end
|
|
15
|
+
assert_equal '403: Forbidden', error.message
|
|
15
16
|
end
|
|
16
17
|
|
|
17
18
|
it 'handles a 400 error that returns JSON' do
|
|
18
|
-
error = assert_raises
|
|
19
|
+
error = assert_raises Arena::Error do
|
|
19
20
|
Arena.channel('delightfully-absurd')
|
|
20
21
|
end
|
|
21
22
|
assert_equal '400: Internal Server Error - Something went wrong.', error.message
|
|
22
23
|
end
|
|
24
|
+
|
|
25
|
+
it 'handles a 400 error that returns nil' do
|
|
26
|
+
error = assert_raises Arena::Error do
|
|
27
|
+
Arena.channel('delightfully-absurd')
|
|
28
|
+
end
|
|
29
|
+
assert_equal '403: Unexpected Error', error.message
|
|
30
|
+
end
|
|
23
31
|
end
|
|
24
32
|
end
|
metadata
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: arena
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.2.
|
|
4
|
+
version: 0.2.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- dzuc
|
|
8
|
+
autorequire:
|
|
8
9
|
bindir: bin
|
|
9
10
|
cert_chain: []
|
|
10
|
-
date:
|
|
11
|
+
date: 2025-10-13 00:00:00.000000000 Z
|
|
11
12
|
dependencies:
|
|
12
13
|
- !ruby/object:Gem::Dependency
|
|
13
14
|
name: httparty
|
|
@@ -94,6 +95,7 @@ files:
|
|
|
94
95
|
- lib/arena/user_feed.rb
|
|
95
96
|
- lib/arena/version.rb
|
|
96
97
|
- test/cassettes/Arena/channel/handles_a_400_error_that_returns_JSON.yml
|
|
98
|
+
- test/cassettes/Arena/channel/handles_a_400_error_that_returns_nil.yml
|
|
97
99
|
- test/cassettes/Arena/channel/handles_a_403_error.yml
|
|
98
100
|
- test/cassettes/Arena/channel/returns_a_channel.yml
|
|
99
101
|
- test/lib/arena/api_test.rb
|
|
@@ -103,6 +105,7 @@ homepage: https://www.are.na/
|
|
|
103
105
|
licenses: []
|
|
104
106
|
metadata:
|
|
105
107
|
rubygems_mfa_required: 'true'
|
|
108
|
+
post_install_message:
|
|
106
109
|
rdoc_options: []
|
|
107
110
|
require_paths:
|
|
108
111
|
- lib
|
|
@@ -117,7 +120,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
117
120
|
- !ruby/object:Gem::Version
|
|
118
121
|
version: '0'
|
|
119
122
|
requirements: []
|
|
120
|
-
rubygems_version: 3.
|
|
123
|
+
rubygems_version: 3.5.16
|
|
124
|
+
signing_key:
|
|
121
125
|
specification_version: 4
|
|
122
126
|
summary: Wrapper for Arena's API
|
|
123
127
|
test_files: []
|