metal_archives 0.8.0 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +59 -7
- data/.rspec +1 -0
- data/.rubocop.yml +14 -0
- data/.travis.yml +11 -0
- data/Gemfile +2 -0
- data/{LICENSE → LICENSE.md} +0 -0
- data/README.md +77 -9
- data/Rakefile +5 -3
- data/lib/metal_archives.rb +8 -0
- data/lib/metal_archives/configuration.rb +28 -7
- data/lib/metal_archives/error.rb +37 -30
- data/lib/metal_archives/http_client.rb +21 -42
- data/lib/metal_archives/middleware/headers.rb +38 -0
- data/lib/metal_archives/middleware/rewrite_endpoint.rb +38 -0
- data/lib/metal_archives/models/artist.rb +51 -65
- data/lib/metal_archives/models/band.rb +41 -39
- data/lib/metal_archives/models/base_model.rb +88 -59
- data/lib/metal_archives/models/label.rb +7 -6
- data/lib/metal_archives/parsers/artist.rb +110 -99
- data/lib/metal_archives/parsers/band.rb +168 -156
- data/lib/metal_archives/parsers/label.rb +54 -52
- data/lib/metal_archives/parsers/parser.rb +73 -71
- data/lib/metal_archives/utils/collection.rb +7 -1
- data/lib/metal_archives/utils/lru_cache.rb +11 -4
- data/lib/metal_archives/utils/nil_date.rb +54 -0
- data/lib/metal_archives/utils/range.rb +16 -8
- data/lib/metal_archives/version.rb +3 -1
- data/metal_archives.gemspec +21 -11
- data/spec/configuration_spec.rb +101 -0
- data/spec/factories/artist_factory.rb +37 -0
- data/spec/factories/band_factory.rb +60 -0
- data/spec/factories/nil_date_factory.rb +9 -0
- data/spec/factories/range_factory.rb +8 -0
- data/spec/models/artist_spec.rb +142 -0
- data/spec/models/band_spec.rb +179 -0
- data/spec/models/base_model_spec.rb +217 -0
- data/spec/parser_spec.rb +19 -0
- data/spec/spec_helper.rb +111 -0
- data/spec/support/factory_girl.rb +5 -0
- data/spec/support/metal_archives.rb +26 -0
- data/spec/utils/collection_spec.rb +72 -0
- data/spec/utils/lru_cache_spec.rb +53 -0
- data/spec/utils/nil_date_spec.rb +98 -0
- data/spec/utils/range_spec.rb +62 -0
- metadata +142 -57
- data/test/base_model_test.rb +0 -111
- data/test/configuration_test.rb +0 -57
- data/test/parser_test.rb +0 -37
- data/test/property/artist_property_test.rb +0 -43
- data/test/property/band_property_test.rb +0 -94
- data/test/query/artist_query_test.rb +0 -109
- data/test/query/band_query_test.rb +0 -152
- data/test/test_helper.rb +0 -25
- data/test/utils/collection_test.rb +0 -51
- data/test/utils/lru_cache_test.rb +0 -22
- data/test/utils/range_test.rb +0 -42
metadata
CHANGED
@@ -1,139 +1,197 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: metal_archives
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Florian Dejonckheere
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-06-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: byebug
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
19
|
+
version: '0'
|
20
20
|
type: :development
|
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: '
|
26
|
+
version: '0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rake
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - "
|
31
|
+
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
33
|
+
version: '0'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- - "
|
38
|
+
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '
|
40
|
+
version: '0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: rdoc
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- - "
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rspec
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: factory_girl
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
46
74
|
- !ruby/object:Gem::Version
|
47
|
-
version: '
|
75
|
+
version: '0'
|
48
76
|
type: :development
|
49
77
|
prerelease: false
|
50
78
|
version_requirements: !ruby/object:Gem::Requirement
|
51
79
|
requirements:
|
52
|
-
- - "
|
80
|
+
- - ">="
|
53
81
|
- !ruby/object:Gem::Version
|
54
|
-
version: '
|
82
|
+
version: '0'
|
55
83
|
- !ruby/object:Gem::Dependency
|
56
|
-
name:
|
84
|
+
name: faker
|
57
85
|
requirement: !ruby/object:Gem::Requirement
|
58
86
|
requirements:
|
59
|
-
- - "
|
87
|
+
- - ">="
|
60
88
|
- !ruby/object:Gem::Version
|
61
|
-
version: '
|
89
|
+
version: '0'
|
62
90
|
type: :development
|
63
91
|
prerelease: false
|
64
92
|
version_requirements: !ruby/object:Gem::Requirement
|
65
93
|
requirements:
|
66
|
-
- - "
|
94
|
+
- - ">="
|
67
95
|
- !ruby/object:Gem::Version
|
68
|
-
version: '
|
96
|
+
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: rubocop
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: coveralls
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - ">="
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - ">="
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0'
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: debase
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - ">="
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '0'
|
132
|
+
type: :development
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - ">="
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: '0'
|
69
139
|
- !ruby/object:Gem::Dependency
|
70
140
|
name: faraday
|
71
141
|
requirement: !ruby/object:Gem::Requirement
|
72
142
|
requirements:
|
73
|
-
- - "
|
143
|
+
- - ">="
|
74
144
|
- !ruby/object:Gem::Version
|
75
|
-
version: '0
|
145
|
+
version: '0'
|
76
146
|
type: :runtime
|
77
147
|
prerelease: false
|
78
148
|
version_requirements: !ruby/object:Gem::Requirement
|
79
149
|
requirements:
|
80
|
-
- - "
|
150
|
+
- - ">="
|
81
151
|
- !ruby/object:Gem::Version
|
82
|
-
version: '0
|
152
|
+
version: '0'
|
83
153
|
- !ruby/object:Gem::Dependency
|
84
154
|
name: faraday_throttler
|
85
155
|
requirement: !ruby/object:Gem::Requirement
|
86
156
|
requirements:
|
87
|
-
- - "
|
157
|
+
- - ">="
|
88
158
|
- !ruby/object:Gem::Version
|
89
|
-
version: 0
|
159
|
+
version: '0'
|
90
160
|
type: :runtime
|
91
161
|
prerelease: false
|
92
162
|
version_requirements: !ruby/object:Gem::Requirement
|
93
163
|
requirements:
|
94
|
-
- - "
|
164
|
+
- - ">="
|
95
165
|
- !ruby/object:Gem::Version
|
96
|
-
version: 0
|
166
|
+
version: '0'
|
97
167
|
- !ruby/object:Gem::Dependency
|
98
168
|
name: nokogiri
|
99
169
|
requirement: !ruby/object:Gem::Requirement
|
100
170
|
requirements:
|
101
|
-
- - "~>"
|
102
|
-
- !ruby/object:Gem::Version
|
103
|
-
version: '1.6'
|
104
171
|
- - ">="
|
105
172
|
- !ruby/object:Gem::Version
|
106
|
-
version:
|
173
|
+
version: '0'
|
107
174
|
type: :runtime
|
108
175
|
prerelease: false
|
109
176
|
version_requirements: !ruby/object:Gem::Requirement
|
110
177
|
requirements:
|
111
|
-
- - "~>"
|
112
|
-
- !ruby/object:Gem::Version
|
113
|
-
version: '1.6'
|
114
178
|
- - ">="
|
115
179
|
- !ruby/object:Gem::Version
|
116
|
-
version:
|
180
|
+
version: '0'
|
117
181
|
- !ruby/object:Gem::Dependency
|
118
182
|
name: countries
|
119
183
|
requirement: !ruby/object:Gem::Requirement
|
120
184
|
requirements:
|
121
|
-
- - "~>"
|
122
|
-
- !ruby/object:Gem::Version
|
123
|
-
version: '1.2'
|
124
185
|
- - ">="
|
125
186
|
- !ruby/object:Gem::Version
|
126
|
-
version:
|
187
|
+
version: '0'
|
127
188
|
type: :runtime
|
128
189
|
prerelease: false
|
129
190
|
version_requirements: !ruby/object:Gem::Requirement
|
130
191
|
requirements:
|
131
|
-
- - "~>"
|
132
|
-
- !ruby/object:Gem::Version
|
133
|
-
version: '1.2'
|
134
192
|
- - ">="
|
135
193
|
- !ruby/object:Gem::Version
|
136
|
-
version:
|
194
|
+
version: '0'
|
137
195
|
description:
|
138
196
|
email:
|
139
197
|
- florian@floriandejonckheere.be
|
@@ -142,15 +200,20 @@ extensions: []
|
|
142
200
|
extra_rdoc_files: []
|
143
201
|
files:
|
144
202
|
- ".gitignore"
|
203
|
+
- ".rspec"
|
204
|
+
- ".rubocop.yml"
|
205
|
+
- ".travis.yml"
|
145
206
|
- CHANGELOG.md
|
146
207
|
- Gemfile
|
147
|
-
- LICENSE
|
208
|
+
- LICENSE.md
|
148
209
|
- README.md
|
149
210
|
- Rakefile
|
150
211
|
- lib/metal_archives.rb
|
151
212
|
- lib/metal_archives/configuration.rb
|
152
213
|
- lib/metal_archives/error.rb
|
153
214
|
- lib/metal_archives/http_client.rb
|
215
|
+
- lib/metal_archives/middleware/headers.rb
|
216
|
+
- lib/metal_archives/middleware/rewrite_endpoint.rb
|
154
217
|
- lib/metal_archives/models/artist.rb
|
155
218
|
- lib/metal_archives/models/band.rb
|
156
219
|
- lib/metal_archives/models/base_model.rb
|
@@ -161,20 +224,26 @@ files:
|
|
161
224
|
- lib/metal_archives/parsers/parser.rb
|
162
225
|
- lib/metal_archives/utils/collection.rb
|
163
226
|
- lib/metal_archives/utils/lru_cache.rb
|
227
|
+
- lib/metal_archives/utils/nil_date.rb
|
164
228
|
- lib/metal_archives/utils/range.rb
|
165
229
|
- lib/metal_archives/version.rb
|
166
230
|
- metal_archives.gemspec
|
167
|
-
-
|
168
|
-
-
|
169
|
-
-
|
170
|
-
-
|
171
|
-
-
|
172
|
-
-
|
173
|
-
-
|
174
|
-
-
|
175
|
-
-
|
176
|
-
-
|
177
|
-
-
|
231
|
+
- spec/configuration_spec.rb
|
232
|
+
- spec/factories/artist_factory.rb
|
233
|
+
- spec/factories/band_factory.rb
|
234
|
+
- spec/factories/nil_date_factory.rb
|
235
|
+
- spec/factories/range_factory.rb
|
236
|
+
- spec/models/artist_spec.rb
|
237
|
+
- spec/models/band_spec.rb
|
238
|
+
- spec/models/base_model_spec.rb
|
239
|
+
- spec/parser_spec.rb
|
240
|
+
- spec/spec_helper.rb
|
241
|
+
- spec/support/factory_girl.rb
|
242
|
+
- spec/support/metal_archives.rb
|
243
|
+
- spec/utils/collection_spec.rb
|
244
|
+
- spec/utils/lru_cache_spec.rb
|
245
|
+
- spec/utils/nil_date_spec.rb
|
246
|
+
- spec/utils/range_spec.rb
|
178
247
|
homepage: http://github.com/floriandejonckheere/metal_archives
|
179
248
|
licenses:
|
180
249
|
- MIT
|
@@ -195,8 +264,24 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
195
264
|
version: '0'
|
196
265
|
requirements: []
|
197
266
|
rubyforge_project:
|
198
|
-
rubygems_version: 2.6.
|
267
|
+
rubygems_version: 2.6.12
|
199
268
|
signing_key:
|
200
269
|
specification_version: 4
|
201
270
|
summary: Metal Archives Ruby API
|
202
|
-
test_files:
|
271
|
+
test_files:
|
272
|
+
- spec/configuration_spec.rb
|
273
|
+
- spec/factories/artist_factory.rb
|
274
|
+
- spec/factories/band_factory.rb
|
275
|
+
- spec/factories/nil_date_factory.rb
|
276
|
+
- spec/factories/range_factory.rb
|
277
|
+
- spec/models/artist_spec.rb
|
278
|
+
- spec/models/band_spec.rb
|
279
|
+
- spec/models/base_model_spec.rb
|
280
|
+
- spec/parser_spec.rb
|
281
|
+
- spec/spec_helper.rb
|
282
|
+
- spec/support/factory_girl.rb
|
283
|
+
- spec/support/metal_archives.rb
|
284
|
+
- spec/utils/collection_spec.rb
|
285
|
+
- spec/utils/lru_cache_spec.rb
|
286
|
+
- spec/utils/nil_date_spec.rb
|
287
|
+
- spec/utils/range_spec.rb
|
data/test/base_model_test.rb
DELETED
@@ -1,111 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
|
3
|
-
require 'metal_archives/models/base_model'
|
4
|
-
|
5
|
-
##
|
6
|
-
# Sample model without :id property
|
7
|
-
#
|
8
|
-
class ModelOne < MetalArchives::BaseModel
|
9
|
-
property :property_one
|
10
|
-
end
|
11
|
-
|
12
|
-
##
|
13
|
-
# Sample model without :assemble method
|
14
|
-
#
|
15
|
-
class ModelTwo < MetalArchives::BaseModel
|
16
|
-
property :id
|
17
|
-
property :property_one
|
18
|
-
end
|
19
|
-
|
20
|
-
##
|
21
|
-
# Sample complete model
|
22
|
-
#
|
23
|
-
class ModelThree < MetalArchives::BaseModel
|
24
|
-
property :id
|
25
|
-
property :property_one
|
26
|
-
|
27
|
-
def assemble
|
28
|
-
instance_variable_set "@property_one", 'Property One'
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
##
|
33
|
-
# Sample complete model
|
34
|
-
#
|
35
|
-
class ModelFour < MetalArchives::BaseModel
|
36
|
-
property :id
|
37
|
-
property :property_one
|
38
|
-
|
39
|
-
def assemble
|
40
|
-
instance_variable_set "@property_one", 'Property One'
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
44
|
-
##
|
45
|
-
# BaseModel tests
|
46
|
-
#
|
47
|
-
class BaseModelTest < Test::Unit::TestCase
|
48
|
-
def test_need_id
|
49
|
-
assert_raise MetalArchives::Errors::NotImplementedError do
|
50
|
-
ModelOne.new(:property_one => 'foo')
|
51
|
-
end
|
52
|
-
end
|
53
|
-
|
54
|
-
def test_need_assemble
|
55
|
-
assert_raise MetalArchives::Errors::NotImplementedError do
|
56
|
-
ModelTwo.new(:id => 'foo').property_one
|
57
|
-
end
|
58
|
-
end
|
59
|
-
|
60
|
-
def test_constructor
|
61
|
-
model = ModelThree.new(:id => 'foo', :property_one => 'bar')
|
62
|
-
|
63
|
-
assert model.instance_variable_defined? '@id'
|
64
|
-
assert model.instance_variable_defined? '@property_one'
|
65
|
-
assert !model.instance_variable_defined?('@property_two')
|
66
|
-
end
|
67
|
-
|
68
|
-
def test_methods
|
69
|
-
model = ModelThree.new(:id => 'foo')
|
70
|
-
|
71
|
-
assert_respond_to model, :id
|
72
|
-
assert_respond_to model, :id?
|
73
|
-
assert_respond_to model, :id=
|
74
|
-
|
75
|
-
assert_respond_to model, :property_one
|
76
|
-
assert_respond_to model, :property_one?
|
77
|
-
assert_respond_to model, :property_one=
|
78
|
-
end
|
79
|
-
|
80
|
-
def test_assemble
|
81
|
-
model = ModelThree.new :id => 'foo'
|
82
|
-
|
83
|
-
assert_equal 'foo', model.id
|
84
|
-
assert_equal 'Property One', model.property_one
|
85
|
-
end
|
86
|
-
|
87
|
-
def test_lazy_load
|
88
|
-
model = ModelThree.new :id => 'foo'
|
89
|
-
|
90
|
-
assert model.instance_variable_defined? '@id'
|
91
|
-
assert !model.instance_variable_defined?('@property_one')
|
92
|
-
|
93
|
-
model.property_one
|
94
|
-
|
95
|
-
assert model.instance_variable_defined? '@id'
|
96
|
-
assert model.instance_variable_defined? '@property_one'
|
97
|
-
assert_equal 'Property One', model.property_one
|
98
|
-
end
|
99
|
-
|
100
|
-
def test_equality
|
101
|
-
m1 = ModelThree.new :id => 'id_one'
|
102
|
-
m2 = ModelThree.new :id => 'id_one'
|
103
|
-
m3 = ModelThree.new :id => 'id_two'
|
104
|
-
m4 = ModelFour.new :id => 'id_one'
|
105
|
-
|
106
|
-
assert_equal m1, m2
|
107
|
-
assert_not_equal m2, m3
|
108
|
-
assert_not_equal m1, m3
|
109
|
-
assert_not_equal m1, m4
|
110
|
-
end
|
111
|
-
end
|
data/test/configuration_test.rb
DELETED
@@ -1,57 +0,0 @@
|
|
1
|
-
$:.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
2
|
-
require 'test/unit'
|
3
|
-
|
4
|
-
require 'metal_archives'
|
5
|
-
require 'metal_archives/error'
|
6
|
-
|
7
|
-
##
|
8
|
-
# Configuration tests
|
9
|
-
#
|
10
|
-
class ConfigurationTest < Test::Unit::TestCase
|
11
|
-
def setup
|
12
|
-
MetalArchives.config = nil
|
13
|
-
end
|
14
|
-
|
15
|
-
def test_no_configuration
|
16
|
-
assert_raise MetalArchives::Errors::InvalidConfigurationError do
|
17
|
-
MetalArchives::Band.search 'some_name'
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
def test_missing_app_name
|
22
|
-
assert_raise MetalArchives::Errors::InvalidConfigurationError do
|
23
|
-
MetalArchives.configure do |c|
|
24
|
-
c.app_version = MetalArchives::VERSION
|
25
|
-
c.app_contact = `git config user.email`.chomp || 'user@example.com'
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
def test_missing_app_version
|
31
|
-
assert_raise MetalArchives::Errors::InvalidConfigurationError do
|
32
|
-
MetalArchives.configure do |c|
|
33
|
-
c.app_name = 'MetalArchivesGemTestSuite'
|
34
|
-
c.app_contact = `git config user.email`.chomp || 'user@example.com'
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
def test_missing_app_contact
|
40
|
-
assert_raise MetalArchives::Errors::InvalidConfigurationError do
|
41
|
-
MetalArchives.configure do |c|
|
42
|
-
c.app_name = 'MetalArchivesGemTestSuite'
|
43
|
-
c.app_version = MetalArchives::VERSION
|
44
|
-
end
|
45
|
-
end
|
46
|
-
end
|
47
|
-
|
48
|
-
def test_full_configuration
|
49
|
-
assert_nothing_raised do
|
50
|
-
MetalArchives.configure do |c|
|
51
|
-
c.app_name = 'MetalArchivesGemTestSuite'
|
52
|
-
c.app_version = MetalArchives::VERSION
|
53
|
-
c.app_contact = `git config user.email`.chomp || 'user@example.com'
|
54
|
-
end
|
55
|
-
end
|
56
|
-
end
|
57
|
-
end
|