calibre-ruby 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/calibre.rb +7 -0
- data/lib/calibre/author.rb +2 -2
- data/lib/calibre/book.rb +21 -4
- data/lib/calibre/comment.rb +8 -0
- data/lib/calibre/identifier.rb +9 -0
- data/lib/calibre/language.rb +12 -0
- data/lib/calibre/publisher.rb +12 -0
- data/lib/calibre/rating.rb +12 -0
- data/lib/calibre/series.rb +12 -0
- data/lib/calibre/tag.rb +12 -0
- data/lib/calibre/version.rb +1 -1
- metadata +9 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: afd2661d0ccf57af8af51f30dda2138d4882ed3b
|
4
|
+
data.tar.gz: 3023c261eb8a7fbc6947c3505d2ea52872b3b05f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cee0c325707725cc987ba09f5cee7288819c0ce73b370138ce0ac2f674ba80621e6edec5bc0dcc0276a008773f3858e49fa84634f2148afbe9bc964c4c891f90
|
7
|
+
data.tar.gz: dfe5421dcbff8ebeb995e0cd33c5242cdac392a06d76b8d04c5e10dcab8d5fd9232bd4090e675fffe51c7f22e14238efd148da271d7eb5ef9f51462f4c0cacc4
|
data/lib/calibre.rb
CHANGED
@@ -4,6 +4,13 @@ require 'active_record'
|
|
4
4
|
require_relative 'calibre/author'
|
5
5
|
require_relative 'calibre/book'
|
6
6
|
require_relative 'calibre/data'
|
7
|
+
require_relative 'calibre/comment'
|
8
|
+
require_relative 'calibre/identifier'
|
9
|
+
require_relative 'calibre/publisher'
|
10
|
+
require_relative 'calibre/rating'
|
11
|
+
require_relative 'calibre/tag'
|
12
|
+
require_relative 'calibre/series'
|
13
|
+
require_relative 'calibre/language'
|
7
14
|
|
8
15
|
module Calibre
|
9
16
|
def self.db=(calibre_db)
|
data/lib/calibre/author.rb
CHANGED
data/lib/calibre/book.rb
CHANGED
@@ -3,11 +3,28 @@ module Calibre
|
|
3
3
|
# name is the same as the class
|
4
4
|
class AbstractBook < ActiveRecord::Base
|
5
5
|
has_many :data, foreign_key: 'book', class_name: 'Calibre::Data'
|
6
|
+
has_many :comments, foreign_key: 'book', class_name: 'Calibre::Comment'
|
7
|
+
has_many :identifiers, foreign_key: 'book', class_name: 'Calibre::Identifier'
|
6
8
|
self.table_name = 'books'
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
9
|
+
|
10
|
+
%w[author publisher rating tag].each do |association|
|
11
|
+
has_and_belongs_to_many "#{association}s".to_sym,
|
12
|
+
join_table: "books_#{association}s_link",
|
13
|
+
association_foreign_key: association,
|
14
|
+
foreign_key: 'book'
|
15
|
+
end
|
16
|
+
|
17
|
+
# This association is pluralized
|
18
|
+
has_and_belongs_to_many :series,
|
19
|
+
join_table: "books_series_link",
|
20
|
+
association_foreign_key: 'series',
|
21
|
+
foreign_key: 'book'
|
22
|
+
|
23
|
+
# And this one is weirdly name
|
24
|
+
has_and_belongs_to_many :languages,
|
25
|
+
join_table: "books_languages_link",
|
26
|
+
association_foreign_key: 'lang_code',
|
27
|
+
foreign_key: 'book'
|
11
28
|
|
12
29
|
def cover
|
13
30
|
File.join(path, 'cover.jpg')
|
@@ -0,0 +1,8 @@
|
|
1
|
+
class Calibre::Comment < ActiveRecord::Base
|
2
|
+
belongs_to :reference, foreign_key: 'book', class_name: 'Calibre::Book'
|
3
|
+
self.table_name = 'comments'
|
4
|
+
|
5
|
+
# We alias reference, because the relationship can't clash with the
|
6
|
+
# foreign key
|
7
|
+
alias :book :reference
|
8
|
+
end
|
@@ -0,0 +1,9 @@
|
|
1
|
+
class Calibre::Identifier < ActiveRecord::Base
|
2
|
+
belongs_to :reference, foreign_key: 'book', class_name: 'Calibre::Book'
|
3
|
+
self.table_name = 'identifiers'
|
4
|
+
self.inheritance_column = 'noop'
|
5
|
+
|
6
|
+
# We alias reference, because the relationship can't clash with the
|
7
|
+
# foreign key
|
8
|
+
alias :book :reference
|
9
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
module Calibre
|
2
|
+
class AbstractLanguage < ActiveRecord::Base
|
3
|
+
self.table_name = 'languages'
|
4
|
+
|
5
|
+
has_and_belongs_to_many :books,
|
6
|
+
join_table: 'books_languages_link',
|
7
|
+
association_foreign_key: 'book',
|
8
|
+
foreign_key: 'lang_code'
|
9
|
+
end
|
10
|
+
|
11
|
+
class Language < AbstractLanguage; end
|
12
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
module Calibre
|
2
|
+
class AbstractPublisher < ActiveRecord::Base
|
3
|
+
self.table_name = 'publishers'
|
4
|
+
|
5
|
+
has_and_belongs_to_many :books,
|
6
|
+
join_table: 'books_publishers_link',
|
7
|
+
association_foreign_key: 'book',
|
8
|
+
foreign_key: 'publisher'
|
9
|
+
end
|
10
|
+
|
11
|
+
class Publisher < AbstractPublisher; end
|
12
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
module Calibre
|
2
|
+
class AbstractRating < ActiveRecord::Base
|
3
|
+
self.table_name = 'ratings'
|
4
|
+
|
5
|
+
has_and_belongs_to_many :books,
|
6
|
+
join_table: 'books_ratings_link',
|
7
|
+
association_foreign_key: 'book',
|
8
|
+
foreign_key: 'rating'
|
9
|
+
end
|
10
|
+
|
11
|
+
class Rating < AbstractRating; end
|
12
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
module Calibre
|
2
|
+
class AbstractSeries < ActiveRecord::Base
|
3
|
+
self.table_name = 'series'
|
4
|
+
|
5
|
+
has_and_belongs_to_many :books,
|
6
|
+
join_table: 'books_series_link',
|
7
|
+
association_foreign_key: 'book',
|
8
|
+
foreign_key: 'series'
|
9
|
+
end
|
10
|
+
|
11
|
+
class Series < AbstractSeries; end
|
12
|
+
end
|
data/lib/calibre/tag.rb
ADDED
data/lib/calibre/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: calibre-ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- fauno
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-08-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
@@ -53,7 +53,14 @@ files:
|
|
53
53
|
- lib/calibre.rb
|
54
54
|
- lib/calibre/author.rb
|
55
55
|
- lib/calibre/book.rb
|
56
|
+
- lib/calibre/comment.rb
|
56
57
|
- lib/calibre/data.rb
|
58
|
+
- lib/calibre/identifier.rb
|
59
|
+
- lib/calibre/language.rb
|
60
|
+
- lib/calibre/publisher.rb
|
61
|
+
- lib/calibre/rating.rb
|
62
|
+
- lib/calibre/series.rb
|
63
|
+
- lib/calibre/tag.rb
|
57
64
|
- lib/calibre/version.rb
|
58
65
|
homepage: https://0xacab.org/partido-interdimensional-pirata/calibre-ruby
|
59
66
|
licenses:
|