active_brainz 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/Gemfile +9 -0
- data/LICENSE.md +21 -0
- data/README.md +83 -0
- data/config/inflections.rb +9 -0
- data/lib/active_brainz.rb +36 -0
- data/lib/active_brainz/models/area/area.rb +123 -0
- data/lib/active_brainz/models/area/area_type.rb +37 -0
- data/lib/active_brainz/models/artist/artist.rb +150 -0
- data/lib/active_brainz/models/artist/artist_alias.rb +62 -0
- data/lib/active_brainz/models/artist/artist_alias_type.rb +37 -0
- data/lib/active_brainz/models/artist/artist_credit.rb +60 -0
- data/lib/active_brainz/models/artist/artist_credit_name.rb +46 -0
- data/lib/active_brainz/models/artist/artist_type.rb +37 -0
- data/lib/active_brainz/models/base.rb +16 -0
- data/lib/active_brainz/models/concerns/has_begin_end_date.rb +27 -0
- data/lib/active_brainz/models/concerns/has_gid.rb +15 -0
- data/lib/active_brainz/models/concerns/has_parent_children.rb +20 -0
- data/lib/active_brainz/models/gender/gender.rb +41 -0
- data/lib/active_brainz/models/genre/genre.rb +36 -0
- data/lib/active_brainz/models/genre/genre_alias.rb +42 -0
- data/lib/active_brainz/models/label/label.rb +121 -0
- data/lib/active_brainz/models/label/label_alias.rb +62 -0
- data/lib/active_brainz/models/label/label_alias_type.rb +37 -0
- data/lib/active_brainz/models/label/label_type.rb +37 -0
- data/lib/active_brainz/models/medium/medium.rb +68 -0
- data/lib/active_brainz/models/place/place.rb +97 -0
- data/lib/active_brainz/models/place/place_alias.rb +62 -0
- data/lib/active_brainz/models/place/place_alias_type.rb +37 -0
- data/lib/active_brainz/models/place/place_type.rb +37 -0
- data/lib/active_brainz/models/recording/recording.rb +101 -0
- data/lib/active_brainz/models/release/release.rb +150 -0
- data/lib/active_brainz/models/release/release_group.rb +100 -0
- data/lib/active_brainz/models/track/track.rb +72 -0
- data/lib/active_brainz/version.rb +24 -0
- metadata +372 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: de315d1362f515a08a4b332ca37cb680c1f7cc0b56631d267ca6d01dba86f064
|
4
|
+
data.tar.gz: 1b10dab84039dc27fc85e3180f1d31c280ff961bca4055600bbafa67cc929cde
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: b81268c56a7c2ffa2f527c6c66d7bf766c7d1d39058df455d7116b667788bc40e244b9cef702564abbc627090b667c78f4f40d3288fbc22f5c9069b03b728174
|
7
|
+
data.tar.gz: 59378fea9c9b97441c95cdddd8d55e724cb011ec4b39de09801de7207eeadb22aa5de94c818e658a82c9dc3502de8d8da96e49a3bceb95b180e890fad15a06fc
|
data/Gemfile
ADDED
data/LICENSE.md
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2020 Florian Dejonckheere
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,83 @@
|
|
1
|
+
# ActiveBrainz
|
2
|
+
|
3
|
+
![Continuous Integration](https://github.com/floriandejonckheere/active_brainz/workflows/Continuous%20Integration/badge.svg)
|
4
|
+
![Release](https://img.shields.io/github/v/release/floriandejonckheere/active_brainz?label=Latest%20release)
|
5
|
+
|
6
|
+
ActiveRecord integrations for the [MusicBrainz database](https://musicbrainz.org/doc/MusicBrainz_Database).
|
7
|
+
|
8
|
+
## Installation
|
9
|
+
|
10
|
+
Add this line to your application's Gemfile:
|
11
|
+
|
12
|
+
```ruby
|
13
|
+
gem "active_brainz"
|
14
|
+
```
|
15
|
+
|
16
|
+
And then execute:
|
17
|
+
|
18
|
+
$ bundle install
|
19
|
+
|
20
|
+
Or install it yourself as:
|
21
|
+
|
22
|
+
$ gem install active_brainz
|
23
|
+
|
24
|
+
## Configuration
|
25
|
+
|
26
|
+
Configure your `database.yml` with the MusicBrainz database:
|
27
|
+
|
28
|
+
```yaml
|
29
|
+
musicbrainz:
|
30
|
+
adapter: postgresql
|
31
|
+
host: postgres
|
32
|
+
port: 5432
|
33
|
+
database: musicbrainz
|
34
|
+
user: musicbrainz
|
35
|
+
password: musicbrainz
|
36
|
+
```
|
37
|
+
|
38
|
+
## Usage
|
39
|
+
|
40
|
+
TODO: Write usage instructions here
|
41
|
+
|
42
|
+
## Documentation
|
43
|
+
|
44
|
+
The SQL scripts used to create the MusicBrainz database schema can be found on their [Github repository](https://github.com/metabrainz/musicbrainz-server/tree/master/admin/sql).
|
45
|
+
|
46
|
+
## Development
|
47
|
+
|
48
|
+
After checking out the repo, run `bin/setup` to install dependencies.
|
49
|
+
Then, run `rake spec` to run the tests.
|
50
|
+
You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
51
|
+
Modify `config/database.rb` or use environment variables to connect to a non-localhost server.
|
52
|
+
|
53
|
+
The following rake tasks are available:
|
54
|
+
|
55
|
+
```
|
56
|
+
rake active_brainz:models:annotate # Annotate models
|
57
|
+
rake active_brainz:models:generate # Generates models based on db/schema.rb file
|
58
|
+
rake active_brainz:models:render # Generate and annotate models
|
59
|
+
rake db:create # Creates the database
|
60
|
+
rake db:drop # Drops the database
|
61
|
+
rake db:schema:dump # Dumps the database structure to db/schema.rb
|
62
|
+
rake db:schema:load # Recreates the databases from the schema.rb file
|
63
|
+
rake spec # Run RSpec code examples
|
64
|
+
|
65
|
+
```
|
66
|
+
|
67
|
+
To release a new version, update the version number in `lib/active_brainz/version.rb`, commit it and create a git tag starting with `v`, and push it to the repository.
|
68
|
+
Github Actions will automatically run the test suite, build the `.gem` file and push it to [rubygems.org](https://rubygems.org).
|
69
|
+
|
70
|
+
If MusicBrainz' database schema version gets bumped, don't forget to bump the schema version in `lib/active_brainz/version.rb` as well.
|
71
|
+
|
72
|
+
## Contributing
|
73
|
+
|
74
|
+
Bug reports and pull requests are welcome on GitHub at [https://github.com/floriandejonckheere/active_brainz](https://github.com/floriandejonckheere/active_brainz).
|
75
|
+
This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/floriandejonckheere/active_brainz/blob/master/CODE_OF_CONDUCT.md).
|
76
|
+
|
77
|
+
## License
|
78
|
+
|
79
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
80
|
+
|
81
|
+
## Code of Conduct
|
82
|
+
|
83
|
+
Everyone interacting in the ActiveBrainz project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/floriandejonckheere/active_brainz/blob/master/CODE_OF_CONDUCT.md).
|
@@ -0,0 +1,36 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "zeitwerk"
|
4
|
+
require "byebug" if ENV["ACTIVE_BRAINZ_ENV"] == "development"
|
5
|
+
require "active_support/all"
|
6
|
+
|
7
|
+
module ActiveBrainz
|
8
|
+
class << self
|
9
|
+
# Code loader instance
|
10
|
+
attr_reader :loader
|
11
|
+
|
12
|
+
def root
|
13
|
+
@root ||= Pathname.new(File.expand_path(File.join("..", ".."), __FILE__))
|
14
|
+
end
|
15
|
+
|
16
|
+
def setup
|
17
|
+
@loader = Zeitwerk::Loader.for_gem
|
18
|
+
|
19
|
+
# Register inflections
|
20
|
+
require root.join("config/inflections.rb")
|
21
|
+
|
22
|
+
# Set up code loader
|
23
|
+
loader.enable_reloading if ENV["ACTIVE_BRAINZ_ENV"] == "development"
|
24
|
+
loader.collapse("lib/active_brainz/models")
|
25
|
+
loader.collapse("lib/active_brainz/models/*")
|
26
|
+
|
27
|
+
loader.setup
|
28
|
+
loader.eager_load
|
29
|
+
|
30
|
+
# Load initializers
|
31
|
+
Dir[root.join("config/initializers/*.rb")].sort.each { |f| require f }
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
ActiveBrainz.setup
|
@@ -0,0 +1,123 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module ActiveBrainz
|
4
|
+
class Area < Base
|
5
|
+
self.table_name = "area"
|
6
|
+
|
7
|
+
include HasGID
|
8
|
+
include HasBeginEndDate
|
9
|
+
|
10
|
+
belongs_to :area_type,
|
11
|
+
class_name: "AreaType",
|
12
|
+
foreign_key: "type",
|
13
|
+
optional: true
|
14
|
+
|
15
|
+
# has_many :area_aliases,
|
16
|
+
# class_name: "AreaAlias",
|
17
|
+
# foreign_key: "area"
|
18
|
+
|
19
|
+
# has_many :area_annotations,
|
20
|
+
# class_name: "AreaAnnotation",
|
21
|
+
# foreign_key: "area"
|
22
|
+
|
23
|
+
# has_many :area_attributes,
|
24
|
+
# class_name: "AreaAttribute",
|
25
|
+
# foreign_key: "area"
|
26
|
+
|
27
|
+
# has_many :area_tag_raws,
|
28
|
+
# class_name: "AreaTagRaw",
|
29
|
+
# foreign_key: "area"
|
30
|
+
|
31
|
+
# has_many :area_tags,
|
32
|
+
# class_name: "AreaTag",
|
33
|
+
# foreign_key: "area"
|
34
|
+
|
35
|
+
has_many :area_artists,
|
36
|
+
class_name: "Artist",
|
37
|
+
foreign_key: "area"
|
38
|
+
|
39
|
+
has_many :begin_area_artists,
|
40
|
+
class_name: "Artist",
|
41
|
+
foreign_key: "begin_area"
|
42
|
+
|
43
|
+
has_many :end_area_artists,
|
44
|
+
class_name: "Artist",
|
45
|
+
foreign_key: "end_area"
|
46
|
+
|
47
|
+
# has_many :area_country_areas,
|
48
|
+
# class_name: "CountryArea",
|
49
|
+
# foreign_key: "area"
|
50
|
+
|
51
|
+
# has_many :area_edit_areas,
|
52
|
+
# class_name: "EditArea",
|
53
|
+
# foreign_key: "area"
|
54
|
+
|
55
|
+
# has_many :area_editor_collection_areas,
|
56
|
+
# class_name: "EditorCollectionArea",
|
57
|
+
# foreign_key: "area"
|
58
|
+
|
59
|
+
# has_many :area_editors,
|
60
|
+
# class_name: "Editor",
|
61
|
+
# foreign_key: "area"
|
62
|
+
|
63
|
+
# has_many :area_iso_3166_1s,
|
64
|
+
# class_name: "Iso31661",
|
65
|
+
# foreign_key: "area"
|
66
|
+
|
67
|
+
# has_many :area_iso_3166_2s,
|
68
|
+
# class_name: "Iso31662",
|
69
|
+
# foreign_key: "area"
|
70
|
+
|
71
|
+
# has_many :area_iso_3166_3s,
|
72
|
+
# class_name: "Iso31663",
|
73
|
+
# foreign_key: "area"
|
74
|
+
|
75
|
+
has_many :area_labels,
|
76
|
+
class_name: "Label",
|
77
|
+
foreign_key: "area"
|
78
|
+
|
79
|
+
# has_many :area_new_ids,
|
80
|
+
# class_name: "AreaGIDRedirect",
|
81
|
+
# foreign_key: "new_id"
|
82
|
+
|
83
|
+
# has_many :area_places,
|
84
|
+
# class_name: "Place",
|
85
|
+
# foreign_key: "area"
|
86
|
+
|
87
|
+
attribute :name
|
88
|
+
attribute :comment
|
89
|
+
|
90
|
+
attribute :edits_pending, :integer
|
91
|
+
attribute :last_updated, :datetime
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
# == Schema Information
|
96
|
+
#
|
97
|
+
# Table name: area
|
98
|
+
#
|
99
|
+
# id :integer not null, primary key
|
100
|
+
# begin_date_day :integer
|
101
|
+
# begin_date_month :integer
|
102
|
+
# begin_date_year :integer
|
103
|
+
# comment :string(255) default(""), not null
|
104
|
+
# edits_pending :integer default(0), not null
|
105
|
+
# end_date_day :integer
|
106
|
+
# end_date_month :integer
|
107
|
+
# end_date_year :integer
|
108
|
+
# ended :boolean default(FALSE), not null
|
109
|
+
# gid :uuid not null
|
110
|
+
# last_updated :datetime
|
111
|
+
# name :string not null
|
112
|
+
# type :integer
|
113
|
+
#
|
114
|
+
# Indexes
|
115
|
+
#
|
116
|
+
# area_idx_gid (gid) UNIQUE
|
117
|
+
# area_idx_name (name)
|
118
|
+
# area_idx_name_txt (mb_simple_tsvector((name)::text)) USING gin
|
119
|
+
#
|
120
|
+
# Foreign Keys
|
121
|
+
#
|
122
|
+
# area_fk_type (type => area_type.id)
|
123
|
+
#
|
@@ -0,0 +1,37 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module ActiveBrainz
|
4
|
+
class AreaType < Base
|
5
|
+
self.table_name = "area_type"
|
6
|
+
|
7
|
+
include HasGID
|
8
|
+
include HasParentChildren
|
9
|
+
|
10
|
+
has_many :areas,
|
11
|
+
class_name: "Area",
|
12
|
+
foreign_key: "type"
|
13
|
+
|
14
|
+
attribute :name
|
15
|
+
attribute :description
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
# == Schema Information
|
20
|
+
#
|
21
|
+
# Table name: area_type
|
22
|
+
#
|
23
|
+
# id :integer not null, primary key
|
24
|
+
# child_order :integer default(0), not null
|
25
|
+
# description :text
|
26
|
+
# gid :uuid not null
|
27
|
+
# name :string(255) not null
|
28
|
+
# parent :integer
|
29
|
+
#
|
30
|
+
# Indexes
|
31
|
+
#
|
32
|
+
# area_type_idx_gid (gid) UNIQUE
|
33
|
+
#
|
34
|
+
# Foreign Keys
|
35
|
+
#
|
36
|
+
# area_type_fk_parent (parent => area_type.id)
|
37
|
+
#
|
@@ -0,0 +1,150 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module ActiveBrainz
|
4
|
+
class Artist < Base
|
5
|
+
self.table_name = "artist"
|
6
|
+
|
7
|
+
include HasGID
|
8
|
+
include HasBeginEndDate
|
9
|
+
|
10
|
+
belongs_to :artist_area,
|
11
|
+
class_name: "Area",
|
12
|
+
foreign_key: "area",
|
13
|
+
optional: true
|
14
|
+
|
15
|
+
belongs_to :artist_type,
|
16
|
+
class_name: "ArtistType",
|
17
|
+
foreign_key: "type",
|
18
|
+
optional: true
|
19
|
+
|
20
|
+
belongs_to :artist_begin_area,
|
21
|
+
class_name: "Area",
|
22
|
+
foreign_key: "begin_area",
|
23
|
+
optional: true
|
24
|
+
|
25
|
+
belongs_to :artist_end_area,
|
26
|
+
class_name: "Area",
|
27
|
+
foreign_key: "end_area",
|
28
|
+
optional: true
|
29
|
+
|
30
|
+
belongs_to :artist_gender,
|
31
|
+
class_name: "Gender",
|
32
|
+
foreign_key: "gender",
|
33
|
+
optional: true
|
34
|
+
|
35
|
+
has_many :artist_aliases,
|
36
|
+
class_name: "ArtistAlias",
|
37
|
+
foreign_key: "artist"
|
38
|
+
|
39
|
+
# has_many :artist_annotations,
|
40
|
+
# class_name: "ArtistAnnotation",
|
41
|
+
# foreign_key: "artist"
|
42
|
+
|
43
|
+
# has_many :artist_attributes,
|
44
|
+
# class_name: "ArtistAttribute",
|
45
|
+
# foreign_key: "artist"
|
46
|
+
|
47
|
+
has_many :artist_credit_names,
|
48
|
+
class_name: "ArtistCreditName",
|
49
|
+
foreign_key: "artist"
|
50
|
+
|
51
|
+
# has_many :artist_ipis,
|
52
|
+
# class_name: "ArtistIPI",
|
53
|
+
# foreign_key: "artist"
|
54
|
+
|
55
|
+
# has_many :artist_isnis,
|
56
|
+
# class_name: "ArtistISNI",
|
57
|
+
# foreign_key: "artist"
|
58
|
+
|
59
|
+
# has_many :artist_meta,
|
60
|
+
# class_name: "ArtistMeta",
|
61
|
+
# foreign_key: "id"
|
62
|
+
|
63
|
+
# has_many :artist_rating_raws,
|
64
|
+
# class_name: "ArtistRatingRaw",
|
65
|
+
# foreign_key: "artist"
|
66
|
+
|
67
|
+
# has_many :artist_tag_raws,
|
68
|
+
# class_name: "ArtistTagRaw",
|
69
|
+
# foreign_key: "artist"
|
70
|
+
|
71
|
+
# has_many :artist_tags,
|
72
|
+
# class_name: "ArtistTag",
|
73
|
+
# foreign_key: "artist"
|
74
|
+
|
75
|
+
# has_many :artist_edit_artists,
|
76
|
+
# class_name: "EditArtist",
|
77
|
+
# foreign_key: "artist"
|
78
|
+
|
79
|
+
# has_many :artist_editor_collection_artists,
|
80
|
+
# class_name: "EditorCollectionArtist",
|
81
|
+
# foreign_key: "artist"
|
82
|
+
|
83
|
+
# has_many :artist_editor_subscribe_artists,
|
84
|
+
# class_name: "EditorSubscribeArtist",
|
85
|
+
# foreign_key: "artist"
|
86
|
+
|
87
|
+
# has_many :artist_editor_watch_artists,
|
88
|
+
# class_name: "EditorWatchArtist",
|
89
|
+
# foreign_key: "artist"
|
90
|
+
|
91
|
+
# has_many :artist_new_ids,
|
92
|
+
# class_name: "ArtistGIDRedirect",
|
93
|
+
# foreign_key: "new_id"
|
94
|
+
|
95
|
+
attribute :name
|
96
|
+
attribute :sort_name
|
97
|
+
|
98
|
+
attribute :comment
|
99
|
+
attribute :edits_pending, :integer
|
100
|
+
attribute :last_updated, :datetime
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
104
|
+
# == Schema Information
|
105
|
+
#
|
106
|
+
# Table name: artist
|
107
|
+
#
|
108
|
+
# id :integer not null, primary key
|
109
|
+
# area :integer
|
110
|
+
# begin_area :integer
|
111
|
+
# begin_date_day :integer
|
112
|
+
# begin_date_month :integer
|
113
|
+
# begin_date_year :integer
|
114
|
+
# comment :string(255) default(""), not null
|
115
|
+
# edits_pending :integer default(0), not null
|
116
|
+
# end_area :integer
|
117
|
+
# end_date_day :integer
|
118
|
+
# end_date_month :integer
|
119
|
+
# end_date_year :integer
|
120
|
+
# ended :boolean default(FALSE), not null
|
121
|
+
# gender :integer
|
122
|
+
# gid :uuid not null
|
123
|
+
# last_updated :datetime
|
124
|
+
# name :string not null
|
125
|
+
# sort_name :string not null
|
126
|
+
# type :integer
|
127
|
+
#
|
128
|
+
# Indexes
|
129
|
+
#
|
130
|
+
# artist_idx_area (area)
|
131
|
+
# artist_idx_begin_area (begin_area)
|
132
|
+
# artist_idx_end_area (end_area)
|
133
|
+
# artist_idx_gid (gid) UNIQUE
|
134
|
+
# artist_idx_lower_name (lower((name)::text))
|
135
|
+
# artist_idx_musicbrainz_collate (name)
|
136
|
+
# artist_idx_name (name)
|
137
|
+
# artist_idx_null_comment (name) UNIQUE WHERE (comment IS NULL)
|
138
|
+
# artist_idx_sort_name (sort_name)
|
139
|
+
# artist_idx_txt (mb_simple_tsvector((name)::text)) USING gin
|
140
|
+
# artist_idx_txt_sort (mb_simple_tsvector((sort_name)::text)) USING gin
|
141
|
+
# artist_idx_uniq_name_comment (name,comment) UNIQUE WHERE (comment IS NOT NULL)
|
142
|
+
#
|
143
|
+
# Foreign Keys
|
144
|
+
#
|
145
|
+
# artist_fk_area (area => area.id)
|
146
|
+
# artist_fk_begin_area (begin_area => area.id)
|
147
|
+
# artist_fk_end_area (end_area => area.id)
|
148
|
+
# artist_fk_gender (gender => gender.id)
|
149
|
+
# artist_fk_type (type => artist_type.id)
|
150
|
+
#
|