Module: MetalArchives
- Defined in:
- lib/metal_archives.rb,
lib/metal_archives/errors.rb,
lib/metal_archives/version.rb,
lib/metal_archives/cache/base.rb,
lib/metal_archives/cache/null.rb,
lib/metal_archives/collection.rb,
lib/metal_archives/cache/redis.rb,
lib/metal_archives/http_client.rb,
lib/metal_archives/models/band.rb,
lib/metal_archives/models/base.rb,
lib/metal_archives/cache/memory.rb,
lib/metal_archives/models/label.rb,
lib/metal_archives/parsers/band.rb,
lib/metal_archives/parsers/base.rb,
lib/metal_archives/parsers/date.rb,
lib/metal_archives/parsers/year.rb,
lib/metal_archives/configuration.rb,
lib/metal_archives/models/artist.rb,
lib/metal_archives/parsers/genre.rb,
lib/metal_archives/parsers/label.rb,
lib/metal_archives/models/release.rb,
lib/metal_archives/parsers/artist.rb,
lib/metal_archives/parsers/parser.rb,
lib/metal_archives/parsers/country.rb,
lib/metal_archives/parsers/release.rb
Overview
Metal Archives Ruby API
Defined Under Namespace
Modules: Cache, Errors, Parsers, Version Classes: Artist, Band, Base, Collection, Configuration, HTTPClient, Label, Release
Constant Summary collapse
Class Attribute Summary collapse
-
.loader ⇒ Object
readonly
Code loader instance.
Class Method Summary collapse
-
.cache ⇒ Object
Cache instance.
-
.config ⇒ Object
API configuration.
-
.configure {|config| ... } ⇒ Object
Configure API options.
-
.http ⇒ Object
HTTP client.
-
.root ⇒ Object
Root path.
-
.setup ⇒ Object
Set up application framework.
Class Attribute Details
.loader ⇒ Object (readonly)
Code loader instance
13 14 15 |
# File 'lib/metal_archives.rb', line 13 def loader @loader end |
Class Method Details
.cache ⇒ Object
Cache instance
41 42 43 44 45 46 47 |
# File 'lib/metal_archives.rb', line 41 def cache raise MetalArchives::Errors::InvalidConfigurationError, "cache has not been configured" unless config.cache_strategy @cache ||= Cache .const_get(loader.inflector.camelize(config.cache_strategy, root)) .new(config.) end |
.config ⇒ Object
API configuration
Instance of MetalArchives::Configuration
34 35 36 |
# File 'lib/metal_archives.rb', line 34 def config @config ||= Configuration.new end |
.configure {|config| ... } ⇒ Object
Configure API options.
A block must be specified, to which a MetalArchives::Configuration parameter will be passed.
- Raises
-
InvalidConfigurationException
58 59 60 61 62 63 64 |
# File 'lib/metal_archives.rb', line 58 def configure raise Errors::InvalidConfigurationError, "no configuration block given" unless block_given? yield config config.validate! end |
.http ⇒ Object
HTTP client
25 26 27 |
# File 'lib/metal_archives.rb', line 25 def http @http ||= HTTPClient.new end |
.root ⇒ Object
Root path
18 19 20 |
# File 'lib/metal_archives.rb', line 18 def root @root ||= Pathname.new(File.(File.join("..", ".."), __FILE__)) end |
.setup ⇒ Object
Set up application framework
69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 |
# File 'lib/metal_archives.rb', line 69 def setup @loader = Zeitwerk::Loader.for_gem # Register inflections require root.join("config/inflections.rb") # Set up code loader loader.enable_reloading if ENV["METAL_ARCHIVES_ENV"] == "development" loader.collapse(root.join("lib/metal_archives/models")) loader.do_not_eager_load(root.join("lib/metal_archives/cache")) loader.setup loader.eager_load # Load initializers Dir[root.join("config/initializers/*.rb")].sort.each { |f| require f } end |