twing_earch 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +9 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +6 -0
- data/Gemfile.lock +105 -0
- data/LICENSE.txt +21 -0
- data/README.md +108 -0
- data/Rakefile +2 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/lib/twing_earch.rb +8 -0
- data/lib/twing_earch/earch.rb +28 -0
- data/lib/twing_earch/notify.rb +39 -0
- data/lib/twing_earch/rule.rb +102 -0
- data/lib/twing_earch/rules.rb +15 -0
- data/lib/twing_earch/version.rb +3 -0
- data/twing_earch.gemspec +26 -0
- metadata +116 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 586fdf7ef41deba96a0533e2abebbc1cfbf2e970
|
4
|
+
data.tar.gz: c3133c0d61f1a8d6f05780223710cd4cc1aaf031
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: ec33c407118478de09a18b43c87774a4f2ce88e9187d746a6813f2336ff5ee103d5c9beb002d5015c0fe655c6403808544390bc079d67ebc4e9b5a3a97f283e4
|
7
|
+
data.tar.gz: 840a63920248958a29c4000a09f4bd0188ba61b0185b27a43e5ea0979a06a70e39e761a23d49441a850e36bc5cff0b1a2e0a61472c4d94ecad7cdce116574877
|
data/.gitignore
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
2
|
+
|
3
|
+
## Our Pledge
|
4
|
+
|
5
|
+
In the interest of fostering an open and welcoming environment, we as
|
6
|
+
contributors and maintainers pledge to making participation in our project and
|
7
|
+
our community a harassment-free experience for everyone, regardless of age, body
|
8
|
+
size, disability, ethnicity, gender identity and expression, level of experience,
|
9
|
+
nationality, personal appearance, race, religion, or sexual identity and
|
10
|
+
orientation.
|
11
|
+
|
12
|
+
## Our Standards
|
13
|
+
|
14
|
+
Examples of behavior that contributes to creating a positive environment
|
15
|
+
include:
|
16
|
+
|
17
|
+
* Using welcoming and inclusive language
|
18
|
+
* Being respectful of differing viewpoints and experiences
|
19
|
+
* Gracefully accepting constructive criticism
|
20
|
+
* Focusing on what is best for the community
|
21
|
+
* Showing empathy towards other community members
|
22
|
+
|
23
|
+
Examples of unacceptable behavior by participants include:
|
24
|
+
|
25
|
+
* The use of sexualized language or imagery and unwelcome sexual attention or
|
26
|
+
advances
|
27
|
+
* Trolling, insulting/derogatory comments, and personal or political attacks
|
28
|
+
* Public or private harassment
|
29
|
+
* Publishing others' private information, such as a physical or electronic
|
30
|
+
address, without explicit permission
|
31
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
32
|
+
professional setting
|
33
|
+
|
34
|
+
## Our Responsibilities
|
35
|
+
|
36
|
+
Project maintainers are responsible for clarifying the standards of acceptable
|
37
|
+
behavior and are expected to take appropriate and fair corrective action in
|
38
|
+
response to any instances of unacceptable behavior.
|
39
|
+
|
40
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
41
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
42
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
43
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
44
|
+
threatening, offensive, or harmful.
|
45
|
+
|
46
|
+
## Scope
|
47
|
+
|
48
|
+
This Code of Conduct applies both within project spaces and in public spaces
|
49
|
+
when an individual is representing the project or its community. Examples of
|
50
|
+
representing a project or community include using an official project e-mail
|
51
|
+
address, posting via an official social media account, or acting as an appointed
|
52
|
+
representative at an online or offline event. Representation of a project may be
|
53
|
+
further defined and clarified by project maintainers.
|
54
|
+
|
55
|
+
## Enforcement
|
56
|
+
|
57
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
58
|
+
reported by contacting the project team at flum.1025@gmail.com. All
|
59
|
+
complaints will be reviewed and investigated and will result in a response that
|
60
|
+
is deemed necessary and appropriate to the circumstances. The project team is
|
61
|
+
obligated to maintain confidentiality with regard to the reporter of an incident.
|
62
|
+
Further details of specific enforcement policies may be posted separately.
|
63
|
+
|
64
|
+
Project maintainers who do not follow or enforce the Code of Conduct in good
|
65
|
+
faith may face temporary or permanent repercussions as determined by other
|
66
|
+
members of the project's leadership.
|
67
|
+
|
68
|
+
## Attribution
|
69
|
+
|
70
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
71
|
+
available at [http://contributor-covenant.org/version/1/4][version]
|
72
|
+
|
73
|
+
[homepage]: http://contributor-covenant.org
|
74
|
+
[version]: http://contributor-covenant.org/version/1/4/
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,105 @@
|
|
1
|
+
PATH
|
2
|
+
remote: ../twing
|
3
|
+
specs:
|
4
|
+
twing (0.1.0)
|
5
|
+
hashie
|
6
|
+
redis-namespace
|
7
|
+
redis-objects
|
8
|
+
twitter
|
9
|
+
|
10
|
+
PATH
|
11
|
+
remote: .
|
12
|
+
specs:
|
13
|
+
twing_earch (0.1.0)
|
14
|
+
slack-ruby-client
|
15
|
+
|
16
|
+
GEM
|
17
|
+
remote: https://rubygems.org/
|
18
|
+
specs:
|
19
|
+
activesupport (5.2.1)
|
20
|
+
concurrent-ruby (~> 1.0, >= 1.0.2)
|
21
|
+
i18n (>= 0.7, < 2)
|
22
|
+
minitest (~> 5.1)
|
23
|
+
tzinfo (~> 1.1)
|
24
|
+
addressable (2.5.2)
|
25
|
+
public_suffix (>= 2.0.2, < 4.0)
|
26
|
+
buftok (0.2.0)
|
27
|
+
coderay (1.1.2)
|
28
|
+
concurrent-ruby (1.0.5)
|
29
|
+
domain_name (0.5.20180417)
|
30
|
+
unf (>= 0.0.5, < 1.0.0)
|
31
|
+
equalizer (0.0.11)
|
32
|
+
faraday (0.15.2)
|
33
|
+
multipart-post (>= 1.2, < 3)
|
34
|
+
faraday_middleware (0.12.2)
|
35
|
+
faraday (>= 0.7.4, < 1.0)
|
36
|
+
gli (2.17.2)
|
37
|
+
hashie (3.6.0)
|
38
|
+
http (3.3.0)
|
39
|
+
addressable (~> 2.3)
|
40
|
+
http-cookie (~> 1.0)
|
41
|
+
http-form_data (~> 2.0)
|
42
|
+
http_parser.rb (~> 0.6.0)
|
43
|
+
http-cookie (1.0.3)
|
44
|
+
domain_name (~> 0.5)
|
45
|
+
http-form_data (2.1.1)
|
46
|
+
http_parser.rb (0.6.0)
|
47
|
+
i18n (1.1.0)
|
48
|
+
concurrent-ruby (~> 1.0)
|
49
|
+
memoizable (0.4.2)
|
50
|
+
thread_safe (~> 0.3, >= 0.3.1)
|
51
|
+
method_source (0.9.0)
|
52
|
+
minitest (5.11.3)
|
53
|
+
multipart-post (2.0.0)
|
54
|
+
naught (1.1.0)
|
55
|
+
pry (0.11.3)
|
56
|
+
coderay (~> 1.1.0)
|
57
|
+
method_source (~> 0.9.0)
|
58
|
+
public_suffix (3.0.3)
|
59
|
+
rake (10.5.0)
|
60
|
+
redis (4.0.2)
|
61
|
+
redis-namespace (1.6.0)
|
62
|
+
redis (>= 3.0.4)
|
63
|
+
redis-objects (1.4.0)
|
64
|
+
redis (~> 4.0)
|
65
|
+
simple_oauth (0.3.1)
|
66
|
+
slack-ruby-client (0.11.1)
|
67
|
+
activesupport
|
68
|
+
faraday (>= 0.9)
|
69
|
+
faraday_middleware
|
70
|
+
gli
|
71
|
+
hashie
|
72
|
+
websocket-driver
|
73
|
+
thread_safe (0.3.6)
|
74
|
+
twitter (6.2.0)
|
75
|
+
addressable (~> 2.3)
|
76
|
+
buftok (~> 0.2.0)
|
77
|
+
equalizer (~> 0.0.11)
|
78
|
+
http (~> 3.0)
|
79
|
+
http-form_data (~> 2.0)
|
80
|
+
http_parser.rb (~> 0.6.0)
|
81
|
+
memoizable (~> 0.4.0)
|
82
|
+
multipart-post (~> 2.0)
|
83
|
+
naught (~> 1.0)
|
84
|
+
simple_oauth (~> 0.3.0)
|
85
|
+
tzinfo (1.2.5)
|
86
|
+
thread_safe (~> 0.1)
|
87
|
+
unf (0.1.4)
|
88
|
+
unf_ext
|
89
|
+
unf_ext (0.0.7.5)
|
90
|
+
websocket-driver (0.7.0)
|
91
|
+
websocket-extensions (>= 0.1.0)
|
92
|
+
websocket-extensions (0.1.3)
|
93
|
+
|
94
|
+
PLATFORMS
|
95
|
+
ruby
|
96
|
+
|
97
|
+
DEPENDENCIES
|
98
|
+
bundler (~> 1.16)
|
99
|
+
pry
|
100
|
+
rake (~> 10.0)
|
101
|
+
twing!
|
102
|
+
twing_earch!
|
103
|
+
|
104
|
+
BUNDLED WITH
|
105
|
+
1.16.3
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2018 flum1025
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,108 @@
|
|
1
|
+
# TwingEarch
|
2
|
+
|
3
|
+
This application monitors the Twitter timeline and notifies Slack according to the conditions.
|
4
|
+
|
5
|
+
<img width="631" alt="2017-08-25 11 28 11" src="https://user-images.githubusercontent.com/9972700/29697194-a281ca3e-8988-11e7-9027-67449a9e2e34.png">
|
6
|
+
|
7
|
+
Migration from [earch](https://github.com/flum1025/earch)
|
8
|
+
|
9
|
+
## Installation
|
10
|
+
|
11
|
+
Add this line to your application's Gemfile
|
12
|
+
|
13
|
+
$ gem install twing_earch
|
14
|
+
|
15
|
+
## Usage
|
16
|
+
|
17
|
+
Add configuration
|
18
|
+
|
19
|
+
REF: [twing#configuration-file](https://github.com/flum1025/twing#configuration-file)
|
20
|
+
|
21
|
+
Example
|
22
|
+
|
23
|
+
```yaml
|
24
|
+
modules:
|
25
|
+
earch:
|
26
|
+
slack:
|
27
|
+
api_key:
|
28
|
+
token: xxxxxxxxxxxxxxxxxxxxx
|
29
|
+
user_icon: ':earch:'
|
30
|
+
notify_channel: '#earch'
|
31
|
+
icon: ':flum_:'
|
32
|
+
source_user: flum_
|
33
|
+
rules:
|
34
|
+
- text:
|
35
|
+
type: regexp
|
36
|
+
match test.*
|
37
|
+
screen_name: twitterdev
|
38
|
+
- hashtag:
|
39
|
+
- test
|
40
|
+
- events
|
41
|
+
favorite_count: 50
|
42
|
+
- retweet_count:
|
43
|
+
type: range
|
44
|
+
match 0..10
|
45
|
+
- lang: ja
|
46
|
+
retweet: false
|
47
|
+
quote: false
|
48
|
+
reply: true
|
49
|
+
```
|
50
|
+
|
51
|
+
And, run
|
52
|
+
|
53
|
+
$ twing -s setting.yml --home-timeline --earch
|
54
|
+
|
55
|
+
## Configuration File
|
56
|
+
|
57
|
+
### slack
|
58
|
+
|
59
|
+
This key is for `Slack` configuration.
|
60
|
+
|
61
|
+
Argument|Required|Description
|
62
|
+
---|---|---
|
63
|
+
api_key|Required|Get from [Bots](https://your-team.slack.com/apps/manage/custom-integrations)
|
64
|
+
user_icon|Optional|Set the [Slack emoji](https://flum1025.slack.com/customize/emoji)
|
65
|
+
notify_channel|Required|Specify the notification channel
|
66
|
+
icon|Optional|Set your Twitter account icon
|
67
|
+
source_user|Optional|Set your Twitter screen_name
|
68
|
+
|
69
|
+
### rules
|
70
|
+
|
71
|
+
The value corresponding to a key is need to `Array`. You can use multiple rules and conditions.
|
72
|
+
|
73
|
+
Argument|DataType|Example|Comments
|
74
|
+
---|---|---|---
|
75
|
+
text|String|`text: tweet text`
|
76
|
+
||Regexp|`text:`<br> `type: regexp`<br> ` match: ^\d+$`
|
77
|
+
user_id|String|`user_id: "12345"`|Not a number
|
78
|
+
user_name|String|`user_name: twitter name`
|
79
|
+
||Regexp|`user_name:`<br> `type: regexp`<br> ` match: ^[A-Z]+$`
|
80
|
+
screen_name|String|`screen_name: screen name`
|
81
|
+
||Regexp|`screen_name:`<br> `type: regexp`<br> ` match: ^@test[0-9]+`
|
82
|
+
favorite_count|Integer|`favorite_count: 50`|Get over 50 the number of favorites
|
83
|
+
||Range|`favorite_count:`<br> `type: range`<br> ` match: 10..20`|The number of favorites is 10 to 20
|
84
|
+
retweet_count|Integer|`retweet_count: 50`
|
85
|
+
||Range|`retweet_count:`<br> `type: range`<br> ` match: 10..20`
|
86
|
+
lang|String|`lang: ja`
|
87
|
+
||Regexp|`lang:`<br> `type: regexp`<br> ` match: ja\|en`
|
88
|
+
user_lang|String|`user_lang: ja`
|
89
|
+
||Regexp|`user_lang:`<br> `type: regexp`<br> ` match: ja\|en`
|
90
|
+
source|Array\<String>|`source: [TweetDeck, Twitter for WEB]`
|
91
|
+
hashtag|Array\<String>|`source: [test, memo]`|
|
92
|
+
mention|Array\<String>|`source: [twitter, twitterdev]`|String for screen_name
|
93
|
+
||Array\<Integer>|`source: [123, 456]`|Integer for id
|
94
|
+
reply|Boolean|`reply: false`
|
95
|
+
quote|Boolean|`quote: false`
|
96
|
+
retweet|Boolean|`retweet: false`
|
97
|
+
|
98
|
+
## Contributing
|
99
|
+
|
100
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/flum1025/twing_earch. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
101
|
+
|
102
|
+
## License
|
103
|
+
|
104
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
105
|
+
|
106
|
+
## Code of Conduct
|
107
|
+
|
108
|
+
Everyone interacting in the TwingEarch project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/flum1025/twing_earch/blob/master/CODE_OF_CONDUCT.md).
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "twing_earch"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
data/lib/twing_earch.rb
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'twing/modules/base'
|
2
|
+
|
3
|
+
class Earch < Twing::Modules::Base
|
4
|
+
require 'twing_earch/notify'
|
5
|
+
require 'twing_earch/rules'
|
6
|
+
|
7
|
+
attr_reader :notify, :rules
|
8
|
+
|
9
|
+
def initialize(*args)
|
10
|
+
super
|
11
|
+
@notify = Notify.new(setting.slack)
|
12
|
+
@rules = Rules.new(setting.rules || {})
|
13
|
+
end
|
14
|
+
|
15
|
+
def on_message(object)
|
16
|
+
case object
|
17
|
+
when Twitter::Tweet
|
18
|
+
logger.debug("Tweet #{object.id}")
|
19
|
+
execute(object)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
private
|
24
|
+
|
25
|
+
def execute(object)
|
26
|
+
notify.notify(object) if rules.match?(object)
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
require 'slack-ruby-client'
|
2
|
+
|
3
|
+
class Earch::Notify
|
4
|
+
attr_reader :client, :setting
|
5
|
+
|
6
|
+
def initialize(setting)
|
7
|
+
@setting = setting
|
8
|
+
@client = Slack::Web::Client.new(setting.api_key)
|
9
|
+
end
|
10
|
+
|
11
|
+
def notify(object)
|
12
|
+
client.chat_postMessage(
|
13
|
+
icon_emoji: setting.user_icon,
|
14
|
+
username: 'Earch',
|
15
|
+
channel: setting.notify_channel,
|
16
|
+
attachments: body(object)
|
17
|
+
)
|
18
|
+
end
|
19
|
+
|
20
|
+
def body(object)
|
21
|
+
[
|
22
|
+
{
|
23
|
+
fallback: "#{object.text} by @#{object.user.screen_name}",
|
24
|
+
color: '#4169e1',
|
25
|
+
author_name: "#{object.user.name}(@#{object.user.screen_name})",
|
26
|
+
author_link: object.user.url,
|
27
|
+
author_icon: object.user.profile_image_url_https,
|
28
|
+
text: object.text,
|
29
|
+
fields: [
|
30
|
+
{
|
31
|
+
value: "<#{object.url}|Tweet>",
|
32
|
+
}
|
33
|
+
],
|
34
|
+
footer: "#{setting.icon} #{setting.source_user}",
|
35
|
+
ts: object.created_at.to_f
|
36
|
+
}
|
37
|
+
]
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,102 @@
|
|
1
|
+
class Earch::Rule
|
2
|
+
def initialize(rule)
|
3
|
+
@rule = rule
|
4
|
+
end
|
5
|
+
|
6
|
+
def match?(object)
|
7
|
+
@rule.map { |k,v| send(k, parse(v), object )}.all?
|
8
|
+
end
|
9
|
+
|
10
|
+
private
|
11
|
+
|
12
|
+
def parse(condition)
|
13
|
+
if condition.is_a?(Hash)
|
14
|
+
[:type, :match].each do |key|
|
15
|
+
raise ArgumentError, "'#{key}' key not found" if condition.send(key).nil?
|
16
|
+
end
|
17
|
+
|
18
|
+
return Regexp.new(condition.match) if condition.type == 'regexp'
|
19
|
+
return Range.new(*condition.match.split('..').map(&:to_i)) if condition.type == 'range'
|
20
|
+
end
|
21
|
+
|
22
|
+
condition
|
23
|
+
end
|
24
|
+
|
25
|
+
def text(rule, object)
|
26
|
+
compare(rule, object.text)
|
27
|
+
end
|
28
|
+
|
29
|
+
def user_id(rule, object)
|
30
|
+
compare(rule, object.user.id_str)
|
31
|
+
end
|
32
|
+
|
33
|
+
def user_name(rule, object)
|
34
|
+
compare(rule, object.user.name)
|
35
|
+
end
|
36
|
+
|
37
|
+
def screen_name(rule, object)
|
38
|
+
compare(rule, object.user.screen_name)
|
39
|
+
end
|
40
|
+
|
41
|
+
def favorite_count(rule, object)
|
42
|
+
compare(rule, object.favorite_count)
|
43
|
+
end
|
44
|
+
|
45
|
+
def retweet_count(rule, object)
|
46
|
+
compare(rule, object.retweet_count)
|
47
|
+
end
|
48
|
+
|
49
|
+
def lang(rule, object)
|
50
|
+
compare(rule, object.lang)
|
51
|
+
end
|
52
|
+
|
53
|
+
def user_lang(rule, object)
|
54
|
+
compare(rule, object.user.lang)
|
55
|
+
end
|
56
|
+
|
57
|
+
def source(rule, object)
|
58
|
+
compare(rule, object.source.gsub(/<(.+)\">/,"").gsub(/<\/a>/,""))
|
59
|
+
end
|
60
|
+
|
61
|
+
def reply(rule, object)
|
62
|
+
compare(rule, object.reply?)
|
63
|
+
end
|
64
|
+
|
65
|
+
def hashtag(rule, object)
|
66
|
+
compare(rule, object.hashtags.map { |h| h.text })
|
67
|
+
end
|
68
|
+
|
69
|
+
def mention(rule, object)
|
70
|
+
if !rule.nil? && !rule.empty?
|
71
|
+
key = rule.first.is_a?(Integer) ? :id : :screen_name
|
72
|
+
compare(rule, object.user_mentions.map { |h| h.send(key) })
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
def quote(rule, object)
|
77
|
+
compare(rule, object.quote?)
|
78
|
+
end
|
79
|
+
|
80
|
+
def retweet(rule, object)
|
81
|
+
compare(rule, object.retweet?)
|
82
|
+
end
|
83
|
+
|
84
|
+
def compare(rule, target)
|
85
|
+
case rule
|
86
|
+
when Regexp
|
87
|
+
rule =~ target
|
88
|
+
when Integer
|
89
|
+
rule <= target
|
90
|
+
when Range
|
91
|
+
rule.include?(target)
|
92
|
+
when Array
|
93
|
+
if target.is_a?(Array)
|
94
|
+
!(rule & target).empty?
|
95
|
+
else
|
96
|
+
rule.include?(target)
|
97
|
+
end
|
98
|
+
else
|
99
|
+
rule == target
|
100
|
+
end
|
101
|
+
end
|
102
|
+
end
|
data/twing_earch.gemspec
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'twing_earch/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = 'twing_earch'
|
8
|
+
spec.version = TwingEarch::VERSION
|
9
|
+
spec.authors = ['flum1025']
|
10
|
+
spec.email = ['flum.1025@gmail.com']
|
11
|
+
spec.summary = 'Earch for Twing'
|
12
|
+
spec.description = spec.summary
|
13
|
+
spec.homepage = 'https://github.com/flum1025/twing_earch'
|
14
|
+
spec.license = 'MIT'
|
15
|
+
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
|
16
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
17
|
+
end
|
18
|
+
spec.bindir = 'exe'
|
19
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
20
|
+
spec.require_paths = ['lib']
|
21
|
+
|
22
|
+
spec.add_development_dependency 'bundler', '~> 1.16'
|
23
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
24
|
+
spec.add_development_dependency 'pry'
|
25
|
+
spec.add_dependency 'slack-ruby-client'
|
26
|
+
end
|
metadata
ADDED
@@ -0,0 +1,116 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: twing_earch
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- flum1025
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2018-08-19 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.16'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.16'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: pry
|
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: slack-ruby-client
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
description: Earch for Twing
|
70
|
+
email:
|
71
|
+
- flum.1025@gmail.com
|
72
|
+
executables: []
|
73
|
+
extensions: []
|
74
|
+
extra_rdoc_files: []
|
75
|
+
files:
|
76
|
+
- ".gitignore"
|
77
|
+
- CODE_OF_CONDUCT.md
|
78
|
+
- Gemfile
|
79
|
+
- Gemfile.lock
|
80
|
+
- LICENSE.txt
|
81
|
+
- README.md
|
82
|
+
- Rakefile
|
83
|
+
- bin/console
|
84
|
+
- bin/setup
|
85
|
+
- lib/twing_earch.rb
|
86
|
+
- lib/twing_earch/earch.rb
|
87
|
+
- lib/twing_earch/notify.rb
|
88
|
+
- lib/twing_earch/rule.rb
|
89
|
+
- lib/twing_earch/rules.rb
|
90
|
+
- lib/twing_earch/version.rb
|
91
|
+
- twing_earch.gemspec
|
92
|
+
homepage: https://github.com/flum1025/twing_earch
|
93
|
+
licenses:
|
94
|
+
- MIT
|
95
|
+
metadata: {}
|
96
|
+
post_install_message:
|
97
|
+
rdoc_options: []
|
98
|
+
require_paths:
|
99
|
+
- lib
|
100
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
101
|
+
requirements:
|
102
|
+
- - ">="
|
103
|
+
- !ruby/object:Gem::Version
|
104
|
+
version: '0'
|
105
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
106
|
+
requirements:
|
107
|
+
- - ">="
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: '0'
|
110
|
+
requirements: []
|
111
|
+
rubyforge_project:
|
112
|
+
rubygems_version: 2.6.8
|
113
|
+
signing_key:
|
114
|
+
specification_version: 4
|
115
|
+
summary: Earch for Twing
|
116
|
+
test_files: []
|