cinch-twitterwatch 1.0.2 → 1.0.4

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
- !binary "U0hBMQ==":
3
- metadata.gz: 4b745d127c6fe8c403ac4f105f995a116acb04b7
4
- data.tar.gz: 63a71efaf6719ac11311116ee6ab2cdac89ade80
2
+ SHA1:
3
+ metadata.gz: 5cb6bb0efb75b1458d01bc6a920c4060a7cfb812
4
+ data.tar.gz: 8b0e79db3d6037f7a13c612c2a06aad71e3ef9ba
5
5
  SHA512:
6
- metadata.gz: 0496c061f9c544579d5d809e2886006dd8175f0346501d73c272192a6c521b04d6f24f169371c666c3f0a5ec65d3b3aabb1779505d384dd8928cf7f44b6401a3
7
- data.tar.gz: 688ad1a73518af042410df7251947c97e6dca431c114d3874cd83102eea33121c0081058cac4c8ee419dced156339accabcefed2e42fcafbc9ddeaa21465e6bf
6
+ metadata.gz: 073e1c70ca6bdcaf58d29f23ebf414fa3d563bc4265da57082f2e1b154632aaa63a944cc224f46ce9791ef2ebfa146df4343987fd3f245bfd07d174cb1e6e43b
7
+ data.tar.gz: 11f29d9222efac7efd3b1a3a90c56c1712797ddb865637d79c7dcd3b63231035000ab0ea6f24e448d4dc9794bb76c6dc0b82b5cbebd31442eaf05164108b743c
@@ -1,17 +1,16 @@
1
1
  ---
2
2
  language: ruby
3
3
  rvm:
4
- - 2.1.0
5
- - 2.0.0
6
- - 1.9.3
7
- - 1.9.2
8
- - 1.8.7
9
- - jruby-18mode
10
- - jruby-19mode
11
- - rbx
12
- - ruby-head
13
- - jruby-head
14
- - ree
4
+ - 2.1.0
5
+ - 2.0.0
6
+ - 1.9.3
7
+ - 1.9.2
8
+ - 1.8.7
9
+ - jruby-18mode
10
+ - jruby-19mode
11
+ - ruby-head
12
+ - jruby-head
13
+ - ree
15
14
  matrix:
16
15
  allow_failures:
17
16
  - rvm: 1.8.7
@@ -25,6 +25,6 @@ Gem::Specification.new do |spec|
25
25
  spec.add_development_dependency 'cinch-test', '~> 0.0', '>= 0.0.4'
26
26
 
27
27
  spec.add_dependency 'twitter', '~> 5.7', '>= 5.7.1'
28
- spec.add_dependency 'cinch', '~> 2.0', '>= 2.0.12'
28
+ spec.add_dependency 'cinch', '~> 2', '>= 2.0.12'
29
29
  spec.add_dependency 'cinch-toolbox', '~> 1.1', '>= 1.1.2'
30
30
  end
@@ -3,81 +3,83 @@ require 'cinch'
3
3
  require 'cinch/toolbox'
4
4
  require 'twitter'
5
5
 
6
- module Cinch::Plugins
7
- # Cinch Plugin to post twitter statuses
8
- class TwitterWatch
9
- include Cinch::Plugin
6
+ module Cinch
7
+ module Plugins
8
+ # Cinch Plugin to post twitter statuses
9
+ class TwitterWatch
10
+ include Cinch::Plugin
10
11
 
11
- timer 15, method: :check_watched
12
+ timer 15, method: :check_watched
12
13
 
13
- def initialize(*args)
14
- super
15
- @client = twitter_client
16
- @watched = build_watchers
17
- end
14
+ def initialize(*args)
15
+ super
16
+ @client = twitter_client
17
+ @watched = build_watchers
18
+ end
18
19
 
19
- def check_watched
20
- return unless @watched
21
- @watched.each { |w| check_for_tweet(w) }
22
- rescue Twitter::Error::NotFound
23
- debug 'You have set an invalid or protected user ' +
24
- 'to watch, please correct this error'
25
- rescue Twitter::Error::TooManyRequests
26
- debug 'Trottled checking user; sleeping 60 seconds.'
27
- sleep 60
28
- end
20
+ def check_watched
21
+ return unless @watched
22
+ @watched.each { |w| check_for_tweet(w) }
23
+ rescue Twitter::Error::NotFound
24
+ debug 'You have set an invalid or protected user ' \
25
+ 'to watch, please correct this error'
26
+ rescue Twitter::Error::TooManyRequests
27
+ debug 'Trottled checking user; sleeping 60 seconds.'
28
+ sleep 60
29
+ end
29
30
 
30
- def check_for_tweet(w)
31
- # Just check the last tweet, if they are posting more than once
32
- # every timer tick we don't want to spam the channel.
33
- debug "Checking Tweets for #{w.nick} (#{w.tweet_cache.count} cached)"
34
- tweet = @client.user(w.nick).status
35
- status = w.tweet_unless_cached(tweet.id)
36
- Channel(w.channel).msg(tweet_text(w.nick, status)) unless status.nil?
37
- end
31
+ def check_for_tweet(w)
32
+ # Just check the last tweet, if they are posting more than once
33
+ # every timer tick we don't want to spam the channel.
34
+ debug "Checking Tweets for #{w.nick} (#{w.tweet_cache.count} cached)"
35
+ tweet = @client.user(w.nick).status
36
+ status = w.tweet_unless_cached(tweet.id)
37
+ Channel(w.channel).msg(tweet_text(w.nick, status)) unless status.nil?
38
+ end
38
39
 
39
- def format_tweet(url)
40
- # Parse the url and get the relevant data
41
- user, status = parse_twitter_url(url)
40
+ def format_tweet(url)
41
+ # Parse the url and get the relevant data
42
+ user, status = parse_twitter_url(url)
42
43
 
43
- # Return blank if we didn't get a good user and status
44
- return if user.nil? || status.nil?
44
+ # Return blank if we didn't get a good user and status
45
+ return if user.nil? || status.nil?
45
46
 
46
- tweet(user, status)
47
- end
47
+ tweet(user, status)
48
+ end
48
49
 
49
- def tweet_text(user, status)
50
- # Scrub the tweet for returns so we don't have multilined responses.
51
- status.gsub!(/[\n]+/, ' ') if status.match(/\n/)
52
- "@#{user} tweeted \"#{status}\""
53
- end
50
+ def tweet_text(user, status)
51
+ # Scrub the tweet for returns so we don't have multilined responses.
52
+ flat_status = status.gsub(/[\n]+/, ' ')
53
+ "@#{user} tweeted \"#{flat_status}\""
54
+ end
54
55
 
55
- private
56
+ private
56
57
 
57
- def parse_twitter_url(url)
58
- tweet_id = url[%r(statuse?s?/(\d+)/?), 1]
59
- user = url[%r(/?#?!?/([^\/]+)/statuse?s?), 1]
60
- [user, Twitter.status(tweet_id).text]
61
- end
58
+ def parse_twitter_url(url)
59
+ tweet_id = url[%r{statuse?s?/(\d+)/?}, 1]
60
+ user = url[%r{/?#?!?/([^\/]+)/statuse?s?}, 1]
61
+ [user, Twitter.status(tweet_id).text]
62
+ end
62
63
 
63
- def build_watchers
64
- watched = []
65
- config[:watchers].each_pair do |chan, users|
66
- users.each do |user|
67
- watcher = Cache.new(user, chan, @client)
68
- debug "#{watcher.init_cache}"
69
- watched << watcher
64
+ def build_watchers
65
+ watched = []
66
+ config[:watchers].each_pair do |chan, users|
67
+ users.each do |user|
68
+ watcher = Cache.new(user, chan, @client)
69
+ debug "#{watcher.init_cache}"
70
+ watched << watcher
71
+ end
70
72
  end
73
+ watched
71
74
  end
72
- watched
73
- end
74
75
 
75
- def twitter_client
76
- Twitter::REST::Client.new do |c|
77
- c.consumer_key = config[:consumer_key]
78
- c.consumer_secret = config[:consumer_secret]
79
- c.access_token = config[:access_token]
80
- c.access_token_secret = config[:access_secret]
76
+ def twitter_client
77
+ Twitter::REST::Client.new do |c|
78
+ c.consumer_key = config[:consumer_key]
79
+ c.consumer_secret = config[:consumer_secret]
80
+ c.access_token = config[:access_token]
81
+ c.access_token_secret = config[:access_secret]
82
+ end
81
83
  end
82
84
  end
83
85
  end
@@ -1,34 +1,37 @@
1
- module Cinch::Plugins
2
- class TwitterWatch
3
- class Cache
4
- attr_accessor :nick, :channel, :tweet_cache, :client
1
+ module Cinch
2
+ module Plugins
3
+ class TwitterWatch
4
+ # Class for tracking the already retrieved tweets so that we don't repost
5
+ class Cache
6
+ attr_accessor :nick, :channel, :tweet_cache, :client
5
7
 
6
- def initialize(nick, channel, client)
7
- @nick = nick
8
- @client = client
9
- @channel = channel
10
- @tweet_cache = {}
11
- end
8
+ def initialize(nick, channel, client)
9
+ @nick = nick
10
+ @client = client
11
+ @channel = channel
12
+ @tweet_cache = {}
13
+ end
12
14
 
13
- def init_cache
14
- @client.user_timeline(@nick).each do |tweet|
15
- cache_tweet(tweet.id)
15
+ def init_cache
16
+ @client.user_timeline(@nick).each do |tweet|
17
+ cache_tweet(tweet.id)
18
+ end
19
+ "Cache: [#{@nick}]: #{@tweet_cache.count} tweets cached."
20
+ rescue Twitter::Error::NotFound
21
+ debug "You have set an invalid or protected user (#{@nick}) to " \
22
+ ' watch, please correct this error'
16
23
  end
17
- "Cache: [#{@nick}]: #{@tweet_cache.count} tweets cached."
18
- rescue Twitter::Error::NotFound
19
- debug "You have set an invalid or protected user (#{@nick}) to " +
20
- ' watch, please correct this error'
21
- end
22
24
 
23
- def tweet_unless_cached(tweet_id)
24
- return if @tweet_cache.key?(tweet_id)
25
- cache_tweet(tweet_id)
26
- @client.status(tweet_id).text
27
- end
25
+ def tweet_unless_cached(tweet_id)
26
+ return if @tweet_cache.key?(tweet_id)
27
+ cache_tweet(tweet_id)
28
+ @client.status(tweet_id).text
29
+ end
28
30
 
29
- def cache_tweet(tweet_id)
30
- @tweet_cache[tweet_id.to_i] = true
31
- true
31
+ def cache_tweet(tweet_id)
32
+ @tweet_cache[tweet_id.to_i] = true
33
+ true
34
+ end
32
35
  end
33
36
  end
34
37
  end
@@ -3,7 +3,7 @@ module Cinch
3
3
  module Plugins
4
4
  # Versioning info
5
5
  class TwitterWatch
6
- VERSION = '1.0.2'
6
+ VERSION = '1.0.4'
7
7
  end
8
8
  end
9
9
  end
metadata CHANGED
@@ -1,149 +1,149 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cinch-twitterwatch
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.2
4
+ version: 1.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brian Haberer
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-03-26 00:00:00.000000000 Z
11
+ date: 2016-05-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ~>
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
19
  version: '1.3'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ~>
24
+ - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '1.3'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ~>
31
+ - - "~>"
32
32
  - !ruby/object:Gem::Version
33
33
  version: '10.1'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ~>
38
+ - - "~>"
39
39
  - !ruby/object:Gem::Version
40
40
  version: '10.1'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rspec
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - ~>
45
+ - - "~>"
46
46
  - !ruby/object:Gem::Version
47
47
  version: '2.14'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - ~>
52
+ - - "~>"
53
53
  - !ruby/object:Gem::Version
54
54
  version: '2.14'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: coveralls
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - ~>
59
+ - - "~>"
60
60
  - !ruby/object:Gem::Version
61
61
  version: '0.7'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - ~>
66
+ - - "~>"
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0.7'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: cinch-test
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - ~>
73
+ - - "~>"
74
74
  - !ruby/object:Gem::Version
75
75
  version: '0.0'
76
- - - ! '>='
76
+ - - ">="
77
77
  - !ruby/object:Gem::Version
78
78
  version: 0.0.4
79
79
  type: :development
80
80
  prerelease: false
81
81
  version_requirements: !ruby/object:Gem::Requirement
82
82
  requirements:
83
- - - ~>
83
+ - - "~>"
84
84
  - !ruby/object:Gem::Version
85
85
  version: '0.0'
86
- - - ! '>='
86
+ - - ">="
87
87
  - !ruby/object:Gem::Version
88
88
  version: 0.0.4
89
89
  - !ruby/object:Gem::Dependency
90
90
  name: twitter
91
91
  requirement: !ruby/object:Gem::Requirement
92
92
  requirements:
93
- - - ~>
93
+ - - "~>"
94
94
  - !ruby/object:Gem::Version
95
95
  version: '5.7'
96
- - - ! '>='
96
+ - - ">="
97
97
  - !ruby/object:Gem::Version
98
98
  version: 5.7.1
99
99
  type: :runtime
100
100
  prerelease: false
101
101
  version_requirements: !ruby/object:Gem::Requirement
102
102
  requirements:
103
- - - ~>
103
+ - - "~>"
104
104
  - !ruby/object:Gem::Version
105
105
  version: '5.7'
106
- - - ! '>='
106
+ - - ">="
107
107
  - !ruby/object:Gem::Version
108
108
  version: 5.7.1
109
109
  - !ruby/object:Gem::Dependency
110
110
  name: cinch
111
111
  requirement: !ruby/object:Gem::Requirement
112
112
  requirements:
113
- - - ~>
113
+ - - "~>"
114
114
  - !ruby/object:Gem::Version
115
- version: '2.0'
116
- - - ! '>='
115
+ version: '2'
116
+ - - ">="
117
117
  - !ruby/object:Gem::Version
118
118
  version: 2.0.12
119
119
  type: :runtime
120
120
  prerelease: false
121
121
  version_requirements: !ruby/object:Gem::Requirement
122
122
  requirements:
123
- - - ~>
123
+ - - "~>"
124
124
  - !ruby/object:Gem::Version
125
- version: '2.0'
126
- - - ! '>='
125
+ version: '2'
126
+ - - ">="
127
127
  - !ruby/object:Gem::Version
128
128
  version: 2.0.12
129
129
  - !ruby/object:Gem::Dependency
130
130
  name: cinch-toolbox
131
131
  requirement: !ruby/object:Gem::Requirement
132
132
  requirements:
133
- - - ~>
133
+ - - "~>"
134
134
  - !ruby/object:Gem::Version
135
135
  version: '1.1'
136
- - - ! '>='
136
+ - - ">="
137
137
  - !ruby/object:Gem::Version
138
138
  version: 1.1.2
139
139
  type: :runtime
140
140
  prerelease: false
141
141
  version_requirements: !ruby/object:Gem::Requirement
142
142
  requirements:
143
- - - ~>
143
+ - - "~>"
144
144
  - !ruby/object:Gem::Version
145
145
  version: '1.1'
146
- - - ! '>='
146
+ - - ">="
147
147
  - !ruby/object:Gem::Version
148
148
  version: 1.1.2
149
149
  description: Cinch plugin that watches for new tweets from users.
@@ -153,8 +153,8 @@ executables: []
153
153
  extensions: []
154
154
  extra_rdoc_files: []
155
155
  files:
156
- - .gitignore
157
- - .travis.yml
156
+ - ".gitignore"
157
+ - ".travis.yml"
158
158
  - Gemfile
159
159
  - LICENSE.txt
160
160
  - README.md
@@ -176,17 +176,17 @@ require_paths:
176
176
  - lib
177
177
  required_ruby_version: !ruby/object:Gem::Requirement
178
178
  requirements:
179
- - - ! '>='
179
+ - - ">="
180
180
  - !ruby/object:Gem::Version
181
181
  version: '0'
182
182
  required_rubygems_version: !ruby/object:Gem::Requirement
183
183
  requirements:
184
- - - ! '>='
184
+ - - ">="
185
185
  - !ruby/object:Gem::Version
186
186
  version: '0'
187
187
  requirements: []
188
188
  rubyforge_project:
189
- rubygems_version: 2.2.2
189
+ rubygems_version: 2.4.8
190
190
  signing_key:
191
191
  specification_version: 4
192
192
  summary: Cinch Plugin to follow twitter.