active_brainz 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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
@@ -0,0 +1,62 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module ActiveBrainz
|
4
|
+
class ArtistAlias < Base
|
5
|
+
self.table_name = "artist_alias"
|
6
|
+
|
7
|
+
include HasBeginEndDate
|
8
|
+
|
9
|
+
belongs_to :artist_alias_artist,
|
10
|
+
class_name: "Artist",
|
11
|
+
foreign_key: "artist",
|
12
|
+
optional: true
|
13
|
+
|
14
|
+
belongs_to :artist_alias_type,
|
15
|
+
class_name: "ArtistAliasType",
|
16
|
+
foreign_key: "type",
|
17
|
+
optional: true
|
18
|
+
|
19
|
+
attribute :name
|
20
|
+
attribute :sort_name
|
21
|
+
|
22
|
+
attribute :locale
|
23
|
+
attribute :primary_for_locale, :boolean
|
24
|
+
|
25
|
+
attribute :edits_pending, :integer
|
26
|
+
attribute :last_updated, :datetime
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
# == Schema Information
|
31
|
+
#
|
32
|
+
# Table name: artist_alias
|
33
|
+
#
|
34
|
+
# id :integer not null, primary key
|
35
|
+
# artist :integer not null
|
36
|
+
# begin_date_day :integer
|
37
|
+
# begin_date_month :integer
|
38
|
+
# begin_date_year :integer
|
39
|
+
# edits_pending :integer default(0), not null
|
40
|
+
# end_date_day :integer
|
41
|
+
# end_date_month :integer
|
42
|
+
# end_date_year :integer
|
43
|
+
# ended :boolean default(FALSE), not null
|
44
|
+
# last_updated :datetime
|
45
|
+
# locale :text
|
46
|
+
# name :string not null
|
47
|
+
# primary_for_locale :boolean default(FALSE), not null
|
48
|
+
# sort_name :string not null
|
49
|
+
# type :integer
|
50
|
+
#
|
51
|
+
# Indexes
|
52
|
+
#
|
53
|
+
# artist_alias_idx_artist (artist)
|
54
|
+
# artist_alias_idx_primary (artist,locale) UNIQUE WHERE ((primary_for_locale = true) AND (locale IS NOT NULL))
|
55
|
+
# artist_alias_idx_txt (mb_simple_tsvector((name)::text)) USING gin
|
56
|
+
# artist_alias_idx_txt_sort (mb_simple_tsvector((sort_name)::text)) USING gin
|
57
|
+
#
|
58
|
+
# Foreign Keys
|
59
|
+
#
|
60
|
+
# artist_alias_fk_artist (artist => artist.id)
|
61
|
+
# artist_alias_fk_type (type => artist_alias_type.id)
|
62
|
+
#
|
@@ -0,0 +1,37 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module ActiveBrainz
|
4
|
+
class ArtistAliasType < Base
|
5
|
+
self.table_name = "artist_alias_type"
|
6
|
+
|
7
|
+
include HasGID
|
8
|
+
include HasParentChildren
|
9
|
+
|
10
|
+
has_many :artist_aliases,
|
11
|
+
class_name: "ArtistAlias",
|
12
|
+
foreign_key: "type"
|
13
|
+
|
14
|
+
attribute :name
|
15
|
+
attribute :description
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
# == Schema Information
|
20
|
+
#
|
21
|
+
# Table name: artist_alias_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 :text not null
|
28
|
+
# parent :integer
|
29
|
+
#
|
30
|
+
# Indexes
|
31
|
+
#
|
32
|
+
# artist_alias_type_idx_gid (gid) UNIQUE
|
33
|
+
#
|
34
|
+
# Foreign Keys
|
35
|
+
#
|
36
|
+
# artist_alias_type_fk_parent (parent => artist_alias_type.id)
|
37
|
+
#
|
@@ -0,0 +1,60 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module ActiveBrainz
|
4
|
+
class ArtistCredit < Base
|
5
|
+
self.table_name = "artist_credit"
|
6
|
+
|
7
|
+
# has_many :alternative_releases,
|
8
|
+
# class_name: "AlternativeRelease",
|
9
|
+
# foreign_key: "artist_credit"
|
10
|
+
|
11
|
+
# has_many :alternative_tracks,
|
12
|
+
# class_name: "AlternativeTrack",
|
13
|
+
# foreign_key: "artist_credit"
|
14
|
+
|
15
|
+
has_many :artist_credit_names,
|
16
|
+
class_name: "ArtistCreditName",
|
17
|
+
foreign_key: "artist_credit"
|
18
|
+
|
19
|
+
has_many :recordings,
|
20
|
+
class_name: "Recording",
|
21
|
+
foreign_key: "artist_credit"
|
22
|
+
|
23
|
+
has_many :release_groups,
|
24
|
+
class_name: "ReleaseGroup",
|
25
|
+
foreign_key: "artist_credit"
|
26
|
+
|
27
|
+
has_many :releases,
|
28
|
+
class_name: "Release",
|
29
|
+
foreign_key: "artist_credit"
|
30
|
+
|
31
|
+
has_many :tracks,
|
32
|
+
class_name: "Track",
|
33
|
+
foreign_key: "artist_credit"
|
34
|
+
|
35
|
+
attribute :name
|
36
|
+
|
37
|
+
attribute :edits_pending, :integer
|
38
|
+
attribute :artist_count, :integer
|
39
|
+
attribute :ref_count, :integer
|
40
|
+
|
41
|
+
attribute :created, :datetime
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
# == Schema Information
|
46
|
+
#
|
47
|
+
# Table name: artist_credit
|
48
|
+
#
|
49
|
+
# id :integer not null, primary key
|
50
|
+
# artist_count :integer not null
|
51
|
+
# created :datetime
|
52
|
+
# edits_pending :integer default(0), not null
|
53
|
+
# name :string not null
|
54
|
+
# ref_count :integer default(0)
|
55
|
+
#
|
56
|
+
# Indexes
|
57
|
+
#
|
58
|
+
# artist_credit_idx_musicbrainz_collate (name)
|
59
|
+
# artist_credit_idx_txt (mb_simple_tsvector((name)::text)) USING gin
|
60
|
+
#
|
@@ -0,0 +1,46 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module ActiveBrainz
|
4
|
+
class ArtistCreditName < Base
|
5
|
+
self.table_name = "artist_credit_name"
|
6
|
+
self.primary_key = %w(artist_credit position)
|
7
|
+
|
8
|
+
belongs_to :artist_credit_name_artist,
|
9
|
+
class_name: "Artist",
|
10
|
+
foreign_key: "artist",
|
11
|
+
optional: true
|
12
|
+
|
13
|
+
belongs_to :artist_credit_name_artist_credit,
|
14
|
+
class_name: "ArtistCredit",
|
15
|
+
foreign_key: "artist_credit",
|
16
|
+
optional: true
|
17
|
+
|
18
|
+
attribute :name
|
19
|
+
|
20
|
+
attribute :position, :integer
|
21
|
+
|
22
|
+
attribute :join_phrase
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
# == Schema Information
|
27
|
+
#
|
28
|
+
# Table name: artist_credit_name
|
29
|
+
#
|
30
|
+
# artist :integer not null
|
31
|
+
# artist_credit :integer not null
|
32
|
+
# join_phrase :text default(""), not null
|
33
|
+
# name :string not null
|
34
|
+
# position :integer not null
|
35
|
+
#
|
36
|
+
# Indexes
|
37
|
+
#
|
38
|
+
# artist_credit_name_idx_artist (artist)
|
39
|
+
# artist_credit_name_idx_musicbrainz_collate (name)
|
40
|
+
# artist_credit_name_idx_txt (mb_simple_tsvector((name)::text)) USING gin
|
41
|
+
#
|
42
|
+
# Foreign Keys
|
43
|
+
#
|
44
|
+
# artist_credit_name_fk_artist (artist => artist.id) ON DELETE => cascade
|
45
|
+
# artist_credit_name_fk_artist_credit (artist_credit => artist_credit.id) ON DELETE => cascade
|
46
|
+
#
|
@@ -0,0 +1,37 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module ActiveBrainz
|
4
|
+
class ArtistType < Base
|
5
|
+
self.table_name = "artist_type"
|
6
|
+
|
7
|
+
include HasGID
|
8
|
+
include HasParentChildren
|
9
|
+
|
10
|
+
has_many :artists,
|
11
|
+
class_name: "Artist",
|
12
|
+
foreign_key: "type"
|
13
|
+
|
14
|
+
attribute :name
|
15
|
+
attribute :description
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
# == Schema Information
|
20
|
+
#
|
21
|
+
# Table name: artist_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
|
+
# artist_type_idx_gid (gid) UNIQUE
|
33
|
+
#
|
34
|
+
# Foreign Keys
|
35
|
+
#
|
36
|
+
# artist_type_fk_parent (parent => artist_type.id)
|
37
|
+
#
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "active_record"
|
4
|
+
|
5
|
+
module ActiveBrainz
|
6
|
+
class Base < ActiveRecord::Base
|
7
|
+
self.abstract_class = true
|
8
|
+
self.inheritance_column = nil
|
9
|
+
|
10
|
+
establish_connection :musicbrainz
|
11
|
+
|
12
|
+
def readonly?
|
13
|
+
ENV["ACTIVE_BRAINZ_ENV"] != "test"
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module ActiveBrainz
|
4
|
+
module HasBeginEndDate
|
5
|
+
extend ActiveSupport::Concern
|
6
|
+
|
7
|
+
included do
|
8
|
+
attribute :begin_date_year, :integer
|
9
|
+
attribute :begin_date_month, :integer
|
10
|
+
attribute :begin_date_day, :integer
|
11
|
+
|
12
|
+
attribute :end_date_year, :integer
|
13
|
+
attribute :end_date_month, :integer
|
14
|
+
attribute :end_date_day, :integer
|
15
|
+
|
16
|
+
attribute :ended, :boolean
|
17
|
+
|
18
|
+
def begin_date
|
19
|
+
@begin_date ||= Date.new(*[begin_date_year, begin_date_month, begin_date_day].compact)
|
20
|
+
end
|
21
|
+
|
22
|
+
def end_date
|
23
|
+
@end_date ||= Date.new(*[end_date_year, end_date_month, end_date_day].compact)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module ActiveBrainz
|
4
|
+
module HasParentChildren
|
5
|
+
extend ActiveSupport::Concern
|
6
|
+
|
7
|
+
included do
|
8
|
+
has_many :children,
|
9
|
+
class_name: name.demodulize,
|
10
|
+
foreign_key: "parent"
|
11
|
+
|
12
|
+
belongs_to :parent,
|
13
|
+
class_name: name.demodulize,
|
14
|
+
foreign_key: "parent",
|
15
|
+
optional: true
|
16
|
+
|
17
|
+
attribute :child_order, :integer
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module ActiveBrainz
|
4
|
+
class Gender < Base
|
5
|
+
self.table_name = "gender"
|
6
|
+
|
7
|
+
include HasGID
|
8
|
+
include HasParentChildren
|
9
|
+
|
10
|
+
has_many :artists,
|
11
|
+
class_name: "Artist",
|
12
|
+
foreign_key: "gender"
|
13
|
+
|
14
|
+
# has_many :editors,
|
15
|
+
# class_name: "Editor",
|
16
|
+
# foreign_key: "gender"
|
17
|
+
|
18
|
+
attribute :name
|
19
|
+
attribute :description
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
# == Schema Information
|
24
|
+
#
|
25
|
+
# Table name: gender
|
26
|
+
#
|
27
|
+
# id :integer not null, primary key
|
28
|
+
# child_order :integer default(0), not null
|
29
|
+
# description :text
|
30
|
+
# gid :uuid not null
|
31
|
+
# name :string(255) not null
|
32
|
+
# parent :integer
|
33
|
+
#
|
34
|
+
# Indexes
|
35
|
+
#
|
36
|
+
# gender_idx_gid (gid) UNIQUE
|
37
|
+
#
|
38
|
+
# Foreign Keys
|
39
|
+
#
|
40
|
+
# gender_fk_parent (parent => gender.id)
|
41
|
+
#
|
@@ -0,0 +1,36 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module ActiveBrainz
|
4
|
+
class Genre < Base
|
5
|
+
self.table_name = "genre"
|
6
|
+
|
7
|
+
include HasGID
|
8
|
+
|
9
|
+
has_many :genre_aliases,
|
10
|
+
class_name: "GenreAlias",
|
11
|
+
foreign_key: "genre"
|
12
|
+
|
13
|
+
attribute :name
|
14
|
+
attribute :comment
|
15
|
+
|
16
|
+
attribute :edits_pending, :integer
|
17
|
+
attribute :last_updated, :datetime
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
# == Schema Information
|
22
|
+
#
|
23
|
+
# Table name: genre
|
24
|
+
#
|
25
|
+
# id :integer not null, primary key
|
26
|
+
# comment :string(255) default(""), not null
|
27
|
+
# edits_pending :integer default(0), not null
|
28
|
+
# gid :uuid not null
|
29
|
+
# last_updated :datetime
|
30
|
+
# name :string not null
|
31
|
+
#
|
32
|
+
# Indexes
|
33
|
+
#
|
34
|
+
# genre_idx_gid (gid) UNIQUE
|
35
|
+
# genre_idx_name (lower((name)::text)) UNIQUE
|
36
|
+
#
|
@@ -0,0 +1,42 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module ActiveBrainz
|
4
|
+
class GenreAlias < Base
|
5
|
+
self.table_name = "genre_alias"
|
6
|
+
|
7
|
+
belongs_to :genre_alias_genre,
|
8
|
+
class_name: "Genre",
|
9
|
+
foreign_key: "genre",
|
10
|
+
optional: true
|
11
|
+
|
12
|
+
attribute :name
|
13
|
+
|
14
|
+
attribute :locale
|
15
|
+
attribute :primary_for_locale, :boolean
|
16
|
+
|
17
|
+
attribute :edits_pending, :integer
|
18
|
+
attribute :last_updated, :datetime
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
# == Schema Information
|
23
|
+
#
|
24
|
+
# Table name: genre_alias
|
25
|
+
#
|
26
|
+
# id :integer not null, primary key
|
27
|
+
# edits_pending :integer default(0), not null
|
28
|
+
# genre :integer not null
|
29
|
+
# last_updated :datetime
|
30
|
+
# locale :text
|
31
|
+
# name :string not null
|
32
|
+
# primary_for_locale :boolean default(FALSE), not null
|
33
|
+
#
|
34
|
+
# Indexes
|
35
|
+
#
|
36
|
+
# genre_alias_idx_genre (genre)
|
37
|
+
# genre_alias_idx_primary (genre,locale) UNIQUE WHERE ((primary_for_locale = true) AND (locale IS NOT NULL))
|
38
|
+
#
|
39
|
+
# Foreign Keys
|
40
|
+
#
|
41
|
+
# genre_alias_fk_genre (genre => genre.id)
|
42
|
+
#
|