ruby_loggly 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/.document ADDED
@@ -0,0 +1,5 @@
1
+ lib/**/*.rb
2
+ bin/*
3
+ -
4
+ features/**/*.feature
5
+ LICENSE.txt
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --color
data/Gemfile ADDED
@@ -0,0 +1,15 @@
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
+ gem "rcov", ">= 0"
15
+ 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
+ = ruby_loggly
2
+
3
+ Description goes here.
4
+
5
+ == Contributing to ruby_loggly
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
+
data/Rakefile ADDED
@@ -0,0 +1,50 @@
1
+ # encoding: utf-8
2
+
3
+ require 'rubygems'
4
+ require 'bundler'
5
+ begin
6
+ Bundler.setup(:default, :development)
7
+ rescue Bundler::BundlerError => e
8
+ $stderr.puts e.message
9
+ $stderr.puts "Run `bundle install` to install missing gems"
10
+ exit e.status_code
11
+ end
12
+ require 'rake'
13
+
14
+ require 'jeweler'
15
+ Jeweler::Tasks.new do |gem|
16
+ # gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
17
+ gem.name = "ruby_loggly"
18
+ gem.homepage = "http://github.com/mitchel456/ruby_loggly"
19
+ gem.license = "MIT"
20
+ gem.summary = "Simple Ruby interface to Loggly"
21
+ gem.description ="A simple Ruby interface to the Loggly API"
22
+ gem.email = "mitchellryanj@gmail.com"
23
+ gem.authors = ["Ryan Mitchell"]
24
+ gem.version = "0.0.1"
25
+ # dependencies defined in Gemfile
26
+ end
27
+ Jeweler::RubygemsDotOrgTasks.new
28
+
29
+ require 'rspec/core'
30
+ require 'rspec/core/rake_task'
31
+ RSpec::Core::RakeTask.new(:spec) do |spec|
32
+ spec.pattern = FileList['spec/**/*_spec.rb']
33
+ end
34
+
35
+ RSpec::Core::RakeTask.new(:rcov) do |spec|
36
+ spec.pattern = 'spec/**/*_spec.rb'
37
+ spec.rcov = true
38
+ end
39
+
40
+ task :default => :spec
41
+
42
+ require 'rake/rdoctask'
43
+ Rake::RDocTask.new do |rdoc|
44
+ version = File.exist?('VERSION') ? File.read('VERSION') : ""
45
+
46
+ rdoc.rdoc_dir = 'rdoc'
47
+ rdoc.title = "ruby_loggly #{version}"
48
+ rdoc.rdoc_files.include('README*')
49
+ rdoc.rdoc_files.include('lib/**/*.rb')
50
+ end
@@ -0,0 +1,20 @@
1
+ require 'rest_client'
2
+
3
+ class Loggly
4
+
5
+ def initialize(options)
6
+ @uri = options[:uri]
7
+ @user = options[:user]
8
+ @pass = options[:pass]
9
+ @key = options[:key]
10
+ end
11
+
12
+ def log(log_data)
13
+ RestClient.post("https://logs.loggly.com/inputs/#{@key}", log_data)
14
+ end
15
+
16
+ def search(query)
17
+ RestClient.get("https://#{@uri}/api/search", {:params => {:q => query}})
18
+ end
19
+
20
+ end
@@ -0,0 +1,55 @@
1
+ require 'spec_helper'
2
+
3
+ describe Loggly do
4
+
5
+ before(:all) do
6
+ @test_uri = 'example.loggly.com'
7
+ @test_user = 'user'
8
+ @test_pass = 'pass'
9
+ @test_key = '123456'
10
+ @loggly = Loggly.new(
11
+ :uri => @test_uri,
12
+ :user => @test_user,
13
+ :pass => @test_pass,
14
+ :key => @test_key
15
+ )
16
+ end
17
+
18
+ describe "#search" do
19
+
20
+ before(:each) do
21
+ RestClient.stub!(:get)
22
+ end
23
+
24
+ it "should generate an appropriate RestClient GET" do
25
+ search_string = "search string"
26
+ RestClient.should_receive(:get).with(@test_uri, {:params => {:q => search_string}})
27
+ @loggly.search("search string")
28
+ end
29
+ end
30
+
31
+ describe "#log" do
32
+
33
+ before(:each) do
34
+ RestClient.stub!(:post)
35
+ end
36
+
37
+ it "should generate an appropriate RestClient POST with a raw payload" do
38
+ log_string = "this is a test log"
39
+ RestClient.should_receive(:post).with(
40
+ "https://logs.loggly.com/inputs/%s" % @test_key,
41
+ log_string
42
+ )
43
+ @loggly.log(log_string)
44
+ end
45
+
46
+ it "should generate an appropriate RestClient POST with parameters" do
47
+ log_parameters = { :time => 123456, :type => 'foo', :logger => 'bar' }
48
+ RestClient.should_receive(:post).with(
49
+ "https://logs.loggly.com/inputs/%s" % @test_key,
50
+ log_parameters
51
+ )
52
+ @loggly.log(log_parameters)
53
+ end
54
+ end
55
+ end
@@ -0,0 +1,12 @@
1
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
2
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
3
+ require 'rspec'
4
+ require 'ruby_loggly'
5
+
6
+ # Requires supporting files with custom matchers and macros, etc,
7
+ # in ./support/ and its subdirectories.
8
+ Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
9
+
10
+ RSpec.configure do |config|
11
+
12
+ end
metadata ADDED
@@ -0,0 +1,114 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: ruby_loggly
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Ryan Mitchell
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2011-07-29 00:00:00.000000000Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: rest-client
16
+ requirement: &27576864 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: 1.6.3
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: *27576864
25
+ - !ruby/object:Gem::Dependency
26
+ name: rspec
27
+ requirement: &27576540 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ! '>'
31
+ - !ruby/object:Gem::Version
32
+ version: 2.3.0
33
+ type: :development
34
+ prerelease: false
35
+ version_requirements: *27576540
36
+ - !ruby/object:Gem::Dependency
37
+ name: bundler
38
+ requirement: &27576252 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ! '>'
42
+ - !ruby/object:Gem::Version
43
+ version: 1.0.0
44
+ type: :development
45
+ prerelease: false
46
+ version_requirements: *27576252
47
+ - !ruby/object:Gem::Dependency
48
+ name: jeweler
49
+ requirement: &27575952 !ruby/object:Gem::Requirement
50
+ none: false
51
+ requirements:
52
+ - - ! '>='
53
+ - !ruby/object:Gem::Version
54
+ version: 1.6.4
55
+ type: :development
56
+ prerelease: false
57
+ version_requirements: *27575952
58
+ - !ruby/object:Gem::Dependency
59
+ name: rcov
60
+ requirement: &27575664 !ruby/object:Gem::Requirement
61
+ none: false
62
+ requirements:
63
+ - - ! '>='
64
+ - !ruby/object:Gem::Version
65
+ version: '0'
66
+ type: :development
67
+ prerelease: false
68
+ version_requirements: *27575664
69
+ description: A simple Ruby interface to the Loggly API
70
+ email: mitchellryanj@gmail.com
71
+ executables: []
72
+ extensions: []
73
+ extra_rdoc_files:
74
+ - LICENSE.txt
75
+ - README.rdoc
76
+ files:
77
+ - .document
78
+ - .rspec
79
+ - Gemfile
80
+ - LICENSE.txt
81
+ - README.rdoc
82
+ - Rakefile
83
+ - lib/ruby_loggly.rb
84
+ - spec/ruby_loggly_spec.rb
85
+ - spec/spec_helper.rb
86
+ homepage: http://github.com/mitchel456/ruby_loggly
87
+ licenses:
88
+ - MIT
89
+ post_install_message:
90
+ rdoc_options: []
91
+ require_paths:
92
+ - lib
93
+ required_ruby_version: !ruby/object:Gem::Requirement
94
+ none: false
95
+ requirements:
96
+ - - ! '>='
97
+ - !ruby/object:Gem::Version
98
+ version: '0'
99
+ segments:
100
+ - 0
101
+ hash: -721368077
102
+ required_rubygems_version: !ruby/object:Gem::Requirement
103
+ none: false
104
+ requirements:
105
+ - - ! '>='
106
+ - !ruby/object:Gem::Version
107
+ version: '0'
108
+ requirements: []
109
+ rubyforge_project:
110
+ rubygems_version: 1.7.2
111
+ signing_key:
112
+ specification_version: 3
113
+ summary: Simple Ruby interface to Loggly
114
+ test_files: []