cinch-logsearch 1.0.1 → 1.0.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: 539f25b720fc7069294eb3dc6441813c2163425b
4
+ data.tar.gz: f43efe6302319444492fd2220a49abc3c6a061d0
5
+ SHA512:
6
+ metadata.gz: dec9b6b89c3e5e3f45e07965a389ad32d9af8e34f65822b57c5b107172aff00690502b594e47a062279db0dbffdc54f487ad8b16786873b7824f56ec4535855d
7
+ data.tar.gz: 088dd753b61637807274b05b2020d25cd7edd63da736943356c5455a6b1cec464af37db463281aad663ddf1002e3a237f99c2d83cc416d2c43641d8473d30302
@@ -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,20 +8,18 @@ Gem::Specification.new do |gem|
8
8
  gem.version = Cinch::Plugins::LogSearch::VERSION
9
9
  gem.authors = ['Brian Haberer']
10
10
  gem.email = ['bhaberer@gmail.com']
11
- gem.description = %q{Cinch Plugin to search log files for users.}
12
- gem.summary = %q{Cinch Plugin for searching irc logs.}
11
+ gem.description = %q(Cinch Plugin to search log files for users.)
12
+ gem.summary = %q(Cinch Plugin for searching irc logs.)
13
13
  gem.homepage = 'https://github.com/bhaberer/cinch-logsearch'
14
14
  gem.license = 'MIT'
15
-
16
15
  gem.files = `git ls-files`.split($/)
17
- gem.executables = gem.files.grep(%r{^bin/}).map{ |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.0'
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.0'
24
+ gem.add_dependency 'cinch', '~> 2'
27
25
  end
@@ -1,62 +1,64 @@
1
1
  # -*- encoding : utf-8 -*-
2
2
  require 'cinch'
3
3
 
4
- module Cinch::Plugins
5
- # CInch Plugin to search logs
6
- class LogSearch
7
- include Cinch::Plugin
4
+ module Cinch
5
+ module Plugins
6
+ # CInch Plugin to search logs
7
+ class LogSearch
8
+ include Cinch::Plugin
8
9
 
9
- self.help = 'Use .search <text> to search the logs. *Only works via ' +
10
- 'private message*, limited to 5 results for now.'
10
+ self.help = 'Use .search <text> to search the logs. *Only works via ' \
11
+ 'private message*, limited to 5 results for now.'
11
12
 
12
- match /search (.*)/, react_on: :private
13
+ match(/search (.*)/, react_on: :private)
13
14
 
14
- def initialize(*args)
15
- super
16
- @max_results = config[:max_results] || 5
17
- @log_directory = config[:logs_directory] ||
18
- File.join('.', 'logs', '*.log')
19
- end
15
+ def initialize(*args)
16
+ super
17
+ @max_results = config[:max_results] || 5
18
+ @log_directory = config[:logs_directory] ||
19
+ File.join('.', 'logs', '*.log')
20
+ end
20
21
 
21
- def execute(m, search)
22
- return unless log_files_exist?
22
+ def execute(m, search)
23
+ return unless log_files_exist?
23
24
 
24
- matches = search_for(search)
25
+ matches = search_for(search)
25
26
 
26
- if matches.empty?
27
- m.user.msg 'No matches found!'
28
- return
29
- end
27
+ if matches.empty?
28
+ m.user.msg 'No matches found!'
29
+ return
30
+ end
30
31
 
31
- msg = ['Found', matches.count, 'matches before giving up,',
32
- 'here\'s the most recent', @max_results]
32
+ msg = ['Found', matches.count, 'matches before giving up,',
33
+ 'here\'s the most recent', @max_results]
33
34
 
34
- m.user.msg msg.join(' ')
35
- matches.each { |match| m.user.msg match }
36
- end
35
+ m.user.msg msg.join(' ')
36
+ matches.each { |match| m.user.msg match }
37
+ end
37
38
 
38
- private
39
+ private
39
40
 
40
- def log_files_exist?
41
- return true if File.exist?(@log_directory)
42
- debug 'Log files not found!'
43
- false
44
- end
41
+ def log_files_exist?
42
+ return true if File.exist?(@log_directory)
43
+ debug 'Log files not found!'
44
+ false
45
+ end
45
46
 
46
- def search_for(search_term)
47
- matches = []
47
+ def search_for(search_term)
48
+ matches = []
48
49
 
49
- # Search the logs for the phrase, this is pretty simple and kind of dumb.
50
- # Probably make this smarter by using a real search algo at some point
51
- # if people care.
52
- Dir[@log_directory].sort.reverse.each do |file|
53
- matches += File.open(file, 'r').grep(Regexp.new(search_term))
54
- # For the sake of sanity, stop looking once we find @max_results
55
- break if matches.length > @max_results
56
- end
50
+ # Search the logs for the phrase, this is pretty simple and kind of
51
+ # dumb. I should probably make this smarter by using a real search
52
+ # algo at some point, if people care.
53
+ Dir[@log_directory].sort.reverse.each do |file|
54
+ matches += File.open(file, 'r').grep(Regexp.new(search_term))
55
+ # For the sake of sanity, stop looking once we find @max_results
56
+ break if matches.length > @max_results
57
+ end
57
58
 
58
- # I hate new lines.
59
- matches.map(&:chomp).reverse[0..(@max_results - 1)].reverse
59
+ # I hate new lines.
60
+ matches.map(&:chomp).reverse[0..(@max_results - 1)].reverse
61
+ end
60
62
  end
61
63
  end
62
64
  end
@@ -3,7 +3,7 @@ module Cinch
3
3
  module Plugins
4
4
  # Version info
5
5
  class LogSearch
6
- VERSION = '1.0.1'
6
+ VERSION = '1.0.2'
7
7
  end
8
8
  end
9
9
  end
@@ -1,7 +1,7 @@
1
1
  # -*- coding: utf-8 -*-
2
2
  require 'spec_helper'
3
3
 
4
- LOG = File.join('/tmp', 'cinch-testing.log')
4
+ LOG = File.join('/tmp', 'cinch-testing.log')
5
5
 
6
6
  describe Cinch::Plugins::LogSearch do
7
7
  include Cinch::Test
@@ -12,28 +12,30 @@ describe Cinch::Plugins::LogSearch do
12
12
  end
13
13
 
14
14
  it 'should not find anything if no logs are present' do
15
- get_replies(make_message(@bot, '!search foo'), :private).
16
- first.text.should == "No matches found!"
15
+ msg = get_replies(make_message(@bot, '!search foo'), :private).first
16
+ expect(msg.text).to eq('No matches found!')
17
17
  end
18
18
 
19
19
  it 'should not return any response when users search in channel' do
20
- get_replies(make_message(@bot, '!search foo'), :channel).
21
- should be_empty
20
+ expect(get_replies(make_message(@bot, '!search foo', { channel: '#foo' })))
21
+ .to be_empty
22
22
  end
23
23
 
24
24
  it 'should let users search log files' do
25
- get_replies(make_message(@bot, '!search movie'), :private).
26
- first.text.should == "Found 1 matches before giving up, here's the most recent 5"
25
+ msg = get_replies(make_message(@bot, '!search movie'), :private).first
26
+ expect(msg.text)
27
+ .to eq('Found 1 matches before giving up, here\'s the most recent 5')
27
28
  end
28
29
 
29
- it 'should allow users to do complex searches' do
30
- get_replies(make_message(@bot, '!search \sw.+\s'), :private).
31
- first.text.should == "Found 3 matches before giving up, here's the most recent 5"
30
+ it 'should allow users to do complex searches' do
31
+ msg = get_replies(make_message(@bot, '!search \sw.+\s'), :private).first
32
+ expect(msg.text)
33
+ .to eq('Found 3 matches before giving up, here\'s the most recent 5')
32
34
  end
33
35
  end
34
36
 
35
- def build_logs
36
- log = <<" EOF"
37
+ def build_logs
38
+ log = <<" EOF"
37
39
  [2012-07-24 23:09:15] <Carnivor> Oh. Good. You timed out.
38
40
  [2012-07-24 23:09:20] <feen> no
39
41
  [2012-07-24 23:09:22] <feen> i got back home
@@ -54,7 +56,7 @@ def build_logs
54
56
  [2012-07-24 23:10:51] <feen> ten thousand times
55
57
  [2012-07-24 23:11:27] <silveridea> well im going to attempt sleep
56
58
  EOF
57
- File.open(LOG, 'w') do |file|
59
+ File.open(LOG, 'w') do |file|
58
60
  file.write(log)
59
61
  end
60
62
  end
metadata CHANGED
@@ -1,96 +1,91 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cinch-logsearch
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-18 00:00:00.000000000 Z
11
+ date: 2014-08-01 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.0
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.0
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.0
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.0
88
+ version: '2'
94
89
  description: Cinch Plugin to search log files for users.
95
90
  email:
96
91
  - bhaberer@gmail.com
@@ -109,35 +104,31 @@ files:
109
104
  - lib/cinch/plugins/logsearch.rb
110
105
  - lib/cinch/plugins/logsearch/version.rb
111
106
  - spec/cinch-logsearch_spec.rb
112
- - spec/secret.rb
113
107
  - spec/spec_helper.rb
114
108
  homepage: https://github.com/bhaberer/cinch-logsearch
115
109
  licenses:
116
110
  - MIT
111
+ metadata: {}
117
112
  post_install_message:
118
113
  rdoc_options: []
119
114
  require_paths:
120
115
  - lib
121
116
  required_ruby_version: !ruby/object:Gem::Requirement
122
- none: false
123
117
  requirements:
124
118
  - - ! '>='
125
119
  - !ruby/object:Gem::Version
126
120
  version: '0'
127
121
  required_rubygems_version: !ruby/object:Gem::Requirement
128
- none: false
129
122
  requirements:
130
123
  - - ! '>='
131
124
  - !ruby/object:Gem::Version
132
125
  version: '0'
133
126
  requirements: []
134
127
  rubyforge_project:
135
- rubygems_version: 1.8.25
128
+ rubygems_version: 2.2.2
136
129
  signing_key:
137
- specification_version: 3
130
+ specification_version: 4
138
131
  summary: Cinch Plugin for searching irc logs.
139
132
  test_files:
140
133
  - spec/cinch-logsearch_spec.rb
141
- - spec/secret.rb
142
134
  - spec/spec_helper.rb
143
- has_rdoc:
@@ -1,4 +0,0 @@
1
- ENV['CONSUMER_KEY'] = 'JX9aDzSNnzK2eZnUBVe5OQ'
2
- ENV['CONSUMER_SECRET'] = 'H6J1yHlWbScTE0qCPnOQcatFFypHSYYy6oC6B5ogflU'
3
- ENV['OAUTH_TOKEN'] = '1028981-26j3aDmrJKWUmfNjUHiF5tfaC64go551zk9fVHxtuk'
4
- ENV['OAUTH_SECRET'] = 'fBooPZxuJHBLulw5IXAudIn61NFAD5sgCYxfOKnfI'