metal_archives 2.2.0 → 2.2.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.github/workflows/ci.yml +46 -0
- data/.github/workflows/release.yml +69 -0
- data/.gitignore +6 -6
- data/.overcommit.yml +35 -0
- data/.rspec +1 -0
- data/.rubocop.yml +54 -8
- data/.rubocop_todo.yml +92 -0
- data/CHANGELOG.md +22 -0
- data/Gemfile +1 -1
- data/LICENSE.md +1 -1
- data/README.md +35 -64
- data/Rakefile +8 -7
- data/bin/console +41 -0
- data/bin/setup +8 -0
- data/docker-compose.yml +14 -0
- data/lib/metal_archives.rb +48 -29
- data/lib/metal_archives/{utils/collection.rb → collection.rb} +0 -0
- data/lib/metal_archives/configuration.rb +9 -33
- data/lib/metal_archives/{error.rb → errors.rb} +0 -0
- data/lib/metal_archives/http_client.rb +13 -8
- data/lib/metal_archives/{utils/lru_cache.rb → lru_cache.rb} +0 -0
- data/lib/metal_archives/middleware/cache_check.rb +2 -4
- data/lib/metal_archives/middleware/encoding.rb +2 -2
- data/lib/metal_archives/middleware/headers.rb +5 -5
- data/lib/metal_archives/middleware/rewrite_endpoint.rb +2 -2
- data/lib/metal_archives/models/artist.rb +40 -24
- data/lib/metal_archives/models/band.rb +47 -29
- data/lib/metal_archives/models/base_model.rb +64 -61
- data/lib/metal_archives/models/label.rb +11 -11
- data/lib/metal_archives/models/release.rb +17 -15
- data/lib/metal_archives/{utils/nil_date.rb → nil_date.rb} +10 -18
- data/lib/metal_archives/parsers/artist.rb +62 -31
- data/lib/metal_archives/parsers/band.rb +97 -74
- data/lib/metal_archives/parsers/label.rb +21 -21
- data/lib/metal_archives/parsers/parser.rb +23 -8
- data/lib/metal_archives/parsers/release.rb +77 -72
- data/lib/metal_archives/{utils/range.rb → range.rb} +5 -2
- data/lib/metal_archives/version.rb +12 -1
- data/metal_archives.env.example +7 -0
- data/metal_archives.gemspec +40 -28
- data/nginx/default.conf +60 -0
- metadata +126 -65
- data/.travis.yml +0 -12
- data/spec/configuration_spec.rb +0 -96
- data/spec/factories/artist_factory.rb +0 -37
- data/spec/factories/band_factory.rb +0 -60
- data/spec/factories/nil_date_factory.rb +0 -9
- data/spec/factories/range_factory.rb +0 -8
- data/spec/models/artist_spec.rb +0 -138
- data/spec/models/band_spec.rb +0 -164
- data/spec/models/base_model_spec.rb +0 -219
- data/spec/models/release_spec.rb +0 -133
- data/spec/parser_spec.rb +0 -19
- data/spec/spec_helper.rb +0 -111
- data/spec/support/factory_girl.rb +0 -5
- data/spec/support/metal_archives.rb +0 -33
- data/spec/utils/collection_spec.rb +0 -72
- data/spec/utils/lru_cache_spec.rb +0 -53
- data/spec/utils/nil_date_spec.rb +0 -156
- data/spec/utils/range_spec.rb +0 -62
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: fa109d3fe5566a0b824be6a2dd5842aa74c23a46696ed296e2dc6eda07d98fd9
|
4
|
+
data.tar.gz: 461d4cdbaa1fb598d17a44940123346bbea4bb263ac30800aafaf301acb10ae0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0ad284631c8d240be0de4326f19e837e68d32c8dc812fbb399b61a3b138aa1fc0fc114b1a6b1d476d27ca8e6cf37161d9290ed6f967a52d6bc82398c075b4aaa
|
7
|
+
data.tar.gz: 1b3b611ee16a1f2397d0fa1e0cc5b1ae2e66346d4ddcb5ed3c3be64bf4de0393912895de92e979aa1d484badb904d534a68545443af21fd022dcf0c96c0ff7b1
|
@@ -0,0 +1,46 @@
|
|
1
|
+
name: CI
|
2
|
+
|
3
|
+
on:
|
4
|
+
push:
|
5
|
+
tags-ignore:
|
6
|
+
- '*'
|
7
|
+
branches:
|
8
|
+
- '*'
|
9
|
+
|
10
|
+
jobs:
|
11
|
+
build:
|
12
|
+
name: Continuous Integration
|
13
|
+
runs-on: ubuntu-latest
|
14
|
+
|
15
|
+
steps:
|
16
|
+
- uses: actions/checkout@v1
|
17
|
+
|
18
|
+
- name: Setup Ruby
|
19
|
+
uses: actions/setup-ruby@v1
|
20
|
+
with:
|
21
|
+
ruby-version: 2.7.x
|
22
|
+
|
23
|
+
- name: Cache Gems
|
24
|
+
uses: actions/cache@v1
|
25
|
+
with:
|
26
|
+
path: vendor/bundle
|
27
|
+
key: ${{ runner.os }}-gem-${{ hashFiles('**/Gemfile') }}
|
28
|
+
restore-keys: |
|
29
|
+
${{ runner.os }}-gem-
|
30
|
+
|
31
|
+
- name: Install Gems
|
32
|
+
run: |
|
33
|
+
gem install bundler
|
34
|
+
bundle config path vendor/bundle
|
35
|
+
bundle install --jobs 4 --retry 3
|
36
|
+
|
37
|
+
- name: Test
|
38
|
+
env:
|
39
|
+
MA_ENDPOINT: ${{ secrets.MA_ENDPOINT }}
|
40
|
+
MA_ENDPOINT_USER: ${{ secrets.MA_ENDPOINT_USER }}
|
41
|
+
MA_ENDPOINT_PASSWORD: ${{ secrets.MA_ENDPOINT_PASSWORD }}
|
42
|
+
WEBMOCK_ALLOW_HOST: ${{ secrets.WEBMOCK_ALLOW_HOST }}
|
43
|
+
run: bundle exec rspec --profile 10 --format progress
|
44
|
+
|
45
|
+
- name: Lint
|
46
|
+
run: bundle exec rubocop --parallel --display-cop-names
|
@@ -0,0 +1,69 @@
|
|
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/.gitignore
CHANGED
@@ -1,6 +1,3 @@
|
|
1
|
-
Gemfile.lock
|
2
|
-
.idea
|
3
|
-
|
4
1
|
*.tar.gz
|
5
2
|
*.gem
|
6
3
|
*.rbc
|
@@ -13,9 +10,12 @@ Gemfile.lock
|
|
13
10
|
/test/tmp/
|
14
11
|
/test/version_tmp/
|
15
12
|
/tmp/
|
13
|
+
nginx/*.key
|
14
|
+
nginx/*.pem
|
16
15
|
|
17
16
|
# Used by dotenv library to load environment variables.
|
18
17
|
# .env
|
18
|
+
*.env
|
19
19
|
|
20
20
|
## Specific to RubyMotion:
|
21
21
|
.dat*
|
@@ -46,9 +46,9 @@ build-iPhoneSimulator/
|
|
46
46
|
|
47
47
|
# for a library or gem, you might want to ignore these files since the code is
|
48
48
|
# intended to run in multiple environments; otherwise, check them in:
|
49
|
-
|
50
|
-
|
51
|
-
|
49
|
+
Gemfile.lock
|
50
|
+
.ruby-version
|
51
|
+
.ruby-gemset
|
52
52
|
|
53
53
|
# unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
|
54
54
|
.rvmrc
|
data/.overcommit.yml
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
# Use this file to configure the Overcommit hooks you wish to use. This will
|
2
|
+
# extend the default configuration defined in:
|
3
|
+
# https://github.com/sds/overcommit/blob/master/config/default.yml
|
4
|
+
#
|
5
|
+
# At the topmost level of this YAML file is a key representing type of hook
|
6
|
+
# being run (e.g. pre-commit, commit-msg, etc.). Within each type you can
|
7
|
+
# customize each hook, such as whether to only run it on certain files (via
|
8
|
+
# `include`), whether to only display output if it fails (via `quiet`), etc.
|
9
|
+
#
|
10
|
+
# For a complete list of hooks, see:
|
11
|
+
# https://github.com/sds/overcommit/tree/master/lib/overcommit/hook
|
12
|
+
#
|
13
|
+
# For a complete list of options that you can use to customize hooks, see:
|
14
|
+
# https://github.com/sds/overcommit#configuration
|
15
|
+
#
|
16
|
+
# Uncomment the following lines to make the configuration take effect.
|
17
|
+
|
18
|
+
PreCommit:
|
19
|
+
Fasterer:
|
20
|
+
enabled: true
|
21
|
+
|
22
|
+
Flay:
|
23
|
+
enabled: true
|
24
|
+
|
25
|
+
Pronto:
|
26
|
+
enabled: true
|
27
|
+
|
28
|
+
Reek:
|
29
|
+
enabled: true
|
30
|
+
|
31
|
+
RuboCop:
|
32
|
+
enabled: true
|
33
|
+
|
34
|
+
RubySyntax:
|
35
|
+
enabled: true
|
data/.rspec
CHANGED
data/.rubocop.yml
CHANGED
@@ -1,17 +1,63 @@
|
|
1
|
-
|
2
|
-
Max: 120
|
1
|
+
inherit_from: .rubocop_todo.yml
|
3
2
|
|
4
|
-
|
5
|
-
|
3
|
+
AllCops:
|
4
|
+
TargetRubyVersion: 2.7
|
6
5
|
|
7
|
-
|
6
|
+
Layout/MultilineMethodCallIndentation:
|
7
|
+
EnforcedStyle: indented
|
8
|
+
|
9
|
+
Layout/ParameterAlignment:
|
10
|
+
EnforcedStyle: with_fixed_indentation
|
11
|
+
|
12
|
+
Lint/AssignmentInCondition:
|
13
|
+
AllowSafeAssignment: true
|
14
|
+
|
15
|
+
Lint/SafeNavigationWithEmpty:
|
8
16
|
Enabled: false
|
9
17
|
|
10
18
|
Metrics/BlockLength:
|
19
|
+
Exclude:
|
20
|
+
- spec/**/*.rb
|
21
|
+
|
22
|
+
Metrics/MethodLength:
|
11
23
|
Enabled: false
|
12
24
|
|
13
|
-
Style/
|
14
|
-
EnforcedStyle:
|
25
|
+
Style/Alias:
|
26
|
+
EnforcedStyle: prefer_alias_method
|
27
|
+
|
28
|
+
Style/FrozenStringLiteralComment:
|
29
|
+
Enabled: true
|
15
30
|
|
16
|
-
Style/
|
31
|
+
Style/HashEachMethods:
|
32
|
+
Enabled: true
|
33
|
+
|
34
|
+
Style/HashTransformKeys:
|
35
|
+
Enabled: true
|
36
|
+
|
37
|
+
Style/HashTransformValues:
|
38
|
+
Enabled: true
|
39
|
+
|
40
|
+
Style/PercentLiteralDelimiters:
|
41
|
+
PreferredDelimiters:
|
42
|
+
default: "()"
|
43
|
+
"%i": "()"
|
44
|
+
"%I": "()"
|
45
|
+
"%r": "()"
|
46
|
+
"%w": "()"
|
47
|
+
"%W": "()"
|
48
|
+
|
49
|
+
Style/RegexpLiteral:
|
50
|
+
EnforcedStyle: slashes
|
51
|
+
AllowInnerSlashes: false
|
52
|
+
|
53
|
+
Style/StringLiterals:
|
54
|
+
EnforcedStyle: double_quotes
|
55
|
+
|
56
|
+
Style/SymbolArray:
|
17
57
|
Enabled: false
|
58
|
+
|
59
|
+
Style/TrailingCommaInArrayLiteral:
|
60
|
+
EnforcedStyleForMultiline: comma
|
61
|
+
|
62
|
+
Style/TrailingCommaInHashLiteral:
|
63
|
+
EnforcedStyleForMultiline: comma
|
data/.rubocop_todo.yml
ADDED
@@ -0,0 +1,92 @@
|
|
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
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,27 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## 3.0.0
|
4
|
+
|
5
|
+
- Support for Ruby < 2.5 dropped
|
6
|
+
|
7
|
+
## 2.2.0
|
8
|
+
|
9
|
+
- Add `Release` model
|
10
|
+
|
11
|
+
## 2.1.1
|
12
|
+
|
13
|
+
- Fix UTF-8 conversion errors
|
14
|
+
- Don't `load!` unconditionally on `find!` and `find_by!`
|
15
|
+
|
16
|
+
## 2.1.0
|
17
|
+
|
18
|
+
- Added Ruby compatibility down to 2.1
|
19
|
+
- Band and Label: return `NilDate`
|
20
|
+
|
21
|
+
## 2.0.0
|
22
|
+
|
23
|
+
- Artist returns `NilDate`s
|
24
|
+
|
3
25
|
## 1.0.0
|
4
26
|
|
5
27
|
- Add `Artist#photo`
|
data/Gemfile
CHANGED
data/LICENSE.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
Copyright (c) 2016 Florian Dejonckheere
|
1
|
+
Copyright (c) 2016-2020 Florian Dejonckheere
|
2
2
|
|
3
3
|
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
4
4
|
|
data/README.md
CHANGED
@@ -1,23 +1,31 @@
|
|
1
|
-
# Metal Archives
|
1
|
+
# Metal Archives Ruby API
|
2
|
+
|
3
|
+
MetalArchives is a Ruby API that transparently wraps, caches and normalizes the [Metal Archives](https://www.metal-archives.com) website.
|
2
4
|
|
3
5
|
## Installation
|
4
6
|
|
5
|
-
|
6
|
-
|
7
|
+
Add this line to your application's Gemfile.
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem "metal_archives", "0.1.0"
|
7
11
|
```
|
8
12
|
|
9
|
-
|
13
|
+
And then execute:
|
10
14
|
|
11
|
-
```
|
12
|
-
|
15
|
+
```sh
|
16
|
+
bundle
|
13
17
|
```
|
14
18
|
|
15
|
-
|
16
|
-
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
```sh
|
22
|
+
gem install metal_archives
|
17
23
|
```
|
18
24
|
|
19
25
|
## Configuration
|
20
26
|
|
27
|
+
Configure MetalArchives before using it:
|
28
|
+
|
21
29
|
```ruby
|
22
30
|
MetalArchives.configure do |c|
|
23
31
|
## Application identity (required)
|
@@ -36,7 +44,9 @@ MetalArchives.configure do |c|
|
|
36
44
|
c.cache_size = 100
|
37
45
|
|
38
46
|
## Metal Archives endpoint (optional, overrides default)
|
39
|
-
# c.endpoint =
|
47
|
+
# c.endpoint = "https://www.metal-archives.com/"
|
48
|
+
# c.endpoint_user = "my_user"
|
49
|
+
# c.endpoint_password = "my_password"
|
40
50
|
|
41
51
|
## Custom logger (optional)
|
42
52
|
c.logger = Logger.new File.new('metal_archives.log')
|
@@ -77,79 +87,40 @@ Refer to the model's [RDoc documentation](https://floriandejonckheere.github.io/
|
|
77
87
|
|
78
88
|
## Lazy loading
|
79
89
|
|
80
|
-
By default when an model (Artist, Band, ...) is created, no data is fetched.
|
90
|
+
By default when an model (Artist, Band, ...) is created, no data is fetched.
|
91
|
+
This leads to instantiation of a model with an invalid ID not throwing any errors.
|
92
|
+
Calling any attribute other than `id` will cause all data to be fetched and any errors to be thrown.
|
93
|
+
Refer to the respective methods to find out what errors are thrown in what circumstances.
|
81
94
|
|
82
95
|
Models can be forced to load all data by calling the `:load!` method.
|
83
96
|
|
84
97
|
## Cache
|
85
98
|
|
86
|
-
In order not to stress the Metal Archives server, you can quickly set up a local proxy that caches the requests.
|
99
|
+
In order not to stress the Metal Archives server, you can quickly set up a local proxy that caches the requests.
|
87
100
|
|
88
101
|
```
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
# Set cache key to include identifying components
|
93
|
-
proxy_cache_key $scheme$proxy_host$request_uri;
|
94
|
-
|
95
|
-
# Add cache status to log
|
96
|
-
log_format cache '$remote_addr - $remote_user [$time_local] "$request" $status $body_bytes_sent "$http_referer" "$http_user_agent" cs=$upstream_cache_status';
|
97
|
-
|
98
|
-
server {
|
99
|
-
server_name metal-archives.myhost.com;
|
100
|
-
listen 443 ssl;
|
101
|
-
listen [::]:443 ssl;
|
102
|
-
|
103
|
-
ssl_certificate /path/to/ssl_certificate.crt;
|
104
|
-
ssl_certificate_key /path/to/ssl_certificate_key.key;
|
105
|
-
|
106
|
-
access_log /var/log/nginx/metal_archives_access.log;
|
107
|
-
error_log /var/log/nginx/metal_archives_error.log;
|
108
|
-
|
109
|
-
# Limit HTTP requests
|
110
|
-
limit_req_zone $binary_remote_addr zone=ma_limit_req:10m rate=2r/s;
|
111
|
-
|
112
|
-
location / {
|
113
|
-
proxy_redirect off;
|
114
|
-
proxy_set_header Host www.metal-archives.com;
|
115
|
-
proxy_set_header X-Forwarded-Host $host;
|
116
|
-
proxy_set_header X-Forwarded-Server $host;
|
117
|
-
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
118
|
-
proxy_set_header X-Real-IP $remote_addr;
|
119
|
-
|
120
|
-
proxy_pass https://www.metal-archives.com/;
|
121
|
-
|
122
|
-
limit_req zone=ma_limit_req burst=5;
|
123
|
-
|
124
|
-
proxy_ignore_headers X-Accel-Expires;
|
125
|
-
proxy_ignore_headers Expires;
|
126
|
-
proxy_ignore_headers Cache-Control;
|
127
|
-
proxy_ignore_headers Set-Cookie;
|
102
|
+
docker-compose up -d
|
103
|
+
```
|
128
104
|
|
129
|
-
|
130
|
-
proxy_hide_header Pragma;
|
105
|
+
A caching proxy server is now available on `http://localhost/`.
|
131
106
|
|
132
|
-
|
133
|
-
proxy_cache metal_archives;
|
134
|
-
proxy_cache_valid 200 301 302 30d;
|
135
|
-
proxy_cache_valid 404 7d;
|
136
|
-
expires 30d;
|
137
|
-
}
|
107
|
+
## Testing
|
138
108
|
|
139
|
-
|
140
|
-
}
|
141
|
-
```
|
109
|
+
Run tests:
|
142
110
|
|
143
|
-
## Testing
|
144
111
|
```
|
145
|
-
|
112
|
+
bundle exec rake test
|
146
113
|
```
|
147
114
|
|
148
115
|
## Documentation
|
116
|
+
|
117
|
+
Generate documentation:
|
118
|
+
|
149
119
|
```
|
150
120
|
$ bundle exec rake rdoc
|
151
121
|
```
|
152
122
|
|
153
123
|
## Copyright
|
154
124
|
|
155
|
-
Copyright 2016 Florian Dejonckheere.
|
125
|
+
Copyright 2016-2020 Florian Dejonckheere.
|
126
|
+
All content acquired through the usage of this API is copyrighted by the respective owner.
|