rubyhexagon 1.6.4 → 2.0.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/lib/rubyhexagon.rb +34 -18
- data/lib/rubyhexagon/api.rb +96 -0
- data/lib/rubyhexagon/{login.rb → api/artist.rb} +9 -19
- data/lib/rubyhexagon/api/note.rb +50 -0
- data/lib/rubyhexagon/api/pool.rb +51 -0
- data/lib/rubyhexagon/api/post.rb +92 -0
- data/lib/rubyhexagon/api/post/flag.rb +36 -0
- data/lib/rubyhexagon/api/post/tag_item.rb +36 -0
- data/lib/rubyhexagon/api/tag.rb +65 -0
- data/lib/rubyhexagon/api/tag/alias.rb +41 -0
- data/lib/rubyhexagon/api/tag/implication.rb +41 -0
- data/lib/rubyhexagon/api/user.rb +52 -0
- data/lib/rubyhexagon/artist.rb +44 -32
- data/lib/rubyhexagon/error.rb +4 -5
- data/lib/rubyhexagon/note.rb +112 -0
- data/lib/rubyhexagon/pool.rb +22 -50
- data/lib/rubyhexagon/post.rb +142 -161
- data/lib/rubyhexagon/post/flag.rb +78 -0
- data/lib/rubyhexagon/post/image.rb +114 -0
- data/lib/rubyhexagon/post/tag_item.rb +74 -0
- data/lib/rubyhexagon/search/posts.rb +3 -3
- data/lib/rubyhexagon/tag.rb +20 -47
- data/lib/rubyhexagon/tag/alias.rb +87 -0
- data/lib/rubyhexagon/tag/implication.rb +91 -0
- data/lib/rubyhexagon/tag/type.rb +79 -0
- data/lib/rubyhexagon/user.rb +24 -30
- data/lib/rubyhexagon/user/level.rb +92 -0
- metadata +22 -13
- data/lib/rubyhexagon/helper/api.rb +0 -99
- data/lib/rubyhexagon/image.rb +0 -122
- data/lib/rubyhexagon/level.rb +0 -58
- data/lib/rubyhexagon/search/flag_history.rb +0 -62
- data/lib/rubyhexagon/search/pools.rb +0 -62
- data/lib/rubyhexagon/search/tag_history.rb +0 -61
- data/lib/rubyhexagon/search/tags.rb +0 -139
- data/lib/rubyhexagon/tag_change.rb +0 -69
- data/lib/rubyhexagon/type.rb +0 -72
@@ -1,69 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
# Copyright 2014-2018 Maxine Michalski <maxine@furfind.net>
|
4
|
-
#
|
5
|
-
# This file is part of rubyhexagon.
|
6
|
-
#
|
7
|
-
# rubyhexagon is free software: you can redistribute it and/or modify
|
8
|
-
# it under the terms of the GNU General Public License as published by
|
9
|
-
# the Free Software Foundation, either version 3 of the License, or
|
10
|
-
# (at your option) any later version.
|
11
|
-
#
|
12
|
-
# rubyhexagon is distributed in the hope that it will be useful,
|
13
|
-
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
14
|
-
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
15
|
-
# GNU General Public License for more details.
|
16
|
-
# You should have received a copy of the GNU General Public License
|
17
|
-
# along with rubyhexagon. If not, see <http://www.gnu.org/licenses/>.
|
18
|
-
|
19
|
-
module Rubyhexagon
|
20
|
-
# This class holds post information, fetched from e621, and gives access in a
|
21
|
-
# more Ruby like manner.
|
22
|
-
#
|
23
|
-
# @author Maxine Michalski
|
24
|
-
# @since 1.4.0
|
25
|
-
class TagChange
|
26
|
-
# @return [Integer] change ID
|
27
|
-
attr_reader :id
|
28
|
-
|
29
|
-
# @return [Integer] post ID that got updated
|
30
|
-
attr_reader :post_id
|
31
|
-
|
32
|
-
# @return [Time] time of change
|
33
|
-
attr_reader :created_at
|
34
|
-
|
35
|
-
# @return [Array<String>] new tags
|
36
|
-
attr_reader :tags
|
37
|
-
|
38
|
-
# @return [Array<String>] new sources
|
39
|
-
attr_reader :sources
|
40
|
-
|
41
|
-
# @author Maxine Michalski
|
42
|
-
#
|
43
|
-
# Initializer for TagChange
|
44
|
-
#
|
45
|
-
# @param post [Hash]
|
46
|
-
#
|
47
|
-
# @return the object
|
48
|
-
def initialize(post)
|
49
|
-
post.each do |k, v|
|
50
|
-
if k.to_s =~ /id$/
|
51
|
-
v = v.to_i
|
52
|
-
unless k.to_s.match(/id$/) && v.is_a?(Integer) && v.positive?
|
53
|
-
raise InvalidIDError, "ID out of range: #{v}"
|
54
|
-
end
|
55
|
-
end
|
56
|
-
instance_variable_set("@#{k}".to_sym, v)
|
57
|
-
end
|
58
|
-
end
|
59
|
-
|
60
|
-
# @author Maxine Michalski
|
61
|
-
#
|
62
|
-
# Comparison method for tag changes
|
63
|
-
#
|
64
|
-
# @return [TrueClass, FalseClass]
|
65
|
-
def ==(other)
|
66
|
-
other.is_a?(TagChange) && @id == other.id
|
67
|
-
end
|
68
|
-
end
|
69
|
-
end
|
data/lib/rubyhexagon/type.rb
DELETED
@@ -1,72 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
# Copyright 2014-2018 Maxine Michalski <maxine@furfind.net>
|
4
|
-
#
|
5
|
-
# This file is part of rubyhexagon.
|
6
|
-
#
|
7
|
-
# rubyhexagon is free software: you can redistribute it and/or modify
|
8
|
-
# it under the terms of the GNU General Public License as published by
|
9
|
-
# the Free Software Foundation, either version 3 of the License, or
|
10
|
-
# (at your option) any later version.
|
11
|
-
#
|
12
|
-
# rubyhexagon is distributed in the hope that it will be useful,
|
13
|
-
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
14
|
-
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
15
|
-
# GNU General Public License for more details.
|
16
|
-
# You should have received a copy of the GNU General Public License
|
17
|
-
# along with rubyhexagon. If not, see <http://www.gnu.org/licenses/>.
|
18
|
-
|
19
|
-
module Rubyhexagon
|
20
|
-
# Class to hold type information.
|
21
|
-
#
|
22
|
-
# @api private
|
23
|
-
# @author Maxine Michalski
|
24
|
-
# @since 1.0.0
|
25
|
-
class Type
|
26
|
-
# @return [Integer] id of type
|
27
|
-
attr_reader :id
|
28
|
-
|
29
|
-
# @return [String] name of type
|
30
|
-
attr_reader :name
|
31
|
-
|
32
|
-
# @author Maxine Michalski
|
33
|
-
#
|
34
|
-
# Initializer for Type.
|
35
|
-
#
|
36
|
-
# @raise ArgumentError if type ID is not valid
|
37
|
-
#
|
38
|
-
# @param type [Hash] type data, fetched from e621
|
39
|
-
# @option type [Integer] :id Type ID (can be one of 0, 1, 3, 4 or 5
|
40
|
-
# @option type [
|
41
|
-
#
|
42
|
-
# @return the object
|
43
|
-
def initialize(id, locked)
|
44
|
-
unless [0, 1, 3, 4, 5].include?(id)
|
45
|
-
raise ArgumentError, "Unkown type id: #{id}"
|
46
|
-
end
|
47
|
-
@id = id.to_i
|
48
|
-
@name = [:general, :artist, nil, :copyright, :character, :species][@id]
|
49
|
-
@locked = locked ? true : false
|
50
|
-
end
|
51
|
-
|
52
|
-
# @author Maxine Michalski
|
53
|
-
#
|
54
|
-
# Comparison method for Types, to give a more meaningful comparison.
|
55
|
-
#
|
56
|
-
# @return [TrueClass, FalseClass]
|
57
|
-
def ==(other)
|
58
|
-
other.is_a?(Type) && @id == other.id && @name == other.name &&
|
59
|
-
@locked == other.locked?
|
60
|
-
end
|
61
|
-
|
62
|
-
# @author Maxine Michalski
|
63
|
-
#
|
64
|
-
# Check if this type is locked for the tag who has it assigned.
|
65
|
-
#
|
66
|
-
# @return [TrueClass] tag type is locked
|
67
|
-
# @return [FalseClass] tag type is not locked
|
68
|
-
def locked?
|
69
|
-
@locked
|
70
|
-
end
|
71
|
-
end
|
72
|
-
end
|