cloud-logger2 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: d74cbdd792d1d9a439fce7a2015515ea0fa7abba
4
+ data.tar.gz: 11b45dc691a968fd20d842fe77e94aefd75dbe5b
5
+ SHA512:
6
+ metadata.gz: 6f6d59e20918f0ca85ba395ef63eb298f71bc1c46f63ab38faa1914bc7feea223b55a6eaf07d37977b77ef4e905772735a043be3c2d91737f41b125c7b1cc863
7
+ data.tar.gz: 9eda548c46fd959c5b0a695cfb2ad492168908f7390ffb1370c418a36d6dbb31cbcc1b2047a44bc6b85d0ab24aaacedcfb024e83521edb2a7203b07535326822
data/Gemfile ADDED
@@ -0,0 +1,14 @@
1
+ source "http://rubygems.org"
2
+ # Add dependencies required to use your gem here.
3
+ # Example:
4
+ # gem "activesupport", ">= 2.3.5"
5
+
6
+ gem "rest-client", ">= 1.6.3"
7
+
8
+ # Add dependencies to develop your gem here.
9
+ # Include everything needed to run rake, tests, features, etc.
10
+ group :development do
11
+ gem "rspec", "> 2.3.0"
12
+ gem "bundler", "> 1.0.0"
13
+ gem "jeweler", ">= 1.6.4"
14
+ end
data/LICENSE.txt ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2011 Ryan Mitchell
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.rdoc ADDED
@@ -0,0 +1,19 @@
1
+ = cloud-logger
2
+
3
+ Description goes here.
4
+
5
+ == Contributing to cloud-logger
6
+
7
+ * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
8
+ * Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it
9
+ * Fork the project
10
+ * Start a feature/bugfix branch
11
+ * Commit and push until you are happy with your contribution
12
+ * Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
13
+ * Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
14
+
15
+ == Copyright
16
+
17
+ Copyright (c) 2011 Ryan Mitchell. See LICENSE.txt for
18
+ further details.
19
+
@@ -0,0 +1,59 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = "cloud-logger2"
8
+ s.version = "0.0.1"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Ryan Mitchell"]
12
+ s.date = "2011-09-22"
13
+ s.description = "A simple Ruby interface to the APIs of various cloud logging services"
14
+ s.email = "mitchellryanj@gmail.com"
15
+ s.extra_rdoc_files = [
16
+ "LICENSE.txt",
17
+ "README.rdoc"
18
+ ]
19
+ s.files = [
20
+ "Gemfile",
21
+ "LICENSE.txt",
22
+ "README.rdoc",
23
+ "cloud-logger2.gemspec",
24
+ "lib/base.rb",
25
+ "lib/cloud-logger2.rb",
26
+ "lib/event.rb",
27
+ "lib/loggly.rb",
28
+ ]
29
+ s.homepage = "http://github.com/ryan-mitchell/cloud-logger"
30
+ s.licenses = ["MIT"]
31
+ s.require_paths = ["lib"]
32
+ s.rubygems_version = "1.8.10"
33
+ s.summary = "Simple Ruby interface to cloud logging services such as Loggly and Papertrail"
34
+
35
+ if s.respond_to? :specification_version then
36
+ s.specification_version = 3
37
+
38
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
39
+ s.add_runtime_dependency(%q<rest-client>, [">= 1.6.3"])
40
+ s.add_development_dependency(%q<rspec>, ["> 2.3.0"])
41
+ s.add_development_dependency(%q<bundler>, ["> 1.0.0"])
42
+ s.add_development_dependency(%q<jeweler>, [">= 1.6.4"])
43
+ s.add_development_dependency(%q<rcov>, [">= 0"])
44
+ else
45
+ s.add_dependency(%q<rest-client>, [">= 1.6.3"])
46
+ s.add_dependency(%q<rspec>, ["> 2.3.0"])
47
+ s.add_dependency(%q<bundler>, ["> 1.0.0"])
48
+ s.add_dependency(%q<jeweler>, [">= 1.6.4"])
49
+ s.add_dependency(%q<rcov>, [">= 0"])
50
+ end
51
+ else
52
+ s.add_dependency(%q<rest-client>, [">= 1.6.3"])
53
+ s.add_dependency(%q<rspec>, ["> 2.3.0"])
54
+ s.add_dependency(%q<bundler>, ["> 1.0.0"])
55
+ s.add_dependency(%q<jeweler>, [">= 1.6.4"])
56
+ s.add_dependency(%q<rcov>, [">= 0"])
57
+ end
58
+ end
59
+
data/lib/base.rb ADDED
@@ -0,0 +1,5 @@
1
+ module CloudLogger2
2
+
3
+ class Base
4
+ end
5
+ end
@@ -0,0 +1,4 @@
1
+ require 'rest_client'
2
+ require 'base'
3
+ require 'event'
4
+ require 'loggly'
data/lib/event.rb ADDED
@@ -0,0 +1,21 @@
1
+ require 'date'
2
+
3
+ module CloudLogger2
4
+
5
+ class Event
6
+
7
+ attr_accessor :timestamp, :text
8
+
9
+ def initialize(text, timestamp)
10
+ @text = text
11
+
12
+ if timestamp.instance_of? DateTime
13
+ @timestamp = timestamp
14
+ elsif timestamp.instance_of? Fixnum
15
+ @timestamp = DateTime.new(timestamp)
16
+ else
17
+ @timestamp = DateTime.parse(timestamp.to_s)
18
+ end
19
+ end
20
+ end
21
+ end
data/lib/loggly.rb ADDED
@@ -0,0 +1,30 @@
1
+ module Cloudlogger2
2
+
3
+ class Loggly < Base
4
+
5
+ # a json object with a data property which is an array with zero or more elements
6
+ #ResponseMatcher = /\{\s*"data": \[\s*(\{.*?\})*\s*\]/m
7
+
8
+ def initialize(options)
9
+ @subdomain = options[:subdomain]
10
+ @user = options[:user]
11
+ @pass = options[:pass]
12
+ @key = options[:key]
13
+ @ec2 = options[:ec2] ||= false
14
+ end
15
+
16
+ def log(log_data)
17
+ ec2flag = @ec2 ? 'ec2.' : ''
18
+ RestClient.post("https://#{ec2flag}logs-01.loggly.com/inputs/#{@key}", log_data)
19
+ end
20
+
21
+ def search(query)
22
+ raw_response = RestClient.get("https://#{@user}:#{@pass}@#{@subdomain}.loggly.com/apiv2/search", {:params => {:q => query}})
23
+ result = JSON.parse(raw_response)['data'].map do |log_entry|
24
+ Cloudlogger2::Event.new(log_entry['text'], log_entry['timestamp'])
25
+ end
26
+ yield result if block_given?
27
+ result
28
+ end
29
+ end
30
+ end
metadata ADDED
@@ -0,0 +1,123 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: cloud-logger2
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Ryan Mitchell
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2011-09-22 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rest-client
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: 1.6.3
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: 1.6.3
27
+ - !ruby/object:Gem::Dependency
28
+ name: rspec
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">"
32
+ - !ruby/object:Gem::Version
33
+ version: 2.3.0
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">"
39
+ - !ruby/object:Gem::Version
40
+ version: 2.3.0
41
+ - !ruby/object:Gem::Dependency
42
+ name: bundler
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">"
46
+ - !ruby/object:Gem::Version
47
+ version: 1.0.0
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">"
53
+ - !ruby/object:Gem::Version
54
+ version: 1.0.0
55
+ - !ruby/object:Gem::Dependency
56
+ name: jeweler
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: 1.6.4
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: 1.6.4
69
+ - !ruby/object:Gem::Dependency
70
+ name: rcov
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ description: A simple Ruby interface to the APIs of various cloud logging services
84
+ email: mitchellryanj@gmail.com
85
+ executables: []
86
+ extensions: []
87
+ extra_rdoc_files:
88
+ - LICENSE.txt
89
+ - README.rdoc
90
+ files:
91
+ - Gemfile
92
+ - LICENSE.txt
93
+ - README.rdoc
94
+ - cloud-logger2.gemspec
95
+ - lib/base.rb
96
+ - lib/cloud-logger2.rb
97
+ - lib/event.rb
98
+ - lib/loggly.rb
99
+ homepage: http://github.com/ryan-mitchell/cloud-logger
100
+ licenses:
101
+ - MIT
102
+ metadata: {}
103
+ post_install_message:
104
+ rdoc_options: []
105
+ require_paths:
106
+ - lib
107
+ required_ruby_version: !ruby/object:Gem::Requirement
108
+ requirements:
109
+ - - ">="
110
+ - !ruby/object:Gem::Version
111
+ version: '0'
112
+ required_rubygems_version: !ruby/object:Gem::Requirement
113
+ requirements:
114
+ - - ">="
115
+ - !ruby/object:Gem::Version
116
+ version: '0'
117
+ requirements: []
118
+ rubyforge_project:
119
+ rubygems_version: 2.0.14
120
+ signing_key:
121
+ specification_version: 3
122
+ summary: Simple Ruby interface to cloud logging services such as Loggly and Papertrail
123
+ test_files: []