papertrail 0.9.1 → 0.9.2.pre1

Sign up to get free protection for your applications and to get access to all the features.
@@ -6,6 +6,11 @@ require 'papertrail/connection'
6
6
  module Papertrail
7
7
  class Cli
8
8
  def run
9
+ # Let it slide if we have invalid JSON
10
+ if JSON.respond_to?(:default_options)
11
+ JSON.default_options[:check_utf8] = false
12
+ end
13
+
9
14
  options = {
10
15
  :configfile => nil,
11
16
  :delay => 2,
@@ -57,10 +62,16 @@ module Papertrail
57
62
 
58
63
  if options[:system]
59
64
  query_options[:system_id] = connection.find_id_for_source(options[:system])
65
+ unless query_options[:system_id]
66
+ abort "System \"#{options[:system]}\" not found"
67
+ end
60
68
  end
61
69
 
62
70
  if options[:group]
63
71
  query_options[:group_id] = connection.find_id_for_group(options[:group])
72
+ unless query_options[:group_id]
73
+ abort "Group \"#{options[:group]}\" not found"
74
+ end
64
75
  end
65
76
 
66
77
  search_query = connection.query(ARGV[0], query_options)
@@ -42,21 +42,23 @@ module Papertrail
42
42
  def find_id_for_source(name)
43
43
  response = @connection.get('/api/v1/systems.json')
44
44
 
45
- response.body.each do |source|
46
- return source['id'] if source['name'] =~ /#{Regexp.escape(name)}/i
47
- end
48
-
49
- return nil
45
+ find_id_for_item(response.body, name)
50
46
  end
51
47
 
52
48
  def find_id_for_group(name)
53
49
  response = @connection.get('/api/v1/groups.json')
54
50
 
55
- response.body.each do |group|
56
- return group['id'] if group['name'] =~ /#{Regexp.escape(name)}/i
51
+ find_id_for_item(response.body, name)
52
+ end
53
+
54
+ def find_id_for_item(items, name_wanted)
55
+ items.each do |item|
56
+ return item['id'] if item['name'] == name_wanted
57
57
  end
58
58
 
59
- return nil
59
+ items.each do |item|
60
+ return item['id'] if item['name'] =~ /#{Regexp.escape(name_wanted)}/i
61
+ end
60
62
  end
61
63
 
62
64
  def query(query = nil, options = {})
data/lib/papertrail.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  module Papertrail
2
- VERSION = "0.9.1"
2
+ VERSION = "0.9.2.pre1"
3
3
  end
4
4
 
5
5
  require 'papertrail/search_client'
data/papertrail.gemspec CHANGED
@@ -13,8 +13,8 @@ Gem::Specification.new do |s|
13
13
  ## If your rubyforge_project name is different, then edit it and comment out
14
14
  ## the sub! line in the Rakefile
15
15
  s.name = 'papertrail'
16
- s.version = '0.9.1'
17
- s.date = '2012-03-12'
16
+ s.version = '0.9.2.pre1'
17
+ s.date = '2012-05-02'
18
18
  s.rubyforge_project = 'papertrail'
19
19
 
20
20
  ## Make sure your summary is short. The description may be as long
metadata CHANGED
@@ -1,12 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: papertrail
3
3
  version: !ruby/object:Gem::Version
4
- prerelease: false
4
+ prerelease: true
5
5
  segments:
6
6
  - 0
7
7
  - 9
8
+ - 2
9
+ - pre
8
10
  - 1
9
- version: 0.9.1
11
+ version: 0.9.2.pre1
10
12
  platform: ruby
11
13
  authors:
12
14
  - Papertrail
@@ -14,25 +16,23 @@ autorequire:
14
16
  bindir: bin
15
17
  cert_chain: []
16
18
 
17
- date: 2012-03-12 00:00:00 -07:00
19
+ date: 2012-05-02 00:00:00 -07:00
18
20
  default_executable: papertrail
19
21
  dependencies:
20
22
  - !ruby/object:Gem::Dependency
21
- name: yajl-ruby
22
- prerelease: false
23
- requirement: &id001 !ruby/object:Gem::Requirement
23
+ version_requirements: &id001 !ruby/object:Gem::Requirement
24
24
  requirements:
25
25
  - - ">="
26
26
  - !ruby/object:Gem::Version
27
27
  segments:
28
28
  - 0
29
29
  version: "0"
30
+ requirement: *id001
31
+ name: yajl-ruby
32
+ prerelease: false
30
33
  type: :runtime
31
- version_requirements: *id001
32
34
  - !ruby/object:Gem::Dependency
33
- name: faraday
34
- prerelease: false
35
- requirement: &id002 !ruby/object:Gem::Requirement
35
+ version_requirements: &id002 !ruby/object:Gem::Requirement
36
36
  requirements:
37
37
  - - ">="
38
38
  - !ruby/object:Gem::Version
@@ -46,12 +46,12 @@ dependencies:
46
46
  - 0
47
47
  - 9
48
48
  version: "0.9"
49
+ requirement: *id002
50
+ name: faraday
51
+ prerelease: false
49
52
  type: :runtime
50
- version_requirements: *id002
51
53
  - !ruby/object:Gem::Dependency
52
- name: faraday_middleware
53
- prerelease: false
54
- requirement: &id003 !ruby/object:Gem::Requirement
54
+ version_requirements: &id003 !ruby/object:Gem::Requirement
55
55
  requirements:
56
56
  - - ~>
57
57
  - !ruby/object:Gem::Version
@@ -60,8 +60,10 @@ dependencies:
60
60
  - 8
61
61
  - 4
62
62
  version: 0.8.4
63
+ requirement: *id003
64
+ name: faraday_middleware
65
+ prerelease: false
63
66
  type: :runtime
64
- version_requirements: *id003
65
67
  description: Command-line client for Papertrail hosted log management service. Tails and searches app server logs and system syslog. Supports Boolean search and works with grep and pipe output (Unix).
66
68
  email: troy@sevenscale.com
67
69
  executables:
@@ -102,11 +104,13 @@ required_ruby_version: !ruby/object:Gem::Requirement
102
104
  version: "0"
103
105
  required_rubygems_version: !ruby/object:Gem::Requirement
104
106
  requirements:
105
- - - ">="
107
+ - - ">"
106
108
  - !ruby/object:Gem::Version
107
109
  segments:
108
- - 0
109
- version: "0"
110
+ - 1
111
+ - 3
112
+ - 1
113
+ version: 1.3.1
110
114
  requirements: []
111
115
 
112
116
  rubyforge_project: papertrail