mangadex 5.4.11.2 → 5.5.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +14 -19
- data/README.md +23 -0
- data/lib/extensions.rb +199 -5
- data/lib/mangadex/api/response.rb +10 -0
- data/lib/mangadex/chapter.rb +1 -6
- data/lib/mangadex/content_rating.rb +6 -7
- data/lib/mangadex/cover_art.rb +1 -0
- data/lib/mangadex/internal/definition.rb +2 -2
- data/lib/mangadex/internal/request.rb +1 -3
- data/lib/mangadex/internal/with_attributes.rb +11 -16
- data/lib/mangadex/manga.rb +3 -0
- data/lib/mangadex/mangadex_object.rb +1 -2
- data/lib/mangadex/relationship.rb +1 -1
- data/lib/mangadex/utils.rb +19 -0
- data/lib/mangadex/version.rb +3 -3
- data/lib/mangadex.rb +1 -1
- data/mangadex.gemspec +0 -1
- metadata +3 -16
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9af83b63f2dd0e3b6a23a1536fbf726979ba352a28d9625f8056366709520c19
|
4
|
+
data.tar.gz: 92587895df8db92ef0910f2e3ee6adb6b0a92891f77e358a90a49f08a24b8eb2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a236969d31689030cc2695cbb2f5faaba6a449e950c651a8bf008967580e1ca81989b997c33d9d69b594d5f81406c4797300388dc01d6446c010506ab4e81b67
|
7
|
+
data.tar.gz: 9bc990f30a1a2962f40cce8b3bff9b95903a17b46840708f1016ee0b4dffe5e990a4a2ecb0d24c461a160d0947b0ada7034840f281de0c620ad7e55ad9b86959
|
data/Gemfile.lock
CHANGED
@@ -1,8 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
mangadex (5.
|
5
|
-
activesupport (~> 6.1)
|
4
|
+
mangadex (5.5.6)
|
6
5
|
psych (~> 4.0.1)
|
7
6
|
rest-client (~> 2.1)
|
8
7
|
sorbet-runtime
|
@@ -10,32 +9,31 @@ PATH
|
|
10
9
|
GEM
|
11
10
|
remote: https://rubygems.org/
|
12
11
|
specs:
|
13
|
-
activesupport (
|
12
|
+
activesupport (7.0.1)
|
14
13
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
15
14
|
i18n (>= 1.6, < 2)
|
16
15
|
minitest (>= 5.1)
|
17
16
|
tzinfo (~> 2.0)
|
18
|
-
zeitwerk (~> 2.3)
|
19
17
|
addressable (2.8.0)
|
20
18
|
public_suffix (>= 2.0.2, < 5.0)
|
21
19
|
coderay (1.1.3)
|
22
20
|
concurrent-ruby (1.1.9)
|
23
21
|
crack (0.4.5)
|
24
22
|
rexml
|
25
|
-
diff-lcs (1.
|
23
|
+
diff-lcs (1.5.0)
|
26
24
|
domain_name (0.5.20190701)
|
27
25
|
unf (>= 0.0.5, < 1.0.0)
|
28
26
|
hashdiff (1.0.1)
|
29
27
|
http-accept (1.7.0)
|
30
28
|
http-cookie (1.0.4)
|
31
29
|
domain_name (~> 0.5)
|
32
|
-
i18n (1.
|
30
|
+
i18n (1.9.1)
|
33
31
|
concurrent-ruby (~> 1.0)
|
34
32
|
method_source (1.0.0)
|
35
33
|
mime-types (3.4.1)
|
36
34
|
mime-types-data (~> 3.2015)
|
37
35
|
mime-types-data (3.2022.0105)
|
38
|
-
minitest (5.
|
36
|
+
minitest (5.15.0)
|
39
37
|
mustermann (1.1.1)
|
40
38
|
ruby2_keywords (~> 0.0.1)
|
41
39
|
netrc (0.11.0)
|
@@ -65,27 +63,26 @@ GEM
|
|
65
63
|
rspec-core (~> 3.10.0)
|
66
64
|
rspec-expectations (~> 3.10.0)
|
67
65
|
rspec-mocks (~> 3.10.0)
|
68
|
-
rspec-core (3.10.
|
66
|
+
rspec-core (3.10.2)
|
69
67
|
rspec-support (~> 3.10.0)
|
70
|
-
rspec-expectations (3.10.
|
68
|
+
rspec-expectations (3.10.2)
|
71
69
|
diff-lcs (>= 1.2.0, < 2.0)
|
72
70
|
rspec-support (~> 3.10.0)
|
73
|
-
rspec-mocks (3.10.
|
71
|
+
rspec-mocks (3.10.3)
|
74
72
|
diff-lcs (>= 1.2.0, < 2.0)
|
75
73
|
rspec-support (~> 3.10.0)
|
76
|
-
rspec-support (3.10.
|
74
|
+
rspec-support (3.10.3)
|
77
75
|
ruby2_keywords (0.0.5)
|
78
76
|
sinatra (2.1.0)
|
79
77
|
mustermann (~> 1.0)
|
80
78
|
rack (~> 2.2)
|
81
79
|
rack-protection (= 2.1.0)
|
82
80
|
tilt (~> 2.0)
|
83
|
-
smart_properties (1.
|
84
|
-
sorbet (0.5.
|
85
|
-
sorbet-static (= 0.5.
|
86
|
-
sorbet-runtime (0.5.
|
87
|
-
sorbet-static (0.5.
|
88
|
-
sorbet-static (0.5.9152-x86_64-linux)
|
81
|
+
smart_properties (1.17.0)
|
82
|
+
sorbet (0.5.9619)
|
83
|
+
sorbet-static (= 0.5.9619)
|
84
|
+
sorbet-runtime (0.5.9724)
|
85
|
+
sorbet-static (0.5.9619-x86_64-linux)
|
89
86
|
stringio (3.0.1)
|
90
87
|
tilt (2.0.10)
|
91
88
|
tzinfo (2.0.4)
|
@@ -97,10 +94,8 @@ GEM
|
|
97
94
|
addressable (>= 2.8.0)
|
98
95
|
crack (>= 0.3.2)
|
99
96
|
hashdiff (>= 0.4.0, < 2.0.0)
|
100
|
-
zeitwerk (2.4.2)
|
101
97
|
|
102
98
|
PLATFORMS
|
103
|
-
x86_64-darwin-20
|
104
99
|
x86_64-linux
|
105
100
|
|
106
101
|
DEPENDENCIES
|
data/README.md
CHANGED
@@ -4,6 +4,15 @@
|
|
4
4
|
|
5
5
|
Welcome to `mangadex`, your next favourite Ruby gem for interacting with [Mangadex](https://mangadex.org).
|
6
6
|
|
7
|
+
## Important information
|
8
|
+
|
9
|
+
**By using this gem you accept**:
|
10
|
+
- To **credit [Mangadex](https://mangadex.org)**. This gem is your friendly neighbourhood wrapper on _their_ API.
|
11
|
+
- To **credit scanlation groups**, especially if you offer the ability to read chapters.
|
12
|
+
- **Not to run any ads** on the service that will use this gem. Please do not make money off of Mangadex's services.
|
13
|
+
|
14
|
+
These are Mangadex's [rules](https://api.mangadex.org/docs.html#section/Acceptable-use-policy), please follow them.
|
15
|
+
|
7
16
|
## Installation
|
8
17
|
|
9
18
|
Add this line to your application's Gemfile:
|
@@ -81,6 +90,8 @@ found_manga = response.data
|
|
81
90
|
|
82
91
|
#### Authenticate
|
83
92
|
|
93
|
+
with a block...:
|
94
|
+
|
84
95
|
```ruby
|
85
96
|
Mangadex::Auth.login(username: 'username', password: 'password') do |user|
|
86
97
|
# `user` is of type Mangadex::Api::User
|
@@ -91,6 +102,18 @@ Mangadex::Auth.login(username: 'username', password: 'password') do |user|
|
|
91
102
|
end
|
92
103
|
```
|
93
104
|
|
105
|
+
...or inline...:
|
106
|
+
|
107
|
+
```ruby
|
108
|
+
# `user` is of type Mangadex::Api::User
|
109
|
+
user = Mangadex::Auth.login(username: 'username', password: 'password')
|
110
|
+
|
111
|
+
puts(user.mangadex_user_id)
|
112
|
+
puts(user.session)
|
113
|
+
puts(user.refresh)
|
114
|
+
puts(user.session_valid_until)
|
115
|
+
```
|
116
|
+
|
94
117
|
You can access the authenticated user by using context:
|
95
118
|
|
96
119
|
```ruby
|
data/lib/extensions.rb
CHANGED
@@ -1,12 +1,206 @@
|
|
1
1
|
# typed: true
|
2
|
-
|
2
|
+
|
3
|
+
class Array
|
4
|
+
def to_query(key)
|
5
|
+
prefix = "#{key}[]"
|
6
|
+
|
7
|
+
if empty?
|
8
|
+
nil.to_query(prefix)
|
9
|
+
else
|
10
|
+
collect { |value| value.to_query(prefix) }.join "&"
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
def to_param
|
15
|
+
collect(&:to_param).join "/"
|
16
|
+
end
|
17
|
+
end
|
3
18
|
|
4
19
|
class Hash
|
5
|
-
def
|
6
|
-
|
20
|
+
def symbolize_keys
|
21
|
+
transform_keys { |key| key.to_sym rescue key }
|
22
|
+
end
|
23
|
+
|
24
|
+
def to_query(namespace = nil)
|
25
|
+
query = collect do |key, value|
|
26
|
+
unless (value.is_a?(Hash) || value.is_a?(Array)) && value.empty?
|
27
|
+
value.to_query(namespace ? "#{namespace}[#{key}]" : key)
|
28
|
+
end
|
29
|
+
end.compact
|
30
|
+
|
31
|
+
query.sort! unless namespace.to_s.include?("[]")
|
32
|
+
query.join("&")
|
33
|
+
end
|
34
|
+
alias_method :to_param, :to_query
|
35
|
+
|
36
|
+
def deep_transform_keys(&block)
|
37
|
+
_deep_transform_keys_in_object(self, &block)
|
38
|
+
end
|
39
|
+
|
40
|
+
private
|
41
|
+
|
42
|
+
def _deep_transform_keys_in_object(object, &block)
|
43
|
+
case object
|
44
|
+
when Hash
|
45
|
+
object.each_with_object({}) do |(key, value), result|
|
46
|
+
result[yield(key)] = _deep_transform_keys_in_object(value, &block)
|
47
|
+
end
|
48
|
+
when Array
|
49
|
+
object.map { |e| _deep_transform_keys_in_object(e, &block) }
|
50
|
+
else
|
51
|
+
object
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
class Object
|
57
|
+
def blank?
|
58
|
+
respond_to?(:empty?) ? !!empty? : !self
|
59
|
+
end
|
60
|
+
|
61
|
+
def present?
|
62
|
+
!blank?
|
63
|
+
end
|
64
|
+
|
65
|
+
def presence
|
66
|
+
present? ? self : nil
|
67
|
+
end
|
68
|
+
|
69
|
+
def to_param
|
70
|
+
to_s
|
71
|
+
end
|
72
|
+
|
73
|
+
def to_query(key)
|
74
|
+
"#{CGI.escape(key.to_param)}=#{CGI.escape(to_param.to_s)}"
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
class NilClass
|
79
|
+
def to_param
|
80
|
+
self
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
class TrueClass
|
85
|
+
def to_param
|
86
|
+
self
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
class FalseClass
|
91
|
+
def to_param
|
92
|
+
self
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
class String
|
97
|
+
def to_query(key)
|
98
|
+
"#{CGI.escape(key.to_param)}=#{CGI.escape(to_param.to_s)}"
|
99
|
+
end
|
100
|
+
|
101
|
+
def to_param
|
102
|
+
to_s
|
103
|
+
end
|
104
|
+
end
|
105
|
+
|
106
|
+
class Symbol
|
107
|
+
def to_query(key)
|
108
|
+
"#{CGI.escape(key.to_param)}=#{CGI.escape(to_param.to_s)}"
|
109
|
+
end
|
110
|
+
end
|
111
|
+
|
112
|
+
class StringInquirer < String
|
113
|
+
private
|
114
|
+
|
115
|
+
def respond_to_missing?(method_name, include_private = false)
|
116
|
+
method_name.end_with?("?") || super
|
117
|
+
end
|
118
|
+
|
119
|
+
def method_missing(method_name, *arguments)
|
120
|
+
if method_name.end_with?("?")
|
121
|
+
self == method_name[0..-2]
|
122
|
+
else
|
123
|
+
super
|
124
|
+
end
|
7
125
|
end
|
126
|
+
end
|
127
|
+
|
128
|
+
module Concern
|
129
|
+
class MultipleIncludedBlocks < StandardError # :nodoc:
|
130
|
+
def initialize
|
131
|
+
super "Cannot define multiple 'included' blocks for a Concern"
|
132
|
+
end
|
133
|
+
end
|
134
|
+
|
135
|
+
class MultiplePrependBlocks < StandardError # :nodoc:
|
136
|
+
def initialize
|
137
|
+
super "Cannot define multiple 'prepended' blocks for a Concern"
|
138
|
+
end
|
139
|
+
end
|
140
|
+
|
141
|
+
def self.extended(base) # :nodoc:
|
142
|
+
base.instance_variable_set(:@_dependencies, [])
|
143
|
+
end
|
144
|
+
|
145
|
+
def append_features(base) # :nodoc:
|
146
|
+
if base.instance_variable_defined?(:@_dependencies)
|
147
|
+
base.instance_variable_get(:@_dependencies) << self
|
148
|
+
false
|
149
|
+
else
|
150
|
+
return false if base < self
|
151
|
+
@_dependencies.each { |dep| base.include(dep) }
|
152
|
+
super
|
153
|
+
base.extend const_get(:ClassMethods) if const_defined?(:ClassMethods)
|
154
|
+
base.class_eval(&@_included_block) if instance_variable_defined?(:@_included_block)
|
155
|
+
end
|
156
|
+
end
|
157
|
+
|
158
|
+
def prepend_features(base) # :nodoc:
|
159
|
+
if base.instance_variable_defined?(:@_dependencies)
|
160
|
+
base.instance_variable_get(:@_dependencies).unshift self
|
161
|
+
false
|
162
|
+
else
|
163
|
+
return false if base < self
|
164
|
+
@_dependencies.each { |dep| base.prepend(dep) }
|
165
|
+
super
|
166
|
+
base.singleton_class.prepend const_get(:ClassMethods) if const_defined?(:ClassMethods)
|
167
|
+
base.class_eval(&@_prepended_block) if instance_variable_defined?(:@_prepended_block)
|
168
|
+
end
|
169
|
+
end
|
170
|
+
|
171
|
+
def included(base = nil, &block)
|
172
|
+
if base.nil?
|
173
|
+
if instance_variable_defined?(:@_included_block)
|
174
|
+
if @_included_block.source_location != block.source_location
|
175
|
+
raise MultipleIncludedBlocks
|
176
|
+
end
|
177
|
+
else
|
178
|
+
@_included_block = block
|
179
|
+
end
|
180
|
+
else
|
181
|
+
super
|
182
|
+
end
|
183
|
+
end
|
184
|
+
|
185
|
+
def prepended(base = nil, &block)
|
186
|
+
if base.nil?
|
187
|
+
if instance_variable_defined?(:@_prepended_block)
|
188
|
+
if @_prepended_block.source_location != block.source_location
|
189
|
+
raise MultiplePrependBlocks
|
190
|
+
end
|
191
|
+
else
|
192
|
+
@_prepended_block = block
|
193
|
+
end
|
194
|
+
else
|
195
|
+
super
|
196
|
+
end
|
197
|
+
end
|
198
|
+
|
199
|
+
def class_methods(&class_methods_module_definition)
|
200
|
+
mod = const_defined?(:ClassMethods, false) ?
|
201
|
+
const_get(:ClassMethods) :
|
202
|
+
const_set(:ClassMethods, Module.new)
|
8
203
|
|
9
|
-
|
10
|
-
ActiveSupport::HashWithIndifferentAccess.new(self)
|
204
|
+
mod.module_eval(&class_methods_module_definition)
|
11
205
|
end
|
12
206
|
end
|
@@ -57,6 +57,8 @@ module Mangadex
|
|
57
57
|
def count
|
58
58
|
data.is_a?(Array) ? data.count : nil
|
59
59
|
end
|
60
|
+
alias_method :size, :count
|
61
|
+
alias_method :length, :count
|
60
62
|
|
61
63
|
def each(&block)
|
62
64
|
if data.is_a?(Array)
|
@@ -70,6 +72,14 @@ module Mangadex
|
|
70
72
|
each.to_a
|
71
73
|
end
|
72
74
|
|
75
|
+
def first
|
76
|
+
to_a.first
|
77
|
+
end
|
78
|
+
|
79
|
+
def last
|
80
|
+
to_a.last
|
81
|
+
end
|
82
|
+
|
73
83
|
def as_json(*)
|
74
84
|
Hash(raw_data)
|
75
85
|
end
|
data/lib/mangadex/chapter.rb
CHANGED
@@ -15,6 +15,7 @@ module Mangadex
|
|
15
15
|
:uploader,
|
16
16
|
:external_url,
|
17
17
|
:version,
|
18
|
+
:readable_at,
|
18
19
|
:created_at,
|
19
20
|
:updated_at,
|
20
21
|
:publish_at
|
@@ -80,12 +81,6 @@ module Mangadex
|
|
80
81
|
Mangadex::AtHome.page_urls(id, data_saver: data_saver)
|
81
82
|
end
|
82
83
|
|
83
|
-
def as_json(*)
|
84
|
-
super.merge({
|
85
|
-
preview_image_url: preview_image_url,
|
86
|
-
})
|
87
|
-
end
|
88
|
-
|
89
84
|
def self.attributes_to_inspect
|
90
85
|
[:id, :type, :title, :volume, :chapter, :pages, :publish_at]
|
91
86
|
end
|
@@ -1,7 +1,4 @@
|
|
1
1
|
# typed: false
|
2
|
-
require "active_support/string_inquirer"
|
3
|
-
require "active_support/core_ext/module/delegation"
|
4
|
-
|
5
2
|
module Mangadex
|
6
3
|
class ContentRating
|
7
4
|
extend T::Sig
|
@@ -21,8 +18,6 @@ module Mangadex
|
|
21
18
|
PORNOGRAPHIC => 3,
|
22
19
|
}.freeze
|
23
20
|
|
24
|
-
delegate_missing_to :value
|
25
|
-
|
26
21
|
sig { params(content_rating: T::Api::ContentRating).returns(T::Array[ContentRating]) }
|
27
22
|
def self.anything_below(content_rating)
|
28
23
|
SCORES.keys.map { |key| ContentRating.new(key) }.select { |record| record <= content_rating }.sort
|
@@ -38,9 +33,9 @@ module Mangadex
|
|
38
33
|
@value = ensure_value!(value.to_s)
|
39
34
|
end
|
40
35
|
|
41
|
-
sig { returns(
|
36
|
+
sig { returns(StringInquirer) }
|
42
37
|
def value
|
43
|
-
|
38
|
+
StringInquirer.new(@value)
|
44
39
|
end
|
45
40
|
|
46
41
|
sig { params(other: T.any(ContentRating, String, Symbol)).returns(Integer) }
|
@@ -67,6 +62,10 @@ module Mangadex
|
|
67
62
|
value.to_s
|
68
63
|
end
|
69
64
|
|
65
|
+
def method_missing(method_name, *args, **kwargs)
|
66
|
+
value.send(method_name, *args, **kwargs)
|
67
|
+
end
|
68
|
+
|
70
69
|
private
|
71
70
|
|
72
71
|
sig { params(value: T.any(T::Api::Text, T::Api::ContentRating)).returns(T.any(T::Api::Text, T::Api::ContentRating)) }
|
data/lib/mangadex/cover_art.rb
CHANGED
@@ -140,8 +140,8 @@ module Mangadex
|
|
140
140
|
end
|
141
141
|
|
142
142
|
def validate(args, definition)
|
143
|
-
args = Hash(args)
|
144
|
-
definition = Hash(definition)
|
143
|
+
args = Hash(args)
|
144
|
+
definition = Hash(definition)
|
145
145
|
return args if definition.empty?
|
146
146
|
|
147
147
|
errors = []
|
@@ -1,8 +1,6 @@
|
|
1
1
|
# typed: false
|
2
2
|
require 'rest-client'
|
3
3
|
require 'json'
|
4
|
-
require 'active_support/core_ext/object/to_query'
|
5
|
-
require 'active_support/core_ext/hash/keys'
|
6
4
|
|
7
5
|
module Mangadex
|
8
6
|
module Internal
|
@@ -84,7 +82,7 @@ module Mangadex
|
|
84
82
|
return path if params.blank?
|
85
83
|
|
86
84
|
params = params.deep_transform_keys do |key|
|
87
|
-
key.to_s
|
85
|
+
Mangadex::Utils.camelize(key.to_s)
|
88
86
|
end
|
89
87
|
"#{path}?#{params.to_query}"
|
90
88
|
end
|
@@ -1,11 +1,9 @@
|
|
1
1
|
# typed: false
|
2
2
|
|
3
|
-
require "active_support/hash_with_indifferent_access"
|
4
|
-
|
5
3
|
module Mangadex
|
6
4
|
module Internal
|
7
5
|
module WithAttributes
|
8
|
-
extend
|
6
|
+
extend Concern
|
9
7
|
|
10
8
|
attr_accessor \
|
11
9
|
:id,
|
@@ -28,16 +26,18 @@ module Mangadex
|
|
28
26
|
end
|
29
27
|
|
30
28
|
def type
|
31
|
-
self.name.split('::').last
|
29
|
+
Mangadex::Utils.underscore(self.name.split('::').last)
|
32
30
|
end
|
33
31
|
|
34
32
|
def from_data(data, related_type: nil, source_obj: nil)
|
35
33
|
base_class_name = self.name.gsub('::', '_')
|
36
34
|
klass_name = self.name
|
37
35
|
target_attributes_class_name = "#{base_class_name}_Attributes"
|
38
|
-
|
36
|
+
|
37
|
+
data = data.transform_keys(&:to_s)
|
38
|
+
|
39
39
|
klass = if const_defined?(target_attributes_class_name)
|
40
|
-
target_attributes_class_name
|
40
|
+
Object.const_get(target_attributes_class_name)
|
41
41
|
else
|
42
42
|
class_contents = <<-END
|
43
43
|
# typed: true
|
@@ -54,13 +54,12 @@ module Mangadex
|
|
54
54
|
Object.const_get(target_attributes_class_name)
|
55
55
|
end
|
56
56
|
|
57
|
-
data = data.with_indifferent_access
|
58
|
-
|
59
57
|
relationships = data['relationships']&.map do |relationship_data|
|
60
58
|
Relationship.from_data(relationship_data, MangadexObject.new(**data))
|
61
59
|
end
|
62
60
|
|
63
|
-
|
61
|
+
found_attributes = data['attributes'] || {}
|
62
|
+
attributes = klass.new(**Hash(found_attributes.symbolize_keys))
|
64
63
|
|
65
64
|
initialize_hash = {
|
66
65
|
id: data['id'],
|
@@ -101,17 +100,13 @@ module Mangadex
|
|
101
100
|
attributes.send(method_name)
|
102
101
|
elsif any_relationships?
|
103
102
|
existing_relationships = relationships.map(&:type)
|
104
|
-
|
105
|
-
looking_for_relationship = original_relationship.singularize
|
106
|
-
is_looking_for_many = original_relationship != looking_for_relationship
|
103
|
+
looking_for_relationship = method_name.to_s
|
107
104
|
|
108
105
|
if existing_relationships.include?(looking_for_relationship)
|
109
|
-
|
110
|
-
relationships.send(search_method) do |relationship|
|
106
|
+
result = relationships.select do |relationship|
|
111
107
|
relationship.type == looking_for_relationship
|
112
108
|
end
|
113
|
-
|
114
|
-
[]
|
109
|
+
result.size == 1 ? result.first : result
|
115
110
|
else
|
116
111
|
super
|
117
112
|
end
|
data/lib/mangadex/manga.rb
CHANGED
@@ -19,6 +19,8 @@ module Mangadex
|
|
19
19
|
:tags,
|
20
20
|
:state,
|
21
21
|
:version,
|
22
|
+
:chapter_numbers_reset_on_new_volume,
|
23
|
+
:available_translated_languages,
|
22
24
|
:created_at,
|
23
25
|
:updated_at
|
24
26
|
|
@@ -116,6 +118,7 @@ module Mangadex
|
|
116
118
|
'/manga/random',
|
117
119
|
Mangadex::Internal::Definition.validate(args, {
|
118
120
|
includes: { accepts: Array },
|
121
|
+
content_rating: { accepts: %w(safe suggestive erotica pornographic), converts: to_a },
|
119
122
|
})
|
120
123
|
)
|
121
124
|
end
|
@@ -1,5 +1,4 @@
|
|
1
1
|
# typed: false
|
2
|
-
require "active_support/inflector"
|
3
2
|
require_relative "internal/with_attributes"
|
4
3
|
|
5
4
|
module Mangadex
|
@@ -19,7 +18,7 @@ module Mangadex
|
|
19
18
|
def initialize(**args)
|
20
19
|
args.keys.each do |attribute|
|
21
20
|
original_attribute = attribute
|
22
|
-
attribute = attribute.to_s
|
21
|
+
attribute = Mangadex::Utils.underscore(attribute.to_s)
|
23
22
|
attribute_to_set = "#{attribute}="
|
24
23
|
|
25
24
|
if respond_to?(attribute_to_set)
|
@@ -25,7 +25,7 @@ module Mangadex
|
|
25
25
|
# data: Relationship data
|
26
26
|
# source_obj: The object to witch the object belongs to
|
27
27
|
def from_data(data, source_obj = nil)
|
28
|
-
data = data.
|
28
|
+
data = data.transform_keys(&:to_s)
|
29
29
|
klass = class_for_relationship_type(data['type'])
|
30
30
|
|
31
31
|
if klass && data['attributes']&.any?
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# typed: false
|
2
|
+
|
3
|
+
module Mangadex
|
4
|
+
class Utils
|
5
|
+
class << self
|
6
|
+
def camelize(string, uppercase_first_letter = false)
|
7
|
+
string.split('_').each_with_index.map do |x, i|
|
8
|
+
i == 0 && !uppercase_first_letter ? x : x.capitalize
|
9
|
+
end.join
|
10
|
+
end
|
11
|
+
|
12
|
+
def underscore(string)
|
13
|
+
string.gsub(/([A-Z]+)(?=[A-Z][a-z])|([a-z\d])(?=[A-Z])/) do
|
14
|
+
($1 || $2) << "_"
|
15
|
+
end.tr('-', '_').downcase
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
data/lib/mangadex/version.rb
CHANGED
data/lib/mangadex.rb
CHANGED
data/mangadex.gemspec
CHANGED
@@ -24,7 +24,6 @@ Gem::Specification.new do |spec|
|
|
24
24
|
|
25
25
|
spec.add_dependency "psych", "~> 4.0.1"
|
26
26
|
spec.add_dependency "rest-client", "~> 2.1"
|
27
|
-
spec.add_dependency "activesupport", "~> 6.1"
|
28
27
|
spec.add_dependency "sorbet-runtime"
|
29
28
|
|
30
29
|
spec.add_development_dependency "bundler", "~> 2.2.19"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mangadex
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 5.
|
4
|
+
version: 5.5.6
|
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: 2022-
|
11
|
+
date: 2022-03-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: psych
|
@@ -38,20 +38,6 @@ dependencies:
|
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '2.1'
|
41
|
-
- !ruby/object:Gem::Dependency
|
42
|
-
name: activesupport
|
43
|
-
requirement: !ruby/object:Gem::Requirement
|
44
|
-
requirements:
|
45
|
-
- - "~>"
|
46
|
-
- !ruby/object:Gem::Version
|
47
|
-
version: '6.1'
|
48
|
-
type: :runtime
|
49
|
-
prerelease: false
|
50
|
-
version_requirements: !ruby/object:Gem::Requirement
|
51
|
-
requirements:
|
52
|
-
- - "~>"
|
53
|
-
- !ruby/object:Gem::Version
|
54
|
-
version: '6.1'
|
55
41
|
- !ruby/object:Gem::Dependency
|
56
42
|
name: sorbet-runtime
|
57
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -210,6 +196,7 @@ files:
|
|
210
196
|
- lib/mangadex/types.rb
|
211
197
|
- lib/mangadex/upload.rb
|
212
198
|
- lib/mangadex/user.rb
|
199
|
+
- lib/mangadex/utils.rb
|
213
200
|
- lib/mangadex/version.rb
|
214
201
|
- mangadex.gemspec
|
215
202
|
- sorbet/config
|