harpy 1.0.0 → 2.0.0.preview1
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 +5 -5
- data/.forgejo/workflows/test.yml +33 -0
- data/.github/workflows/test.yml +20 -0
- data/.gitignore +2 -1
- data/README.md +8 -9
- data/harpy.gemspec +8 -5
- data/lib/harpy/client.rb +51 -13
- data/lib/harpy/entry_point.rb +3 -3
- data/lib/harpy/gem_version.rb +14 -0
- data/lib/harpy/resource.rb +113 -96
- data/lib/harpy/version.rb +9 -0
- data/lib/harpy.rb +3 -2
- data/spec/harpy/client_spec.rb +85 -36
- data/spec/harpy/entry_point_spec.rb +19 -19
- data/spec/harpy/resource_spec.rb +254 -255
- data/spec/harpy_spec.rb +20 -20
- data/spec/spec_helper.rb +31 -2
- metadata +63 -51
- data/.travis.yml +0 -9
- data/Gemfile.lock +0 -56
data/spec/harpy_spec.rb
CHANGED
|
@@ -4,94 +4,94 @@ describe Harpy do
|
|
|
4
4
|
after{ Harpy.reset }
|
|
5
5
|
|
|
6
6
|
it "defaults to Harpy::Client" do
|
|
7
|
-
Harpy.client.
|
|
7
|
+
expect(Harpy.client).to be_kind_of Harpy::Client
|
|
8
8
|
end
|
|
9
9
|
|
|
10
10
|
it "does allow using another client" do
|
|
11
11
|
custom_client = double
|
|
12
12
|
Harpy.client = custom_client
|
|
13
|
-
Harpy.client.
|
|
13
|
+
expect(Harpy.client).to be custom_client
|
|
14
14
|
end
|
|
15
15
|
|
|
16
16
|
it "has no default entry_point_url" do
|
|
17
|
-
Harpy.entry_point_url.
|
|
17
|
+
expect(Harpy.entry_point_url).to be_nil
|
|
18
18
|
end
|
|
19
19
|
|
|
20
20
|
it "does allow setting an entry_point_url" do
|
|
21
21
|
Harpy.entry_point_url = "http://localhost"
|
|
22
|
-
Harpy.entry_point_url.
|
|
22
|
+
expect(Harpy.entry_point_url).to eq("http://localhost")
|
|
23
23
|
end
|
|
24
24
|
|
|
25
25
|
it "raises Harpy::EntryPointRequired when trying to access entry_point and none has been created yet" do
|
|
26
|
-
|
|
26
|
+
expect{ Harpy.entry_point }.to raise_error Harpy::EntryPointRequired
|
|
27
27
|
end
|
|
28
28
|
|
|
29
29
|
it "returns a valid Harpy::EntryPoint object if entry_point_url has been set" do
|
|
30
30
|
Harpy.entry_point_url = "http://localhost"
|
|
31
|
-
Harpy.entry_point.
|
|
32
|
-
Harpy.entry_point.url.
|
|
31
|
+
expect(Harpy.entry_point).to be_kind_of Harpy::EntryPoint
|
|
32
|
+
expect(Harpy.entry_point.url).to eq("http://localhost")
|
|
33
33
|
end
|
|
34
34
|
|
|
35
35
|
it "does allow setting entry_point manually" do
|
|
36
36
|
Harpy.entry_point = (entry_point = double)
|
|
37
|
-
Harpy.entry_point.
|
|
38
|
-
entry_point.
|
|
39
|
-
Harpy.entry_point_url.
|
|
37
|
+
expect(Harpy.entry_point).to be entry_point
|
|
38
|
+
expect(entry_point).to receive(:url).and_return "http://localhost"
|
|
39
|
+
expect(Harpy.entry_point_url).to eq("http://localhost")
|
|
40
40
|
end
|
|
41
41
|
|
|
42
42
|
it "Harpy.reset clears both client and entry_point" do
|
|
43
43
|
Harpy.entry_point_url = "http://localhost"
|
|
44
44
|
Harpy.client = (custom_client = double)
|
|
45
45
|
Harpy.reset
|
|
46
|
-
Harpy.entry_point_url.
|
|
47
|
-
Harpy.client.
|
|
46
|
+
expect(Harpy.entry_point_url).to be_nil
|
|
47
|
+
expect(Harpy.client).not_to be custom_client
|
|
48
48
|
end
|
|
49
49
|
end
|
|
50
50
|
|
|
51
51
|
describe Harpy::Exception do
|
|
52
52
|
it "is an ::Exception" do
|
|
53
|
-
Harpy::Exception.ancestors.
|
|
53
|
+
expect(Harpy::Exception.ancestors).to include ::Exception
|
|
54
54
|
end
|
|
55
55
|
end
|
|
56
56
|
|
|
57
57
|
describe Harpy::EntryPointRequired do
|
|
58
58
|
it "is an Harpy::Exception" do
|
|
59
|
-
Harpy::EntryPointRequired.ancestors.
|
|
59
|
+
expect(Harpy::EntryPointRequired.ancestors).to include Harpy::Exception
|
|
60
60
|
end
|
|
61
61
|
end
|
|
62
62
|
|
|
63
63
|
describe Harpy::UrlRequired do
|
|
64
64
|
it "is an Harpy::Exception" do
|
|
65
|
-
Harpy::UrlRequired.ancestors.
|
|
65
|
+
expect(Harpy::UrlRequired.ancestors).to include Harpy::Exception
|
|
66
66
|
end
|
|
67
67
|
end
|
|
68
68
|
|
|
69
69
|
describe Harpy::BodyToBig do
|
|
70
70
|
it "is an Harpy::Exception" do
|
|
71
|
-
Harpy::BodyToBig.ancestors.
|
|
71
|
+
expect(Harpy::BodyToBig.ancestors).to include Harpy::Exception
|
|
72
72
|
end
|
|
73
73
|
end
|
|
74
74
|
|
|
75
75
|
describe Harpy::ClientTimeout do
|
|
76
76
|
it "is an Harpy::Exception" do
|
|
77
|
-
Harpy::ClientTimeout.ancestors.
|
|
77
|
+
expect(Harpy::ClientTimeout.ancestors).to include Harpy::Exception
|
|
78
78
|
end
|
|
79
79
|
end
|
|
80
80
|
|
|
81
81
|
describe Harpy::ClientError do
|
|
82
82
|
it "is an Harpy::Exception" do
|
|
83
|
-
Harpy::ClientError.ancestors.
|
|
83
|
+
expect(Harpy::ClientError.ancestors).to include Harpy::Exception
|
|
84
84
|
end
|
|
85
85
|
end
|
|
86
86
|
|
|
87
87
|
describe Harpy::Unauthorized do
|
|
88
88
|
it "is an Harpy::Exception" do
|
|
89
|
-
Harpy::Unauthorized.ancestors.
|
|
89
|
+
expect(Harpy::Unauthorized.ancestors).to include Harpy::Exception
|
|
90
90
|
end
|
|
91
91
|
end
|
|
92
92
|
|
|
93
93
|
describe Harpy::InvalidResponseCode do
|
|
94
94
|
it "is an Harpy::Exception" do
|
|
95
|
-
Harpy::InvalidResponseCode.ancestors.
|
|
95
|
+
expect(Harpy::InvalidResponseCode.ancestors).to include Harpy::Exception
|
|
96
96
|
end
|
|
97
97
|
end
|
data/spec/spec_helper.rb
CHANGED
|
@@ -1,10 +1,39 @@
|
|
|
1
|
+
require "webmock/rspec"
|
|
2
|
+
require "httpx"
|
|
1
3
|
require "harpy"
|
|
2
|
-
|
|
4
|
+
|
|
5
|
+
WebMock.disable_net_connect!
|
|
3
6
|
|
|
4
7
|
Dir[File.expand_path("../support/**/*.rb", __FILE__)].each{|f| require f}
|
|
5
8
|
|
|
9
|
+
module HTTPXSpecHelpers
|
|
10
|
+
def httpx_response(options)
|
|
11
|
+
session = HTTPX::Session.new
|
|
12
|
+
request = session.build_request("GET", "http://localhost")
|
|
13
|
+
headers = options[:headers] || {}
|
|
14
|
+
if headers.is_a?(String)
|
|
15
|
+
headers = headers.lines.each_with_object({}) do |line, parsed|
|
|
16
|
+
name, value = line.split(":", 2)
|
|
17
|
+
parsed[name.strip] = value.strip if value
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
response = HTTPX::Response.new(request, options[:code], "1.1", headers)
|
|
22
|
+
response << options[:body] if options[:body]
|
|
23
|
+
response.finish!
|
|
24
|
+
response
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def httpx_error_response(error)
|
|
28
|
+
session = HTTPX::Session.new
|
|
29
|
+
request = session.build_request("GET", "http://localhost")
|
|
30
|
+
HTTPX::ErrorResponse.new(request, error)
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
|
|
6
34
|
RSpec.configure do |config|
|
|
35
|
+
config.include HTTPXSpecHelpers
|
|
7
36
|
config.after(:each) do
|
|
8
|
-
|
|
37
|
+
WebMock.reset!
|
|
9
38
|
end
|
|
10
39
|
end
|
metadata
CHANGED
|
@@ -1,100 +1,113 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: harpy
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version:
|
|
4
|
+
version: 2.0.0.preview1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Joseph HALTER
|
|
8
8
|
- Jonathan TRON
|
|
9
|
-
autorequire:
|
|
10
9
|
bindir: bin
|
|
11
10
|
cert_chain: []
|
|
12
|
-
date:
|
|
11
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
13
12
|
dependencies:
|
|
14
13
|
- !ruby/object:Gem::Dependency
|
|
15
|
-
name:
|
|
14
|
+
name: httpx
|
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
|
16
|
+
requirements:
|
|
17
|
+
- - ">="
|
|
18
|
+
- !ruby/object:Gem::Version
|
|
19
|
+
version: '1.0'
|
|
20
|
+
type: :runtime
|
|
21
|
+
prerelease: false
|
|
16
22
|
version_requirements: !ruby/object:Gem::Requirement
|
|
17
23
|
requirements:
|
|
18
|
-
- -
|
|
24
|
+
- - ">="
|
|
19
25
|
- !ruby/object:Gem::Version
|
|
20
|
-
version: 0
|
|
26
|
+
version: '1.0'
|
|
27
|
+
- !ruby/object:Gem::Dependency
|
|
28
|
+
name: activesupport
|
|
21
29
|
requirement: !ruby/object:Gem::Requirement
|
|
22
30
|
requirements:
|
|
23
|
-
- -
|
|
31
|
+
- - ">="
|
|
24
32
|
- !ruby/object:Gem::Version
|
|
25
|
-
version:
|
|
26
|
-
prerelease: false
|
|
33
|
+
version: 5.2.0
|
|
27
34
|
type: :runtime
|
|
28
|
-
|
|
29
|
-
name: activesupport
|
|
35
|
+
prerelease: false
|
|
30
36
|
version_requirements: !ruby/object:Gem::Requirement
|
|
31
37
|
requirements:
|
|
32
|
-
- -
|
|
38
|
+
- - ">="
|
|
33
39
|
- !ruby/object:Gem::Version
|
|
34
|
-
version:
|
|
40
|
+
version: 5.2.0
|
|
41
|
+
- !ruby/object:Gem::Dependency
|
|
42
|
+
name: activemodel
|
|
35
43
|
requirement: !ruby/object:Gem::Requirement
|
|
36
44
|
requirements:
|
|
37
|
-
- -
|
|
45
|
+
- - ">="
|
|
38
46
|
- !ruby/object:Gem::Version
|
|
39
|
-
version:
|
|
40
|
-
prerelease: false
|
|
47
|
+
version: 5.2.0
|
|
41
48
|
type: :runtime
|
|
42
|
-
|
|
43
|
-
name: activemodel
|
|
49
|
+
prerelease: false
|
|
44
50
|
version_requirements: !ruby/object:Gem::Requirement
|
|
45
51
|
requirements:
|
|
46
|
-
- -
|
|
52
|
+
- - ">="
|
|
47
53
|
- !ruby/object:Gem::Version
|
|
48
|
-
version:
|
|
54
|
+
version: 5.2.0
|
|
55
|
+
- !ruby/object:Gem::Dependency
|
|
56
|
+
name: hash-deep-merge
|
|
49
57
|
requirement: !ruby/object:Gem::Requirement
|
|
50
58
|
requirements:
|
|
51
|
-
- -
|
|
59
|
+
- - ">="
|
|
52
60
|
- !ruby/object:Gem::Version
|
|
53
|
-
version:
|
|
54
|
-
prerelease: false
|
|
61
|
+
version: 0.1.1
|
|
55
62
|
type: :runtime
|
|
56
|
-
|
|
57
|
-
name: hash-deep-merge
|
|
63
|
+
prerelease: false
|
|
58
64
|
version_requirements: !ruby/object:Gem::Requirement
|
|
59
65
|
requirements:
|
|
60
|
-
- -
|
|
66
|
+
- - ">="
|
|
61
67
|
- !ruby/object:Gem::Version
|
|
62
68
|
version: 0.1.1
|
|
69
|
+
- !ruby/object:Gem::Dependency
|
|
70
|
+
name: rake
|
|
63
71
|
requirement: !ruby/object:Gem::Requirement
|
|
64
72
|
requirements:
|
|
65
|
-
- -
|
|
73
|
+
- - ">="
|
|
66
74
|
- !ruby/object:Gem::Version
|
|
67
|
-
version: 0.
|
|
75
|
+
version: 0.8.7
|
|
76
|
+
type: :development
|
|
68
77
|
prerelease: false
|
|
69
|
-
type: :runtime
|
|
70
|
-
- !ruby/object:Gem::Dependency
|
|
71
|
-
name: rake
|
|
72
78
|
version_requirements: !ruby/object:Gem::Requirement
|
|
73
79
|
requirements:
|
|
74
|
-
- -
|
|
80
|
+
- - ">="
|
|
75
81
|
- !ruby/object:Gem::Version
|
|
76
82
|
version: 0.8.7
|
|
83
|
+
- !ruby/object:Gem::Dependency
|
|
84
|
+
name: rspec
|
|
77
85
|
requirement: !ruby/object:Gem::Requirement
|
|
78
86
|
requirements:
|
|
79
|
-
- -
|
|
87
|
+
- - ">="
|
|
80
88
|
- !ruby/object:Gem::Version
|
|
81
|
-
version: 0
|
|
82
|
-
prerelease: false
|
|
89
|
+
version: '0'
|
|
83
90
|
type: :development
|
|
84
|
-
|
|
85
|
-
name: rspec
|
|
91
|
+
prerelease: false
|
|
86
92
|
version_requirements: !ruby/object:Gem::Requirement
|
|
87
93
|
requirements:
|
|
88
|
-
- -
|
|
94
|
+
- - ">="
|
|
89
95
|
- !ruby/object:Gem::Version
|
|
90
96
|
version: '0'
|
|
97
|
+
- !ruby/object:Gem::Dependency
|
|
98
|
+
name: webmock
|
|
91
99
|
requirement: !ruby/object:Gem::Requirement
|
|
92
100
|
requirements:
|
|
93
|
-
- -
|
|
101
|
+
- - ">="
|
|
94
102
|
- !ruby/object:Gem::Version
|
|
95
103
|
version: '0'
|
|
96
|
-
prerelease: false
|
|
97
104
|
type: :development
|
|
105
|
+
prerelease: false
|
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
107
|
+
requirements:
|
|
108
|
+
- - ">="
|
|
109
|
+
- !ruby/object:Gem::Version
|
|
110
|
+
version: '0'
|
|
98
111
|
description: Client for REST API with HATEOAS
|
|
99
112
|
email:
|
|
100
113
|
- joseph.halter@thetalentbox.com
|
|
@@ -103,11 +116,11 @@ executables: []
|
|
|
103
116
|
extensions: []
|
|
104
117
|
extra_rdoc_files: []
|
|
105
118
|
files:
|
|
106
|
-
- .
|
|
107
|
-
- .
|
|
108
|
-
- .
|
|
119
|
+
- ".forgejo/workflows/test.yml"
|
|
120
|
+
- ".github/workflows/test.yml"
|
|
121
|
+
- ".gitignore"
|
|
122
|
+
- ".rspec"
|
|
109
123
|
- Gemfile
|
|
110
|
-
- Gemfile.lock
|
|
111
124
|
- LICENSE
|
|
112
125
|
- README.md
|
|
113
126
|
- Rakefile
|
|
@@ -116,7 +129,9 @@ files:
|
|
|
116
129
|
- lib/harpy/client.rb
|
|
117
130
|
- lib/harpy/collection.rb
|
|
118
131
|
- lib/harpy/entry_point.rb
|
|
132
|
+
- lib/harpy/gem_version.rb
|
|
119
133
|
- lib/harpy/resource.rb
|
|
134
|
+
- lib/harpy/version.rb
|
|
120
135
|
- spec/harpy/client_spec.rb
|
|
121
136
|
- spec/harpy/entry_point_spec.rb
|
|
122
137
|
- spec/harpy/resource_spec.rb
|
|
@@ -126,24 +141,21 @@ homepage: https://github.com/TalentBox/harpy
|
|
|
126
141
|
licenses:
|
|
127
142
|
- MIT
|
|
128
143
|
metadata: {}
|
|
129
|
-
post_install_message:
|
|
130
144
|
rdoc_options: []
|
|
131
145
|
require_paths:
|
|
132
146
|
- lib
|
|
133
147
|
required_ruby_version: !ruby/object:Gem::Requirement
|
|
134
148
|
requirements:
|
|
135
|
-
- -
|
|
149
|
+
- - ">="
|
|
136
150
|
- !ruby/object:Gem::Version
|
|
137
|
-
version: '
|
|
151
|
+
version: '3.4'
|
|
138
152
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
139
153
|
requirements:
|
|
140
|
-
- -
|
|
154
|
+
- - ">="
|
|
141
155
|
- !ruby/object:Gem::Version
|
|
142
156
|
version: '0'
|
|
143
157
|
requirements: []
|
|
144
|
-
|
|
145
|
-
rubygems_version: 2.1.9
|
|
146
|
-
signing_key:
|
|
158
|
+
rubygems_version: 4.0.23
|
|
147
159
|
specification_version: 4
|
|
148
160
|
summary: Client for REST API
|
|
149
161
|
test_files:
|
data/.travis.yml
DELETED
data/Gemfile.lock
DELETED
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
PATH
|
|
2
|
-
remote: .
|
|
3
|
-
specs:
|
|
4
|
-
harpy (1.0.0)
|
|
5
|
-
activemodel (>= 3.1.0)
|
|
6
|
-
activesupport (>= 3.1.0)
|
|
7
|
-
hash-deep-merge (~> 0.1.1)
|
|
8
|
-
typhoeus (~> 0.6.5)
|
|
9
|
-
|
|
10
|
-
GEM
|
|
11
|
-
remote: http://rubygems.org/
|
|
12
|
-
specs:
|
|
13
|
-
activemodel (4.0.2)
|
|
14
|
-
activesupport (= 4.0.2)
|
|
15
|
-
builder (~> 3.1.0)
|
|
16
|
-
activesupport (4.0.2)
|
|
17
|
-
i18n (~> 0.6, >= 0.6.4)
|
|
18
|
-
minitest (~> 4.2)
|
|
19
|
-
multi_json (~> 1.3)
|
|
20
|
-
thread_safe (~> 0.1)
|
|
21
|
-
tzinfo (~> 0.3.37)
|
|
22
|
-
atomic (1.1.14-java)
|
|
23
|
-
builder (3.1.4)
|
|
24
|
-
diff-lcs (1.2.4)
|
|
25
|
-
ethon (0.6.2)
|
|
26
|
-
ffi (>= 1.3.0)
|
|
27
|
-
mime-types (~> 1.18)
|
|
28
|
-
ffi (1.9.3-java)
|
|
29
|
-
hash-deep-merge (0.1.1)
|
|
30
|
-
i18n (0.6.9)
|
|
31
|
-
mime-types (1.25.1)
|
|
32
|
-
minitest (4.7.5)
|
|
33
|
-
multi_json (1.8.4)
|
|
34
|
-
rake (10.1.0)
|
|
35
|
-
rspec (2.14.1)
|
|
36
|
-
rspec-core (~> 2.14.0)
|
|
37
|
-
rspec-expectations (~> 2.14.0)
|
|
38
|
-
rspec-mocks (~> 2.14.0)
|
|
39
|
-
rspec-core (2.14.5)
|
|
40
|
-
rspec-expectations (2.14.2)
|
|
41
|
-
diff-lcs (>= 1.1.3, < 2.0)
|
|
42
|
-
rspec-mocks (2.14.3)
|
|
43
|
-
thread_safe (0.1.3-java)
|
|
44
|
-
atomic
|
|
45
|
-
typhoeus (0.6.7)
|
|
46
|
-
ethon (~> 0.6.2)
|
|
47
|
-
tzinfo (0.3.38)
|
|
48
|
-
|
|
49
|
-
PLATFORMS
|
|
50
|
-
java
|
|
51
|
-
ruby
|
|
52
|
-
|
|
53
|
-
DEPENDENCIES
|
|
54
|
-
harpy!
|
|
55
|
-
rake (>= 0.8.7)
|
|
56
|
-
rspec
|