rubyhexagon 1.0.0 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/rubyhexagon.rb +4 -1
- data/lib/rubyhexagon/image.rb +5 -2
- data/lib/rubyhexagon/post.rb +16 -21
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f3b33b5997c2add67eddbfeea3016cc29e5699996b7dc38a2653ed692bbdeb0f
|
4
|
+
data.tar.gz: d5df5106fef14164a6e33ce3e0b35a80836b2902b299cbc53d574944f32894f6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a9abec7cf7b10ac58e7c11cf6ad5fb7ed660af4c29153d2cab8082d738345d1f5cc67004d2c3ccc7bf196089a157f0a7f2370f7508309b65a2223df0bb2cfd5b
|
7
|
+
data.tar.gz: ff325c1d8f244e1ddf40eea8590fa339f5007f848033feb73ef18fe82fe0a5b95db11df3cde327ef2f5583d273eff354707a437e8a2b7d9500ed58f2cb041f89
|
data/lib/rubyhexagon.rb
CHANGED
data/lib/rubyhexagon/image.rb
CHANGED
@@ -70,12 +70,15 @@ module E621
|
|
70
70
|
#
|
71
71
|
# @param dirname [String] path where to save. This needs be an existing
|
72
72
|
# directory. This overwrites existing files.
|
73
|
+
# @param filename [String] name of file, without extension
|
74
|
+
#
|
73
75
|
# @raise [ArgumentError] Argument given is not an existing directory
|
74
|
-
def save!(dirname = './')
|
76
|
+
def save!(dirname = './', filename = nil)
|
75
77
|
raise ArgumentError, 'Not a directory!' unless File.directory?(dirname)
|
78
|
+
filename ||= @md5
|
76
79
|
loop do
|
77
80
|
stream = open(@url, @user_agent).read
|
78
|
-
File.open("#{dirname}/#{
|
81
|
+
File.open("#{dirname}/#{filename}.#{@ext}", 'w') do |f|
|
79
82
|
f.print stream
|
80
83
|
end
|
81
84
|
break if Digest::MD5.hexdigest(stream) == @md5
|
data/lib/rubyhexagon/post.rb
CHANGED
@@ -74,6 +74,9 @@ module E621
|
|
74
74
|
# @return [E621::Preview] preview data in E621::Preview format
|
75
75
|
attr_reader :preview
|
76
76
|
|
77
|
+
# @return [Array<String>] tag names only for convenience
|
78
|
+
attr_reader :tag_names
|
79
|
+
|
77
80
|
# @author Maxine Michalski
|
78
81
|
#
|
79
82
|
# Initializer for Post.
|
@@ -132,31 +135,22 @@ module E621
|
|
132
135
|
# Test status with an optional parameter. This is more meant to be used by
|
133
136
|
# alias methods
|
134
137
|
#
|
135
|
-
# @
|
136
|
-
# @return [FalseClass]
|
137
|
-
def test_status(status = nil)
|
138
|
-
status ||= __callee__.to_s.sub(/\?/, '').to_sym
|
139
|
-
@status == status
|
140
|
-
end
|
141
|
-
alias active? test_status
|
142
|
-
alias flagged? test_status
|
143
|
-
alias pending? test_status
|
144
|
-
alias deleted? test_status
|
145
|
-
|
146
|
-
# @author Maxine Michalski
|
147
|
-
#
|
148
|
-
# Check a post for a certain rating. This is rather meant to be used via
|
149
|
-
# alias methids.
|
138
|
+
# @param test_var [Symbol] variable under test
|
150
139
|
#
|
151
140
|
# @return [TrueClass]
|
152
141
|
# @return [FalseClass]
|
153
|
-
def
|
154
|
-
|
155
|
-
|
142
|
+
def test(test_var = nil)
|
143
|
+
test_var ||= __callee__.to_s.sub(/\?/, '').to_sym
|
144
|
+
test_ar = %i[safe questionable explicit]
|
145
|
+
test_ar.include?(test_var) ? @rating == test_var : @status == test_var
|
156
146
|
end
|
157
|
-
alias
|
158
|
-
alias
|
159
|
-
alias
|
147
|
+
alias active? test
|
148
|
+
alias flagged? test
|
149
|
+
alias pending? test
|
150
|
+
alias deleted? test
|
151
|
+
alias safe? test
|
152
|
+
alias questionable? test
|
153
|
+
alias explicit? test
|
160
154
|
|
161
155
|
# @author Maxine Michalski
|
162
156
|
#
|
@@ -173,6 +167,7 @@ module E621
|
|
173
167
|
#
|
174
168
|
# Helper function, to setup post file data
|
175
169
|
def setup_file_data(post)
|
170
|
+
@tag_names = post[:tags].split(/\s+/)
|
176
171
|
@md5 = post[:md5]
|
177
172
|
@image = E621::Image.new(url: post[:file_url], ext: post[:file_ext],
|
178
173
|
width: post[:width], height: post[:height])
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rubyhexagon
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Maxine Michalski
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-03-
|
11
|
+
date: 2018-03-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: json
|