iqdb changes
This commit is contained in:
29
app/logical/iqdb/command.rb
Normal file
29
app/logical/iqdb/command.rb
Normal file
@@ -0,0 +1,29 @@
|
||||
module Iqdb
|
||||
class Command
|
||||
attr_reader :database
|
||||
|
||||
def initialize(database)
|
||||
@database = database
|
||||
end
|
||||
|
||||
def process(&block)
|
||||
IO.popen("iqdb #{database}", "w", &block)
|
||||
end
|
||||
|
||||
def add(post)
|
||||
hex = post.id.to_s(16)
|
||||
process do |io|
|
||||
io.puts "add 0 #{hex} :#{post.preview_file_path}"
|
||||
io.puts "quit"
|
||||
end
|
||||
end
|
||||
|
||||
def remove(post_id)
|
||||
hex = post_id.to_s(16)
|
||||
process do |io|
|
||||
io.puts "remove 0 #{hex}"
|
||||
io.puts "quit"
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user