metal_archives 2.2.3 → 3.2.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 +16 -1
- data/LICENSE.md +17 -4
- data/README.md +37 -29
- 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 +57 -21
- 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} +57 -50
- data/lib/metal_archives/models/label.rb +7 -8
- data/lib/metal_archives/models/release.rb +21 -18
- data/lib/metal_archives/parsers/artist.rb +41 -36
- 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 +17 -77
- data/lib/metal_archives/parsers/release.rb +29 -18
- data/lib/metal_archives/parsers/year.rb +31 -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
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2c000d091859fb144ab19500353d4901a3cb2aa2e10962e5a138a12e40c5eb11
|
4
|
+
data.tar.gz: cf9428989c5b8c3f5b36169219fbb62632703a797df2c31bf041ed8dd7e053ad
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 56d38a266d6d882b9df4fe4a2efb0d2d9cf9a7f473a19d0bf3ff360a1967edd566c1f49f98a58e58cfcd2d245e856dd28b9fdc3d9bca6f283d253e752c99778e
|
7
|
+
data.tar.gz: a0db17d07d3703743247ed7c59dffcdbefa7686f7d50b8af4f3b6ff9d3fcc640a25208253125ad94784f9b6755298dade393a7a435fac24a8797dcf5d85ff25f
|
data/.github/workflows/ci.yml
CHANGED
@@ -1,32 +1,44 @@
|
|
1
|
-
name:
|
1
|
+
name: Continuous Integration
|
2
2
|
|
3
3
|
on:
|
4
4
|
push:
|
5
|
-
tags-ignore:
|
6
|
-
- '*'
|
7
5
|
branches:
|
8
6
|
- '*'
|
7
|
+
tags:
|
8
|
+
- '*'
|
9
|
+
schedule:
|
10
|
+
- cron: '0 7 * * 1'
|
9
11
|
|
10
12
|
jobs:
|
11
13
|
build:
|
12
14
|
name: Continuous Integration
|
13
|
-
runs-on: ubuntu-
|
15
|
+
runs-on: ubuntu-20.04
|
16
|
+
strategy:
|
17
|
+
matrix:
|
18
|
+
ruby: [ "2.6", "2.7", "3.0" ]
|
19
|
+
|
20
|
+
container:
|
21
|
+
image: ruby:3.0-alpine
|
22
|
+
|
23
|
+
services:
|
24
|
+
redis:
|
25
|
+
image: redis:alpine
|
14
26
|
|
15
27
|
steps:
|
16
|
-
- uses: actions/checkout@
|
28
|
+
- uses: actions/checkout@v2
|
17
29
|
|
18
|
-
- name:
|
19
|
-
|
20
|
-
|
21
|
-
|
30
|
+
- name: Install dependencies
|
31
|
+
run: |
|
32
|
+
apk add build-base git cmake openssl-dev
|
33
|
+
apk add tar
|
22
34
|
|
23
35
|
- name: Cache Gems
|
24
|
-
uses: actions/cache@
|
36
|
+
uses: actions/cache@v2.1.3
|
25
37
|
with:
|
26
38
|
path: vendor/bundle
|
27
|
-
key: ${{ runner.os }}-gem-${{ hashFiles('**/Gemfile') }}
|
39
|
+
key: ${{ runner.os }}-${{ matrix.ruby }}-gem-${{ hashFiles('**/Gemfile.lock') }}
|
28
40
|
restore-keys: |
|
29
|
-
${{ runner.os }}-gem-
|
41
|
+
${{ runner.os }}-${{ matrix.ruby }}-gem-
|
30
42
|
|
31
43
|
- name: Install Gems
|
32
44
|
run: |
|
@@ -40,7 +52,42 @@ jobs:
|
|
40
52
|
MA_ENDPOINT_USER: ${{ secrets.MA_ENDPOINT_USER }}
|
41
53
|
MA_ENDPOINT_PASSWORD: ${{ secrets.MA_ENDPOINT_PASSWORD }}
|
42
54
|
WEBMOCK_ALLOW_HOST: ${{ secrets.WEBMOCK_ALLOW_HOST }}
|
55
|
+
REDIS_URL: "redis://redis:6379/"
|
43
56
|
run: bundle exec rspec --profile 10 --format progress
|
44
57
|
|
45
58
|
- name: Lint
|
46
59
|
run: bundle exec rubocop --parallel --display-cop-names
|
60
|
+
|
61
|
+
release:
|
62
|
+
name: Release application
|
63
|
+
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
|
64
|
+
runs-on: ubuntu-20.04
|
65
|
+
needs: build
|
66
|
+
|
67
|
+
steps:
|
68
|
+
- uses: actions/checkout@v2
|
69
|
+
|
70
|
+
- name: Set version
|
71
|
+
run: |
|
72
|
+
echo "VERSION=${GITHUB_REF/refs\/tags\//}" >> $GITHUB_ENV
|
73
|
+
|
74
|
+
- name: Publish to RubyGems
|
75
|
+
run: |
|
76
|
+
mkdir -p ~/.gem
|
77
|
+
touch ~/.gem/credentials
|
78
|
+
chmod 0600 ~/.gem/credentials
|
79
|
+
printf -- "---\n:rubygems_api_key: ${GEM_HOST_API_KEY}\n" > ~/.gem/credentials
|
80
|
+
gem build *.gemspec
|
81
|
+
gem push *.gem
|
82
|
+
env:
|
83
|
+
GEM_HOST_API_KEY: ${{secrets.RUBYGEMS_API_KEY}}
|
84
|
+
|
85
|
+
- name: Create Github Release
|
86
|
+
uses: actions/create-release@v1
|
87
|
+
env:
|
88
|
+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
89
|
+
with:
|
90
|
+
tag_name: ${{ github.ref }}
|
91
|
+
release_name: ${{ github.ref }}
|
92
|
+
body: |
|
93
|
+
Gem ${{ github.event.repository.name }} ${{ env.VERSION }} was released
|
data/.rspec
CHANGED
data/.rubocop.yml
CHANGED
@@ -1,7 +1,13 @@
|
|
1
|
-
|
1
|
+
require:
|
2
|
+
- rubocop-performance
|
3
|
+
- rubocop-rspec
|
2
4
|
|
3
5
|
AllCops:
|
4
|
-
|
6
|
+
NewCops: enable
|
7
|
+
TargetRubyVersion: 2.6
|
8
|
+
|
9
|
+
Layout/LineLength:
|
10
|
+
Enabled: false
|
5
11
|
|
6
12
|
Layout/MultilineMethodCallIndentation:
|
7
13
|
EnforcedStyle: indented
|
@@ -15,26 +21,35 @@ Lint/AssignmentInCondition:
|
|
15
21
|
Lint/SafeNavigationWithEmpty:
|
16
22
|
Enabled: false
|
17
23
|
|
24
|
+
Metrics/AbcSize:
|
25
|
+
Enabled: false
|
26
|
+
|
27
|
+
Metrics/CyclomaticComplexity:
|
28
|
+
Enabled: false
|
29
|
+
|
18
30
|
Metrics/BlockLength:
|
19
|
-
|
20
|
-
|
31
|
+
Enabled: false
|
32
|
+
|
33
|
+
Metrics/ClassLength:
|
34
|
+
Enabled: false
|
21
35
|
|
22
36
|
Metrics/MethodLength:
|
23
37
|
Enabled: false
|
24
38
|
|
25
|
-
|
26
|
-
|
39
|
+
Metrics/PerceivedComplexity:
|
40
|
+
Enabled: false
|
27
41
|
|
28
|
-
|
29
|
-
Enabled:
|
42
|
+
RSpec/ExampleLength:
|
43
|
+
Enabled: false
|
30
44
|
|
31
|
-
|
32
|
-
|
45
|
+
RSpec/FilePath:
|
46
|
+
Exclude:
|
47
|
+
- spec/metal_archives/models/*
|
33
48
|
|
34
|
-
|
35
|
-
Enabled:
|
49
|
+
RSpec/MultipleExpectations:
|
50
|
+
Enabled: false
|
36
51
|
|
37
|
-
Style/
|
52
|
+
Style/FrozenStringLiteralComment:
|
38
53
|
Enabled: true
|
39
54
|
|
40
55
|
Style/PercentLiteralDelimiters:
|
@@ -46,18 +61,17 @@ Style/PercentLiteralDelimiters:
|
|
46
61
|
"%w": "()"
|
47
62
|
"%W": "()"
|
48
63
|
|
49
|
-
Style/RegexpLiteral:
|
50
|
-
EnforcedStyle: slashes
|
51
|
-
AllowInnerSlashes: false
|
52
|
-
|
53
64
|
Style/StringLiterals:
|
54
65
|
EnforcedStyle: double_quotes
|
55
66
|
|
56
67
|
Style/SymbolArray:
|
57
|
-
|
68
|
+
EnforcedStyle: brackets
|
69
|
+
|
70
|
+
Style/TrailingCommaInArguments:
|
71
|
+
EnforcedStyleForMultiline: consistent_comma
|
58
72
|
|
59
73
|
Style/TrailingCommaInArrayLiteral:
|
60
|
-
EnforcedStyleForMultiline:
|
74
|
+
EnforcedStyleForMultiline: consistent_comma
|
61
75
|
|
62
76
|
Style/TrailingCommaInHashLiteral:
|
63
|
-
EnforcedStyleForMultiline:
|
77
|
+
EnforcedStyleForMultiline: consistent_comma
|
data/CHANGELOG.md
CHANGED
@@ -1,8 +1,23 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## 3.2.0
|
4
|
+
|
5
|
+
- Add band property on release
|
6
|
+
|
7
|
+
## 3.1.1
|
8
|
+
|
9
|
+
- Fix some invalid parsing
|
10
|
+
|
11
|
+
## 3.1.0
|
12
|
+
|
13
|
+
- Add members property on band
|
14
|
+
|
3
15
|
## 3.0.0
|
4
16
|
|
5
|
-
-
|
17
|
+
- Dropped support for Ruby < 2.5
|
18
|
+
- `MetalArchives::Errors::APIError` changed
|
19
|
+
- Dropped support for Faraday middleware
|
20
|
+
- Added support for basic authentication
|
6
21
|
|
7
22
|
## 2.2.0
|
8
23
|
|
data/LICENSE.md
CHANGED
@@ -1,7 +1,20 @@
|
|
1
|
-
Copyright
|
1
|
+
Copyright 2020 Florian Dejonckheere
|
2
2
|
|
3
|
-
Permission is hereby granted, free of charge, to any person obtaining
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
4
10
|
|
5
|
-
The above copyright notice and this permission notice shall be
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
6
13
|
|
7
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
CHANGED
@@ -1,5 +1,9 @@
|
|
1
1
|
# Metal Archives Ruby API
|
2
2
|
|
3
|
+
![Continuous Integration](https://github.com/floriandejonckheere/metal_archives/workflows/Continuous%20Integration/badge.svg)
|
4
|
+
![Release](https://img.shields.io/github/v/release/floriandejonckheere/metal_archives?label=Latest%20release)
|
5
|
+
|
6
|
+
|
3
7
|
MetalArchives is a Ruby API that transparently wraps, caches and normalizes the [Metal Archives](https://www.metal-archives.com) website.
|
4
8
|
|
5
9
|
## Installation
|
@@ -7,7 +11,7 @@ MetalArchives is a Ruby API that transparently wraps, caches and normalizes the
|
|
7
11
|
Add this line to your application's Gemfile.
|
8
12
|
|
9
13
|
```ruby
|
10
|
-
gem "metal_archives"
|
14
|
+
gem "metal_archives"
|
11
15
|
```
|
12
16
|
|
13
17
|
And then execute:
|
@@ -29,19 +33,14 @@ Configure MetalArchives before using it:
|
|
29
33
|
```ruby
|
30
34
|
MetalArchives.configure do |c|
|
31
35
|
## Application identity (required)
|
32
|
-
c.app_name =
|
33
|
-
c.app_version =
|
34
|
-
c.app_contact =
|
35
|
-
|
36
|
-
##
|
37
|
-
|
38
|
-
c.
|
39
|
-
|
40
|
-
## Connect additional Faraday middleware
|
41
|
-
# c.middleware = [MyMiddleware, MyOtherMiddleware]
|
42
|
-
|
43
|
-
## Custom cache size per object class (optional, overrides defaults)
|
44
|
-
c.cache_size = 100
|
36
|
+
c.app_name = "My App"
|
37
|
+
c.app_version = "1.0"
|
38
|
+
c.app_contact = "support@mymusicapp.com"
|
39
|
+
|
40
|
+
## Enable Redis as caching backend (optional, overrides default memory cache)
|
41
|
+
## Available cache strategies: :memory, :redis or :null (disable caching)
|
42
|
+
# c.cache_strategy = :redis
|
43
|
+
# c.cache_options = { url: "redis://redis:6379", ttl: 1.month.to_i }
|
45
44
|
|
46
45
|
## Metal Archives endpoint (optional, overrides default)
|
47
46
|
# c.endpoint = "https://www.metal-archives.com/"
|
@@ -49,7 +48,7 @@ MetalArchives.configure do |c|
|
|
49
48
|
# c.endpoint_password = "my_password"
|
50
49
|
|
51
50
|
## Custom logger (optional)
|
52
|
-
c.logger = Logger.new File.new(
|
51
|
+
c.logger = Logger.new File.new("metal_archives.log")
|
53
52
|
c.logger.level = Logger::INFO
|
54
53
|
end
|
55
54
|
```
|
@@ -57,24 +56,24 @@ end
|
|
57
56
|
## Usage
|
58
57
|
|
59
58
|
```ruby
|
60
|
-
require
|
59
|
+
require "metal_archives"
|
61
60
|
|
62
61
|
# Search for bands
|
63
|
-
@alquimia_list = MetalArchives::Band.search(
|
62
|
+
@alquimia_list = MetalArchives::Band.search("Alquimia")
|
64
63
|
|
65
64
|
# Find bands by name
|
66
|
-
@iron_maiden = MetalArchives::Band.find_by(:
|
65
|
+
@iron_maiden = MetalArchives::Band.find_by(name: "Iron Maiden")
|
67
66
|
|
68
67
|
# Find bands by attributes
|
69
|
-
require
|
68
|
+
require "countries"
|
70
69
|
|
71
|
-
@bands_in_belgium = MetalArchives::Band.search_by
|
72
|
-
@bands_formed_in_1990 = MetalArchives::Band.search_by
|
70
|
+
@bands_in_belgium = MetalArchives::Band.search_by(country: ISO3166::Country["BE"])
|
71
|
+
@bands_formed_in_1990 = MetalArchives::Band.search_by(year: 1990..)
|
73
72
|
|
74
73
|
# Metal Archives' usual tips apply
|
75
74
|
|
76
|
-
@bands_containing_hell = MetalArchives::Band.search_by :
|
77
|
-
@non_melodic_death_bands = MetalArchives::Band.search_by :
|
75
|
+
@bands_containing_hell = MetalArchives::Band.search_by name: "*hell*"
|
76
|
+
@non_melodic_death_bands = MetalArchives::Band.search_by genre: "death -melodic"
|
78
77
|
|
79
78
|
# Methods returning multiple results return a MetalArchives::Collection.
|
80
79
|
# Collection wraps a paginated resource, and can be used to iterate over huge queries.
|
@@ -92,17 +91,27 @@ This leads to instantiation of a model with an invalid ID not throwing any error
|
|
92
91
|
Calling any attribute other than `id` will cause all data to be fetched and any errors to be thrown.
|
93
92
|
Refer to the respective methods to find out what errors are thrown in what circumstances.
|
94
93
|
|
95
|
-
Models can be forced to load all data by calling the
|
94
|
+
Models can be forced to load all data by calling the `load!` method.
|
96
95
|
|
97
96
|
## Cache
|
98
97
|
|
99
|
-
|
98
|
+
The gem has builtin caching functionality.
|
99
|
+
By default, an in-memory cache is used that evicts cache entries using an LRU-based algorithm.
|
100
|
+
However, it is also possible to use Redis as a caching backend.
|
101
|
+
Don't forget to include the `redis` gem in your application bundle if you wish to use Redis caching.
|
102
|
+
|
103
|
+
In order not to stress the Metal Archives server, you can quickly set up a local HTTP proxy that caches the requests.
|
100
104
|
|
101
105
|
```
|
106
|
+
# Generate TLS client certificates for NGINX
|
107
|
+
openssl req -nodes -new -x509 -keyout nginx/client.key -out nginx/client.pem
|
108
|
+
|
109
|
+
|
110
|
+
# Start proxy server
|
102
111
|
docker-compose up -d
|
103
112
|
```
|
104
113
|
|
105
|
-
A caching proxy server is now available on `http://localhost/`.
|
114
|
+
A caching proxy server is now available on `http://localhost:8080/`.
|
106
115
|
|
107
116
|
## Testing
|
108
117
|
|
@@ -120,7 +129,6 @@ Generate documentation:
|
|
120
129
|
$ bundle exec rake rdoc
|
121
130
|
```
|
122
131
|
|
123
|
-
##
|
132
|
+
## License
|
124
133
|
|
125
|
-
|
126
|
-
All content acquired through the usage of this API is copyrighted by the respective owner.
|
134
|
+
See [LICENSE.md](LICENSE.md).
|
data/bin/console
CHANGED
@@ -15,21 +15,18 @@ MetalArchives.configure do |c|
|
|
15
15
|
c.app_version = "1.0"
|
16
16
|
c.app_contact = "support@mymusicapp.com"
|
17
17
|
|
18
|
-
##
|
19
|
-
|
20
|
-
# c.
|
21
|
-
|
22
|
-
## Connect additional Faraday middleware
|
23
|
-
# c.middleware = [MyMiddleware, MyOtherMiddleware]
|
24
|
-
|
25
|
-
## Custom cache size per object class (optional, overrides defaults)
|
26
|
-
# c.cache_size = 100
|
18
|
+
## Enable Redis as caching backend (optional, overrides default memory cache)
|
19
|
+
## Available cache strategies: :memory, :redis or :null (disable caching)
|
20
|
+
# c.cache_strategy = :redis
|
21
|
+
# c.cache_options = { url: "redis://redis:6379", ttl: 1.month.to_i }
|
27
22
|
|
28
23
|
## Metal Archives endpoint (optional, overrides default)
|
29
|
-
|
24
|
+
c.endpoint = ENV["MA_ENDPOINT"] if ENV["MA_ENDPOINT"]
|
25
|
+
c.endpoint_user = ENV["MA_ENDPOINT_USER"] if ENV["MA_ENDPOINT_USER"]
|
26
|
+
c.endpoint_password = ENV["MA_ENDPOINT_PASSWORD"] if ENV["MA_ENDPOINT_PASSWORD"]
|
30
27
|
|
31
28
|
## Custom logger (optional)
|
32
|
-
c.logger = Logger.new
|
29
|
+
c.logger = Logger.new $stdout
|
33
30
|
c.logger.level = Logger::WARN
|
34
31
|
end
|
35
32
|
|
File without changes
|
data/docker-compose.yml
CHANGED
@@ -4,11 +4,20 @@ services:
|
|
4
4
|
nginx:
|
5
5
|
image: nginx:alpine
|
6
6
|
ports:
|
7
|
-
- "
|
7
|
+
- "0.0.0.0:8080:80"
|
8
8
|
volumes:
|
9
9
|
- ./nginx/:/etc/nginx/conf.d/
|
10
10
|
- nginx:/cache/
|
11
11
|
restart: always
|
12
12
|
|
13
|
+
redis:
|
14
|
+
image: redis:alpine
|
15
|
+
ports:
|
16
|
+
- "0.0.0.0:6379:6379"
|
17
|
+
volumes:
|
18
|
+
- redis:/data/
|
19
|
+
restart: always
|
20
|
+
|
13
21
|
volumes:
|
14
22
|
nginx:
|
23
|
+
redis:
|