retrobot 0.3.2 → 0.3.3
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/.gitignore +1 -0
- data/.travis.yml +2 -1
- data/ChangeLog.md +4 -0
- data/lib/retrobot.rb +27 -4
- data/lib/retrobot/config.rb +9 -0
- data/lib/retrobot/tweet_filters/retweet.rb +1 -1
- data/lib/retrobot/tweet_filters/tweet.rb +1 -2
- data/lib/retrobot/version.rb +1 -1
- data/retrobot.example.yml +1 -0
- data/spec/lib/retrobot_spec.rb +15 -0
- data/spec/spec_helper.rb +1 -1
- metadata +3 -4
- data/Gemfile.lock +0 -72
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a07ffd05e9636227ff02974c5fec321e325e8074
|
4
|
+
data.tar.gz: 283059383b9df7552d2f0707300b9ae86ca66090
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ce0c93e370528b6d1af9c209e576b09eebc74d0584c909106b38b54956cdf24feaccc3c73b4d4c4e9904ba37643731b656b45f938d01c4c96a08a1b8b32ceeb1
|
7
|
+
data.tar.gz: e12385d0b8efc843ecc2a4ed5261218bfd562d6ad99c07ad394b11e0dddaf96039f8e4e88c3dd1ec974f518409845cf8dc16c94c2fff6dabd53a2ef0a9f5df65
|
data/.gitignore
CHANGED
data/.travis.yml
CHANGED
data/ChangeLog.md
CHANGED
@@ -1,4 +1,8 @@
|
|
1
1
|
# ChangeLog
|
2
|
+
## 0.3.3
|
3
|
+
- Add dying_message feature and `dying_mention_to` option (Thanks @sonots)
|
4
|
+
- Bug fix: error with retryable-2.0.0 (Thanks @hansode)
|
5
|
+
|
2
6
|
## 0.3.2
|
3
7
|
- Add `remove_hashtag` option (Thanks @kenjiskywalker)
|
4
8
|
- https://github.com/mirakui/retrobot/pull/10
|
data/lib/retrobot.rb
CHANGED
@@ -61,20 +61,43 @@ class Retrobot
|
|
61
61
|
break;
|
62
62
|
end
|
63
63
|
end
|
64
|
-
csv.slice! last_index..-1
|
65
|
-
|
64
|
+
csv.slice! last_index..-1 if last_index
|
65
|
+
if csv.empty?
|
66
|
+
logger.fatal "No data is left. Please update the tweets.csv"
|
67
|
+
false
|
68
|
+
else
|
69
|
+
logger.info "Next update: \"#{csv.last[5]}\" at #{@config.retro_days.since(Time.parse(csv.last[3]))}"
|
70
|
+
true
|
71
|
+
end
|
66
72
|
end
|
67
73
|
|
68
74
|
def tweet_loop
|
69
75
|
logger.info 'start'
|
70
76
|
loop do
|
71
77
|
line = csv.last
|
78
|
+
unless line
|
79
|
+
dying_message
|
80
|
+
return false
|
81
|
+
end
|
72
82
|
if process_line(line)
|
73
83
|
csv.pop
|
74
84
|
end
|
75
85
|
sleep @config.loop_interval
|
76
86
|
logger.debug '.'
|
77
87
|
end
|
88
|
+
true
|
89
|
+
end
|
90
|
+
|
91
|
+
def dying_message
|
92
|
+
message = "No data is left. Please update my tweets.csv. Pee.. Gaa..."
|
93
|
+
tweet_text = if mention = @config.dying_mention_to
|
94
|
+
"#{mention} #{message}"
|
95
|
+
else
|
96
|
+
message
|
97
|
+
end
|
98
|
+
twitter = TweetFilters::Tweet.new(self)
|
99
|
+
twitter.tweet(tweet_text)
|
100
|
+
logger.fatal message
|
78
101
|
end
|
79
102
|
|
80
103
|
def process_line(line)
|
@@ -139,8 +162,8 @@ class Retrobot
|
|
139
162
|
|
140
163
|
def main
|
141
164
|
init_configuration
|
142
|
-
init_csv
|
143
|
-
tweet_loop
|
165
|
+
exit 1 unless init_csv
|
166
|
+
exit 1 unless tweet_loop
|
144
167
|
end
|
145
168
|
|
146
169
|
private
|
data/lib/retrobot/config.rb
CHANGED
@@ -20,6 +20,7 @@ class Retrobot
|
|
20
20
|
add_in_reply_to_url
|
21
21
|
suppress_pattern
|
22
22
|
remove_hashtag
|
23
|
+
dying_mention_to
|
23
24
|
)
|
24
25
|
|
25
26
|
DEFAULTS = {
|
@@ -34,6 +35,7 @@ class Retrobot
|
|
34
35
|
add_in_reply_to_url: false,
|
35
36
|
suppress_pattern: nil,
|
36
37
|
remove_hashtag: false,
|
38
|
+
dying_mention_to: nil,
|
37
39
|
}
|
38
40
|
|
39
41
|
def initialize(options={})
|
@@ -60,6 +62,13 @@ class Retrobot
|
|
60
62
|
def retry_interval; @options[:retry_interval].to_i; end
|
61
63
|
def retry_count; @options[:retry_count].to_i; end
|
62
64
|
|
65
|
+
def dying_mention_to
|
66
|
+
return nil unless @options[:dying_mention_to]
|
67
|
+
# add mention mark (atmark)
|
68
|
+
@options[:dying_mention_to].start_with?('@') ?
|
69
|
+
@options[:dying_mention_to] : "@" + @options[:dying_mention_to]
|
70
|
+
end
|
71
|
+
|
63
72
|
def load_yaml_file!(path)
|
64
73
|
@options.merge! Psych.load_file(path.to_s).symbolize_keys
|
65
74
|
end
|
@@ -25,7 +25,7 @@ class Retrobot
|
|
25
25
|
def retweet(status_id, text=nil)
|
26
26
|
logger.info "retweet: #{status_id} \"#{text}\""
|
27
27
|
return if config.dryrun
|
28
|
-
retryable(tries: config.retry_count, sleep: config.retry_interval) do
|
28
|
+
Retryable.retryable(tries: config.retry_count, sleep: config.retry_interval) do
|
29
29
|
client.retweet status_id
|
30
30
|
end
|
31
31
|
end
|
@@ -12,11 +12,10 @@ class Retrobot
|
|
12
12
|
tweet tweet.text
|
13
13
|
end
|
14
14
|
|
15
|
-
private
|
16
15
|
def tweet(text)
|
17
16
|
logger.info "tweet: #{text}"
|
18
17
|
return if config.dryrun
|
19
|
-
retryable(tries: config.retry_count, sleep: config.retry_interval) do
|
18
|
+
Retryable.retryable(tries: config.retry_count, sleep: config.retry_interval) do
|
20
19
|
client.update text
|
21
20
|
end
|
22
21
|
end
|
data/lib/retrobot/version.rb
CHANGED
data/retrobot.example.yml
CHANGED
@@ -10,3 +10,4 @@ access_secret: your_access_secret
|
|
10
10
|
# add_in_reply_to_url: false (default=false / add url of in_reply_to into the tweet)
|
11
11
|
# remove_hashtag: false (default=false / remove hashtag the tweet)
|
12
12
|
# suppress_pattern: '@\w+' (default=nil / regular expression for tweet text which you don't need to tweet)
|
13
|
+
# dying_mention_to: '@mirakui' (default=nil / send dying message as mention to this person if tweets.csv doesn't have tweets anymore)
|
data/spec/lib/retrobot_spec.rb
CHANGED
@@ -88,5 +88,20 @@ describe Retrobot do
|
|
88
88
|
end
|
89
89
|
end
|
90
90
|
end
|
91
|
+
|
92
|
+
context "no data left" do
|
93
|
+
before do
|
94
|
+
allow(retrobot).to receive(:csv).and_return([]) # empty
|
95
|
+
end
|
96
|
+
|
97
|
+
it 'shoud exit if no data left on starting up' do
|
98
|
+
expect(retrobot.init_csv).to be false
|
99
|
+
end
|
100
|
+
|
101
|
+
it 'should tweet a dying message and exit if no data left on tweet_loop' do
|
102
|
+
expect(client).to receive(:update)
|
103
|
+
expect(retrobot.tweet_loop).to be false
|
104
|
+
end
|
105
|
+
end
|
91
106
|
end
|
92
107
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -5,7 +5,7 @@
|
|
5
5
|
#
|
6
6
|
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
|
7
7
|
RSpec.configure do |config|
|
8
|
-
config.
|
8
|
+
config.raise_errors_for_deprecations!
|
9
9
|
config.run_all_when_everything_filtered = true
|
10
10
|
config.filter_run :focus
|
11
11
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: retrobot
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Issei Naruta
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-02-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: twitter
|
@@ -123,7 +123,6 @@ files:
|
|
123
123
|
- ".travis.yml"
|
124
124
|
- ChangeLog.md
|
125
125
|
- Gemfile
|
126
|
-
- Gemfile.lock
|
127
126
|
- LICENSE.txt
|
128
127
|
- README.md
|
129
128
|
- Rakefile
|
@@ -169,7 +168,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
169
168
|
version: '0'
|
170
169
|
requirements: []
|
171
170
|
rubyforge_project:
|
172
|
-
rubygems_version: 2.
|
171
|
+
rubygems_version: 2.4.5
|
173
172
|
signing_key:
|
174
173
|
specification_version: 4
|
175
174
|
summary: 'Retrobot tweets a word that you''ve tweeted just 1 year ago. (example: @mirakui_retro)'
|
data/Gemfile.lock
DELETED
@@ -1,72 +0,0 @@
|
|
1
|
-
PATH
|
2
|
-
remote: .
|
3
|
-
specs:
|
4
|
-
retrobot (0.3.1)
|
5
|
-
activesupport (~> 4.0)
|
6
|
-
daemons
|
7
|
-
get-twitter-oauth-token
|
8
|
-
retryable
|
9
|
-
twitter (~> 5.8)
|
10
|
-
|
11
|
-
GEM
|
12
|
-
remote: https://rubygems.org/
|
13
|
-
specs:
|
14
|
-
activesupport (4.1.1)
|
15
|
-
i18n (~> 0.6, >= 0.6.9)
|
16
|
-
json (~> 1.7, >= 1.7.7)
|
17
|
-
minitest (~> 5.1)
|
18
|
-
thread_safe (~> 0.1)
|
19
|
-
tzinfo (~> 1.1)
|
20
|
-
addressable (2.3.6)
|
21
|
-
buftok (0.2.0)
|
22
|
-
daemons (1.1.9)
|
23
|
-
diff-lcs (1.2.5)
|
24
|
-
equalizer (0.0.9)
|
25
|
-
faraday (0.9.0)
|
26
|
-
multipart-post (>= 1.2, < 3)
|
27
|
-
get-twitter-oauth-token (1.1.0)
|
28
|
-
oauth
|
29
|
-
http (0.6.1)
|
30
|
-
http_parser.rb (~> 0.6.0)
|
31
|
-
http_parser.rb (0.6.0)
|
32
|
-
i18n (0.6.9)
|
33
|
-
json (1.8.1)
|
34
|
-
memoizable (0.4.2)
|
35
|
-
thread_safe (~> 0.3, >= 0.3.1)
|
36
|
-
minitest (5.3.4)
|
37
|
-
multipart-post (2.0.0)
|
38
|
-
naught (1.0.0)
|
39
|
-
oauth (0.4.7)
|
40
|
-
retryable (1.3.5)
|
41
|
-
rspec (2.99.0)
|
42
|
-
rspec-core (~> 2.99.0)
|
43
|
-
rspec-expectations (~> 2.99.0)
|
44
|
-
rspec-mocks (~> 2.99.0)
|
45
|
-
rspec-core (2.99.0)
|
46
|
-
rspec-expectations (2.99.0)
|
47
|
-
diff-lcs (>= 1.1.3, < 2.0)
|
48
|
-
rspec-mocks (2.99.1)
|
49
|
-
simple_oauth (0.2.0)
|
50
|
-
thread_safe (0.3.4)
|
51
|
-
timecop (0.7.1)
|
52
|
-
twitter (5.10.0)
|
53
|
-
addressable (~> 2.3)
|
54
|
-
buftok (~> 0.2.0)
|
55
|
-
equalizer (~> 0.0.9)
|
56
|
-
faraday (~> 0.9.0)
|
57
|
-
http (~> 0.6.0)
|
58
|
-
http_parser.rb (~> 0.6.0)
|
59
|
-
json (~> 1.8)
|
60
|
-
memoizable (~> 0.4.0)
|
61
|
-
naught (~> 1.0)
|
62
|
-
simple_oauth (~> 0.2.0)
|
63
|
-
tzinfo (1.2.1)
|
64
|
-
thread_safe (~> 0.1)
|
65
|
-
|
66
|
-
PLATFORMS
|
67
|
-
ruby
|
68
|
-
|
69
|
-
DEPENDENCIES
|
70
|
-
retrobot!
|
71
|
-
rspec (= 2.99)
|
72
|
-
timecop
|