md-logstasher 1.0.0.rc2 → 1.0.0.rc3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e7689c23aa5cceb9e620c8e9aa7c71b6cb50ebdd
4
- data.tar.gz: 3a7bdb19c004aa5576190e8b18371e8b7572b994
3
+ metadata.gz: de357b73d80ace9f66dec3772501f39485116454
4
+ data.tar.gz: abdf933ca237337395477d5374631b2bceb11571
5
5
  SHA512:
6
- metadata.gz: 86509444bd96c957f46c7bcb1ed1b88f1709bacc517289d28c7b4a1f43b0b68b037e855c7005624b113927ec85738ae6db02e34558639c7bb9e94e2961e66d08
7
- data.tar.gz: d0718d43f766f1c8ede6d92f15b23d1ffb9b708bf5b02a3544bf8dfb8061b4635339078fd594acc2c8243439e8c99046712130171df8ea851e6f2aee096cc986
6
+ metadata.gz: 633cb72fb229d8a8423ef2a7dc7b89e96d6420d406a94992e6d303fd73f068b66cbf8554c30fe6970921183c0b8a26719344bcf24f6d93b7a69b77c5766f86dd
7
+ data.tar.gz: 80bde9a5868c345cf24487cf15e2323f34884daa30391ec23a9809aea3f8c4f35f819894b9278819607a2ea315d35b6b0758c276599022a3c92054d912385982
@@ -0,0 +1,21 @@
1
+ module LogStasher
2
+ module Device
3
+ def self.factory(config)
4
+ config = config.dup
5
+ type = config.delete(:type) or fail ArgumentError, "No :type given"
6
+
7
+ case type
8
+ when "redis", :redis then
9
+ require "logstasher/device/redis"
10
+
11
+ ::LogStasher::Device::Redis.new(config)
12
+ when "syslog", :syslog then
13
+ require "logstasher/device/syslog"
14
+
15
+ ::LogStasher::Device::Syslog.new(config)
16
+ else
17
+ fail ArgumentError, "Unknown type: #{type}"
18
+ end
19
+ end
20
+ end
21
+ end
@@ -1,3 +1,3 @@
1
1
  module LogStasher
2
- VERSION = "1.0.0.rc2"
2
+ VERSION = "1.0.0.rc3"
3
3
  end
@@ -0,0 +1,46 @@
1
+ require "spec_helper"
2
+
3
+ require "logstasher/device"
4
+ require "logstasher/device/redis"
5
+ require "logstasher/device/syslog"
6
+
7
+ describe LogStasher::Device do
8
+ describe ".factory" do
9
+ it "expects a type" do
10
+ expect {
11
+ ::LogStasher::Device.factory(:no => "type given")
12
+ }.to raise_error(ArgumentError, "No :type given")
13
+ end
14
+
15
+ it "forwards configuration options to the device" do
16
+ ::LogStasher::Device::Redis.should_receive(:new).with(
17
+ :options => "other", :than => "type"
18
+ )
19
+ ::LogStasher::Device.factory(
20
+ :type => 'redis', :options => 'other', :than => "type"
21
+ )
22
+ end
23
+
24
+ it "can create redis devices" do
25
+ ::LogStasher::Device.should_receive(:require)
26
+ .with("logstasher/device/redis")
27
+
28
+ device = ::LogStasher::Device.factory(:type => "redis")
29
+ device.should be_a_kind_of(::LogStasher::Device::Redis)
30
+ end
31
+
32
+ it "can create syslog devices" do
33
+ ::LogStasher::Device.should_receive(:require)
34
+ .with("logstasher/device/syslog")
35
+
36
+ device = ::LogStasher::Device.factory(:type => "syslog")
37
+ device.should be_a_kind_of(::LogStasher::Device::Syslog)
38
+ end
39
+
40
+ it "fails to create unknown devices" do
41
+ expect {
42
+ ::LogStasher::Device.factory(:type => "unknown")
43
+ }.to raise_error(ArgumentError, "Unknown type: unknown")
44
+ end
45
+ end
46
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: md-logstasher
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0.rc2
4
+ version: 1.0.0.rc3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Devin Christensen
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-03-21 00:00:00.000000000 Z
11
+ date: 2014-03-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: logstash-event
@@ -82,6 +82,7 @@ files:
82
82
  - Rakefile
83
83
  - lib/logstasher.rb
84
84
  - lib/logstasher/context_wrapper.rb
85
+ - lib/logstasher/device.rb
85
86
  - lib/logstasher/device/redis.rb
86
87
  - lib/logstasher/device/syslog.rb
87
88
  - lib/logstasher/log_subscriber.rb
@@ -95,6 +96,7 @@ files:
95
96
  - logstasher.gemspec
96
97
  - spec/lib/logstasher/device/redis_spec.rb
97
98
  - spec/lib/logstasher/device/syslog_spec.rb
99
+ - spec/lib/logstasher/device_spec.rb
98
100
  - spec/lib/logstasher/log_subscriber_spec.rb
99
101
  - spec/lib/logstasher/railtie_spec.rb
100
102
  - spec/lib/logstasher_spec.rb
@@ -126,6 +128,7 @@ summary: Awesome rails logs
126
128
  test_files:
127
129
  - spec/lib/logstasher/device/redis_spec.rb
128
130
  - spec/lib/logstasher/device/syslog_spec.rb
131
+ - spec/lib/logstasher/device_spec.rb
129
132
  - spec/lib/logstasher/log_subscriber_spec.rb
130
133
  - spec/lib/logstasher/railtie_spec.rb
131
134
  - spec/lib/logstasher_spec.rb