cinch-links-logger 1.0.2 → 1.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.travis.yml +20 -1
- data/cinch-links-logger.gemspec +12 -16
- data/lib/cinch/plugins/links-logger.rb +45 -43
- data/lib/cinch/plugins/links-logger/version.rb +1 -1
- data/spec/cinch-links-logger_spec.rb +9 -9
- data/spec/spec_helper.rb +8 -1
- metadata +37 -60
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: c02e926f20377bff962dc603021d8425fc2f4ba6
|
4
|
+
data.tar.gz: 686d30c2e22c1679a8ac6880753377c073e0b5a2
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 1b695695a40d6620654a1114bd72dc5be65e9e1ec0debe8d9a9dde6aad00a896c180c58f93f39cb1eb90b23baeca125e7836d0dad23c66399b48b9a5496362d5
|
7
|
+
data.tar.gz: 237c2426b0dea2476ad535b7356fb213c4c5f25ca5052b32a5f75b767230c0d43c38285878f01593740561ae70cef11c24ede3901f8bc7cc99b17183da8c7e27
|
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.
|
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
|
data/cinch-links-logger.gemspec
CHANGED
@@ -8,24 +8,20 @@ Gem::Specification.new do |gem|
|
|
8
8
|
gem.version = Cinch::Plugins::LinksLogger::VERSION
|
9
9
|
gem.authors = ['Brian Haberer']
|
10
10
|
gem.email = ['bhaberer@gmail.com']
|
11
|
-
gem.description = %q
|
12
|
-
gem.summary = %q
|
11
|
+
gem.description = %q(Cinch Plugin to track links in the channel)
|
12
|
+
gem.summary = %q(Cinch Plugin for links logging)
|
13
13
|
gem.homepage = 'https://github.com/bhaberer/cinch-links-logger'
|
14
14
|
gem.license = 'MIT'
|
15
|
-
|
16
15
|
gem.files = `git ls-files`.split($/)
|
17
|
-
gem.executables = gem.files.grep(
|
18
|
-
gem.test_files = gem.files.grep(
|
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
|
-
|
21
|
-
gem.add_development_dependency
|
22
|
-
gem.add_development_dependency
|
23
|
-
gem.add_development_dependency
|
24
|
-
gem.
|
25
|
-
|
26
|
-
gem.add_dependency
|
27
|
-
gem.add_dependency
|
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'
|
19
|
+
gem.add_development_dependency 'rake', '~> 10'
|
20
|
+
gem.add_development_dependency 'rspec', '~> 3'
|
21
|
+
gem.add_development_dependency 'coveralls', '~> 0.7'
|
22
|
+
gem.add_development_dependency 'cinch-test', '~> 0.1', '>= 0.1.1'
|
23
|
+
gem.add_dependency 'cinch', '~> 2'
|
24
|
+
gem.add_dependency 'cinch-cooldown', '~> 1.1', '>= 1.1.1'
|
25
|
+
gem.add_dependency 'cinch-storage', '~> 1.1'
|
26
|
+
gem.add_dependency 'cinch-toolbox', '~> 1.1'
|
31
27
|
end
|
@@ -4,60 +4,62 @@ require 'cinch'
|
|
4
4
|
require 'cinch/toolbox'
|
5
5
|
require 'cinch/storage'
|
6
6
|
|
7
|
-
module Cinch
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
7
|
+
module Cinch
|
8
|
+
module Plugins
|
9
|
+
# Cinch Plugin to track links
|
10
|
+
class LinksLogger
|
11
|
+
include Cinch::Plugin
|
12
|
+
attr_reader :storage
|
12
13
|
|
13
|
-
|
14
|
+
listen_to :channel
|
14
15
|
|
15
|
-
|
16
|
+
self.help = 'Use .links to see the last links posted to the channel.'
|
16
17
|
|
17
|
-
|
18
|
+
match(/links/)
|
18
19
|
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
20
|
+
def initialize(*args)
|
21
|
+
super
|
22
|
+
@storage = Cinch::Storage.new(config[:filename] || 'yaml/links.yaml')
|
23
|
+
@storage.data ||= {}
|
24
|
+
end
|
24
25
|
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
26
|
+
def execute(m)
|
27
|
+
return if Cinch::Toolbox.sent_via_private_message?(m)
|
28
|
+
get_recent_links(m.channel.name).each { |line| m.user.send line }
|
29
|
+
end
|
29
30
|
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
31
|
+
def listen(m)
|
32
|
+
urls = URI.extract(m.message, %w(http https))
|
33
|
+
urls.each do |url|
|
34
|
+
# Ensure we have a Channel Object in the History to dump links into.
|
35
|
+
@storage.data[m.channel.name] ||= Hash.new
|
36
|
+
@link = get_or_create_link(m, url)
|
37
|
+
end
|
36
38
|
end
|
37
|
-
end
|
38
39
|
|
39
|
-
|
40
|
+
private
|
40
41
|
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
42
|
+
def get_or_create_link(m, url)
|
43
|
+
channel = m.channel.name
|
44
|
+
# If the link was posted already, get the old info
|
45
|
+
@storage.data[channel][url] ||= Link.new(m.user.nick, url)
|
46
|
+
@storage.data[channel][url].inc_count
|
47
|
+
@storage.synced_save(@bot)
|
48
|
+
@storage.data[channel][url]
|
49
|
+
end
|
49
50
|
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
51
|
+
def get_recent_links(channel)
|
52
|
+
message = ["Recent Links in #{channel}"]
|
53
|
+
links = @storage.data[channel].values.reverse[0..9]
|
54
|
+
links.each_with_index do |link|
|
55
|
+
message << if link.title.nil?
|
56
|
+
Cinch::Toolbox.expand(link.short_url)
|
57
|
+
else
|
58
|
+
"#{link.short_url} - #{link.title}"
|
59
|
+
end
|
60
|
+
end
|
61
|
+
message
|
59
62
|
end
|
60
|
-
message
|
61
63
|
end
|
62
64
|
end
|
63
65
|
end
|
@@ -10,29 +10,29 @@ describe Cinch::Plugins::LinksLogger do
|
|
10
10
|
|
11
11
|
it 'should capture links' do
|
12
12
|
get_replies(make_message(@bot, 'http://github.com', { channel: '#foo', nick: 'bar' }))
|
13
|
-
@bot.plugins.first.storage.data['#foo'].keys.first
|
14
|
-
|
13
|
+
expect(@bot.plugins.first.storage.data['#foo'].keys.first)
|
14
|
+
.to eq('http://github.com')
|
15
15
|
end
|
16
16
|
|
17
17
|
it 'should capture links count' do
|
18
18
|
15.times { get_replies(make_message(@bot, 'http://github.com', { channel: '#foo' })) }
|
19
19
|
links = @bot.plugins.first.storage.data['#foo']
|
20
|
-
|
21
|
-
links.
|
22
|
-
links.values.first.count.should == 15
|
20
|
+
expect(links.length).to eq(1)
|
21
|
+
expect(links.values.first.count).to eq(15)
|
23
22
|
end
|
24
23
|
|
25
24
|
it 'should not capture malformed URLS' do
|
26
25
|
get_replies(make_message(@bot, 'htp://github.com', { channel: '#foo', nick: 'bar' }))
|
27
26
|
get_replies(make_message(@bot, 'http/github.com', { channel: '#foo', nick: 'bar' }))
|
28
|
-
@bot.plugins.first.storage.data['#foo']
|
29
|
-
|
27
|
+
expect(@bot.plugins.first.storage.data['#foo'])
|
28
|
+
.to be_nil
|
30
29
|
end
|
31
30
|
|
32
31
|
it 'should allow users to get a list of recently linked URLS' do
|
33
32
|
get_replies(make_message(@bot, 'http://github.com', { channel: '#foo', nick: 'bar' }))
|
34
33
|
replies = get_replies(make_message(@bot, '!links', { channel: '#foo', nick: 'test' }))
|
35
|
-
replies.first.text.
|
36
|
-
replies.last.text
|
34
|
+
expect(replies.first.text).to eq('Recent Links in #foo')
|
35
|
+
expect(replies.last.text)
|
36
|
+
.to eq('http://github.com - GitHub · Build software better, together.')
|
37
37
|
end
|
38
38
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1,4 +1,11 @@
|
|
1
1
|
require 'coveralls'
|
2
|
-
|
2
|
+
require 'simplecov'
|
3
|
+
|
4
|
+
SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[
|
5
|
+
SimpleCov::Formatter::HTMLFormatter,
|
6
|
+
Coveralls::SimpleCov::Formatter
|
7
|
+
]
|
8
|
+
SimpleCov.start
|
9
|
+
|
3
10
|
require 'cinch-links-logger'
|
4
11
|
require 'cinch/test'
|
metadata
CHANGED
@@ -1,160 +1,139 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cinch-links-logger
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
5
|
-
prerelease:
|
4
|
+
version: 1.0.3
|
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-
|
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: '
|
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: '
|
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: '
|
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: '
|
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:
|
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:
|
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
|
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
|
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
|
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
|
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.
|
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.
|
136
|
+
version: '1.1'
|
158
137
|
description: Cinch Plugin to track links in the channel
|
159
138
|
email:
|
160
139
|
- bhaberer@gmail.com
|
@@ -178,29 +157,27 @@ files:
|
|
178
157
|
homepage: https://github.com/bhaberer/cinch-links-logger
|
179
158
|
licenses:
|
180
159
|
- MIT
|
160
|
+
metadata: {}
|
181
161
|
post_install_message:
|
182
162
|
rdoc_options: []
|
183
163
|
require_paths:
|
184
164
|
- lib
|
185
165
|
required_ruby_version: !ruby/object:Gem::Requirement
|
186
|
-
none: false
|
187
166
|
requirements:
|
188
167
|
- - ! '>='
|
189
168
|
- !ruby/object:Gem::Version
|
190
169
|
version: '0'
|
191
170
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
192
|
-
none: false
|
193
171
|
requirements:
|
194
172
|
- - ! '>='
|
195
173
|
- !ruby/object:Gem::Version
|
196
174
|
version: '0'
|
197
175
|
requirements: []
|
198
176
|
rubyforge_project:
|
199
|
-
rubygems_version:
|
177
|
+
rubygems_version: 2.2.2
|
200
178
|
signing_key:
|
201
|
-
specification_version:
|
179
|
+
specification_version: 4
|
202
180
|
summary: Cinch Plugin for links logging
|
203
181
|
test_files:
|
204
182
|
- spec/cinch-links-logger_spec.rb
|
205
183
|
- spec/spec_helper.rb
|
206
|
-
has_rdoc:
|