calibre-ruby 0.0.2 → 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 +5 -5
- data/Gemfile +1 -1
- data/calibre-ruby.gemspec +3 -2
- data/lib/calibre/author.rb +5 -3
- data/lib/calibre/book.rb +12 -10
- data/lib/calibre/comment.rb +10 -6
- data/lib/calibre/data.rb +12 -8
- data/lib/calibre/identifier.rb +11 -7
- data/lib/calibre/language.rb +5 -3
- data/lib/calibre/publisher.rb +5 -3
- data/lib/calibre/rating.rb +5 -3
- data/lib/calibre/series.rb +5 -3
- data/lib/calibre/tag.rb +5 -3
- data/lib/calibre/version.rb +3 -1
- data/lib/calibre.rb +3 -1
- metadata +25 -12
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
|
-
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: 9fea1c1cccdbae4cfa35438ca53457d106af62a1887260a0d113a64f5496289d
|
|
4
|
+
data.tar.gz: 715c88ce10bc94d73eda88e94d8edf8cfb31b222245d7b84a86ce3b5e2be5916
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: b538cbfcc4cf63572edad9b22da68d80f6e27db3e533cde259719aa5b9346ad074ee852ca7373d9c320ad9e704498d15739c6506cb95471590492031910e04fd
|
|
7
|
+
data.tar.gz: 00bd3c65d3ea6b1bbf3a8272cff2aef222553f6efa9a881ad75c6aa85949bba5d6accdf347b72c715abb37a92e7b473fab59848e0f98e6b01518ae7aad25edef
|
data/Gemfile
CHANGED
data/calibre-ruby.gemspec
CHANGED
|
@@ -18,6 +18,7 @@ Gem::Specification.new do |gem|
|
|
|
18
18
|
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
|
19
19
|
gem.require_paths = ['lib']
|
|
20
20
|
|
|
21
|
-
gem.add_dependency('activerecord', '~>
|
|
22
|
-
gem.add_dependency('sqlite3'
|
|
21
|
+
gem.add_dependency('activerecord', '~> 7.1.0')
|
|
22
|
+
gem.add_dependency('sqlite3')
|
|
23
|
+
gem.add_development_dependency('rubocop', '~> 1.66.0')
|
|
23
24
|
end
|
data/lib/calibre/author.rb
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
module Calibre
|
|
2
4
|
class AbstractAuthor < ActiveRecord::Base
|
|
3
5
|
self.table_name = 'authors'
|
|
4
6
|
|
|
5
7
|
has_and_belongs_to_many :books,
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
8
|
+
join_table: 'books_authors_link',
|
|
9
|
+
association_foreign_key: 'book',
|
|
10
|
+
foreign_key: 'author'
|
|
9
11
|
end
|
|
10
12
|
|
|
11
13
|
class Author < AbstractAuthor; end
|
data/lib/calibre/book.rb
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
module Calibre
|
|
2
4
|
# We do this to prevent AR to fail miserably because the foreign key
|
|
3
5
|
# name is the same as the class
|
|
@@ -9,22 +11,22 @@ module Calibre
|
|
|
9
11
|
|
|
10
12
|
%w[author publisher rating tag].each do |association|
|
|
11
13
|
has_and_belongs_to_many "#{association}s".to_sym,
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
14
|
+
join_table: "books_#{association}s_link",
|
|
15
|
+
association_foreign_key: association,
|
|
16
|
+
foreign_key: 'book'
|
|
15
17
|
end
|
|
16
18
|
|
|
17
19
|
# This association is pluralized
|
|
18
20
|
has_and_belongs_to_many :series,
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
21
|
+
join_table: 'books_series_link',
|
|
22
|
+
association_foreign_key: 'series',
|
|
23
|
+
foreign_key: 'book'
|
|
22
24
|
|
|
23
25
|
# And this one is weirdly name
|
|
24
26
|
has_and_belongs_to_many :languages,
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
27
|
+
join_table: 'books_languages_link',
|
|
28
|
+
association_foreign_key: 'lang_code',
|
|
29
|
+
foreign_key: 'book'
|
|
28
30
|
|
|
29
31
|
def cover
|
|
30
32
|
File.join(path, 'cover.jpg')
|
|
@@ -36,5 +38,5 @@ module Calibre
|
|
|
36
38
|
end
|
|
37
39
|
|
|
38
40
|
# You can use this :)
|
|
39
|
-
class Book < AbstractBook
|
|
41
|
+
class Book < AbstractBook; end
|
|
40
42
|
end
|
data/lib/calibre/comment.rb
CHANGED
|
@@ -1,8 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
belongs_to :reference, foreign_key: 'book', class_name: 'Calibre::Book'
|
|
3
|
-
self.table_name = 'comments'
|
|
1
|
+
# frozen_string_literal: true
|
|
4
2
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
3
|
+
module Calibre
|
|
4
|
+
class Comment < ActiveRecord::Base
|
|
5
|
+
belongs_to :reference, foreign_key: 'book', class_name: 'Calibre::Book'
|
|
6
|
+
self.table_name = 'comments'
|
|
7
|
+
|
|
8
|
+
# We alias reference, because the relationship can't clash with the
|
|
9
|
+
# foreign key
|
|
10
|
+
alias book reference
|
|
11
|
+
end
|
|
8
12
|
end
|
data/lib/calibre/data.rb
CHANGED
|
@@ -1,12 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
belongs_to :reference, foreign_key: 'book', class_name: 'Calibre::Book'
|
|
3
|
-
self.table_name = 'data'
|
|
1
|
+
# frozen_string_literal: true
|
|
4
2
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
3
|
+
module Calibre
|
|
4
|
+
class Data < ActiveRecord::Base
|
|
5
|
+
belongs_to :reference, foreign_key: 'book', class_name: 'Calibre::Book'
|
|
6
|
+
self.table_name = 'data'
|
|
8
7
|
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
# We alias reference, because the relationship can't clash with the
|
|
9
|
+
# foreign key
|
|
10
|
+
alias book reference
|
|
11
|
+
|
|
12
|
+
def path
|
|
13
|
+
File.join(reference.path, [name, format.downcase].join('.'))
|
|
14
|
+
end
|
|
11
15
|
end
|
|
12
16
|
end
|
data/lib/calibre/identifier.rb
CHANGED
|
@@ -1,9 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
belongs_to :reference, foreign_key: 'book', class_name: 'Calibre::Book'
|
|
3
|
-
self.table_name = 'identifiers'
|
|
4
|
-
self.inheritance_column = 'noop'
|
|
1
|
+
# frozen_string_literal: true
|
|
5
2
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
3
|
+
module Calibre
|
|
4
|
+
class Identifier < ActiveRecord::Base
|
|
5
|
+
belongs_to :reference, foreign_key: 'book', class_name: 'Calibre::Book'
|
|
6
|
+
self.table_name = 'identifiers'
|
|
7
|
+
self.inheritance_column = 'noop'
|
|
8
|
+
|
|
9
|
+
# We alias reference, because the relationship can't clash with the
|
|
10
|
+
# foreign key
|
|
11
|
+
alias book reference
|
|
12
|
+
end
|
|
9
13
|
end
|
data/lib/calibre/language.rb
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
module Calibre
|
|
2
4
|
class AbstractLanguage < ActiveRecord::Base
|
|
3
5
|
self.table_name = 'languages'
|
|
4
6
|
|
|
5
7
|
has_and_belongs_to_many :books,
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
8
|
+
join_table: 'books_languages_link',
|
|
9
|
+
association_foreign_key: 'book',
|
|
10
|
+
foreign_key: 'lang_code'
|
|
9
11
|
end
|
|
10
12
|
|
|
11
13
|
class Language < AbstractLanguage; end
|
data/lib/calibre/publisher.rb
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
module Calibre
|
|
2
4
|
class AbstractPublisher < ActiveRecord::Base
|
|
3
5
|
self.table_name = 'publishers'
|
|
4
6
|
|
|
5
7
|
has_and_belongs_to_many :books,
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
8
|
+
join_table: 'books_publishers_link',
|
|
9
|
+
association_foreign_key: 'book',
|
|
10
|
+
foreign_key: 'publisher'
|
|
9
11
|
end
|
|
10
12
|
|
|
11
13
|
class Publisher < AbstractPublisher; end
|
data/lib/calibre/rating.rb
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
module Calibre
|
|
2
4
|
class AbstractRating < ActiveRecord::Base
|
|
3
5
|
self.table_name = 'ratings'
|
|
4
6
|
|
|
5
7
|
has_and_belongs_to_many :books,
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
8
|
+
join_table: 'books_ratings_link',
|
|
9
|
+
association_foreign_key: 'book',
|
|
10
|
+
foreign_key: 'rating'
|
|
9
11
|
end
|
|
10
12
|
|
|
11
13
|
class Rating < AbstractRating; end
|
data/lib/calibre/series.rb
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
module Calibre
|
|
2
4
|
class AbstractSeries < ActiveRecord::Base
|
|
3
5
|
self.table_name = 'series'
|
|
4
6
|
|
|
5
7
|
has_and_belongs_to_many :books,
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
8
|
+
join_table: 'books_series_link',
|
|
9
|
+
association_foreign_key: 'book',
|
|
10
|
+
foreign_key: 'series'
|
|
9
11
|
end
|
|
10
12
|
|
|
11
13
|
class Series < AbstractSeries; end
|
data/lib/calibre/tag.rb
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
module Calibre
|
|
2
4
|
class AbstractTag < ActiveRecord::Base
|
|
3
5
|
self.table_name = 'tags'
|
|
4
6
|
|
|
5
7
|
has_and_belongs_to_many :books,
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
8
|
+
join_table: 'books_tags_link',
|
|
9
|
+
association_foreign_key: 'book',
|
|
10
|
+
foreign_key: 'tag'
|
|
9
11
|
end
|
|
10
12
|
|
|
11
13
|
class Tag < AbstractTag; end
|
data/lib/calibre/version.rb
CHANGED
data/lib/calibre.rb
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
require 'sqlite3'
|
|
2
4
|
require 'active_record'
|
|
3
5
|
|
|
@@ -15,6 +17,6 @@ require_relative 'calibre/language'
|
|
|
15
17
|
module Calibre
|
|
16
18
|
def self.db=(calibre_db)
|
|
17
19
|
ActiveRecord::Base.establish_connection(adapter: 'sqlite3',
|
|
18
|
-
|
|
20
|
+
database: calibre_db)
|
|
19
21
|
end
|
|
20
22
|
end
|
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.1.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- fauno
|
|
8
|
-
autorequire:
|
|
8
|
+
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2026-08-18 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: activerecord
|
|
@@ -16,28 +16,42 @@ dependencies:
|
|
|
16
16
|
requirements:
|
|
17
17
|
- - "~>"
|
|
18
18
|
- !ruby/object:Gem::Version
|
|
19
|
-
version:
|
|
19
|
+
version: 7.1.0
|
|
20
20
|
type: :runtime
|
|
21
21
|
prerelease: false
|
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
|
23
23
|
requirements:
|
|
24
24
|
- - "~>"
|
|
25
25
|
- !ruby/object:Gem::Version
|
|
26
|
-
version:
|
|
26
|
+
version: 7.1.0
|
|
27
27
|
- !ruby/object:Gem::Dependency
|
|
28
28
|
name: sqlite3
|
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
|
30
30
|
requirements:
|
|
31
|
-
- - "
|
|
31
|
+
- - ">="
|
|
32
32
|
- !ruby/object:Gem::Version
|
|
33
|
-
version:
|
|
33
|
+
version: '0'
|
|
34
34
|
type: :runtime
|
|
35
35
|
prerelease: false
|
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
37
|
+
requirements:
|
|
38
|
+
- - ">="
|
|
39
|
+
- !ruby/object:Gem::Version
|
|
40
|
+
version: '0'
|
|
41
|
+
- !ruby/object:Gem::Dependency
|
|
42
|
+
name: rubocop
|
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
|
44
|
+
requirements:
|
|
45
|
+
- - "~>"
|
|
46
|
+
- !ruby/object:Gem::Version
|
|
47
|
+
version: 1.66.0
|
|
48
|
+
type: :development
|
|
49
|
+
prerelease: false
|
|
36
50
|
version_requirements: !ruby/object:Gem::Requirement
|
|
37
51
|
requirements:
|
|
38
52
|
- - "~>"
|
|
39
53
|
- !ruby/object:Gem::Version
|
|
40
|
-
version: 1.
|
|
54
|
+
version: 1.66.0
|
|
41
55
|
description: This gem provides an ActiveRecord interface to Calibre's book database
|
|
42
56
|
email:
|
|
43
57
|
- fauno@partidopirata.com.ar
|
|
@@ -66,7 +80,7 @@ homepage: https://0xacab.org/partido-interdimensional-pirata/calibre-ruby
|
|
|
66
80
|
licenses:
|
|
67
81
|
- MIT
|
|
68
82
|
metadata: {}
|
|
69
|
-
post_install_message:
|
|
83
|
+
post_install_message:
|
|
70
84
|
rdoc_options: []
|
|
71
85
|
require_paths:
|
|
72
86
|
- lib
|
|
@@ -81,9 +95,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
81
95
|
- !ruby/object:Gem::Version
|
|
82
96
|
version: '0'
|
|
83
97
|
requirements: []
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
signing_key:
|
|
98
|
+
rubygems_version: 3.3.27
|
|
99
|
+
signing_key:
|
|
87
100
|
specification_version: 4
|
|
88
101
|
summary: This gem provides an ActiveRecord interface to Calibre's book database
|
|
89
102
|
test_files: []
|