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.
Files changed (49) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ci.yml +59 -12
  3. data/.rspec +1 -0
  4. data/.rubocop.yml +34 -20
  5. data/CHANGELOG.md +4 -0
  6. data/LICENSE.md +17 -4
  7. data/README.md +29 -14
  8. data/bin/console +8 -11
  9. data/config/inflections.rb +7 -0
  10. data/config/initializers/.keep +0 -0
  11. data/docker-compose.yml +10 -1
  12. data/lib/metal_archives.rb +56 -22
  13. data/lib/metal_archives/cache/base.rb +40 -0
  14. data/lib/metal_archives/cache/memory.rb +68 -0
  15. data/lib/metal_archives/cache/null.rb +22 -0
  16. data/lib/metal_archives/cache/redis.rb +49 -0
  17. data/lib/metal_archives/collection.rb +3 -5
  18. data/lib/metal_archives/configuration.rb +28 -21
  19. data/lib/metal_archives/errors.rb +9 -1
  20. data/lib/metal_archives/http_client.rb +42 -46
  21. data/lib/metal_archives/models/artist.rb +55 -26
  22. data/lib/metal_archives/models/band.rb +43 -36
  23. data/lib/metal_archives/models/{base_model.rb → base.rb} +53 -53
  24. data/lib/metal_archives/models/label.rb +7 -8
  25. data/lib/metal_archives/models/release.rb +11 -17
  26. data/lib/metal_archives/parsers/artist.rb +40 -35
  27. data/lib/metal_archives/parsers/band.rb +73 -29
  28. data/lib/metal_archives/parsers/base.rb +14 -0
  29. data/lib/metal_archives/parsers/country.rb +21 -0
  30. data/lib/metal_archives/parsers/date.rb +31 -0
  31. data/lib/metal_archives/parsers/genre.rb +67 -0
  32. data/lib/metal_archives/parsers/label.rb +21 -13
  33. data/lib/metal_archives/parsers/parser.rb +15 -77
  34. data/lib/metal_archives/parsers/release.rb +22 -18
  35. data/lib/metal_archives/parsers/year.rb +29 -0
  36. data/lib/metal_archives/version.rb +3 -3
  37. data/metal_archives.env.example +7 -4
  38. data/metal_archives.gemspec +7 -4
  39. data/nginx/default.conf +2 -2
  40. metadata +76 -32
  41. data/.github/workflows/release.yml +0 -69
  42. data/.rubocop_todo.yml +0 -92
  43. data/lib/metal_archives/lru_cache.rb +0 -61
  44. data/lib/metal_archives/middleware/cache_check.rb +0 -18
  45. data/lib/metal_archives/middleware/encoding.rb +0 -16
  46. data/lib/metal_archives/middleware/headers.rb +0 -38
  47. data/lib/metal_archives/middleware/rewrite_endpoint.rb +0 -38
  48. data/lib/metal_archives/nil_date.rb +0 -91
  49. data/lib/metal_archives/range.rb +0 -69
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3de990935b078060383b45f512b4c154a67714366af214c524925040fb95cb7b
4
- data.tar.gz: ff36ec2f5b1e5ab7bbe4c2e4593246d02f2bc780253bb9f247b5912fda8ef397
3
+ metadata.gz: cc72b807bbb20dcb70cfc38a6808b1088a3c5a187a6b033f82ef0083e5ff7794
4
+ data.tar.gz: b2424b28220556afc3c777efcd38e10f9b03d92d58905130e53723a0f5e5691c
5
5
  SHA512:
6
- metadata.gz: 1e4ceef2436f5d44f56979a9e0ecd399e5ddd61aea837e66e38cd48938ae71ccba32ed182b56bf75e8cbce29ee458443a97174b4fb93af808a0c42450868b9e1
7
- data.tar.gz: 75596c0feb38577c65a2e64279415a1c8510bb97b1cbb7cf722dd2ac7973e4050e65dfd1238b198519e4696a249ae12de121af7927243f1092cf6331e0dd566b
6
+ metadata.gz: 5d80a6bf547b425d5d85c1b789e62a9224cf77e06911e8e8e45f298041778e2b9e976e754fc1a6f43a939e2e5b5cabf581f7b43b8677d8d48f4023a11df516fb
7
+ data.tar.gz: 2911d68d5725d92def587f482cc01235c280e7989b1903cac2374632136e667f988384141ffbb2ae9c69bae95a555c7f7cac50e96e12af273e562bc372bb141c
@@ -1,32 +1,44 @@
1
- name: CI
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-latest
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@v1
28
+ - uses: actions/checkout@v2
17
29
 
18
- - name: Setup Ruby
19
- uses: actions/setup-ruby@v1
20
- with:
21
- ruby-version: 2.7.x
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@v1
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
@@ -1,2 +1,3 @@
1
+ --color
1
2
  --fail-fast
2
3
  --require spec_helper
data/.rubocop.yml CHANGED
@@ -1,7 +1,13 @@
1
- inherit_from: .rubocop_todo.yml
1
+ require:
2
+ - rubocop-performance
3
+ - rubocop-rspec
2
4
 
3
5
  AllCops:
4
- TargetRubyVersion: 2.7
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
- Exclude:
20
- - spec/**/*.rb
31
+ Enabled: false
32
+
33
+ Metrics/ClassLength:
34
+ Enabled: false
21
35
 
22
36
  Metrics/MethodLength:
23
37
  Enabled: false
24
38
 
25
- Style/Alias:
26
- EnforcedStyle: prefer_alias_method
39
+ Metrics/PerceivedComplexity:
40
+ Enabled: false
27
41
 
28
- Style/FrozenStringLiteralComment:
29
- Enabled: true
42
+ RSpec/ExampleLength:
43
+ Enabled: false
30
44
 
31
- Style/HashEachMethods:
32
- Enabled: true
45
+ RSpec/FilePath:
46
+ Exclude:
47
+ - spec/metal_archives/models/*
33
48
 
34
- Style/HashTransformKeys:
35
- Enabled: true
49
+ RSpec/MultipleExpectations:
50
+ Enabled: false
36
51
 
37
- Style/HashTransformValues:
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
- Enabled: false
68
+ EnforcedStyle: brackets
69
+
70
+ Style/TrailingCommaInArguments:
71
+ EnforcedStyleForMultiline: consistent_comma
58
72
 
59
73
  Style/TrailingCommaInArrayLiteral:
60
- EnforcedStyleForMultiline: comma
74
+ EnforcedStyleForMultiline: consistent_comma
61
75
 
62
76
  Style/TrailingCommaInHashLiteral:
63
- EnforcedStyleForMultiline: comma
77
+ EnforcedStyleForMultiline: consistent_comma
data/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # Changelog
2
2
 
3
+ ## 3.1.0
4
+
5
+ - Add members property on band
6
+
3
7
  ## 3.0.0
4
8
 
5
9
  - Dropped support for Ruby < 2.5
data/LICENSE.md CHANGED
@@ -1,7 +1,20 @@
1
- Copyright (c) 2016-2020 Florian Dejonckheere
1
+ Copyright 2020 Florian Dejonckheere
2
2
 
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:
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 included in all copies or substantial portions of the Software.
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, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
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
@@ -33,8 +37,10 @@ MetalArchives.configure do |c|
33
37
  c.app_version = "1.0"
34
38
  c.app_contact = "support@mymusicapp.com"
35
39
 
36
- ## Custom cache size per object class (optional, overrides defaults)
37
- # c.cache_size = 100
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 }
38
44
 
39
45
  ## Metal Archives endpoint (optional, overrides default)
40
46
  # c.endpoint = "https://www.metal-archives.com/"
@@ -56,18 +62,18 @@ require "metal_archives"
56
62
  @alquimia_list = MetalArchives::Band.search("Alquimia")
57
63
 
58
64
  # Find bands by name
59
- @iron_maiden = MetalArchives::Band.find_by(:name => "Iron Maiden")
65
+ @iron_maiden = MetalArchives::Band.find_by(name: "Iron Maiden")
60
66
 
61
67
  # Find bands by attributes
62
68
  require "countries"
63
69
 
64
- @bands_in_belgium = MetalArchives::Band.search_by :country => ISO3166::Country["BE"]
65
- @bands_formed_in_1990 = MetalArchives::Band.search_by :year => Range.new(Date.new(1990))
70
+ @bands_in_belgium = MetalArchives::Band.search_by(country: ISO3166::Country["BE"])
71
+ @bands_formed_in_1990 = MetalArchives::Band.search_by(year: 1990..)
66
72
 
67
- # Metal Archives" usual tips apply
73
+ # Metal Archives' usual tips apply
68
74
 
69
- @bands_containing_hell = MetalArchives::Band.search_by :name => "*hell*"
70
- @non_melodic_death_bands = MetalArchives::Band.search_by :genre => "death -melodic"
75
+ @bands_containing_hell = MetalArchives::Band.search_by name: "*hell*"
76
+ @non_melodic_death_bands = MetalArchives::Band.search_by genre: "death -melodic"
71
77
 
72
78
  # Methods returning multiple results return a MetalArchives::Collection.
73
79
  # Collection wraps a paginated resource, and can be used to iterate over huge queries.
@@ -85,17 +91,27 @@ This leads to instantiation of a model with an invalid ID not throwing any error
85
91
  Calling any attribute other than `id` will cause all data to be fetched and any errors to be thrown.
86
92
  Refer to the respective methods to find out what errors are thrown in what circumstances.
87
93
 
88
- Models can be forced to load all data by calling the `:load!` method.
94
+ Models can be forced to load all data by calling the `load!` method.
89
95
 
90
96
  ## Cache
91
97
 
92
- In order not to stress the Metal Archives server, you can quickly set up a local proxy that caches the requests.
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.
93
104
 
94
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
95
111
  docker-compose up -d
96
112
  ```
97
113
 
98
- A caching proxy server is now available on `http://localhost/`.
114
+ A caching proxy server is now available on `http://localhost:8080/`.
99
115
 
100
116
  ## Testing
101
117
 
@@ -113,7 +129,6 @@ Generate documentation:
113
129
  $ bundle exec rake rdoc
114
130
  ```
115
131
 
116
- ## Copyright
132
+ ## License
117
133
 
118
- Copyright 2016-2020 Florian Dejonckheere.
119
- 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
- ## Request throttling (optional, overrides defaults)
19
- # c.request_rate = 1
20
- # c.request_timeout = 3
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
- # c.endpoint = "http://www.metal-archives.com/"
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 STDOUT
29
+ c.logger = Logger.new $stdout
33
30
  c.logger.level = Logger::WARN
34
31
  end
35
32
 
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ MetalArchives.loader.inflector.inflect(
4
+ "id" => "ID",
5
+ "http_client" => "HTTPClient",
6
+ "lru_cache" => "LRUCache",
7
+ )
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
- - "80:80"
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:
@@ -1,33 +1,49 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "openssl"
4
-
5
3
  require "zeitwerk"
6
- loader = Zeitwerk::Loader.for_gem
7
- load.enable_reloading if ENV["METAL_ARCHIVES_ENV"] == "development"
8
- loader.inflector.inflect(
9
- "id" => "ID",
10
- "api" => "API",
11
- "http_client" => "HTTPClient",
12
- "lru_cache" => "LRUCache"
13
- )
14
- loader.collapse("lib/metal_archives/models")
15
- loader.setup
4
+ require "byebug" if ENV["METAL_ARCHIVES_ENV"] == "development"
5
+ require "active_support/all"
16
6
 
17
7
  ##
18
8
  # Metal Archives Ruby API
19
9
  #
20
10
  module MetalArchives
21
11
  class << self
12
+ # Code loader instance
13
+ attr_reader :loader
14
+
15
+ ##
16
+ # Root path
17
+ #
18
+ def root
19
+ @root ||= Pathname.new(File.expand_path(File.join("..", ".."), __FILE__))
20
+ end
21
+
22
+ ##
23
+ # HTTP client
24
+ #
25
+ def http
26
+ @http ||= HTTPClient.new
27
+ end
28
+
22
29
  ##
23
30
  # API configuration
24
31
  #
25
32
  # Instance of rdoc-ref:MetalArchives::Configuration
26
33
  #
27
34
  def config
28
- raise MetalArchives::Errors::InvalidConfigurationError, "Gem has not been configured" unless @config
35
+ @config ||= Configuration.new
36
+ end
29
37
 
30
- @config
38
+ ##
39
+ # Cache instance
40
+ #
41
+ def cache
42
+ raise MetalArchives::Errors::InvalidConfigurationError, "cache has not been configured" unless config.cache_strategy
43
+
44
+ @cache ||= Cache
45
+ .const_get(loader.inflector.camelize(config.cache_strategy, root))
46
+ .new(config.cache_options)
31
47
  end
32
48
 
33
49
  ##
@@ -40,19 +56,37 @@ module MetalArchives
40
56
  # - rdoc-ref:InvalidConfigurationException
41
57
  #
42
58
  def configure
43
- raise MetalArchives::Errors::InvalidConfigurationError, "No configuration block given" unless block_given?
59
+ raise Errors::InvalidConfigurationError, "no configuration block given" unless block_given?
60
+
61
+ yield config
62
+
63
+ config.validate!
64
+ end
44
65
 
45
- @config = MetalArchives::Configuration.new
46
- yield @config
66
+ ##
67
+ # Set up application framework
68
+ #
69
+ def setup
70
+ @loader = Zeitwerk::Loader.for_gem
47
71
 
48
- raise MetalArchives::Errors::InvalidConfigurationError, "app_name has not been configured" unless MetalArchives.config.app_name && !MetalArchives.config.app_name.empty?
49
- raise MetalArchives::Errors::InvalidConfigurationError, "app_version has not been configured" unless MetalArchives.config.app_version && !MetalArchives.config.app_version.empty?
72
+ # Register inflections
73
+ require root.join("config/inflections.rb")
50
74
 
51
- return if MetalArchives.config.app_contact && !MetalArchives.config.app_contact.empty?
75
+ # Set up code loader
76
+ loader.enable_reloading if ENV["METAL_ARCHIVES_ENV"] == "development"
77
+ loader.collapse(root.join("lib/metal_archives/models"))
78
+ loader.do_not_eager_load(root.join("lib/metal_archives/cache"))
79
+ loader.setup
80
+ loader.eager_load
52
81
 
53
- raise MetalArchives::Errors::InvalidConfigurationError, "app_contact has not been configured"
82
+ # Load initializers
83
+ Dir[root.join("config/initializers/*.rb")].sort.each { |f| require f }
54
84
  end
55
85
  end
56
86
  end
57
87
 
58
- loader.eager_load
88
+ def reload!
89
+ MetalArchives.loader.reload
90
+ end
91
+
92
+ MetalArchives.setup