cinch-links-titles 1.0.1 → 1.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: 49a8ebd12a6ad2b47b1c66525d3ead4dcfa9248c
4
+ data.tar.gz: e93bdb2029e39c870893f1239d0a474549d5a2db
5
+ SHA512:
6
+ metadata.gz: fe41022c1a90eb5c784ad95e99b2a8ebed088f0f9f4ff648ead484d61b6cab72608ca8a520b3cd3ab75aa7aeec6780148ff3dd3eb778673b186697f4cd78193a
7
+ data.tar.gz: f5d6ea504d67bb34e57bdddc83073f95210ccde8218d9de7467107a8ef7d3e7a68b78e3789805f72cc42bd04ce281a26eae7f3c68a735d699670d3494ca1401c
data/.travis.yml CHANGED
@@ -1,4 +1,23 @@
1
1
  language: ruby
2
+ env:
3
+ global:
4
+ - "JRUBY_OPTS=-Xcext.enabled=true"
2
5
  rvm:
3
- - 1.9.2
6
+ - 2.1.0
7
+ - 2.0.0
4
8
  - 1.9.3
9
+ - 1.9.2
10
+ - 1.8.7
11
+ - jruby-18mode
12
+ - jruby-19mode
13
+ - ruby-head
14
+ - jruby-head
15
+ - ree
16
+ matrix:
17
+ allow_failures:
18
+ - rvm: 1.8.7
19
+ - rvm: ree
20
+ - rvm: jruby-18mode
21
+ - rvm: jruby-19mode
22
+ - rvm: jruby-head
23
+ fast_finish: true
@@ -8,24 +8,21 @@ Gem::Specification.new do |gem|
8
8
  gem.version = Cinch::Plugins::LinksTitles::VERSION
9
9
  gem.authors = ['Brian Haberer']
10
10
  gem.email = ['bhaberer@gmail.com']
11
- gem.description = %q{Cinch Plugin to print link titles to the channel}
12
- gem.summary = %q{Link Titles}
11
+ gem.description = %q(Cinch Plugin to print link titles to the channel)
12
+ gem.summary = %q(Link Titles)
13
13
  gem.homepage = 'https://github.com/bhaberer/cinch-links-titles'
14
14
  gem.license = 'MIT'
15
-
16
15
  gem.files = `git ls-files`.split($/)
17
- gem.executables = gem.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
- gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
16
+ gem.executables = gem.files.grep(/^bin\//).map { |f| File.basename(f) }
17
+ gem.test_files = gem.files.grep(/^(test|spec|features)\//)
19
18
  gem.require_paths = ['lib']
20
19
 
21
- gem.add_development_dependency 'rake'
22
- gem.add_development_dependency 'rspec'
23
- gem.add_development_dependency 'coveralls'
24
- gem.add_development_dependency 'cinch-test'
25
-
26
- gem.add_dependency 'cinch', '~> 2.0.12'
27
- gem.add_dependency 'cinch-cooldown', '~> 1.1.1'
28
- gem.add_dependency 'cinch-storage', '~> 1.1.0'
29
- gem.add_dependency 'cinch-toolbox', '~> 1.1.0'
30
- gem.add_dependency 'time-lord', '~> 1.0.1'
20
+ gem.add_development_dependency 'rake', '~> 10'
21
+ gem.add_development_dependency 'rspec', '~> 3'
22
+ gem.add_development_dependency 'coveralls', '~> 0.7'
23
+ gem.add_development_dependency 'cinch-test', '~> 0.1', '>= 0.1.1'
24
+ gem.add_dependency 'cinch', '~> 2'
25
+ gem.add_dependency 'cinch-cooldown', '~> 1.1', '>= 1.1.1'
26
+ gem.add_dependency 'cinch-storage', '~> 1.1'
27
+ gem.add_dependency 'cinch-toolbox', '~> 1.1'
31
28
  end
@@ -5,114 +5,115 @@ require 'cinch/toolbox'
5
5
  require 'cinch/storage'
6
6
  require 'time-lord'
7
7
 
8
- module Cinch::Plugins
9
- # Plugin to print URL titles in the channel.
10
- class LinksTitles
11
- include Cinch::Plugin
12
- attr_accessor :storage
13
-
14
- # Simple struct object for tracking Links.
15
- class Link < Struct.new(:nick, :title, :count, :short_url, :url, :time)
16
- def to_yaml
17
- { nick: nick, title: title, count: count, short_url: short_url,
18
- url: url, time: time }
8
+ module Cinch
9
+ module Plugins
10
+ # Plugin to print URL titles in the channel.
11
+ class LinksTitles
12
+ include Cinch::Plugin
13
+ attr_accessor :storage
14
+
15
+ # Simple struct object for tracking Links.
16
+ class Link < Struct.new(:nick, :title, :count, :short_url, :url, :time)
17
+ def to_yaml
18
+ { nick: nick, title: title, count: count, short_url: short_url,
19
+ url: url, time: time }
20
+ end
19
21
  end
20
- end
21
22
 
22
- listen_to :channel
23
+ listen_to :channel
23
24
 
24
- def initialize(*args)
25
- super
26
- @storage = Cinch::Storage.new(config[:filename] ||
27
- 'yaml/links-titles.yaml')
28
- @storage.data[:history] ||= {}
29
- @post_stats = config[:stats].nil? ? false : config[:stats]
30
- end
25
+ def initialize(*args)
26
+ super
27
+ @storage = Cinch::Storage.new(config[:filename] ||
28
+ 'yaml/links-titles.yaml')
29
+ @storage.data[:history] ||= {}
30
+ @post_stats = config[:stats].nil? ? false : config[:stats]
31
+ end
31
32
 
32
- def listen(m)
33
- urls = URI.extract(m.message, %w(http https))
34
- urls.each do |url|
35
- # Ensure we have a Channel Object in the History to dump links into.
36
- @storage.data[:history][m.channel.name] ||= Hash.new
33
+ def listen(m)
34
+ urls = URI.extract(m.message, %w(http https))
35
+ urls.each do |url|
36
+ # Ensure we have a Channel Object in the History to dump links into.
37
+ @storage.data[:history][m.channel.name] ||= Hash.new
37
38
 
38
- # Process link
39
- link = process_link(url, m.channel.name, m.user.nick)
39
+ # Process link
40
+ link = process_link(url, m.channel.name, m.user.nick)
40
41
 
41
- # Send link title to channel
42
- post_title(m, link)
42
+ # Send link title to channel
43
+ post_title(m, link)
43
44
 
44
- # Send link stats to channel
45
- post_stats(m, link)
46
- end
45
+ # Send link stats to channel
46
+ post_stats(m, link)
47
+ end
47
48
 
48
- # Don't save unless we found some urls to process
49
- @storage.synced_save(@bot) if urls
50
- end
49
+ # Don't save unless we found some urls to process
50
+ @storage.synced_save(@bot) if urls
51
+ end
51
52
 
52
- private
53
+ private
53
54
 
54
- def process_link(url, channel, nick)
55
- # Make sure it conforms to white/black lists before bothering.
56
- if whitelisted?(url) && !blacklisted?(url)
57
- return get_or_query_link(url, channel, nick)
58
- else
59
- if blacklisted?(url)
60
- debug "Blacklisted URL was not logged #{url}"
55
+ def process_link(url, channel, nick)
56
+ # Make sure it conforms to white/black lists before bothering.
57
+ if whitelisted?(url) && !blacklisted?(url)
58
+ return get_or_query_link(url, channel, nick)
61
59
  else
62
- debug "Domain not Whitelisted #{url}"
60
+ if blacklisted?(url)
61
+ debug "Blacklisted URL was not logged #{url}"
62
+ else
63
+ debug "Domain not Whitelisted #{url}"
64
+ end
65
+ return nil
63
66
  end
64
- return nil
65
67
  end
66
- end
67
68
 
68
- def get_or_query_link(url, channel, nick)
69
- # If the link was posted already, get the old info
70
- if @storage.data[:history][channel].key?(url)
71
- @storage.data[:history][channel][url][:count] += 1
72
- link = @storage.data[:history][channel][url]
73
- else
74
- link = Link.new(nick, Cinch::Toolbox.get_page_title(url) || nil,
75
- 1, Cinch::Toolbox.shorten(url), url, Time.now)
76
- @storage.data[:history][channel][url] = link
69
+ def get_or_query_link(url, channel, nick)
70
+ # If the link was posted already, get the old info
71
+ if @storage.data[:history][channel].key?(url)
72
+ @storage.data[:history][channel][url][:count] += 1
73
+ link = @storage.data[:history][channel][url]
74
+ else
75
+ link = Link.new(nick, Cinch::Toolbox.get_page_title(url) || nil,
76
+ 1, Cinch::Toolbox.shorten(url), url, Time.now)
77
+ @storage.data[:history][channel][url] = link
78
+ end
79
+ link
77
80
  end
78
- link
79
- end
80
81
 
81
- def post_title(m, link)
82
- # Only spam the channel if you have a title
83
- unless link.nil? || link.title.nil?
82
+ def post_title(m, link)
83
+ # Only spam the channel if you have a title
84
+ return if link.nil? || link.title.nil?
84
85
  m.reply "#{link.short_url || link.url} ∴ #{link.title}"
85
86
  end
86
- end
87
87
 
88
- def post_stats(m, link)
89
- # Check to see if we should post stats and if it's been linked
90
- # more than once.
91
- if config[:stats]
92
- if link.count > 1
93
- # No stats if this person was the first one to link it
94
- unless link.nick == m.user.nick
95
- m.reply "That was already linked by #{link.nick} " +
96
- "#{link.time.ago.to_words}.", true
97
- end
98
- end
88
+ def post_stats(m, link)
89
+ # Check to see if we should post stats
90
+ return unless config.key?(:stats)
91
+
92
+ # Check to see if it's been linked more than once.
93
+ return unless link.count > 1
94
+
95
+ # No stats if this person was the first one to link it
96
+ return if link.nick == m.user.nick
97
+
98
+ m.reply "That was already linked by #{link.nick} " \
99
+ "#{link.time.ago.to_words}.", true
99
100
  end
100
- end
101
101
 
102
- def whitelisted?(url)
103
- return true unless config[:whitelist]
104
- debug "Checking Whitelist! #{config[:whitelist]} url: #{url}"
105
- return true if url.match(
106
- Regexp.new("https?:\/\/.*\.?#{config[:whitelist].join('|')}\."))
107
- false
108
- end
102
+ def whitelisted?(url)
103
+ return true unless config[:whitelist]
104
+ debug "Checking Whitelist! #{config[:whitelist]} url: #{url}"
105
+ return true if url.match(
106
+ Regexp.new("https?:\/\/.*\.?#{config[:whitelist].join('|')}\."))
107
+ false
108
+ end
109
109
 
110
- def blacklisted?(url)
111
- return false unless config[:blacklist]
112
- debug "Checking Blacklist! #{config[:blacklist]} url: #{url}"
113
- return true if url.match(
114
- Regexp.new("https?:\/\/.*\.?#{config[:blacklist].join('|')}\."))
115
- false
110
+ def blacklisted?(url)
111
+ return false unless config[:blacklist]
112
+ debug "Checking Blacklist! #{config[:blacklist]} url: #{url}"
113
+ return true if url.match(
114
+ Regexp.new("https?:\/\/.*\.?#{config[:blacklist].join('|')}\."))
115
+ false
116
+ end
116
117
  end
117
118
  end
118
119
  end
@@ -3,7 +3,7 @@ module Cinch
3
3
  module Plugins
4
4
  # Versioning info
5
5
  class LinksTitles
6
- VERSION = '1.0.1'
6
+ VERSION = '1.0.2'
7
7
  end
8
8
  end
9
9
  end
@@ -9,53 +9,54 @@ describe Cinch::Plugins::LinksTitles do
9
9
  end
10
10
 
11
11
  it 'should print titles' do
12
- get_replies(make_message(@bot, 'http://github.com',
13
- { channel: '#foo', nick: 'bar' })).first.text
14
- .should include('GitHub · Build software better, together.')
12
+ reply = get_replies(make_message(@bot, 'http://github.com',
13
+ { channel: '#foo', nick: 'bar' })).first
14
+
15
+ expect(reply.text).to include('GitHub · Build software better, together.')
15
16
  end
16
17
 
17
18
  it 'should obey blacklist and not title blacklisted links' do
18
19
  bot = make_bot(Cinch::Plugins::LinksTitles,
19
20
  { filename: '/dev/null',
20
21
  blacklist: ['twitter'] })
21
- get_replies(make_message(bot, 'http://twitter.com',
22
- { channel: '#foo', nick: 'bar' })).first
23
- .should be_nil
22
+ reply = get_replies(make_message(bot, 'http://twitter.com',
23
+ { channel: '#foo', nick: 'bar' })).first
24
+ expect(reply).to be_nil
24
25
  end
25
26
 
26
27
  it 'should obey blacklist and title unblacklisted links' do
27
28
  bot = make_bot(Cinch::Plugins::LinksTitles,
28
29
  { filename: '/dev/null',
29
30
  blacklist: ['twitter'] })
30
- get_replies(make_message(bot, 'http://facebook.com',
31
- { channel: '#foo', nick: 'bar' })).first
32
- .should_not be_nil
31
+ reply = get_replies(make_message(bot, 'http://facebook.com',
32
+ { channel: '#foo', nick: 'bar' })).first
33
+ expect(reply).not_to be_nil
33
34
  end
34
35
 
35
36
  it 'should obey whitelist and title whitelisted links' do
36
37
  bot = make_bot(Cinch::Plugins::LinksTitles,
37
38
  { filename: '/dev/null',
38
39
  whitelist: ['twitter'] })
39
- get_replies(make_message(bot, 'http://twitter.com',
40
- { channel: '#foo', nick: 'bar' })).first
41
- .should_not be_nil
40
+ reply = get_replies(make_message(bot, 'http://twitter.com',
41
+ { channel: '#foo', nick: 'bar' })).first
42
+ expect(reply).to_not be_nil
42
43
  end
43
44
 
44
45
  it 'should obey whitelist and not title unwhitelisted links' do
45
46
  bot = make_bot(Cinch::Plugins::LinksTitles,
46
47
  { filename: '/dev/null',
47
48
  whitelist: ['twitter'] })
48
- get_replies(make_message(bot, 'http://facebook.com',
49
- { channel: '#foo', nick: 'bar' })).first
50
- .should be_nil
49
+ reply = get_replies(make_message(bot, 'http://facebook.com',
50
+ { channel: '#foo', nick: 'bar' })).first
51
+ expect(reply).to be_nil
51
52
  end
52
53
 
53
54
  it 'should not display stats if they are not enabled' do
54
55
  get_replies(make_message(@bot, 'http://facebook.com',
55
56
  { channel: '#foo', nick: 'bar1' }))
56
- get_replies(make_message(@bot, 'http://facebook.com',
57
- { channel: '#foo', nick: 'bar2' })).last
58
- .should_not include('That was already linked by')
57
+ reply = get_replies(make_message(@bot, 'http://facebook.com',
58
+ { channel: '#foo', nick: 'bar2' })).last
59
+ expect(reply).to_not include('That was already linked by')
59
60
  end
60
61
 
61
62
  it 'should display stats if they are enabled' do
@@ -63,8 +64,8 @@ describe Cinch::Plugins::LinksTitles do
63
64
  { filename: '/dev/null', stats: true })
64
65
  get_replies(make_message(bot, 'http://facebook.com',
65
66
  { channel: '#foo', nick: 'bar1' }))
66
- get_replies(make_message(bot, 'http://facebook.com',
67
- { channel: '#foo', nick: 'bar2' })).last.text
68
- .should include('That was already linked by')
67
+ reply = get_replies(make_message(bot, 'http://facebook.com',
68
+ { channel: '#foo', nick: 'bar2' })).last
69
+ expect(reply.text).to include('That was already linked by')
69
70
  end
70
71
  end
metadata CHANGED
@@ -1,160 +1,139 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cinch-links-titles
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
5
- prerelease:
4
+ version: 1.0.2
6
5
  platform: ruby
7
6
  authors:
8
7
  - Brian Haberer
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2014-02-19 00:00:00.000000000 Z
11
+ date: 2014-07-31 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: rake
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
- - - ! '>='
17
+ - - ~>
20
18
  - !ruby/object:Gem::Version
21
- version: '0'
19
+ version: '10'
22
20
  type: :development
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
- - - ! '>='
24
+ - - ~>
28
25
  - !ruby/object:Gem::Version
29
- version: '0'
26
+ version: '10'
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: rspec
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
- - - ! '>='
31
+ - - ~>
36
32
  - !ruby/object:Gem::Version
37
- version: '0'
33
+ version: '3'
38
34
  type: :development
39
35
  prerelease: false
40
36
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
37
  requirements:
43
- - - ! '>='
38
+ - - ~>
44
39
  - !ruby/object:Gem::Version
45
- version: '0'
40
+ version: '3'
46
41
  - !ruby/object:Gem::Dependency
47
42
  name: coveralls
48
43
  requirement: !ruby/object:Gem::Requirement
49
- none: false
50
44
  requirements:
51
- - - ! '>='
45
+ - - ~>
52
46
  - !ruby/object:Gem::Version
53
- version: '0'
47
+ version: '0.7'
54
48
  type: :development
55
49
  prerelease: false
56
50
  version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
51
  requirements:
59
- - - ! '>='
52
+ - - ~>
60
53
  - !ruby/object:Gem::Version
61
- version: '0'
54
+ version: '0.7'
62
55
  - !ruby/object:Gem::Dependency
63
56
  name: cinch-test
64
57
  requirement: !ruby/object:Gem::Requirement
65
- none: false
66
58
  requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: '0.1'
67
62
  - - ! '>='
68
63
  - !ruby/object:Gem::Version
69
- version: '0'
64
+ version: 0.1.1
70
65
  type: :development
71
66
  prerelease: false
72
67
  version_requirements: !ruby/object:Gem::Requirement
73
- none: false
74
68
  requirements:
69
+ - - ~>
70
+ - !ruby/object:Gem::Version
71
+ version: '0.1'
75
72
  - - ! '>='
76
73
  - !ruby/object:Gem::Version
77
- version: '0'
74
+ version: 0.1.1
78
75
  - !ruby/object:Gem::Dependency
79
76
  name: cinch
80
77
  requirement: !ruby/object:Gem::Requirement
81
- none: false
82
78
  requirements:
83
79
  - - ~>
84
80
  - !ruby/object:Gem::Version
85
- version: 2.0.12
81
+ version: '2'
86
82
  type: :runtime
87
83
  prerelease: false
88
84
  version_requirements: !ruby/object:Gem::Requirement
89
- none: false
90
85
  requirements:
91
86
  - - ~>
92
87
  - !ruby/object:Gem::Version
93
- version: 2.0.12
88
+ version: '2'
94
89
  - !ruby/object:Gem::Dependency
95
90
  name: cinch-cooldown
96
91
  requirement: !ruby/object:Gem::Requirement
97
- none: false
98
92
  requirements:
99
93
  - - ~>
94
+ - !ruby/object:Gem::Version
95
+ version: '1.1'
96
+ - - ! '>='
100
97
  - !ruby/object:Gem::Version
101
98
  version: 1.1.1
102
99
  type: :runtime
103
100
  prerelease: false
104
101
  version_requirements: !ruby/object:Gem::Requirement
105
- none: false
106
102
  requirements:
107
103
  - - ~>
104
+ - !ruby/object:Gem::Version
105
+ version: '1.1'
106
+ - - ! '>='
108
107
  - !ruby/object:Gem::Version
109
108
  version: 1.1.1
110
109
  - !ruby/object:Gem::Dependency
111
110
  name: cinch-storage
112
111
  requirement: !ruby/object:Gem::Requirement
113
- none: false
114
112
  requirements:
115
113
  - - ~>
116
114
  - !ruby/object:Gem::Version
117
- version: 1.1.0
115
+ version: '1.1'
118
116
  type: :runtime
119
117
  prerelease: false
120
118
  version_requirements: !ruby/object:Gem::Requirement
121
- none: false
122
119
  requirements:
123
120
  - - ~>
124
121
  - !ruby/object:Gem::Version
125
- version: 1.1.0
122
+ version: '1.1'
126
123
  - !ruby/object:Gem::Dependency
127
124
  name: cinch-toolbox
128
125
  requirement: !ruby/object:Gem::Requirement
129
- none: false
130
- requirements:
131
- - - ~>
132
- - !ruby/object:Gem::Version
133
- version: 1.1.0
134
- type: :runtime
135
- prerelease: false
136
- version_requirements: !ruby/object:Gem::Requirement
137
- none: false
138
- requirements:
139
- - - ~>
140
- - !ruby/object:Gem::Version
141
- version: 1.1.0
142
- - !ruby/object:Gem::Dependency
143
- name: time-lord
144
- requirement: !ruby/object:Gem::Requirement
145
- none: false
146
126
  requirements:
147
127
  - - ~>
148
128
  - !ruby/object:Gem::Version
149
- version: 1.0.1
129
+ version: '1.1'
150
130
  type: :runtime
151
131
  prerelease: false
152
132
  version_requirements: !ruby/object:Gem::Requirement
153
- none: false
154
133
  requirements:
155
134
  - - ~>
156
135
  - !ruby/object:Gem::Version
157
- version: 1.0.1
136
+ version: '1.1'
158
137
  description: Cinch Plugin to print link titles to the channel
159
138
  email:
160
139
  - bhaberer@gmail.com
@@ -177,29 +156,27 @@ files:
177
156
  homepage: https://github.com/bhaberer/cinch-links-titles
178
157
  licenses:
179
158
  - MIT
159
+ metadata: {}
180
160
  post_install_message:
181
161
  rdoc_options: []
182
162
  require_paths:
183
163
  - lib
184
164
  required_ruby_version: !ruby/object:Gem::Requirement
185
- none: false
186
165
  requirements:
187
166
  - - ! '>='
188
167
  - !ruby/object:Gem::Version
189
168
  version: '0'
190
169
  required_rubygems_version: !ruby/object:Gem::Requirement
191
- none: false
192
170
  requirements:
193
171
  - - ! '>='
194
172
  - !ruby/object:Gem::Version
195
173
  version: '0'
196
174
  requirements: []
197
175
  rubyforge_project:
198
- rubygems_version: 1.8.25
176
+ rubygems_version: 2.2.2
199
177
  signing_key:
200
- specification_version: 3
178
+ specification_version: 4
201
179
  summary: Link Titles
202
180
  test_files:
203
181
  - spec/cinch-links-titles_spec.rb
204
182
  - spec/spec_helper.rb
205
- has_rdoc: