metal_archives 3.0.1 → 3.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/ci.yml +59 -12
- data/.rspec +1 -0
- data/.rubocop.yml +34 -20
- data/CHANGELOG.md +4 -0
- data/LICENSE.md +17 -4
- data/README.md +29 -14
- data/bin/console +8 -11
- data/config/inflections.rb +7 -0
- data/config/initializers/.keep +0 -0
- data/docker-compose.yml +10 -1
- data/lib/metal_archives.rb +56 -22
- data/lib/metal_archives/cache/base.rb +40 -0
- data/lib/metal_archives/cache/memory.rb +68 -0
- data/lib/metal_archives/cache/null.rb +22 -0
- data/lib/metal_archives/cache/redis.rb +49 -0
- data/lib/metal_archives/collection.rb +3 -5
- data/lib/metal_archives/configuration.rb +28 -21
- data/lib/metal_archives/errors.rb +9 -1
- data/lib/metal_archives/http_client.rb +42 -46
- data/lib/metal_archives/models/artist.rb +55 -26
- data/lib/metal_archives/models/band.rb +43 -36
- data/lib/metal_archives/models/{base_model.rb → base.rb} +53 -53
- data/lib/metal_archives/models/label.rb +7 -8
- data/lib/metal_archives/models/release.rb +11 -17
- data/lib/metal_archives/parsers/artist.rb +40 -35
- data/lib/metal_archives/parsers/band.rb +73 -29
- data/lib/metal_archives/parsers/base.rb +14 -0
- data/lib/metal_archives/parsers/country.rb +21 -0
- data/lib/metal_archives/parsers/date.rb +31 -0
- data/lib/metal_archives/parsers/genre.rb +67 -0
- data/lib/metal_archives/parsers/label.rb +21 -13
- data/lib/metal_archives/parsers/parser.rb +15 -77
- data/lib/metal_archives/parsers/release.rb +22 -18
- data/lib/metal_archives/parsers/year.rb +29 -0
- data/lib/metal_archives/version.rb +3 -3
- data/metal_archives.env.example +7 -4
- data/metal_archives.gemspec +7 -4
- data/nginx/default.conf +2 -2
- metadata +76 -32
- data/.github/workflows/release.yml +0 -69
- data/.rubocop_todo.yml +0 -92
- data/lib/metal_archives/lru_cache.rb +0 -61
- data/lib/metal_archives/middleware/cache_check.rb +0 -18
- data/lib/metal_archives/middleware/encoding.rb +0 -16
- data/lib/metal_archives/middleware/headers.rb +0 -38
- data/lib/metal_archives/middleware/rewrite_endpoint.rb +0 -38
- data/lib/metal_archives/nil_date.rb +0 -91
- data/lib/metal_archives/range.rb +0 -69
data/metal_archives.gemspec
CHANGED
@@ -10,9 +10,9 @@ Gem::Specification.new do |spec|
|
|
10
10
|
|
11
11
|
spec.summary = "Metal Archives Ruby API"
|
12
12
|
spec.description = "Ruby API layer that transparently queries, scrapes and caches Metal Archives' website"
|
13
|
-
spec.homepage = "
|
13
|
+
spec.homepage = "https://github.com/floriandejonckheere/metal_archives"
|
14
14
|
spec.license = "MIT"
|
15
|
-
spec.required_ruby_version = Gem::Requirement.new(">= 2.
|
15
|
+
spec.required_ruby_version = Gem::Requirement.new(">= 2.6")
|
16
16
|
|
17
17
|
spec.metadata["source_code_uri"] = "https://github.com/floriandejonckheere/metal_archives"
|
18
18
|
|
@@ -26,8 +26,7 @@ Gem::Specification.new do |spec|
|
|
26
26
|
spec.require_paths = ["lib"]
|
27
27
|
|
28
28
|
spec.add_runtime_dependency "countries"
|
29
|
-
spec.add_runtime_dependency "
|
30
|
-
spec.add_runtime_dependency "faraday_throttler"
|
29
|
+
spec.add_runtime_dependency "http"
|
31
30
|
spec.add_runtime_dependency "nokogiri"
|
32
31
|
spec.add_runtime_dependency "zeitwerk"
|
33
32
|
|
@@ -41,8 +40,12 @@ Gem::Specification.new do |spec|
|
|
41
40
|
spec.add_development_dependency "pronto"
|
42
41
|
spec.add_development_dependency "rake"
|
43
42
|
spec.add_development_dependency "rdoc"
|
43
|
+
spec.add_development_dependency "redis"
|
44
44
|
spec.add_development_dependency "reek"
|
45
45
|
spec.add_development_dependency "rspec"
|
46
46
|
spec.add_development_dependency "rubocop"
|
47
|
+
spec.add_development_dependency "rubocop-performance"
|
48
|
+
spec.add_development_dependency "rubocop-rspec"
|
49
|
+
spec.add_development_dependency "timecop"
|
47
50
|
spec.add_development_dependency "webmock"
|
48
51
|
end
|
data/nginx/default.conf
CHANGED
@@ -26,8 +26,8 @@ server {
|
|
26
26
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
27
27
|
proxy_set_header X-Real-IP $remote_addr;
|
28
28
|
|
29
|
-
proxy_ssl_certificate /etc/nginx/
|
30
|
-
proxy_ssl_certificate_key /etc/nginx/
|
29
|
+
proxy_ssl_certificate /etc/nginx/conf.d/client.pem;
|
30
|
+
proxy_ssl_certificate_key /etc/nginx/conf.d/client.key;
|
31
31
|
proxy_ssl_server_name on;
|
32
32
|
proxy_ssl_session_reuse on;
|
33
33
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: metal_archives
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.0
|
4
|
+
version: 3.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Florian Dejonckheere
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-03-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: countries
|
@@ -25,21 +25,7 @@ dependencies:
|
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
|
-
name:
|
29
|
-
requirement: !ruby/object:Gem::Requirement
|
30
|
-
requirements:
|
31
|
-
- - ">="
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version: '0'
|
34
|
-
type: :runtime
|
35
|
-
prerelease: false
|
36
|
-
version_requirements: !ruby/object:Gem::Requirement
|
37
|
-
requirements:
|
38
|
-
- - ">="
|
39
|
-
- !ruby/object:Gem::Version
|
40
|
-
version: '0'
|
41
|
-
- !ruby/object:Gem::Dependency
|
42
|
-
name: faraday_throttler
|
28
|
+
name: http
|
43
29
|
requirement: !ruby/object:Gem::Requirement
|
44
30
|
requirements:
|
45
31
|
- - ">="
|
@@ -220,6 +206,20 @@ dependencies:
|
|
220
206
|
- - ">="
|
221
207
|
- !ruby/object:Gem::Version
|
222
208
|
version: '0'
|
209
|
+
- !ruby/object:Gem::Dependency
|
210
|
+
name: redis
|
211
|
+
requirement: !ruby/object:Gem::Requirement
|
212
|
+
requirements:
|
213
|
+
- - ">="
|
214
|
+
- !ruby/object:Gem::Version
|
215
|
+
version: '0'
|
216
|
+
type: :development
|
217
|
+
prerelease: false
|
218
|
+
version_requirements: !ruby/object:Gem::Requirement
|
219
|
+
requirements:
|
220
|
+
- - ">="
|
221
|
+
- !ruby/object:Gem::Version
|
222
|
+
version: '0'
|
223
223
|
- !ruby/object:Gem::Dependency
|
224
224
|
name: reek
|
225
225
|
requirement: !ruby/object:Gem::Requirement
|
@@ -262,6 +262,48 @@ dependencies:
|
|
262
262
|
- - ">="
|
263
263
|
- !ruby/object:Gem::Version
|
264
264
|
version: '0'
|
265
|
+
- !ruby/object:Gem::Dependency
|
266
|
+
name: rubocop-performance
|
267
|
+
requirement: !ruby/object:Gem::Requirement
|
268
|
+
requirements:
|
269
|
+
- - ">="
|
270
|
+
- !ruby/object:Gem::Version
|
271
|
+
version: '0'
|
272
|
+
type: :development
|
273
|
+
prerelease: false
|
274
|
+
version_requirements: !ruby/object:Gem::Requirement
|
275
|
+
requirements:
|
276
|
+
- - ">="
|
277
|
+
- !ruby/object:Gem::Version
|
278
|
+
version: '0'
|
279
|
+
- !ruby/object:Gem::Dependency
|
280
|
+
name: rubocop-rspec
|
281
|
+
requirement: !ruby/object:Gem::Requirement
|
282
|
+
requirements:
|
283
|
+
- - ">="
|
284
|
+
- !ruby/object:Gem::Version
|
285
|
+
version: '0'
|
286
|
+
type: :development
|
287
|
+
prerelease: false
|
288
|
+
version_requirements: !ruby/object:Gem::Requirement
|
289
|
+
requirements:
|
290
|
+
- - ">="
|
291
|
+
- !ruby/object:Gem::Version
|
292
|
+
version: '0'
|
293
|
+
- !ruby/object:Gem::Dependency
|
294
|
+
name: timecop
|
295
|
+
requirement: !ruby/object:Gem::Requirement
|
296
|
+
requirements:
|
297
|
+
- - ">="
|
298
|
+
- !ruby/object:Gem::Version
|
299
|
+
version: '0'
|
300
|
+
type: :development
|
301
|
+
prerelease: false
|
302
|
+
version_requirements: !ruby/object:Gem::Requirement
|
303
|
+
requirements:
|
304
|
+
- - ">="
|
305
|
+
- !ruby/object:Gem::Version
|
306
|
+
version: '0'
|
265
307
|
- !ruby/object:Gem::Dependency
|
266
308
|
name: webmock
|
267
309
|
requirement: !ruby/object:Gem::Requirement
|
@@ -287,12 +329,10 @@ extensions: []
|
|
287
329
|
extra_rdoc_files: []
|
288
330
|
files:
|
289
331
|
- ".github/workflows/ci.yml"
|
290
|
-
- ".github/workflows/release.yml"
|
291
332
|
- ".gitignore"
|
292
333
|
- ".overcommit.yml"
|
293
334
|
- ".rspec"
|
294
335
|
- ".rubocop.yml"
|
295
|
-
- ".rubocop_todo.yml"
|
296
336
|
- CHANGELOG.md
|
297
337
|
- Gemfile
|
298
338
|
- LICENSE.md
|
@@ -300,40 +340,44 @@ files:
|
|
300
340
|
- Rakefile
|
301
341
|
- bin/console
|
302
342
|
- bin/setup
|
343
|
+
- config/inflections.rb
|
344
|
+
- config/initializers/.keep
|
303
345
|
- docker-compose.yml
|
304
346
|
- lib/metal_archives.rb
|
347
|
+
- lib/metal_archives/cache/base.rb
|
348
|
+
- lib/metal_archives/cache/memory.rb
|
349
|
+
- lib/metal_archives/cache/null.rb
|
350
|
+
- lib/metal_archives/cache/redis.rb
|
305
351
|
- lib/metal_archives/collection.rb
|
306
352
|
- lib/metal_archives/configuration.rb
|
307
353
|
- lib/metal_archives/errors.rb
|
308
354
|
- lib/metal_archives/http_client.rb
|
309
|
-
- lib/metal_archives/lru_cache.rb
|
310
|
-
- lib/metal_archives/middleware/cache_check.rb
|
311
|
-
- lib/metal_archives/middleware/encoding.rb
|
312
|
-
- lib/metal_archives/middleware/headers.rb
|
313
|
-
- lib/metal_archives/middleware/rewrite_endpoint.rb
|
314
355
|
- lib/metal_archives/models/artist.rb
|
315
356
|
- lib/metal_archives/models/band.rb
|
316
|
-
- lib/metal_archives/models/
|
357
|
+
- lib/metal_archives/models/base.rb
|
317
358
|
- lib/metal_archives/models/label.rb
|
318
359
|
- lib/metal_archives/models/release.rb
|
319
|
-
- lib/metal_archives/nil_date.rb
|
320
360
|
- lib/metal_archives/parsers/artist.rb
|
321
361
|
- lib/metal_archives/parsers/band.rb
|
362
|
+
- lib/metal_archives/parsers/base.rb
|
363
|
+
- lib/metal_archives/parsers/country.rb
|
364
|
+
- lib/metal_archives/parsers/date.rb
|
365
|
+
- lib/metal_archives/parsers/genre.rb
|
322
366
|
- lib/metal_archives/parsers/label.rb
|
323
367
|
- lib/metal_archives/parsers/parser.rb
|
324
368
|
- lib/metal_archives/parsers/release.rb
|
325
|
-
- lib/metal_archives/
|
369
|
+
- lib/metal_archives/parsers/year.rb
|
326
370
|
- lib/metal_archives/version.rb
|
327
371
|
- metal_archives.env.example
|
328
372
|
- metal_archives.gemspec
|
329
373
|
- nginx/default.conf
|
330
374
|
- publish.sh
|
331
|
-
homepage:
|
375
|
+
homepage: https://github.com/floriandejonckheere/metal_archives
|
332
376
|
licenses:
|
333
377
|
- MIT
|
334
378
|
metadata:
|
335
379
|
source_code_uri: https://github.com/floriandejonckheere/metal_archives
|
336
|
-
post_install_message:
|
380
|
+
post_install_message:
|
337
381
|
rdoc_options: []
|
338
382
|
require_paths:
|
339
383
|
- lib
|
@@ -341,7 +385,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
341
385
|
requirements:
|
342
386
|
- - ">="
|
343
387
|
- !ruby/object:Gem::Version
|
344
|
-
version: 2.
|
388
|
+
version: '2.6'
|
345
389
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
346
390
|
requirements:
|
347
391
|
- - ">="
|
@@ -349,7 +393,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
349
393
|
version: '0'
|
350
394
|
requirements: []
|
351
395
|
rubygems_version: 3.1.2
|
352
|
-
signing_key:
|
396
|
+
signing_key:
|
353
397
|
specification_version: 4
|
354
398
|
summary: Metal Archives Ruby API
|
355
399
|
test_files: []
|
@@ -1,69 +0,0 @@
|
|
1
|
-
name: Create release
|
2
|
-
|
3
|
-
on:
|
4
|
-
push:
|
5
|
-
tags:
|
6
|
-
- 'v*'
|
7
|
-
|
8
|
-
jobs:
|
9
|
-
generate:
|
10
|
-
name: Create release
|
11
|
-
runs-on: ubuntu-latest
|
12
|
-
steps:
|
13
|
-
- uses: actions/checkout@v1
|
14
|
-
|
15
|
-
- name: Setup Ruby
|
16
|
-
uses: actions/setup-ruby@v1
|
17
|
-
with:
|
18
|
-
ruby-version: 2.7.x
|
19
|
-
|
20
|
-
- name: Cache Gems
|
21
|
-
uses: actions/cache@v1
|
22
|
-
with:
|
23
|
-
path: vendor/bundle
|
24
|
-
key: ${{ runner.os }}-gem-${{ hashFiles('**/Gemfile') }}
|
25
|
-
restore-keys: |
|
26
|
-
${{ runner.os }}-gem-
|
27
|
-
|
28
|
-
- name: Install Gems
|
29
|
-
run: |
|
30
|
-
gem install bundler
|
31
|
-
bundle config path vendor/bundle
|
32
|
-
bundle install --jobs 4 --retry 3
|
33
|
-
|
34
|
-
- name: Test
|
35
|
-
env:
|
36
|
-
MA_ENDPOINT: ${{ secrets.MA_ENDPOINT }}
|
37
|
-
MA_ENDPOINT_USER: ${{ secrets.MA_ENDPOINT_USER }}
|
38
|
-
MA_ENDPOINT_PASSWORD: ${{ secrets.MA_ENDPOINT_PASSWORD }}
|
39
|
-
WEBMOCK_ALLOW_HOST: ${{ secrets.WEBMOCK_ALLOW_HOST }}
|
40
|
-
run: bundle exec rspec --profile 10 --format progress
|
41
|
-
|
42
|
-
- name: Lint
|
43
|
-
run: bundle exec rubocop --parallel --display-cop-names
|
44
|
-
|
45
|
-
- name: Get the version
|
46
|
-
id: get_version
|
47
|
-
run: echo ::set-output name=VERSION::${GITHUB_REF/refs\/tags\//}
|
48
|
-
|
49
|
-
- name: Publish to RubyGems
|
50
|
-
run: |
|
51
|
-
mkdir -p ~/.gem
|
52
|
-
touch ~/.gem/credentials
|
53
|
-
chmod 0600 ~/.gem/credentials
|
54
|
-
printf -- "---\n:rubygems_api_key: ${GEM_HOST_API_KEY}\n" > ~/.gem/credentials
|
55
|
-
gem build *.gemspec
|
56
|
-
gem push *.gem
|
57
|
-
env:
|
58
|
-
GEM_HOST_API_KEY: ${{secrets.RUBYGEMS_API_KEY}}
|
59
|
-
|
60
|
-
- name: Create Release
|
61
|
-
uses: actions/create-release@v1.0.0
|
62
|
-
env:
|
63
|
-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
64
|
-
with:
|
65
|
-
tag_name: ${{ github.ref }}
|
66
|
-
release_name: ${{ github.ref }}
|
67
|
-
body: |
|
68
|
-
Gem is available as: ${{ github.event.repository.name }}-${{ steps.get_version.outputs.VERSION }}
|
69
|
-
Created by Github Actions
|
data/.rubocop_todo.yml
DELETED
@@ -1,92 +0,0 @@
|
|
1
|
-
# This configuration was generated by
|
2
|
-
# `rubocop --auto-gen-config`
|
3
|
-
# on 2020-04-14 17:51:42 +0200 using RuboCop version 0.80.1.
|
4
|
-
# The point is for the user to remove these configuration records
|
5
|
-
# one by one as the offenses are removed from the code base.
|
6
|
-
# Note that changes in the inspected code, or installation of new
|
7
|
-
# versions of RuboCop, may require this file to be generated again.
|
8
|
-
|
9
|
-
# Offense count: 1
|
10
|
-
Lint/AmbiguousRegexpLiteral:
|
11
|
-
Exclude:
|
12
|
-
- 'lib/metal_archives/parsers/artist.rb'
|
13
|
-
|
14
|
-
# Offense count: 2
|
15
|
-
Lint/EmptyWhen:
|
16
|
-
Exclude:
|
17
|
-
- 'lib/metal_archives/parsers/label.rb'
|
18
|
-
- 'lib/metal_archives/parsers/release.rb'
|
19
|
-
|
20
|
-
# Offense count: 2
|
21
|
-
# Configuration parameters: AllowKeywordBlockArguments.
|
22
|
-
Lint/UnderscorePrefixedVariableName:
|
23
|
-
Exclude:
|
24
|
-
- 'lib/metal_archives/range.rb'
|
25
|
-
|
26
|
-
# Offense count: 6
|
27
|
-
Lint/UselessAssignment:
|
28
|
-
Exclude:
|
29
|
-
- 'lib/metal_archives/parsers/artist.rb'
|
30
|
-
- 'lib/metal_archives/parsers/band.rb'
|
31
|
-
- 'lib/metal_archives/parsers/label.rb'
|
32
|
-
- 'lib/metal_archives/parsers/release.rb'
|
33
|
-
- 'spec/collection_spec.rb'
|
34
|
-
|
35
|
-
# Offense count: 29
|
36
|
-
Metrics/AbcSize:
|
37
|
-
Max: 102
|
38
|
-
|
39
|
-
# Offense count: 9
|
40
|
-
# Configuration parameters: CountComments, ExcludedMethods.
|
41
|
-
# ExcludedMethods: refine
|
42
|
-
Metrics/BlockLength:
|
43
|
-
Max: 42
|
44
|
-
|
45
|
-
# Offense count: 3
|
46
|
-
# Configuration parameters: CountComments.
|
47
|
-
Metrics/ClassLength:
|
48
|
-
Max: 147
|
49
|
-
|
50
|
-
# Offense count: 12
|
51
|
-
Metrics/CyclomaticComplexity:
|
52
|
-
Max: 17
|
53
|
-
|
54
|
-
# Offense count: 12
|
55
|
-
Metrics/PerceivedComplexity:
|
56
|
-
Max: 18
|
57
|
-
|
58
|
-
# Offense count: 1
|
59
|
-
Naming/BinaryOperatorParameterName:
|
60
|
-
Exclude:
|
61
|
-
- 'lib/metal_archives/models/base_model.rb'
|
62
|
-
|
63
|
-
# Offense count: 1
|
64
|
-
# Configuration parameters: EnforcedStyleForLeadingUnderscores.
|
65
|
-
# SupportedStylesForLeadingUnderscores: disallowed, required, optional
|
66
|
-
Naming/MemoizedInstanceVariableName:
|
67
|
-
Exclude:
|
68
|
-
- 'lib/metal_archives/http_client.rb'
|
69
|
-
|
70
|
-
# Offense count: 9
|
71
|
-
# Cop supports --auto-correct.
|
72
|
-
Style/IfUnlessModifier:
|
73
|
-
Exclude:
|
74
|
-
- 'lib/metal_archives.rb'
|
75
|
-
- 'lib/metal_archives/middleware/cache_check.rb'
|
76
|
-
- 'lib/metal_archives/models/base_model.rb'
|
77
|
-
|
78
|
-
# Offense count: 5
|
79
|
-
# Cop supports --auto-correct.
|
80
|
-
# Configuration parameters: AutoCorrect, EnforcedStyle, IgnoredMethods.
|
81
|
-
# SupportedStyles: predicate, comparison
|
82
|
-
Style/NumericPredicate:
|
83
|
-
Exclude:
|
84
|
-
- 'spec/**/*'
|
85
|
-
- 'lib/metal_archives/nil_date.rb'
|
86
|
-
|
87
|
-
# Offense count: 307
|
88
|
-
# Cop supports --auto-correct.
|
89
|
-
# Configuration parameters: AutoCorrect, AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
|
90
|
-
# URISchemes: http, https
|
91
|
-
Layout/LineLength:
|
92
|
-
Max: 963
|
@@ -1,61 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module MetalArchives
|
4
|
-
##
|
5
|
-
# Generic LRU memory cache
|
6
|
-
#
|
7
|
-
class LRUCache
|
8
|
-
def initialize(size = 100)
|
9
|
-
@size = size
|
10
|
-
|
11
|
-
# Underlying data store
|
12
|
-
@cache = {}
|
13
|
-
|
14
|
-
# Array of keys in order of insertion
|
15
|
-
@keys = []
|
16
|
-
end
|
17
|
-
|
18
|
-
def []=(key, value)
|
19
|
-
@cache[key] = value
|
20
|
-
|
21
|
-
@keys.delete key if @keys.include? key
|
22
|
-
|
23
|
-
@keys << key
|
24
|
-
|
25
|
-
pop if @keys.size > @size
|
26
|
-
end
|
27
|
-
|
28
|
-
def [](key)
|
29
|
-
if @keys.include? key
|
30
|
-
MetalArchives.config.logger.debug "Cache hit for #{key}"
|
31
|
-
@keys.delete key
|
32
|
-
@keys << key
|
33
|
-
else
|
34
|
-
MetalArchives.config.logger.debug "Cache miss for #{key}"
|
35
|
-
end
|
36
|
-
|
37
|
-
@cache[key]
|
38
|
-
end
|
39
|
-
|
40
|
-
def clear
|
41
|
-
@cache.clear
|
42
|
-
@keys.clear
|
43
|
-
end
|
44
|
-
|
45
|
-
def include?(key)
|
46
|
-
@cache.include? key
|
47
|
-
end
|
48
|
-
|
49
|
-
def delete(key)
|
50
|
-
@cache.delete key
|
51
|
-
end
|
52
|
-
|
53
|
-
private
|
54
|
-
|
55
|
-
def pop
|
56
|
-
to_remove = @keys.shift @keys.size - @size
|
57
|
-
|
58
|
-
to_remove.each { |key| @cache.delete key }
|
59
|
-
end
|
60
|
-
end
|
61
|
-
end
|