mangadex 5.8.0 → 5.10.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 +4 -4
- data/Gemfile.lock +10 -10
- data/docker-compose.yml +1 -1
- data/lib/mangadex/api/response.rb +13 -1
- data/lib/mangadex/internal/definition.rb +1 -0
- data/lib/mangadex/internal/definitions/year.rb +28 -0
- data/lib/mangadex/internal/with_attributes.rb +31 -13
- data/lib/mangadex/manga.rb +16 -1
- data/lib/mangadex/scanlation_group.rb +1 -0
- data/lib/mangadex/statistic.rb +57 -10
- data/lib/mangadex/thread.rb +24 -0
- data/lib/mangadex/types.rb +1 -0
- data/lib/mangadex/utils.rb +5 -1
- data/lib/mangadex/version.rb +1 -1
- data/mangadex.gemspec +1 -1
- metadata +13 -5
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 18087cc00534cd6237918795bf9a788ce418f09a9e6853507979a6152b3ed573
|
|
4
|
+
data.tar.gz: 9ba7ab45bd94fa41e13a4a7dc263bcf090ccc6b529a8bc7107ce8842cb46e4a4
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: fa61b0946bfb0e13205500cabfb7083bd0585cf9f8eb5bf522c5bd96b786f58f57aca9d6660210e153beb735a979d208baa5c3f6210af47e146664c31adf493a
|
|
7
|
+
data.tar.gz: 8fffed4ae99b25713edb3b53031051663d86205d5b0794dd8f51282aca54f8469d34b16f27ad0b21455bfd8ccb3a81d1d0de15376dfdc3109897b010ad69e8b5
|
data/Gemfile.lock
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
mangadex (5.
|
|
5
|
-
psych (
|
|
4
|
+
mangadex (5.10.0)
|
|
5
|
+
psych (>= 4.0.1, < 5.2.0)
|
|
6
6
|
rest-client (~> 2.1)
|
|
7
7
|
sorbet-runtime
|
|
8
8
|
|
|
@@ -19,12 +19,12 @@ GEM
|
|
|
19
19
|
method_source (1.0.0)
|
|
20
20
|
mime-types (3.4.1)
|
|
21
21
|
mime-types-data (~> 3.2015)
|
|
22
|
-
mime-types-data (3.
|
|
22
|
+
mime-types-data (3.2023.0218.1)
|
|
23
23
|
netrc (0.11.0)
|
|
24
|
-
pry (0.14.
|
|
24
|
+
pry (0.14.2)
|
|
25
25
|
coderay (~> 1.1)
|
|
26
26
|
method_source (~> 1.0)
|
|
27
|
-
psych (
|
|
27
|
+
psych (5.1.0)
|
|
28
28
|
stringio
|
|
29
29
|
rake (13.0.6)
|
|
30
30
|
rest-client (2.1.0)
|
|
@@ -45,11 +45,11 @@ GEM
|
|
|
45
45
|
diff-lcs (>= 1.2.0, < 2.0)
|
|
46
46
|
rspec-support (~> 3.12.0)
|
|
47
47
|
rspec-support (3.12.0)
|
|
48
|
-
sorbet (0.5.
|
|
49
|
-
sorbet-static (= 0.5.
|
|
50
|
-
sorbet-runtime (0.5.
|
|
51
|
-
sorbet-static (0.5.
|
|
52
|
-
stringio (3.0.
|
|
48
|
+
sorbet (0.5.10864)
|
|
49
|
+
sorbet-static (= 0.5.10864)
|
|
50
|
+
sorbet-runtime (0.5.10863)
|
|
51
|
+
sorbet-static (0.5.10864-x86_64-linux)
|
|
52
|
+
stringio (3.0.7)
|
|
53
53
|
unf (0.1.4)
|
|
54
54
|
unf_ext
|
|
55
55
|
unf_ext (0.0.8.2)
|
data/docker-compose.yml
CHANGED
|
@@ -36,6 +36,8 @@ module Mangadex
|
|
|
36
36
|
coerce_entity(data)
|
|
37
37
|
elsif data['response'] == 'collection'
|
|
38
38
|
coerce_collection(data)
|
|
39
|
+
elsif data.keys.include?('statistics')
|
|
40
|
+
coerce_statistics(data)
|
|
39
41
|
else
|
|
40
42
|
data
|
|
41
43
|
end
|
|
@@ -109,7 +111,10 @@ module Mangadex
|
|
|
109
111
|
|
|
110
112
|
# Derive the class name from the type. "Convention over configuration"
|
|
111
113
|
class_from_data = "Mangadex::#{object_type.split('_').collect(&:capitalize).join}"
|
|
112
|
-
|
|
114
|
+
unless Object.const_defined?(class_from_data)
|
|
115
|
+
warn("Expected class #{class_from_data} to be defined")
|
|
116
|
+
return
|
|
117
|
+
end
|
|
113
118
|
|
|
114
119
|
klass = Object.const_get(class_from_data)
|
|
115
120
|
new(
|
|
@@ -142,6 +147,13 @@ module Mangadex
|
|
|
142
147
|
raw_data: data,
|
|
143
148
|
)
|
|
144
149
|
end
|
|
150
|
+
|
|
151
|
+
def self.coerce_statistics(data)
|
|
152
|
+
new(
|
|
153
|
+
result: data['result'],
|
|
154
|
+
data: Mangadex::Statistic.from_data(data['statistics']),
|
|
155
|
+
)
|
|
156
|
+
end
|
|
145
157
|
end
|
|
146
158
|
end
|
|
147
159
|
end
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# typed: false
|
|
2
|
+
|
|
3
|
+
module Mangadex
|
|
4
|
+
module Internal
|
|
5
|
+
module Definitions
|
|
6
|
+
class Year < Base
|
|
7
|
+
def initialize(value)
|
|
8
|
+
super(
|
|
9
|
+
value,
|
|
10
|
+
key: :year,
|
|
11
|
+
accepts: Accepts.new(
|
|
12
|
+
array: ["none"],
|
|
13
|
+
class: Integer,
|
|
14
|
+
condition: :or,
|
|
15
|
+
),
|
|
16
|
+
required: false,
|
|
17
|
+
)
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def validate_accepts
|
|
21
|
+
@accepts.validate!(converted_value)
|
|
22
|
+
rescue ArgumentError => error
|
|
23
|
+
add_error(error.message)
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
end
|
|
@@ -29,11 +29,13 @@ module Mangadex
|
|
|
29
29
|
Mangadex::Utils.underscore(self.name.split('::').last)
|
|
30
30
|
end
|
|
31
31
|
|
|
32
|
-
def from_data(data, related_type: nil, source_obj: nil)
|
|
32
|
+
def from_data(data, related_type: nil, source_obj: nil, direct: false)
|
|
33
33
|
base_class_name = self.name.gsub('::', '_')
|
|
34
34
|
klass_name = self.name
|
|
35
35
|
target_attributes_class_name = "#{base_class_name}_Attributes"
|
|
36
36
|
|
|
37
|
+
return if data.nil? || data.empty?
|
|
38
|
+
|
|
37
39
|
data = data.transform_keys(&:to_s)
|
|
38
40
|
|
|
39
41
|
klass = if const_defined?(target_attributes_class_name)
|
|
@@ -58,22 +60,38 @@ module Mangadex
|
|
|
58
60
|
Relationship.from_data(relationship_data, MangadexObject.new(**data))
|
|
59
61
|
end
|
|
60
62
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
+
if direct
|
|
64
|
+
symbolized_data = data.symbolize_keys
|
|
65
|
+
symbolized_data.transform_keys! do |key|
|
|
66
|
+
Mangadex::Utils.underscore(key)
|
|
67
|
+
end
|
|
68
|
+
keys = symbolized_data.keys
|
|
69
|
+
keys.each do |key|
|
|
70
|
+
attr_accessor key
|
|
71
|
+
end
|
|
63
72
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
related_type: related_type,
|
|
69
|
-
}
|
|
73
|
+
instance = new
|
|
74
|
+
keys.each do |key|
|
|
75
|
+
instance.send("#{key}=", symbolized_data[key])
|
|
76
|
+
end
|
|
70
77
|
|
|
71
|
-
|
|
72
|
-
|
|
78
|
+
instance
|
|
79
|
+
else
|
|
80
|
+
found_attributes = data['attributes'] || {}
|
|
81
|
+
attributes = klass.new(**Hash(found_attributes.symbolize_keys))
|
|
82
|
+
|
|
83
|
+
initialize_hash = {
|
|
84
|
+
id: data['id'],
|
|
85
|
+
type: data['type'] || self.type,
|
|
86
|
+
attributes: attributes,
|
|
87
|
+
related_type: related_type,
|
|
88
|
+
}
|
|
73
89
|
|
|
74
|
-
|
|
90
|
+
relationships = [source_obj].compact unless relationships.present?
|
|
91
|
+
initialize_hash.merge!({relationships: relationships}) if relationships.present?
|
|
75
92
|
|
|
76
|
-
|
|
93
|
+
new(**initialize_hash)
|
|
94
|
+
end
|
|
77
95
|
end
|
|
78
96
|
end
|
|
79
97
|
|
data/lib/mangadex/manga.rb
CHANGED
|
@@ -36,7 +36,7 @@ module Mangadex
|
|
|
36
36
|
author_or_artist: { accepts: String },
|
|
37
37
|
authors: { accepts: [String], converts: :to_a },
|
|
38
38
|
artists: { accepts: [String], converts: :to_a },
|
|
39
|
-
year:
|
|
39
|
+
year: Mangadex::Internal::Definitions::Year,
|
|
40
40
|
included_tags: { accepts: [String], converts: :to_a },
|
|
41
41
|
included_tags_mode: { accepts: %w(OR AND) },
|
|
42
42
|
excluded_tags: { accepts: [String], converts: :to_a },
|
|
@@ -224,5 +224,20 @@ module Mangadex
|
|
|
224
224
|
chapter_args = args.merge({manga: id})
|
|
225
225
|
Chapter.list(**chapter_args)
|
|
226
226
|
end
|
|
227
|
+
|
|
228
|
+
sig { returns(T::Boolean) }
|
|
229
|
+
def has_comments?
|
|
230
|
+
!comments_info.nil? && comments_info.repliesCount > 0
|
|
231
|
+
end
|
|
232
|
+
|
|
233
|
+
def statistics
|
|
234
|
+
@statistics ||= Mangadex::Statistic.get(id).data
|
|
235
|
+
end
|
|
236
|
+
alias :stats :statistics
|
|
237
|
+
|
|
238
|
+
def comments_info
|
|
239
|
+
statistics.comments
|
|
240
|
+
end
|
|
241
|
+
alias :comments :comments_info
|
|
227
242
|
end
|
|
228
243
|
end
|
data/lib/mangadex/statistic.rb
CHANGED
|
@@ -2,30 +2,77 @@
|
|
|
2
2
|
|
|
3
3
|
module Mangadex
|
|
4
4
|
class Statistic < MangadexObject
|
|
5
|
-
|
|
5
|
+
class Rating < MangadexObject
|
|
6
|
+
has_attributes \
|
|
7
|
+
:average,
|
|
8
|
+
:bayesian,
|
|
9
|
+
:distribution
|
|
10
|
+
|
|
11
|
+
def self.attributes_to_inspect
|
|
12
|
+
[:average, :bayesian]
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
class Comments < MangadexObject
|
|
17
|
+
has_attributes \
|
|
18
|
+
:thread_id,
|
|
19
|
+
:replies_count
|
|
20
|
+
|
|
21
|
+
def self.attributes_to_inspect
|
|
22
|
+
[:replies_count]
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
attr_accessor \
|
|
6
27
|
:rating,
|
|
7
|
-
:
|
|
8
|
-
:
|
|
9
|
-
:distribution,
|
|
10
|
-
:follows
|
|
28
|
+
:follows,
|
|
29
|
+
:comments
|
|
11
30
|
|
|
12
|
-
|
|
13
|
-
|
|
31
|
+
class << self
|
|
32
|
+
def from_data(data)
|
|
33
|
+
results = if data.is_a?(Array)
|
|
34
|
+
data.map do |item|
|
|
35
|
+
from_data(item)
|
|
36
|
+
end
|
|
37
|
+
else
|
|
38
|
+
data.keys.map do |manga_id|
|
|
39
|
+
statistics = data[manga_id]
|
|
40
|
+
new(
|
|
41
|
+
rating: Mangadex::Statistic::Rating.from_data(statistics['rating'], direct: true),
|
|
42
|
+
comments: Mangadex::Statistic::Comments.from_data(statistics['comments'], direct: true),
|
|
43
|
+
follows: statistics['follows'],
|
|
44
|
+
)
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
return results.first if results.length == 1
|
|
49
|
+
Mangadex::Api::Response::Collection.new(results)
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
sig { params(uuid: String, raw: T::Boolean).returns(T::Api::GenericResponse) }
|
|
54
|
+
def self.get(uuid, raw: false)
|
|
14
55
|
Mangadex::Internal::Definition.must(uuid)
|
|
15
56
|
|
|
16
57
|
Mangadex::Internal::Request.get(
|
|
17
58
|
'/statistics/manga/%{uuid}' % {uuid: uuid},
|
|
59
|
+
raw: raw,
|
|
18
60
|
)
|
|
19
61
|
end
|
|
20
62
|
|
|
21
|
-
sig { params(args: T::Api::Arguments).returns(T::Api::GenericResponse) }
|
|
22
|
-
def self.list(**args)
|
|
63
|
+
sig { params(raw: T::Boolean, args: T::Api::Arguments).returns(T::Api::GenericResponse) }
|
|
64
|
+
def self.list(raw: false, **args)
|
|
23
65
|
Mangadex::Internal::Request.get(
|
|
24
66
|
'/statistics/manga',
|
|
25
67
|
Mangadex::Internal::Definition.validate(args, {
|
|
26
68
|
manga: { accepts: [String], converts: :to_a },
|
|
27
|
-
})
|
|
69
|
+
}),
|
|
70
|
+
raw: raw,
|
|
28
71
|
)
|
|
29
72
|
end
|
|
73
|
+
|
|
74
|
+
def self.attributes_to_inspect
|
|
75
|
+
[:follows, :rating, :comments]
|
|
76
|
+
end
|
|
30
77
|
end
|
|
31
78
|
end
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
module Mangadex
|
|
2
|
+
class Thread < MangadexObject
|
|
3
|
+
has_attributes \
|
|
4
|
+
:replies_count
|
|
5
|
+
|
|
6
|
+
class << self
|
|
7
|
+
def create(type:, id:)
|
|
8
|
+
payload = {type: type, id: id}
|
|
9
|
+
Mangadex::Internal::Request.post(
|
|
10
|
+
'/forums/thread',
|
|
11
|
+
payload: Mangadex::Internal::Definition.validate(payload, {
|
|
12
|
+
type: { accepts: %w(manga group chapter), converts: :to_s, required: true },
|
|
13
|
+
id: { accepts: String, required: true },
|
|
14
|
+
}),
|
|
15
|
+
auth: true,
|
|
16
|
+
)
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def self.attributes_to_inspect
|
|
21
|
+
[:id, :type, :replies_count]
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
data/lib/mangadex/types.rb
CHANGED
data/lib/mangadex/utils.rb
CHANGED
|
@@ -10,9 +10,13 @@ module Mangadex
|
|
|
10
10
|
end
|
|
11
11
|
|
|
12
12
|
def underscore(string)
|
|
13
|
-
string.
|
|
13
|
+
is_symbol = string.kind_of?(Symbol)
|
|
14
|
+
data = string.to_s
|
|
15
|
+
result = data.gsub(/([A-Z]+)(?=[A-Z][a-z])|([a-z\d])(?=[A-Z])/) do
|
|
14
16
|
($1 || $2) << "_"
|
|
15
17
|
end.tr('-', '_').downcase
|
|
18
|
+
|
|
19
|
+
is_symbol ? result.to_sym : result
|
|
16
20
|
end
|
|
17
21
|
end
|
|
18
22
|
end
|
data/lib/mangadex/version.rb
CHANGED
data/mangadex.gemspec
CHANGED
|
@@ -22,7 +22,7 @@ Gem::Specification.new do |spec|
|
|
|
22
22
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
|
23
23
|
spec.require_paths = ["lib"]
|
|
24
24
|
|
|
25
|
-
spec.add_dependency "psych", "
|
|
25
|
+
spec.add_dependency "psych", ">= 4.0.1", "< 5.2.0"
|
|
26
26
|
spec.add_dependency "rest-client", "~> 2.1"
|
|
27
27
|
spec.add_dependency "sorbet-runtime"
|
|
28
28
|
|
metadata
CHANGED
|
@@ -1,29 +1,35 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: mangadex
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 5.
|
|
4
|
+
version: 5.10.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Akinyele Cafe-Febrissy
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2023-06-07 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: psych
|
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
|
16
16
|
requirements:
|
|
17
|
-
- - "
|
|
17
|
+
- - ">="
|
|
18
18
|
- !ruby/object:Gem::Version
|
|
19
19
|
version: 4.0.1
|
|
20
|
+
- - "<"
|
|
21
|
+
- !ruby/object:Gem::Version
|
|
22
|
+
version: 5.2.0
|
|
20
23
|
type: :runtime
|
|
21
24
|
prerelease: false
|
|
22
25
|
version_requirements: !ruby/object:Gem::Requirement
|
|
23
26
|
requirements:
|
|
24
|
-
- - "
|
|
27
|
+
- - ">="
|
|
25
28
|
- !ruby/object:Gem::Version
|
|
26
29
|
version: 4.0.1
|
|
30
|
+
- - "<"
|
|
31
|
+
- !ruby/object:Gem::Version
|
|
32
|
+
version: 5.2.0
|
|
27
33
|
- !ruby/object:Gem::Dependency
|
|
28
34
|
name: rest-client
|
|
29
35
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -174,6 +180,7 @@ files:
|
|
|
174
180
|
- lib/mangadex/internal/definitions/accepts.rb
|
|
175
181
|
- lib/mangadex/internal/definitions/base.rb
|
|
176
182
|
- lib/mangadex/internal/definitions/content_rating.rb
|
|
183
|
+
- lib/mangadex/internal/definitions/year.rb
|
|
177
184
|
- lib/mangadex/internal/request.rb
|
|
178
185
|
- lib/mangadex/internal/with_attributes.rb
|
|
179
186
|
- lib/mangadex/manga.rb
|
|
@@ -190,6 +197,7 @@ files:
|
|
|
190
197
|
- lib/mangadex/storage/memory.rb
|
|
191
198
|
- lib/mangadex/storage/none.rb
|
|
192
199
|
- lib/mangadex/tag.rb
|
|
200
|
+
- lib/mangadex/thread.rb
|
|
193
201
|
- lib/mangadex/types.rb
|
|
194
202
|
- lib/mangadex/upload.rb
|
|
195
203
|
- lib/mangadex/user.rb
|
|
@@ -246,7 +254,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
246
254
|
- !ruby/object:Gem::Version
|
|
247
255
|
version: '0'
|
|
248
256
|
requirements: []
|
|
249
|
-
rubygems_version: 3.
|
|
257
|
+
rubygems_version: 3.4.10
|
|
250
258
|
signing_key:
|
|
251
259
|
specification_version: 4
|
|
252
260
|
summary: Your next favourite Ruby gem for interacting with Mangadex.org
|