loggregator_messages 0.0.5.pre → 0.1.0.pre

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,14 +1,16 @@
1
1
  class LogMessage
2
2
  def message_type_name
3
- {MessageType::OUT => 'STDOUT', MessageType::ERR => 'STDERR'}[message_type]
3
+ {MessageType::OUT => "STDOUT", MessageType::ERR => "STDERR"}[message_type]
4
4
  end
5
5
 
6
- def source_type_name
7
- {SourceType::CLOUD_CONTROLLER => 'CF[CC]',
8
- SourceType::ROUTER => 'CF[Router]',
9
- SourceType::UAA => 'CF[UAA]',
10
- SourceType::DEA => 'CF[DEA]',
11
- SourceType::WARDEN_CONTAINER => 'App',}[source_type]
6
+ def source_name(id = nil)
7
+ id_string = id ? "/#{id}" : ""
8
+
9
+ {SourceType::CLOUD_CONTROLLER => "CF[CC#{id_string}]",
10
+ SourceType::ROUTER => "CF[Router#{id_string}]",
11
+ SourceType::UAA => "CF[UAA#{id_string}]",
12
+ SourceType::DEA => "CF[DEA#{id_string}]",
13
+ SourceType::WARDEN_CONTAINER => "App#{id_string}",}[source_type]
12
14
  end
13
15
 
14
16
  def time=(time)
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |spec|
4
4
  spec.name = "loggregator_messages"
5
- spec.version = '0.0.5.pre'
5
+ spec.version = '0.1.0.pre'
6
6
  spec.authors = ["Pivotal"]
7
7
  spec.email = ["cf-eng@pivotallabs.com"]
8
8
  spec.description = "Library for all of the protocol buffer messages."
@@ -28,7 +28,7 @@ describe LogMessage do
28
28
  end
29
29
  end
30
30
 
31
- describe "#source_type_name" do
31
+ describe "#source_name" do
32
32
  it "returns CloudController for type == 1" do
33
33
  msg = LogMessage.new(
34
34
  {
@@ -38,7 +38,8 @@ describe LogMessage do
38
38
  :source_type => 1
39
39
  })
40
40
 
41
- expect(msg.source_type_name).to eq("CF[CC]")
41
+ expect(msg.source_name).to eq("CF[CC]")
42
+ expect(msg.source_name(1)).to eq("CF[CC/1]")
42
43
  end
43
44
 
44
45
  it "returns Router for type == 2" do
@@ -50,7 +51,8 @@ describe LogMessage do
50
51
  :source_type => 2
51
52
  })
52
53
 
53
- expect(msg.source_type_name).to eq("CF[Router]")
54
+ expect(msg.source_name).to eq("CF[Router]")
55
+ expect(msg.source_name(2)).to eq("CF[Router/2]")
54
56
  end
55
57
  it "returns UAA for type == 3" do
56
58
  msg = LogMessage.new(
@@ -61,7 +63,8 @@ describe LogMessage do
61
63
  :source_type => 3
62
64
  })
63
65
 
64
- expect(msg.source_type_name).to eq("CF[UAA]")
66
+ expect(msg.source_name).to eq("CF[UAA]")
67
+ expect(msg.source_name("3.1")).to eq("CF[UAA/3.1]")
65
68
  end
66
69
  it "returns DEA for type == 4" do
67
70
  msg = LogMessage.new(
@@ -72,7 +75,8 @@ describe LogMessage do
72
75
  :source_type => 4
73
76
  })
74
77
 
75
- expect(msg.source_type_name).to eq("CF[DEA]")
78
+ expect(msg.source_name).to eq("CF[DEA]")
79
+ expect(msg.source_name("4")).to eq("CF[DEA/4]")
76
80
  end
77
81
  it "returns WardenContainer for type == 5" do
78
82
  msg = LogMessage.new(
@@ -83,7 +87,8 @@ describe LogMessage do
83
87
  :source_type => 5
84
88
  })
85
89
 
86
- expect(msg.source_type_name).to eq("App")
90
+ expect(msg.source_name).to eq("App")
91
+ expect(msg.source_name("my-id-1")).to eq("App/my-id-1")
87
92
  end
88
93
  end
89
94
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: loggregator_messages
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5.pre
4
+ version: 0.1.0.pre
5
5
  prerelease: 6
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-09-13 00:00:00.000000000 Z
12
+ date: 2013-09-19 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: beefcake