retrobot 0.3.1 → 0.3.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 237d796585e44c76de0301958af7802d5e85d7de
4
- data.tar.gz: 2607e0dd0b57a3089a79c20e450a04235c91746b
3
+ metadata.gz: 36483df2d5483d39cb99a144af509657a19bee92
4
+ data.tar.gz: acc2cf7d3ed70ad460fd189d6b12aff67f3ad7fa
5
5
  SHA512:
6
- metadata.gz: bef0efecc73f63232c9ae1863bde8b06285ac23c2e290a3d8bc0096cd5780b9b1de6429fc411802260922b2d5d0256c80bccbb357e461c1c5fc6377559f986d1
7
- data.tar.gz: 862bcafae52911b466c828dbca9f684fe839b8c747556e6f2c9bc86c55cf2616af5714bd8fff32c26a412084d990c60b2c93ba2e3e9ea34f332dcdfe19b994cd
6
+ metadata.gz: 032fe2499a535e62b0af01b792bf2e7c9a48fc72475dc98f603095b4dc87b519c3e3cdaa38d4a83ee8bb93bdfa8343700ce11213619faa8b26dcd8cae9056b3c
7
+ data.tar.gz: 5c855645ebe133640bd96fa87e8624995676ced98ee16d1a24ca37fd4d8f0d3c893f7a7aec56bb55a091ffef272867928800aa3aa29a2f6fdd1fced8fb3913d6
data/ChangeLog.md CHANGED
@@ -1,4 +1,8 @@
1
1
  # ChangeLog
2
+ ## 0.3.2
3
+ - Add `remove_hashtag` option (Thanks @kenjiskywalker)
4
+ - https://github.com/mirakui/retrobot/pull/10
5
+
2
6
  ## 0.3.1
3
7
  - Add `suppress_pattern` option
4
8
  - https://github.com/mirakui/retrobot/pull/9
data/lib/retrobot.rb CHANGED
@@ -99,6 +99,7 @@ class Retrobot
99
99
  @tweet_filters << TweetFilters::RetroDays.new(self)
100
100
  @tweet_filters << TweetFilters::SuppressPattern.new(self) if @config.suppress_pattern
101
101
  @tweet_filters << TweetFilters::AddInReplyToUrl.new(self) if @config.add_in_reply_to_url
102
+ @tweet_filters << TweetFilters::RemoveHashtag.new(self) if @config.remove_hashtag
102
103
  @tweet_filters << TweetFilters::Retweet.new(self)
103
104
  @tweet_filters << TweetFilters::RemoveAtmark.new(self)
104
105
  @tweet_filters << TweetFilters::Unescape.new(self)
@@ -19,6 +19,7 @@ class Retrobot
19
19
  retry_count
20
20
  add_in_reply_to_url
21
21
  suppress_pattern
22
+ remove_hashtag
22
23
  )
23
24
 
24
25
  DEFAULTS = {
@@ -32,6 +33,7 @@ class Retrobot
32
33
  retry_count: 5,
33
34
  add_in_reply_to_url: false,
34
35
  suppress_pattern: nil,
36
+ remove_hashtag: false,
35
37
  }
36
38
 
37
39
  def initialize(options={})
@@ -1,5 +1,6 @@
1
1
  require 'retrobot/tweet_filters/base'
2
2
  require 'retrobot/tweet_filters/remove_atmark'
3
+ require 'retrobot/tweet_filters/remove_hashtag'
3
4
  require 'retrobot/tweet_filters/retro_days'
4
5
  require 'retrobot/tweet_filters/retweet'
5
6
  require 'retrobot/tweet_filters/tweet'
@@ -0,0 +1,20 @@
1
+ require 'retrobot/tweet_filters/base'
2
+
3
+ class Retrobot
4
+ module TweetFilters
5
+ class RemoveHashtag < Base
6
+ def initialize(retrobot)
7
+ super
8
+ end
9
+
10
+ def filter(tweet)
11
+ if config.remove_hashtag
12
+ tweet.text.gsub!(/(|\s)#\w+/, '')
13
+ tweet
14
+ else
15
+ tweet
16
+ end
17
+ end
18
+ end
19
+ end
20
+ end
@@ -1,3 +1,3 @@
1
1
  class Retrobot
2
- VERSION = '0.3.1'
2
+ VERSION = '0.3.2'
3
3
  end
data/retrobot.example.yml CHANGED
@@ -8,4 +8,5 @@ access_secret: your_access_secret
8
8
  # debug: false (default)
9
9
  # dryrun: false (default)
10
10
  # add_in_reply_to_url: false (default=false / add url of in_reply_to into the tweet)
11
+ # remove_hashtag: false (default=false / remove hashtag the tweet)
11
12
  # suppress_pattern: '@\w+' (default=nil / regular expression for tweet text which you don't need to tweet)
@@ -71,6 +71,34 @@ describe Retrobot::TweetFilters do
71
71
  end
72
72
  end
73
73
 
74
+ describe 'RemoveHashtag' do
75
+ let(:filter_class) { Retrobot::TweetFilters::RemoveHashtag}
76
+
77
+ context 'config.remove_hashtag is true' do
78
+ let(:config) { Retrobot::Config.new remove_hashtag: true }
79
+
80
+ it 'removes hashtag' do
81
+ tweet_before = Retrobot::Tweet.new.tap do |t|
82
+ t.text = '@mirakui_retro hello #hashtag nospace#hashtag2'
83
+ end
84
+ tweet_after = filter.filter(tweet_before)
85
+ expect(tweet_after.text).to eq('@mirakui_retro hello nospace')
86
+ end
87
+ end
88
+
89
+ context 'config.remove_hashtag is false' do
90
+ let(:config) { Retrobot::Config.new remove_hashtag: false}
91
+
92
+ it 'dose not removes hashtag' do
93
+ tweet_before = Retrobot::Tweet.new.tap do |t|
94
+ t.text = '@mirakui_retro hello #hashtag nospace#hashtag2'
95
+ end
96
+ tweet_after = filter.filter(tweet_before)
97
+ expect(tweet_after.text).to eq('@mirakui_retro hello #hashtag nospace#hashtag2')
98
+ end
99
+ end
100
+ end
101
+
74
102
  describe 'Unescape' do
75
103
  let(:filter_class) { Retrobot::TweetFilters::Unescape }
76
104
 
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.1
4
+ version: 0.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Issei Naruta
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-06-22 00:00:00.000000000 Z
11
+ date: 2014-10-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: twitter
@@ -136,6 +136,7 @@ files:
136
136
  - lib/retrobot/tweet_filters/add_in_reply_to_url.rb
137
137
  - lib/retrobot/tweet_filters/base.rb
138
138
  - lib/retrobot/tweet_filters/remove_atmark.rb
139
+ - lib/retrobot/tweet_filters/remove_hashtag.rb
139
140
  - lib/retrobot/tweet_filters/retro_days.rb
140
141
  - lib/retrobot/tweet_filters/retweet.rb
141
142
  - lib/retrobot/tweet_filters/suppress_pattern.rb