Class: Akane::Storages::File
Instance Method Summary
collapse
#exitable?, #status, #stop!
Constructor Details
#initialize ⇒ File
Returns a new instance of File.
10
11
12
13
14
15
16
17
|
# File 'lib/akane/storages/file.rb', line 10
def initialize(*)
super
@screen_name_to_id_cache = {}
@dir = Pathname.new(@config["dir"])
[@dir, @dir.join('names'), @dir.join('users'), @dir.join('event'), @dir.join('timeline')].each do |d|
d.mkdir unless d.exist?
end
end
|
Instance Method Details
#mark_as_deleted(account, user_id, tweet_id) ⇒ Object
32
33
34
35
36
37
|
# File 'lib/akane/storages/file.rb', line 32
def mark_as_deleted(account, user_id, )
timeline_deletion_io.puts "#{Time.now.xmlschema},#{user_id},#{}"
(user_id) do |io|
io.puts "#{Time.now.xmlschema},#{user_id},#{}"
end
end
|
#name ⇒ Object
19
20
21
|
# File 'lib/akane/storages/file.rb', line 19
def name
@name ||= "#{self.class.name}:#{@config["dir"]}"
end
|
#record_event(account, event) ⇒ Object
39
40
41
|
# File 'lib/akane/storages/file.rb', line 39
def record_event(account, event)
event_io.puts event.merge(:happened_on => account).to_json
end
|
#record_message(account, message) ⇒ Object
43
44
45
46
47
48
49
50
51
|
# File 'lib/akane/storages/file.rb', line 43
def record_message(account, message)
messages_raw_io_for_user(message.sender.id, message.sender.screen_name) do |io|
io.puts message.attrs.to_json
end
messages_io_for_user(message.sender.id, message.sender.screen_name) do |io|
io.puts "[#{message.created_at.xmlschema}] #{message.sender.screen_name} -> #{message.recipient.screen_name}:" \
" #{message.text} (#{message.sender.id} -> #{message.recipient.id},#{message.id})"
end
end
|
23
24
25
26
27
28
29
30
|
# File 'lib/akane/storages/file.rb', line 23
def (account, )
timeline_io.puts "[#{.created_at.xmlschema}][#{account}] #{.user.screen_name}: " \
"#{.text.gsub(/\r?\n/,' ')} (#{.user.id},#{.id})"
(.user.id, .user.screen_name) do |io|
io.puts .attrs.to_json
end
end
|