cinch-logsearch 1.0.0 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -4,18 +4,19 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
  require 'cinch/plugins/logsearch/version'
5
5
 
6
6
  Gem::Specification.new do |gem|
7
- gem.name = "cinch-logsearch"
7
+ gem.name = 'cinch-logsearch'
8
8
  gem.version = Cinch::Plugins::LogSearch::VERSION
9
- gem.authors = ["Brian Haberer"]
10
- gem.email = ["bhaberer@gmail.com"]
9
+ gem.authors = ['Brian Haberer']
10
+ gem.email = ['bhaberer@gmail.com']
11
11
  gem.description = %q{Cinch Plugin to search log files for users.}
12
12
  gem.summary = %q{Cinch Plugin for searching irc logs.}
13
- gem.homepage = "https://github.com/bhaberer/cinch-logsearch"
13
+ gem.homepage = 'https://github.com/bhaberer/cinch-logsearch'
14
+ gem.license = 'MIT'
14
15
 
15
16
  gem.files = `git ls-files`.split($/)
16
17
  gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
17
18
  gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
18
- gem.require_paths = ["lib"]
19
+ gem.require_paths = ['lib']
19
20
 
20
21
  gem.add_development_dependency 'rake'
21
22
  gem.add_development_dependency 'rspec'
@@ -1,2 +1,3 @@
1
+ # -*- encoding : utf-8 -*-
1
2
  require 'cinch/plugins/logsearch/version'
2
- require 'cinch/plugins/logsearch/logsearch'
3
+ require 'cinch/plugins/logsearch'
@@ -1,17 +1,21 @@
1
+ # -*- encoding : utf-8 -*-
1
2
  require 'cinch'
2
3
 
3
4
  module Cinch::Plugins
5
+ # CInch Plugin to search logs
4
6
  class LogSearch
5
7
  include Cinch::Plugin
6
8
 
7
- self.help = "Use .search <text> to search the logs. *Only works via private message*, limited to 5 results for now."
9
+ self.help = 'Use .search <text> to search the logs. *Only works via ' +
10
+ 'private message*, limited to 5 results for now.'
8
11
 
9
12
  match /search (.*)/, react_on: :private
10
13
 
11
14
  def initialize(*args)
12
15
  super
13
16
  @max_results = config[:max_results] || 5
14
- @log_directory = config[:logs_directory] || File.join('.', 'logs', '*.log')
17
+ @log_directory = config[:logs_directory] ||
18
+ File.join('.', 'logs', '*.log')
15
19
  end
16
20
 
17
21
  def execute(m, search)
@@ -20,15 +24,15 @@ module Cinch::Plugins
20
24
  matches = search_for(search)
21
25
 
22
26
  if matches.empty?
23
- m.user.msg "No matches found!"
24
- else
25
- msg = ['Found', matches.count, 'matches before giving up,',
26
- 'here\'s the most recent', @max_results]
27
- m.user.msg msg.join(' ')
28
- matches.reverse[0..(@max_results - 1)].reverse.each do |match|
29
- m.user.msg match
30
- end
27
+ m.user.msg 'No matches found!'
28
+ return
31
29
  end
30
+
31
+ msg = ['Found', matches.count, 'matches before giving up,',
32
+ 'here\'s the most recent', @max_results]
33
+
34
+ m.user.msg msg.join(' ')
35
+ matches.each { |match| m.user.msg match }
32
36
  end
33
37
 
34
38
  private
@@ -43,7 +47,8 @@ module Cinch::Plugins
43
47
  matches = []
44
48
 
45
49
  # Search the logs for the phrase, this is pretty simple and kind of dumb.
46
- # Probably make this smarter by using a real search algo at some point if people care.
50
+ # Probably make this smarter by using a real search algo at some point
51
+ # if people care.
47
52
  Dir[@log_directory].sort.reverse.each do |file|
48
53
  matches += File.open(file, 'r').grep(Regexp.new(search_term))
49
54
  # For the sake of sanity, stop looking once we find @max_results
@@ -51,7 +56,7 @@ module Cinch::Plugins
51
56
  end
52
57
 
53
58
  # I hate new lines.
54
- matches.map(&:chomp)
59
+ matches.map(&:chomp).reverse[0..(@max_results - 1)].reverse
55
60
  end
56
61
  end
57
62
  end
@@ -1,7 +1,9 @@
1
+ # -*- encoding : utf-8 -*-
1
2
  module Cinch
2
3
  module Plugins
4
+ # Version info
3
5
  class LogSearch
4
- VERSION = "1.0.0"
6
+ VERSION = '1.0.1'
5
7
  end
6
8
  end
7
9
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cinch-logsearch
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-08-21 00:00:00.000000000 Z
12
+ date: 2014-02-18 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rake
@@ -106,13 +106,14 @@ files:
106
106
  - Rakefile
107
107
  - cinch-logsearch.gemspec
108
108
  - lib/cinch-logsearch.rb
109
- - lib/cinch/plugins/logsearch/logsearch.rb
109
+ - lib/cinch/plugins/logsearch.rb
110
110
  - lib/cinch/plugins/logsearch/version.rb
111
111
  - spec/cinch-logsearch_spec.rb
112
112
  - spec/secret.rb
113
113
  - spec/spec_helper.rb
114
114
  homepage: https://github.com/bhaberer/cinch-logsearch
115
- licenses: []
115
+ licenses:
116
+ - MIT
116
117
  post_install_message:
117
118
  rdoc_options: []
118
119
  require_paths: