akane-imkayac 0.0.2 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/akane-imkayac/version.rb +1 -1
- data/lib/akane/storages/imkayac.rb +15 -6
- data/spec/imkayac_spec.rb +35 -1
- metadata +3 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: c577a93ea8e1b5b4e9c38a847ba784686068d75a
|
|
4
|
+
data.tar.gz: bba9ef19a5f412093f0c043d36407feb5ac6e10a
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 109a6d6a35e6c3bea41021e4cb1e197b3885699d6276b90b346a378ea4ca82303994492bae35c9c334dbd3a0bef4937163ef9024f4ceb3049ea9dd01854a23e4
|
|
7
|
+
data.tar.gz: 6643b96aff7cade3fb33b7943a2de179b16c7d662fd47141c18008c68f5ef77fab7c3eae884a6e2e965649c951045a43a848d67710cd0aaf8903b73a27ef63f4
|
|
@@ -20,6 +20,7 @@ module Akane
|
|
|
20
20
|
super
|
|
21
21
|
|
|
22
22
|
@config["keywords"] ||= []
|
|
23
|
+
@config["screen_names"] ||= []
|
|
23
24
|
@config["excludes"] ||= []
|
|
24
25
|
@config["message"] ||= DEFAULT_MESSAGE
|
|
25
26
|
@config["endpoint"] ||= DEFAULT_ENDPOINT
|
|
@@ -39,12 +40,8 @@ module Akane
|
|
|
39
40
|
end
|
|
40
41
|
|
|
41
42
|
def record_tweet(account, tweet)
|
|
42
|
-
unless tweet
|
|
43
|
-
|
|
44
|
-
@config["excludes"].all? { |_| ! tweet.text.include?(_.to_s) } &&
|
|
45
|
-
@config["keywords"].any? { |_| tweet.text.include?(_.to_s) }
|
|
46
|
-
return
|
|
47
|
-
end
|
|
43
|
+
return unless match_rule?(tweet)
|
|
44
|
+
|
|
48
45
|
payload = { message: ERB.new(@config["message"]).result(binding), }
|
|
49
46
|
|
|
50
47
|
payload[:password] = @config["password"] if @config["password"]
|
|
@@ -77,6 +74,18 @@ module Akane
|
|
|
77
74
|
|
|
78
75
|
def record_message(*)
|
|
79
76
|
end
|
|
77
|
+
|
|
78
|
+
private
|
|
79
|
+
|
|
80
|
+
def match_rule?(tweet)
|
|
81
|
+
tweet.text &&
|
|
82
|
+
!tweet.retweet? &&
|
|
83
|
+
@config["excludes"].all? { |_| ! tweet.text.include?(_.to_s) } &&
|
|
84
|
+
(
|
|
85
|
+
@config["keywords"].any? { |_| tweet.text.include?(_.to_s) } ||
|
|
86
|
+
@config["screen_names"].include?(tweet.user.screen_name)
|
|
87
|
+
)
|
|
88
|
+
end
|
|
80
89
|
end
|
|
81
90
|
end
|
|
82
91
|
end
|
data/spec/imkayac_spec.rb
CHANGED
|
@@ -8,7 +8,7 @@ require 'twitter/tweet'
|
|
|
8
8
|
require 'twitter/user'
|
|
9
9
|
|
|
10
10
|
describe Akane::Storages::Imkayac do
|
|
11
|
-
let(:base_config) { {"user" => 'tester', "keywords" => %w(keyword), "excludes" => %w(ignore)} }
|
|
11
|
+
let(:base_config) { {"user" => 'tester', "screen_names" => ["match_user"], "keywords" => %w(keyword), "excludes" => %w(ignore)} }
|
|
12
12
|
let(:config) { base_config }
|
|
13
13
|
|
|
14
14
|
let(:endpoint) { "http://im.kayac.com/api/post" }
|
|
@@ -78,6 +78,40 @@ describe Akane::Storages::Imkayac do
|
|
|
78
78
|
end
|
|
79
79
|
end
|
|
80
80
|
|
|
81
|
+
describe "screen_name matching:" do
|
|
82
|
+
let(:tweet_text) { '---' }
|
|
83
|
+
context "when matched user" do
|
|
84
|
+
let(:screen_name) { 'match_user' }
|
|
85
|
+
|
|
86
|
+
it "sends" do
|
|
87
|
+
subject.record_tweet('tester', tweet)
|
|
88
|
+
|
|
89
|
+
expect(a_request(:post, "#{endpoint}/tester").with(
|
|
90
|
+
body: {message: '[tw] match_user: ---'}
|
|
91
|
+
)).to have_been_made
|
|
92
|
+
end
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
context "when not match" do
|
|
96
|
+
let(:screen_name) { 'doesnt_match_user' }
|
|
97
|
+
|
|
98
|
+
it "doesn't send" do
|
|
99
|
+
subject.record_tweet('tester', tweet)
|
|
100
|
+
expect(a_request(:post, "#{endpoint}/tester")).not_to have_been_made
|
|
101
|
+
end
|
|
102
|
+
end
|
|
103
|
+
|
|
104
|
+
context "when matched user but having excluded keyword" do
|
|
105
|
+
let(:screen_name) { 'match_user' }
|
|
106
|
+
let(:tweet_text) { 'ignore' }
|
|
107
|
+
|
|
108
|
+
it "doesn't send" do
|
|
109
|
+
subject.record_tweet('tester', tweet)
|
|
110
|
+
expect(a_request(:post, "#{endpoint}/tester")).not_to have_been_made
|
|
111
|
+
end
|
|
112
|
+
end
|
|
113
|
+
end
|
|
114
|
+
|
|
81
115
|
describe "message option:" do
|
|
82
116
|
let(:config) { base_config.merge("message" => '<%= tweet.id %> <%= tweet.user.id %> <%= tweet.text %> <%= tweet.user.screen_name %>') }
|
|
83
117
|
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: akane-imkayac
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.0
|
|
4
|
+
version: 0.1.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Shota Fukumori (sora_h)
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2014-02
|
|
11
|
+
date: 2014-08-02 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: akane
|
|
@@ -119,7 +119,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
119
119
|
version: '0'
|
|
120
120
|
requirements: []
|
|
121
121
|
rubyforge_project:
|
|
122
|
-
rubygems_version: 2.2.
|
|
122
|
+
rubygems_version: 2.2.2
|
|
123
123
|
signing_key:
|
|
124
124
|
specification_version: 4
|
|
125
125
|
summary: imkayac storage plugin for akane | for notification
|