marquise 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,27 @@
1
+ require_relative './spec_helper'
2
+ require 'marquise'
3
+
4
+ describe Marquise do
5
+ describe "#tell" do
6
+ let(:marquise) do
7
+ Marquise::FFI.
8
+ should_receive(:marquise_consumer_new).
9
+ with('tcp://localhost:4567', 5).
10
+ and_return('#tell')
11
+
12
+ x = Marquise.new('tcp://localhost:4567')
13
+ # Neuter the Marquise
14
+ ObjectSpace.undefine_finalizer(x)
15
+
16
+ x
17
+ end
18
+
19
+ it "fails if an unknown type of value is passed" do
20
+ expect { marquise.tell [1, 2, 3] }.
21
+ to raise_error(
22
+ ArgumentError,
23
+ /Invalid call to Marquise#tell/
24
+ )
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,153 @@
1
+ require_relative './spec_helper'
2
+ require 'marquise'
3
+
4
+ describe Marquise do
5
+ describe "#tell" do
6
+ let(:marquise) do
7
+ Marquise::FFI.
8
+ should_receive(:marquise_consumer_new).
9
+ with('tcp://localhost:4567', 5).
10
+ and_return('#tell')
11
+ Marquise::FFI.
12
+ should_receive(:marquise_connect).
13
+ with('#tell').
14
+ and_return('#tellconn')
15
+
16
+ x = Marquise.new('tcp://localhost:4567')
17
+ # Neuter the Marquise
18
+ ObjectSpace.undefine_finalizer(x)
19
+
20
+ x
21
+ end
22
+
23
+ describe "(text)" do
24
+ it "sends simple text" do
25
+ Marquise::FFI.stub(:send) do |*args|
26
+ expect(args).to be_an(Array)
27
+ expect(args.length).to eq(8)
28
+
29
+ method, conn, src_f, src_v, src_c, data, len, tstamp = args
30
+
31
+ expect(method).to eq(:marquise_send_text)
32
+ expect(conn).to eq('#tellconn')
33
+
34
+ expect(tstamp).
35
+ to be_within(1_000_000_000).
36
+ of(Time.now.to_f * 1_000_000_000)
37
+
38
+ expect(src_c).to eq(0)
39
+ expect(src_f).to be(nil)
40
+ expect(src_v).to be(nil)
41
+
42
+ expect(len).to eq("hello world".length)
43
+ expect(data).to eq("hello world")
44
+
45
+ 0
46
+ end
47
+
48
+ marquise.tell "hello world"
49
+ end
50
+
51
+ it "sends text and a timestamp" do
52
+ t = Time.now - 86400
53
+
54
+ Marquise::FFI.stub(:send) do |*args|
55
+ expect(args).to be_an(Array)
56
+ expect(args.length).to eq(8)
57
+
58
+ method, conn, src_f, src_v, src_c, data, len, tstamp = args
59
+
60
+ expect(method).to eq(:marquise_send_text)
61
+ expect(conn).to eq('#tellconn')
62
+
63
+ expect(tstamp).to eq(t.to_f * 1_000_000_000)
64
+
65
+ expect(src_c).to eq(0)
66
+ expect(src_f).to be(nil)
67
+ expect(src_v).to be(nil)
68
+
69
+ expect(len).to eq("hello world".length)
70
+ expect(data).to eq("hello world")
71
+
72
+ 0
73
+ end
74
+
75
+ marquise.tell "hello world", t
76
+ end
77
+
78
+ it "sends text and tags" do
79
+ Marquise::FFI.stub(:send) do |*args|
80
+ expect(args).to be_an(Array)
81
+ expect(args.length).to eq(8)
82
+
83
+ method, conn, src_f, src_v, src_c, data, len, tstamp = args
84
+
85
+ expect(method).to eq(:marquise_send_text)
86
+ expect(conn).to eq('#tellconn')
87
+
88
+ expect(tstamp).
89
+ to be_within(1_000_000_000).
90
+ of(Time.now.to_f * 1_000_000_000)
91
+
92
+ expect(src_c).to eq(2)
93
+
94
+ expect(src_f).to be_a(FFI::MemoryPointer)
95
+ expect(src_f.size).to eq(3*src_f.type_size)
96
+ expect(src_f[0].read_pointer.read_string).to eq('foo')
97
+ expect(src_f[1].read_pointer.read_string).to eq('answer')
98
+ expect(src_f[2].read_pointer.address).to eq(0)
99
+
100
+ expect(src_v).to be_a(FFI::MemoryPointer)
101
+ expect(src_v.size).to eq(3*src_f.type_size)
102
+ expect(src_v[0].read_pointer.read_string).to eq('bar')
103
+ expect(src_v[1].read_pointer.read_string).to eq('42')
104
+ expect(src_v[2].read_pointer.address).to eq(0)
105
+
106
+ expect(len).to eq("hello world".length)
107
+ expect(data).to eq("hello world")
108
+
109
+ 0
110
+ end
111
+
112
+ marquise.tell "hello world", :foo => 'bar', 'answer' => 42
113
+ end
114
+
115
+ it "sends text, timestamp and tags (teehee)" do
116
+ t = Time.now + 86400
117
+
118
+ Marquise::FFI.stub(:send) do |*args|
119
+ expect(args).to be_an(Array)
120
+ expect(args.length).to eq(8)
121
+
122
+ method, conn, src_f, src_v, src_c, data, len, tstamp = args
123
+
124
+ expect(method).to eq(:marquise_send_text)
125
+ expect(conn).to eq('#tellconn')
126
+
127
+ expect(tstamp).to eq(t.to_f * 1_000_000_000)
128
+
129
+ expect(src_c).to eq(2)
130
+
131
+ expect(src_f).to be_a(FFI::MemoryPointer)
132
+ expect(src_f.size).to eq(3*src_f.type_size)
133
+ expect(src_f[0].read_pointer.read_string).to eq('foo')
134
+ expect(src_f[1].read_pointer.read_string).to eq('answer')
135
+ expect(src_f[2].read_pointer.address).to eq(0)
136
+
137
+ expect(src_v).to be_a(FFI::MemoryPointer)
138
+ expect(src_v.size).to eq(3*src_f.type_size)
139
+ expect(src_v[0].read_pointer.read_string).to eq('bar')
140
+ expect(src_v[1].read_pointer.read_string).to eq('42')
141
+ expect(src_v[2].read_pointer.address).to eq(0)
142
+
143
+ expect(len).to eq("hello world".length)
144
+ expect(data).to eq("hello world")
145
+
146
+ 0
147
+ end
148
+
149
+ marquise.tell "hello world", t, :foo => 'bar', 'answer' => 42
150
+ end
151
+ end
152
+ end
153
+ end
@@ -0,0 +1,25 @@
1
+ require 'spork'
2
+
3
+ Spork.prefork do
4
+ require 'bundler'
5
+ Bundler.setup(:default, :test)
6
+ require 'rspec/core'
7
+
8
+ require 'rspec/mocks'
9
+
10
+ require 'pry'
11
+ require 'plymouth'
12
+
13
+ RSpec.configure do |config|
14
+ config.fail_fast = true
15
+ # config.full_backtrace = true
16
+
17
+ config.expect_with :rspec do |c|
18
+ c.syntax = :expect
19
+ end
20
+ end
21
+ end
22
+
23
+ Spork.each_run do
24
+ # Nothing to do here, specs will load the files they need
25
+ end
metadata ADDED
@@ -0,0 +1,259 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: marquise
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Matt Palmer
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2014-03-21 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: ffi
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: '1.9'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ version: '1.9'
30
+ - !ruby/object:Gem::Dependency
31
+ name: ffi_dry
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ type: :runtime
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ - !ruby/object:Gem::Dependency
47
+ name: git-version-bump
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ~>
52
+ - !ruby/object:Gem::Version
53
+ version: '0.7'
54
+ type: :runtime
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: '0.7'
62
+ - !ruby/object:Gem::Dependency
63
+ name: rspec
64
+ requirement: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ~>
68
+ - !ruby/object:Gem::Version
69
+ version: '2.14'
70
+ type: :development
71
+ prerelease: false
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ~>
76
+ - !ruby/object:Gem::Version
77
+ version: '2.14'
78
+ - !ruby/object:Gem::Dependency
79
+ name: rake
80
+ requirement: !ruby/object:Gem::Requirement
81
+ none: false
82
+ requirements:
83
+ - - ! '>='
84
+ - !ruby/object:Gem::Version
85
+ version: '0'
86
+ type: :development
87
+ prerelease: false
88
+ version_requirements: !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ! '>='
92
+ - !ruby/object:Gem::Version
93
+ version: '0'
94
+ - !ruby/object:Gem::Dependency
95
+ name: bundler
96
+ requirement: !ruby/object:Gem::Requirement
97
+ none: false
98
+ requirements:
99
+ - - ! '>='
100
+ - !ruby/object:Gem::Version
101
+ version: '0'
102
+ type: :development
103
+ prerelease: false
104
+ version_requirements: !ruby/object:Gem::Requirement
105
+ none: false
106
+ requirements:
107
+ - - ! '>='
108
+ - !ruby/object:Gem::Version
109
+ version: '0'
110
+ - !ruby/object:Gem::Dependency
111
+ name: rdoc
112
+ requirement: !ruby/object:Gem::Requirement
113
+ none: false
114
+ requirements:
115
+ - - ! '>='
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ none: false
122
+ requirements:
123
+ - - ! '>='
124
+ - !ruby/object:Gem::Version
125
+ version: '0'
126
+ - !ruby/object:Gem::Dependency
127
+ name: guard-spork
128
+ requirement: !ruby/object:Gem::Requirement
129
+ none: false
130
+ requirements:
131
+ - - ! '>='
132
+ - !ruby/object:Gem::Version
133
+ version: '0'
134
+ type: :development
135
+ prerelease: false
136
+ version_requirements: !ruby/object:Gem::Requirement
137
+ none: false
138
+ requirements:
139
+ - - ! '>='
140
+ - !ruby/object:Gem::Version
141
+ version: '0'
142
+ - !ruby/object:Gem::Dependency
143
+ name: guard-rspec
144
+ requirement: !ruby/object:Gem::Requirement
145
+ none: false
146
+ requirements:
147
+ - - ! '>='
148
+ - !ruby/object:Gem::Version
149
+ version: '0'
150
+ type: :development
151
+ prerelease: false
152
+ version_requirements: !ruby/object:Gem::Requirement
153
+ none: false
154
+ requirements:
155
+ - - ! '>='
156
+ - !ruby/object:Gem::Version
157
+ version: '0'
158
+ - !ruby/object:Gem::Dependency
159
+ name: rb-inotify
160
+ requirement: !ruby/object:Gem::Requirement
161
+ none: false
162
+ requirements:
163
+ - - ~>
164
+ - !ruby/object:Gem::Version
165
+ version: '0.9'
166
+ type: :development
167
+ prerelease: false
168
+ version_requirements: !ruby/object:Gem::Requirement
169
+ none: false
170
+ requirements:
171
+ - - ~>
172
+ - !ruby/object:Gem::Version
173
+ version: '0.9'
174
+ - !ruby/object:Gem::Dependency
175
+ name: plymouth
176
+ requirement: !ruby/object:Gem::Requirement
177
+ none: false
178
+ requirements:
179
+ - - ! '>='
180
+ - !ruby/object:Gem::Version
181
+ version: '0'
182
+ type: :development
183
+ prerelease: false
184
+ version_requirements: !ruby/object:Gem::Requirement
185
+ none: false
186
+ requirements:
187
+ - - ! '>='
188
+ - !ruby/object:Gem::Version
189
+ version: '0'
190
+ - !ruby/object:Gem::Dependency
191
+ name: pry-debugger
192
+ requirement: !ruby/object:Gem::Requirement
193
+ none: false
194
+ requirements:
195
+ - - ! '>='
196
+ - !ruby/object:Gem::Version
197
+ version: '0'
198
+ type: :development
199
+ prerelease: false
200
+ version_requirements: !ruby/object:Gem::Requirement
201
+ none: false
202
+ requirements:
203
+ - - ! '>='
204
+ - !ruby/object:Gem::Version
205
+ version: '0'
206
+ description:
207
+ email:
208
+ executables: []
209
+ extensions: []
210
+ extra_rdoc_files:
211
+ - README.md
212
+ files:
213
+ - .gitignore
214
+ - Gemfile
215
+ - Guardfile
216
+ - README.md
217
+ - Rakefile
218
+ - lib/marquise.rb
219
+ - lib/marquise/ffi.rb
220
+ - marquise.gemspec
221
+ - spec/marquise_spec.rb
222
+ - spec/marquise_tell_binary_spec.rb
223
+ - spec/marquise_tell_counter_spec.rb
224
+ - spec/marquise_tell_int_spec.rb
225
+ - spec/marquise_tell_real_spec.rb
226
+ - spec/marquise_tell_spec.rb
227
+ - spec/marquise_tell_text_spec.rb
228
+ - spec/spec_helper.rb
229
+ homepage: https://github.com/mpalmer/marquise-ruby
230
+ licenses: []
231
+ post_install_message:
232
+ rdoc_options: []
233
+ require_paths:
234
+ - lib
235
+ required_ruby_version: !ruby/object:Gem::Requirement
236
+ none: false
237
+ requirements:
238
+ - - ! '>='
239
+ - !ruby/object:Gem::Version
240
+ version: '0'
241
+ segments:
242
+ - 0
243
+ hash: 4428946624076758222
244
+ required_rubygems_version: !ruby/object:Gem::Requirement
245
+ none: false
246
+ requirements:
247
+ - - ! '>='
248
+ - !ruby/object:Gem::Version
249
+ version: '0'
250
+ segments:
251
+ - 0
252
+ hash: 4428946624076758222
253
+ requirements: []
254
+ rubyforge_project:
255
+ rubygems_version: 1.8.23
256
+ signing_key:
257
+ specification_version: 3
258
+ summary: Ruby bindings for the marquise data-point transport for Vaultaire
259
+ test_files: []