rubyhexagon 2.0.0 → 2.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: dd11e83da3191060c9511173288f9af58a6750c9
4
- data.tar.gz: eaa6a515b4ad4d00d1dff2a0766c735b7873cfa6
3
+ metadata.gz: db0b8e40637feb6bbf0f6a51172e882da9f50302
4
+ data.tar.gz: 9313eabbf199ad7131adae13d2c07d7fa898bf1d
5
5
  SHA512:
6
- metadata.gz: 4aedb99ec447252a7b9abf1e327d339b55ba0472f15606f0bdee32fa968bf092e9deca3025a64413b1179ec089bb9567ffa72fb26632dd171dcecc20f15651a4
7
- data.tar.gz: f1923e822369f550161992477889872e8659a25c1f8817d5c373b89e68b16b20fe98a3df3acdb2026fcc9151e391dbb61471289d1f8411f3f928c29681e568c3
6
+ metadata.gz: 89e0c912d9b3acd09811fb3924af6716c8341effa924853457b44d4354316b05f7358fb337c8d4a1445be40e810d6a17bfbddb6935e8c4064f8755b372a1b60d
7
+ data.tar.gz: a383b82a2671b960b96f326667d6bfe552017ad83a6c69cb4807521fcd39283b8a0239f090e6e8e920c055d1e1f599b4cdbf9251d15f5d766e983e7b2e0c749f
@@ -26,9 +26,9 @@ require 'tempfile'
26
26
  require_relative 'rubyhexagon/error'
27
27
 
28
28
  require_relative 'rubyhexagon/artist'
29
- require_relative 'rubyhexagon/note'
30
29
  require_relative 'rubyhexagon/post'
31
30
  require_relative 'rubyhexagon/post/flag'
31
+ require_relative 'rubyhexagon/post/note'
32
32
  require_relative 'rubyhexagon/post/tag_item'
33
33
  require_relative 'rubyhexagon/pool'
34
34
  require_relative 'rubyhexagon/post/image'
@@ -48,7 +48,7 @@ module Rubyhexagon
48
48
  # Minor version part
49
49
  MINOR = 0
50
50
  # Patch version part
51
- PATCH = 0
51
+ PATCH = 1
52
52
  # Name of gem
53
53
  NAME = 'rubyhexagon'
54
54
  # Full version string
@@ -62,9 +62,9 @@ E621 = Rubyhexagon
62
62
 
63
63
  require_relative 'rubyhexagon/api'
64
64
  require_relative 'rubyhexagon/api/artist'
65
- require_relative 'rubyhexagon/api/note'
66
65
  require_relative 'rubyhexagon/api/post'
67
66
  require_relative 'rubyhexagon/api/post/flag'
67
+ require_relative 'rubyhexagon/api/post/note'
68
68
  require_relative 'rubyhexagon/api/post/tag_item'
69
69
  require_relative 'rubyhexagon/api/pool'
70
70
  require_relative 'rubyhexagon/api/tag'
@@ -73,7 +73,7 @@ module Rubyhexagon
73
73
 
74
74
  # @author Maxine Michalski
75
75
  #
76
- # A method to make locking easier and that ensures 1 request per scondd.
76
+ # A method to make locking easier and that ensures 1 request per scondd
77
77
  #
78
78
  # @return [Object]
79
79
  def self.lock
@@ -20,8 +20,18 @@ module Rubyhexagon
20
20
  # A class to interact with the e621 web interface.
21
21
  #
22
22
  # @author Maxine Michalski
23
+ # @api public
23
24
  # @since 2.0.0
24
25
  class Artist
26
+ # @author Maxine Michalski
27
+ #
28
+ # Fetch a list of artists
29
+ #
30
+ # @param query [Hsah] Query for fetching artist data
31
+ # @example Get list of artists
32
+ # E621::Artist.list(name: 'artist') #=> Array<E621::Artist>
33
+ # @return [Array<E621::Artist>]
34
+ # @see https://e621.net/help/show/api#artists
25
35
  def self.list(query)
26
36
  raise ArgumentError, 'A Hash is required' unless query.is_a?(Hash)
27
37
  E621::API.fetch(:artist, :index, query).map do |artist|
@@ -20,8 +20,19 @@ module Rubyhexagon
20
20
  # A class to interact with the e621 web interface.
21
21
  #
22
22
  # @author Maxine Michalski
23
+ # @api public
23
24
  # @since 1.4.0
24
25
  class Pool
26
+ # @author Maxine Michalski
27
+ #
28
+ # Fetch pool information
29
+ #
30
+ # @param pool [E621::Pool|Hash] A pool or hash to fetch data for
31
+ # @param page [Hash]
32
+ # @example Get pool information
33
+ # E621::Pool.show(id: 1, page: 1) #=> E621::Pool
34
+ # @return [E621::Pool]
35
+ # @see https://e621.net/help/show/api#pools
25
36
  def self.show(pool, page = nil)
26
37
  unless (pool.is_a?(Hash) && pool[:id].is_a?(Integer)) ||
27
38
  pool.is_a?(E621::Pool)
@@ -34,6 +45,15 @@ module Rubyhexagon
34
45
  end
35
46
  end
36
47
 
48
+ # @author Maxine Michalski
49
+ #
50
+ # Fetch a list of pools
51
+ #
52
+ # @param query [Hsah] Query for fetching pool data
53
+ # @example Get list of pools
54
+ # E621::Pool.list(name: 'moo', page: 1) #=> Array<E621::Pool>
55
+ # @return [Array<E621::Pool>]
56
+ # @see https://e621.net/help/show/api#pools
37
57
  def self.list(query)
38
58
  raise ArgumentError, 'A Hash is required' unless query.is_a?(Hash)
39
59
  E621::API.fetch(:pool, :index, query).map do |pool|
@@ -41,6 +61,15 @@ module Rubyhexagon
41
61
  end
42
62
  end
43
63
 
64
+ # @author Maxine Michalski
65
+ #
66
+ # Fetch pool information
67
+ #
68
+ # @param page [Hash]
69
+ # @example Get pool information
70
+ # poolshow(page: 1) #=> E621::Pool
71
+ # @return [E621::Pool]
72
+ # @see https://e621.net/help/show/api#pools
44
73
  def show(page)
45
74
  page = page[:page]
46
75
  E621::API.fetch(:pool, :show, id: @id, page: page)[:posts].map do |post|
@@ -20,15 +20,18 @@ module Rubyhexagon
20
20
  # A class to interact with the e621 web interface.
21
21
  #
22
22
  # @author Maxine Michalski
23
+ # @api public
23
24
  # @since 1.4.0
24
25
  class Post
25
26
  # @author Maxine Michalski
26
27
  #
27
28
  # Fetch data for post
28
29
  #
29
- # @param user [Hash|E621::Post] User data to fetch from
30
- #
30
+ # @param post [Hash|E621::Post] User data to fetch from
31
+ # @example Get Post information
32
+ # E621::Post.show(id: 1) #=> E621::Post
31
33
  # @return [E621::Post]
34
+ # @see https://e621.net/help/show/api#posts
32
35
  def self.show(post)
33
36
  unless (post.is_a?(Hash) && post[:id].is_a?(Integer)) ||
34
37
  post.is_a?(E621::Post)
@@ -38,6 +41,16 @@ module Rubyhexagon
38
41
  new(E621::API.fetch(:post, :show, id: id))
39
42
  end
40
43
 
44
+ # @author Maxine Michalski
45
+ #
46
+ # Fetch tag information
47
+ #
48
+ # @note This method fetches complete tag information for a post
49
+ # @param post [Hash|E621::Post] User data to fetch from
50
+ # @example Get tags for post
51
+ # E621::Post.tags(id: 1) #=> Array<E621::Tag>
52
+ # @return [Array<E621::Tag>]
53
+ # @see https://e621.net/help/show/api#posts
41
54
  def self.tags(post)
42
55
  unless (post.is_a?(Hash) && post[:id].is_a?(Integer)) ||
43
56
  post.is_a?(E621::Post)
@@ -49,6 +62,14 @@ module Rubyhexagon
49
62
  end
50
63
  end
51
64
 
65
+ # @author Maxine Michalski
66
+ #
67
+ # Fetch a list of posts
68
+ #
69
+ # @example Get a list of posts
70
+ # E621::Post.list(tags: 'female') #=> Array<E621::Post>
71
+ # @return [Array<E621::Post>]
72
+ # @see https://e621.net/help/show/api#posts
52
73
  def self.list(query)
53
74
  raise ArgumentError, 'A Hash is required' unless query.is_a?(Hash)
54
75
  E621::API.fetch(:post, :index, query).map do |post|
@@ -56,6 +77,14 @@ module Rubyhexagon
56
77
  end
57
78
  end
58
79
 
80
+ # @author Maxine Michalski
81
+ #
82
+ # Fetch a list of deleted posts
83
+ #
84
+ # @example Get a list of deleted posts
85
+ # E621::Post.deleted(page: 1) #=> Array<E621::Post>
86
+ # @return [Array<E621::Post>]
87
+ # @see https://e621.net/help/show/api#posts
59
88
  def self.deleted(query)
60
89
  raise ArgumentError, 'A Hash is required' unless query.is_a?(Hash)
61
90
  E621::API.fetch(:post, :deleted_index, query).map do |post|
@@ -63,6 +92,14 @@ module Rubyhexagon
63
92
  end
64
93
  end
65
94
 
95
+ # @author Maxine Michalski
96
+ #
97
+ # Fetch a list of popular posts
98
+ #
99
+ # @example Get popular posts, by day
100
+ # E621::Post.popular_by(:day) #=> E621::Post
101
+ # @return [Array<E621::Post>]
102
+ # @see https://e621.net/help/show/api#posts
66
103
  def self.popular_by(period)
67
104
  unless %i[day week month].include?(period)
68
105
  raise ArgumentError, 'Period must be day, week or month'
@@ -72,10 +109,25 @@ module Rubyhexagon
72
109
  end
73
110
  end
74
111
 
112
+ # @author Maxine Michalski
113
+ #
114
+ # Fetch data for a post
115
+ #
116
+ # @example Get post data
117
+ # post.show #=> E621::Post
118
+ # @return [E621::Post]
119
+ # @see https://e621.net/help/show/api#posts
75
120
  def show
76
121
  E621::Post.new(E621::API.fetch(:post, :show, id: @id))
77
122
  end
78
123
 
124
+ # @author Maxine Michalski
125
+ #
126
+ # Download a file from a post
127
+ #
128
+ # @example Download file
129
+ # post.download(:image) #=> Tempfile
130
+ # @return [Tempfile]
79
131
  def download(which)
80
132
  unless %i[image preview sample].include?(which)
81
133
  raise ArgumentError, 'Unsupported doanload'
@@ -83,9 +135,17 @@ module Rubyhexagon
83
135
  E621::API.download(__send__(which).url)
84
136
  end
85
137
 
138
+ # @author Maxine Michalski
139
+ #
140
+ # List of notes, that belong to a post
141
+ #
142
+ # @example Get nots for a post
143
+ # post.notes #=> Array<E621::Post::Note>
144
+ # @return [E621::Post::Note]
145
+ # @see https://e621.net/help/show/api#notes
86
146
  def notes
87
147
  E621::API.fetch(:note, :index, post_id: @id).map do |n|
88
- E621::Note.new(n)
148
+ E621::Post::Note.new(n)
89
149
  end
90
150
  end
91
151
  end
@@ -21,8 +21,17 @@ module Rubyhexagon
21
21
  # A class to interact with the e621 web interface.
22
22
  #
23
23
  # @author Maxine Michalski
24
+ # @api public
24
25
  # @since 2.0.0
25
26
  class Flag
27
+ # @author Maxine Michalski
28
+ #
29
+ # Fetch a list of flags
30
+ #
31
+ # @example Get a list of posts
32
+ # E621::Post::Flagi.list(page: 1) #=> Array<E621::Post::Flag>
33
+ # @return [Array<E621::Flag>]
34
+ # @see https://e621.net/help/show/api#flaghistory
26
35
  def self.list(query)
27
36
  unless query.is_a?(Hash)
28
37
  raise ArgumentError, 'A Hash or Post object is required'
@@ -0,0 +1,77 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright 2014-2018, 2020 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 Post
21
+ # A class to interact with the e621 web interface.
22
+ #
23
+ # @author Maxine Michalski
24
+ # @api public
25
+ # @since 2.0.0
26
+ class Note
27
+ # @author Maxine Michalski
28
+ #
29
+ # Fetch a list of notes
30
+ #
31
+ # @example Get a list of notes
32
+ # E621::Post::Note.list(id: 1) #=> Array<E621::Post::Note>
33
+ # @return [Array<E621::Note>]
34
+ # @see https://e621.net/help/show/api#notes
35
+ def self.list(post)
36
+ unless post.is_a?(Hash) || post.is_a?(E621::Post)
37
+ raise ArgumentError, 'A Hash or Post object is required'
38
+ end
39
+ post.store(:post_id, post.delete(:id)) if post.is_a?(Hash)
40
+ post = { post_id: post.id } if post.is_a?(E621::Post)
41
+ E621::API.fetch(:note, :index, post).map do |note|
42
+ new(note)
43
+ end
44
+ end
45
+
46
+ # @author Maxine Michalski
47
+ #
48
+ # Search for notes
49
+ #
50
+ # @example Get a list of notes
51
+ # E621::Post::Note.search(query: 'moo') #=> Array<E621::Post::Note>
52
+ # @return [Array<E621::Note>]
53
+ # @see https://e621.net/help/show/api#notes
54
+ def self.search(query)
55
+ raise ArgumentError, 'A Hash is required' unless query.is_a?(Hash)
56
+ E621::API.fetch(:note, :search, query).map do |note|
57
+ new(note)
58
+ end
59
+ end
60
+
61
+ # @author Maxine Michalski
62
+ #
63
+ # Fetch a list of note versions
64
+ #
65
+ # @example Get a list of notes
66
+ # E621::Post::Note.list(post_id: 1) #=> Array<E621::Post::Note>
67
+ # @return [Array<E621::Note>]
68
+ # @see https://e621.net/help/show/api#notes
69
+ def self.history(query)
70
+ raise ArgumentError, 'A Hash is required' unless query.is_a?(Hash)
71
+ E621::API.fetch(:note, :history, query).map do |note|
72
+ new(note)
73
+ end
74
+ end
75
+ end
76
+ end
77
+ end
@@ -21,8 +21,17 @@ module Rubyhexagon
21
21
  # A class to interact with the e621 web interface.
22
22
  #
23
23
  # @author Maxine Michalski
24
+ # @api public
24
25
  # @since 2.0.0
25
26
  class TagItem
27
+ # @author Maxine Michalski
28
+ #
29
+ # Fetch a list of tag items
30
+ #
31
+ # @example Get a list of posts
32
+ # E621::Post::TagItem.list(page: 1) #=> Array<E621::Post::TagItem>
33
+ # @return [Array<E621::TagItem>]
34
+ # @see https://e621.net/help/show/api#taghistory
26
35
  def self.list(query)
27
36
  unless query.is_a?(Hash)
28
37
  raise ArgumentError, 'A Hash or Post object is required'
@@ -20,6 +20,7 @@ module Rubyhexagon
20
20
  # A class to interact with the e621 web interface.
21
21
  #
22
22
  # @author Maxine Michalski
23
+ # @api public
23
24
  # @since 1.4.0
24
25
  class Tag
25
26
  # @author Maxine Michalski
@@ -27,8 +28,10 @@ module Rubyhexagon
27
28
  # Fetch tag data
28
29
  #
29
30
  # @param tag [Hash|E621::Tag] a hash or tag object
30
- #
31
+ # @example Get tag information
32
+ # E621::Tag.show(id: 1) #=> E621::Tag
31
33
  # @return [E621::Tag]
34
+ # @see https://e621.net/help/show/api#tags
32
35
  def self.show(tag)
33
36
  unless (tag.is_a?(Hash) && tag[:id].is_a?(Integer)) ||
34
37
  tag.is_a?(E621::Tag)
@@ -43,8 +46,10 @@ module Rubyhexagon
43
46
  # Fetch a list of tags
44
47
  #
45
48
  # @param query [Hash] query data
46
- #
49
+ # @example Get list of tags
50
+ # E621::Tag.list(name: 'feline') #=> Array<E621::Tag>
47
51
  # @return [Array<E621::Tag>]
52
+ # @see https://e621.net/help/show/api#tags
48
53
  def self.list(query)
49
54
  raise ArgumentError, 'A Hash is required' unless query.is_a?(Hash)
50
55
  E621::API.fetch(:tag, :index, query).map do |tag|
@@ -54,8 +59,9 @@ module Rubyhexagon
54
59
 
55
60
  # @author Maxine Michalski
56
61
  #
57
- # Return a filled Tag object from a tag.
58
- #
62
+ # Return a filled Tag object from a tag
63
+ # @example Gwt tag information
64
+ # tag.show #=> E621::Tag
59
65
  # @return [E621::Tag]
60
66
  def show
61
67
  E621::Tag.new(E621::API.fetch(:tag, :show,
@@ -21,6 +21,7 @@ module Rubyhexagon
21
21
  # A class to interact with the e621 web interface.
22
22
  #
23
23
  # @author Maxine Michalski
24
+ # @api public
24
25
  # @since 2.0.0
25
26
  class Alias
26
27
  # @author Maxine Michalski
@@ -29,7 +30,11 @@ module Rubyhexagon
29
30
  #
30
31
  # @param query [Hash] Parameter for query
31
32
  #
33
+ # @example Get a list of posts
34
+ # E621::Tag::Alias.list(implied_to: 'feline',
35
+ # page: 1) #=> Array<E621::Tag::Alias>
32
36
  # @return [Array[E621::Tag::Alias]
37
+ # @see https://e621.net/help/show/api#aliases
33
38
  def self.list(query)
34
39
  raise ArgumentError, 'A Hash is required' unless query.is_a?(Hash)
35
40
  E621::API.fetch(:tag_alias, :index, query).map do |tag|
@@ -21,6 +21,7 @@ module Rubyhexagon
21
21
  # A class to interact with the e621 web interface.
22
22
  #
23
23
  # @author Maxine Michalski
24
+ # @api public
24
25
  # @since 2.0.0
25
26
  class Implication
26
27
  # @author Maxine Michalski
@@ -29,7 +30,11 @@ module Rubyhexagon
29
30
  #
30
31
  # @param query [Hash] Parameter for query
31
32
  #
33
+ # @example Get a list of posts
34
+ # E621::Tag::Implication.list(implied_to: 'feline',
35
+ # page: 1) #=> Array<E621::Tag::Implication>
32
36
  # @return [Array[E621::Tag::Implication]
37
+ # @see https://e621.net/help/show/api#implications
33
38
  def self.list(query)
34
39
  raise ArgumentError, 'A Hash is required' unless query.is_a?(Hash)
35
40
  E621::API.fetch(:tag_implication, :index, query).map do |tag|