logplex-client 0.1.4
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.
- data/.gitignore +4 -0
- data/Gemfile +13 -0
- data/Makefile +34 -0
- data/README.md +117 -0
- data/bin/logplex +12 -0
- data/lib/logplex/channel.rb +144 -0
- data/lib/logplex/client/backends/http.rb +192 -0
- data/lib/logplex/client/cli.rb +219 -0
- data/lib/logplex/client/version.rb +6 -0
- data/lib/logplex/client.rb +80 -0
- data/lib/logplex/drain.rb +45 -0
- data/lib/logplex/emitter.rb +79 -0
- data/lib/logplex/event.rb +8 -0
- data/lib/logplex/namespace.rb +8 -0
- data/lib/logplex/session.rb +72 -0
- data/lib/logplex/token.rb +42 -0
- data/logplex-client.gemspec +30 -0
- data/spec/documentation_spec.rb +41 -0
- data/spec/logplex/channel_spec.rb +79 -0
- data/spec/logplex/client_spec.rb +40 -0
- data/spec/logplex/session_spec.rb +32 -0
- data/spec/spec_setup.rb +2 -0
- metadata +140 -0
@@ -0,0 +1,79 @@
|
|
1
|
+
require "spec_setup"
|
2
|
+
|
3
|
+
# https://github.com/heroku/logplex/issues/12
|
4
|
+
LOGPLEX_BUG_12_FIXED = false
|
5
|
+
|
6
|
+
describe Logplex::Channel do
|
7
|
+
before :each do
|
8
|
+
@client = Logplex::Client.new(ENV["LOGPLEX_URL"])
|
9
|
+
@channel = @client.create_channel("somename")
|
10
|
+
end
|
11
|
+
|
12
|
+
after(:each) do
|
13
|
+
@channel.destroy unless @skip_channel_destroy
|
14
|
+
end
|
15
|
+
|
16
|
+
context "#create_drain", :if => LOGPLEX_BUG_12_FIXED do
|
17
|
+
before(:each) { @drain = @channel.create_drain }
|
18
|
+
after(:each) { @drain.destroy }
|
19
|
+
|
20
|
+
it "should return a Logplex::Drain" do
|
21
|
+
insist { @drain }.is_a?(Logplex::Drain)
|
22
|
+
end
|
23
|
+
|
24
|
+
it "should create a drain without any drain url" do
|
25
|
+
insist { @drain.drain_url }.nil?
|
26
|
+
end
|
27
|
+
end # create_drain
|
28
|
+
|
29
|
+
context "#create_drain(url)" do
|
30
|
+
let(:url) { ENV["DRAIN_URL"] }
|
31
|
+
before(:each) { @drain = @channel.create_drain(url) }
|
32
|
+
after(:each) { @drain.destroy }
|
33
|
+
|
34
|
+
it "should return a Logplex::Drain" do
|
35
|
+
insist { @drain }.is_a?(Logplex::Drain)
|
36
|
+
end
|
37
|
+
|
38
|
+
it "should create a drain" do
|
39
|
+
insist { @drain.drain_url } == url
|
40
|
+
end
|
41
|
+
end # create_drain
|
42
|
+
|
43
|
+
context "#create_session" do
|
44
|
+
before(:each) { @session = @channel.create_session }
|
45
|
+
# There is no 'destroy a session', so no 'after' hook here.
|
46
|
+
|
47
|
+
it "should return a Logplex::Session" do
|
48
|
+
insist { @session }.is_a?(Logplex::Session)
|
49
|
+
end
|
50
|
+
end # create_session
|
51
|
+
|
52
|
+
context "#create_token" do
|
53
|
+
it "should return a Logplex::Token" do
|
54
|
+
token = @channel.create_token("example")
|
55
|
+
insist { token }.is_a?(Logplex::Token)
|
56
|
+
end
|
57
|
+
end # create_token
|
58
|
+
|
59
|
+
context "#destroy" do
|
60
|
+
it "should destroy the channel" do
|
61
|
+
id = @channel.id
|
62
|
+
@channel.destroy
|
63
|
+
insist { @client.channel(id) }.raises(Logplex::Client::Backends::HTTP::NotFound)
|
64
|
+
@skip_channel_destroy = true
|
65
|
+
end
|
66
|
+
end # destroy
|
67
|
+
|
68
|
+
context "#drains" do
|
69
|
+
it "should return an array" do
|
70
|
+
insist { @channel.drains }.is_a?(Array)
|
71
|
+
end
|
72
|
+
end # drains
|
73
|
+
|
74
|
+
context "#tokens" do
|
75
|
+
it "should return an array" do
|
76
|
+
insist { @channel.drains }.is_a?(Array)
|
77
|
+
end
|
78
|
+
end # tokens
|
79
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
require "spec_setup"
|
2
|
+
|
3
|
+
fail("Missing LOGPLEX_URL in env") if !ENV.has_key?("LOGPLEX_URL")
|
4
|
+
describe Logplex::Client do
|
5
|
+
subject { Logplex::Client.new(ENV["LOGPLEX_URL"]) }
|
6
|
+
|
7
|
+
context "#create_channel" do
|
8
|
+
it "should create a channel and return a Logplex::Channel" do
|
9
|
+
result = subject.create_channel("somename")
|
10
|
+
insist { result }.is_a?(Logplex::Channel)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
context "#channel" do
|
15
|
+
context "with an invalid channel id" do
|
16
|
+
it "should fail" do
|
17
|
+
expected = Logplex::Client::Backends::HTTP::NotFound
|
18
|
+
# Channel 0 should never exist, right?
|
19
|
+
insist { subject.channel(0) }.raises(expected)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
context "with a valid channel id" do
|
24
|
+
before do
|
25
|
+
@expected = subject.create_channel("somename")
|
26
|
+
end
|
27
|
+
|
28
|
+
after do
|
29
|
+
@expected.destroy
|
30
|
+
end
|
31
|
+
|
32
|
+
it "should return a Logplex::Channel with the correct data" do
|
33
|
+
actual = subject.channel(@expected.id)
|
34
|
+
insist { actual.id } == @expected.id
|
35
|
+
insist { actual.drains }.empty?
|
36
|
+
insist { actual.tokens }.empty?
|
37
|
+
end
|
38
|
+
end # with a valid channel id
|
39
|
+
end # channel
|
40
|
+
end # Logplex::Client
|
@@ -0,0 +1,32 @@
|
|
1
|
+
require "spec_setup"
|
2
|
+
|
3
|
+
describe Logplex::Session do
|
4
|
+
before :each do
|
5
|
+
@client = Logplex::Client.new(ENV["LOGPLEX_URL"])
|
6
|
+
@channel = @client.create_channel("somename")
|
7
|
+
end
|
8
|
+
|
9
|
+
after(:each) do
|
10
|
+
@channel.destroy unless @skip_channel_destroy
|
11
|
+
end
|
12
|
+
|
13
|
+
context "#each_event" do
|
14
|
+
before(:each) do
|
15
|
+
@session = @channel.create_session(:tail => true, :num => 0)
|
16
|
+
@emitter = @channel.create_token("example").emitter
|
17
|
+
end
|
18
|
+
|
19
|
+
# There is no 'destroy a session', so no 'after' hook here.
|
20
|
+
|
21
|
+
# No specs here because it's too hard to test right now.
|
22
|
+
# With 'right now' being May 2012, where logplex is syslog
|
23
|
+
# input is firewalled requiring presense on the heroku platform
|
24
|
+
# Thus, iteration on tests is slow (due to the long cycle of 'git push
|
25
|
+
# heroku, heroku run rspec, etc').
|
26
|
+
#
|
27
|
+
# Based on discussions with Jake Vorreuter, priority on these
|
28
|
+
# tests is pretty low and given the high cost (above) of building these
|
29
|
+
# tests, I'm tabling futher development of these specs until
|
30
|
+
# logplex is more accessible remotely.
|
31
|
+
end # each_event
|
32
|
+
end
|
data/spec/spec_setup.rb
ADDED
metadata
ADDED
@@ -0,0 +1,140 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: logplex-client
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.4
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Jacob Vorreuter
|
9
|
+
- Jordan Sissel
|
10
|
+
autorequire:
|
11
|
+
bindir: bin
|
12
|
+
cert_chain: []
|
13
|
+
date: 2013-04-01 00:00:00.000000000 Z
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: clamp
|
17
|
+
requirement: !ruby/object:Gem::Requirement
|
18
|
+
none: false
|
19
|
+
requirements:
|
20
|
+
- - ~>
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: 0.4.0
|
23
|
+
type: :runtime
|
24
|
+
prerelease: false
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
26
|
+
none: false
|
27
|
+
requirements:
|
28
|
+
- - ~>
|
29
|
+
- !ruby/object:Gem::Version
|
30
|
+
version: 0.4.0
|
31
|
+
- !ruby/object:Gem::Dependency
|
32
|
+
name: multi_json
|
33
|
+
requirement: !ruby/object:Gem::Requirement
|
34
|
+
none: false
|
35
|
+
requirements:
|
36
|
+
- - ! '>='
|
37
|
+
- !ruby/object:Gem::Version
|
38
|
+
version: '0'
|
39
|
+
type: :runtime
|
40
|
+
prerelease: false
|
41
|
+
version_requirements: !ruby/object:Gem::Requirement
|
42
|
+
none: false
|
43
|
+
requirements:
|
44
|
+
- - ! '>='
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: '0'
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: excon
|
49
|
+
requirement: !ruby/object:Gem::Requirement
|
50
|
+
none: false
|
51
|
+
requirements:
|
52
|
+
- - ~>
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 0.20.1
|
55
|
+
type: :runtime
|
56
|
+
prerelease: false
|
57
|
+
version_requirements: !ruby/object:Gem::Requirement
|
58
|
+
none: false
|
59
|
+
requirements:
|
60
|
+
- - ~>
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: 0.20.1
|
63
|
+
- !ruby/object:Gem::Dependency
|
64
|
+
name: rest-client
|
65
|
+
requirement: !ruby/object:Gem::Requirement
|
66
|
+
none: false
|
67
|
+
requirements:
|
68
|
+
- - ! '>='
|
69
|
+
- !ruby/object:Gem::Version
|
70
|
+
version: '0'
|
71
|
+
type: :runtime
|
72
|
+
prerelease: false
|
73
|
+
version_requirements: !ruby/object:Gem::Requirement
|
74
|
+
none: false
|
75
|
+
requirements:
|
76
|
+
- - ! '>='
|
77
|
+
- !ruby/object:Gem::Version
|
78
|
+
version: '0'
|
79
|
+
description: A client and library for Logplex
|
80
|
+
email:
|
81
|
+
- jacob.vorreuter@gmail.com
|
82
|
+
- jls@heroku.com
|
83
|
+
executables:
|
84
|
+
- logplex
|
85
|
+
extensions: []
|
86
|
+
extra_rdoc_files: []
|
87
|
+
files:
|
88
|
+
- .gitignore
|
89
|
+
- Gemfile
|
90
|
+
- Makefile
|
91
|
+
- README.md
|
92
|
+
- bin/logplex
|
93
|
+
- lib/logplex/channel.rb
|
94
|
+
- lib/logplex/client.rb
|
95
|
+
- lib/logplex/client/backends/http.rb
|
96
|
+
- lib/logplex/client/cli.rb
|
97
|
+
- lib/logplex/client/version.rb
|
98
|
+
- lib/logplex/drain.rb
|
99
|
+
- lib/logplex/emitter.rb
|
100
|
+
- lib/logplex/event.rb
|
101
|
+
- lib/logplex/namespace.rb
|
102
|
+
- lib/logplex/session.rb
|
103
|
+
- lib/logplex/token.rb
|
104
|
+
- logplex-client.gemspec
|
105
|
+
- spec/documentation_spec.rb
|
106
|
+
- spec/logplex/channel_spec.rb
|
107
|
+
- spec/logplex/client_spec.rb
|
108
|
+
- spec/logplex/session_spec.rb
|
109
|
+
- spec/spec_setup.rb
|
110
|
+
homepage: https://github.com/heroku/logplex-client
|
111
|
+
licenses: []
|
112
|
+
post_install_message:
|
113
|
+
rdoc_options: []
|
114
|
+
require_paths:
|
115
|
+
- lib
|
116
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
117
|
+
none: false
|
118
|
+
requirements:
|
119
|
+
- - ! '>='
|
120
|
+
- !ruby/object:Gem::Version
|
121
|
+
version: '0'
|
122
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
123
|
+
none: false
|
124
|
+
requirements:
|
125
|
+
- - ! '>='
|
126
|
+
- !ruby/object:Gem::Version
|
127
|
+
version: '0'
|
128
|
+
requirements: []
|
129
|
+
rubyforge_project:
|
130
|
+
rubygems_version: 1.8.23
|
131
|
+
signing_key:
|
132
|
+
specification_version: 3
|
133
|
+
summary: A client and library for Logplex
|
134
|
+
test_files:
|
135
|
+
- spec/documentation_spec.rb
|
136
|
+
- spec/logplex/channel_spec.rb
|
137
|
+
- spec/logplex/client_spec.rb
|
138
|
+
- spec/logplex/session_spec.rb
|
139
|
+
- spec/spec_setup.rb
|
140
|
+
has_rdoc:
|