akane 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +18 -0
- data/.rspec +2 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +27 -0
- data/Rakefile +6 -0
- data/akane.gemspec +28 -0
- data/bin/akane +6 -0
- data/lib/akane.rb +5 -0
- data/lib/akane/cli.rb +83 -0
- data/lib/akane/config.rb +25 -0
- data/lib/akane/manager.rb +97 -0
- data/lib/akane/receivers/abstract_receiver.rb +47 -0
- data/lib/akane/receivers/stream.rb +63 -0
- data/lib/akane/recorder.rb +104 -0
- data/lib/akane/storages/abstract_storage.rb +26 -0
- data/lib/akane/storages/elasticsearch.rb +242 -0
- data/lib/akane/storages/file.rb +142 -0
- data/lib/akane/storages/mock.rb +51 -0
- data/lib/akane/storages/stdout.rb +23 -0
- data/lib/akane/version.rb +3 -0
- data/spec/config_spec.rb +19 -0
- data/spec/manager_spec.rb +107 -0
- data/spec/receivers/abstract_receiver_spec.rb +48 -0
- data/spec/receivers/stream_spec.rb +105 -0
- data/spec/recorder_spec.rb +86 -0
- data/spec/spec_helper.rb +16 -0
- data/spec/storages/abstract_storage_spec.rb +20 -0
- data/spec/storages/mock_spec.rb +59 -0
- data/spec/support/mock_tweetstream.rb +86 -0
- metadata +169 -0
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'simplecov'
|
2
|
+
SimpleCov.start
|
3
|
+
|
4
|
+
RSpec.configure do |config|
|
5
|
+
config.treat_symbols_as_metadata_keys_with_true_values = true
|
6
|
+
config.run_all_when_everything_filtered = true
|
7
|
+
config.filter_run :focus
|
8
|
+
|
9
|
+
# Run specs in random order to surface order dependencies. If you find an
|
10
|
+
# order dependency and want to debug it, you can fix the order by providing
|
11
|
+
# the seed, which is printed after each run.
|
12
|
+
# --seed 1234
|
13
|
+
config.order = 'random'
|
14
|
+
end
|
15
|
+
|
16
|
+
require_relative './support/mock_tweetstream'
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'logger'
|
3
|
+
require 'akane/storages/abstract_storage'
|
4
|
+
|
5
|
+
describe Akane::Storages::AbstractStorage do
|
6
|
+
let(:config) { {} }
|
7
|
+
subject { described_class.new(config: config, logger: Logger.new(nil)) }
|
8
|
+
|
9
|
+
describe "#record_tweet" do
|
10
|
+
end
|
11
|
+
|
12
|
+
describe "#mark_as_deleted" do
|
13
|
+
end
|
14
|
+
|
15
|
+
describe "#record_event" do
|
16
|
+
end
|
17
|
+
|
18
|
+
describe "#record_message" do
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,59 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'akane/storages/mock'
|
3
|
+
|
4
|
+
describe Akane::Storages::Mock do
|
5
|
+
let(:config) { {} }
|
6
|
+
subject { described_class.new(config: config, logger: Logger.new(nil)) }
|
7
|
+
|
8
|
+
describe "#record_tweet" do
|
9
|
+
it "records in memory" do
|
10
|
+
described_class.recorded_tweets.clear
|
11
|
+
expect { subject.record_tweet('a', "id" => 42) } \
|
12
|
+
.to change { described_class.recorded_tweets.last } \
|
13
|
+
.from(nil).to(['a', "id" => 42])
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
describe "#mark_as_deleted" do
|
18
|
+
it "records in memory" do
|
19
|
+
described_class.deletion_marks.clear
|
20
|
+
expect { subject.mark_as_deleted('a', 1, 42) } \
|
21
|
+
.to change { described_class.deletion_marks.last } \
|
22
|
+
.from(nil).to(['a', 1, 42])
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
describe "#record_event" do
|
27
|
+
it "records in memory" do
|
28
|
+
described_class.recorded_events.clear
|
29
|
+
expect { subject.record_event('a', 'event' => 'some') } \
|
30
|
+
.to change { described_class.recorded_events.last } \
|
31
|
+
.from(nil).to(['a', 'event' => 'some'])
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
describe "#record_message" do
|
36
|
+
it "records in memory" do
|
37
|
+
described_class.recorded_messages.clear
|
38
|
+
expect { subject.record_message('a', 'id' => 10) } \
|
39
|
+
.to change { described_class.recorded_messages.last } \
|
40
|
+
.from(nil).to(['a', 'id' => 10])
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
describe ".reset!" do
|
45
|
+
it "flushes all recorded" do
|
46
|
+
described_class.recorded_tweets << 1
|
47
|
+
described_class.recorded_events << 1
|
48
|
+
described_class.recorded_messages << 1
|
49
|
+
described_class.deletion_marks << 1
|
50
|
+
|
51
|
+
expect { described_class.reset! } \
|
52
|
+
.to change { [described_class.recorded_tweets,
|
53
|
+
described_class.recorded_messages,
|
54
|
+
described_class.recorded_events,
|
55
|
+
described_class.deletion_marks].map(&:empty?) } \
|
56
|
+
.from([false,false,false,false]).to([true,true,true,true])
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
@@ -0,0 +1,86 @@
|
|
1
|
+
require 'tweetstream'
|
2
|
+
|
3
|
+
|
4
|
+
class TweetStream::MockClient
|
5
|
+
Original = TweetStream::Client
|
6
|
+
|
7
|
+
class << self
|
8
|
+
def clients
|
9
|
+
@clients ||= []
|
10
|
+
end
|
11
|
+
|
12
|
+
def invoke(event, *args)
|
13
|
+
@clients.each do |client|
|
14
|
+
client.invoke(event, *args)
|
15
|
+
end
|
16
|
+
|
17
|
+
self
|
18
|
+
end
|
19
|
+
|
20
|
+
def enable!
|
21
|
+
klass = self
|
22
|
+
TweetStream.instance_eval {
|
23
|
+
remove_const :Client
|
24
|
+
const_set :Client, klass
|
25
|
+
}
|
26
|
+
end
|
27
|
+
|
28
|
+
def disable!
|
29
|
+
klass = Original
|
30
|
+
TweetStream.instance_eval {
|
31
|
+
remove_const :Client
|
32
|
+
const_set :Client, klass
|
33
|
+
}
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
def initialize(options={})
|
38
|
+
@options = options
|
39
|
+
@hooks = {}
|
40
|
+
end
|
41
|
+
|
42
|
+
attr_accessor :options, :hooks
|
43
|
+
|
44
|
+
def on_anything(&block) on('anything', &block) end
|
45
|
+
|
46
|
+
def on_event(event, &block) on(event, &block) end
|
47
|
+
|
48
|
+
def on_timeline_status(&block) on('timeline_status', &block) end
|
49
|
+
def on_delete(&block) on('delete', &block) end
|
50
|
+
|
51
|
+
def on_direct_message(&block) on('direct_message', &block) end
|
52
|
+
|
53
|
+
def on_limit(&block) on('limit', &block) end
|
54
|
+
def on_error(&block) on('error', &block) end
|
55
|
+
def on_unauthorized(&block) on('unauthorized', &block) end
|
56
|
+
|
57
|
+
def on_inited(&block) on('inited', &block) end
|
58
|
+
def on_reconnect(&block) on('reconnect', &block) end
|
59
|
+
|
60
|
+
def on(event, &block)
|
61
|
+
@hooks[event.to_s] = block
|
62
|
+
self
|
63
|
+
end
|
64
|
+
|
65
|
+
def invoke(event, *args)
|
66
|
+
@hooks[event.to_s].call *args
|
67
|
+
end
|
68
|
+
|
69
|
+
def connected?
|
70
|
+
@connected
|
71
|
+
end
|
72
|
+
|
73
|
+
def userstream
|
74
|
+
@connected = true
|
75
|
+
self.class.clients << self
|
76
|
+
self
|
77
|
+
end
|
78
|
+
|
79
|
+
def stop_stream
|
80
|
+
self.class.clients.delete(self)
|
81
|
+
@connected = false
|
82
|
+
self
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
TweetStream::MockClient.enable!
|
metadata
ADDED
@@ -0,0 +1,169 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: akane
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Shota Fukumori (sora_h)
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-01-14 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: tweetstream
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 2.6.0
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 2.6.0
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: elasticsearch
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 0.4.1
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 0.4.1
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: bundler
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rake
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rspec
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: 2.14.1
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: 2.14.1
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: simplecov
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
description: Log the timeline
|
98
|
+
email:
|
99
|
+
- her@sorah.jp
|
100
|
+
executables:
|
101
|
+
- akane
|
102
|
+
extensions: []
|
103
|
+
extra_rdoc_files: []
|
104
|
+
files:
|
105
|
+
- ".gitignore"
|
106
|
+
- ".rspec"
|
107
|
+
- Gemfile
|
108
|
+
- LICENSE.txt
|
109
|
+
- README.md
|
110
|
+
- Rakefile
|
111
|
+
- akane.gemspec
|
112
|
+
- bin/akane
|
113
|
+
- lib/akane.rb
|
114
|
+
- lib/akane/cli.rb
|
115
|
+
- lib/akane/config.rb
|
116
|
+
- lib/akane/manager.rb
|
117
|
+
- lib/akane/receivers/abstract_receiver.rb
|
118
|
+
- lib/akane/receivers/stream.rb
|
119
|
+
- lib/akane/recorder.rb
|
120
|
+
- lib/akane/storages/abstract_storage.rb
|
121
|
+
- lib/akane/storages/elasticsearch.rb
|
122
|
+
- lib/akane/storages/file.rb
|
123
|
+
- lib/akane/storages/mock.rb
|
124
|
+
- lib/akane/storages/stdout.rb
|
125
|
+
- lib/akane/version.rb
|
126
|
+
- spec/config_spec.rb
|
127
|
+
- spec/manager_spec.rb
|
128
|
+
- spec/receivers/abstract_receiver_spec.rb
|
129
|
+
- spec/receivers/stream_spec.rb
|
130
|
+
- spec/recorder_spec.rb
|
131
|
+
- spec/spec_helper.rb
|
132
|
+
- spec/storages/abstract_storage_spec.rb
|
133
|
+
- spec/storages/mock_spec.rb
|
134
|
+
- spec/support/mock_tweetstream.rb
|
135
|
+
homepage: https://github.com/sorah/akane
|
136
|
+
licenses:
|
137
|
+
- MIT
|
138
|
+
metadata: {}
|
139
|
+
post_install_message:
|
140
|
+
rdoc_options: []
|
141
|
+
require_paths:
|
142
|
+
- lib
|
143
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
144
|
+
requirements:
|
145
|
+
- - ">="
|
146
|
+
- !ruby/object:Gem::Version
|
147
|
+
version: '0'
|
148
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
149
|
+
requirements:
|
150
|
+
- - ">="
|
151
|
+
- !ruby/object:Gem::Version
|
152
|
+
version: '0'
|
153
|
+
requirements: []
|
154
|
+
rubyforge_project:
|
155
|
+
rubygems_version: 2.2.0
|
156
|
+
signing_key:
|
157
|
+
specification_version: 4
|
158
|
+
summary: Log your timeline to something
|
159
|
+
test_files:
|
160
|
+
- spec/config_spec.rb
|
161
|
+
- spec/manager_spec.rb
|
162
|
+
- spec/receivers/abstract_receiver_spec.rb
|
163
|
+
- spec/receivers/stream_spec.rb
|
164
|
+
- spec/recorder_spec.rb
|
165
|
+
- spec/spec_helper.rb
|
166
|
+
- spec/storages/abstract_storage_spec.rb
|
167
|
+
- spec/storages/mock_spec.rb
|
168
|
+
- spec/support/mock_tweetstream.rb
|
169
|
+
has_rdoc:
|