zss 0.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 9b273215c353dc2052fe86de1bba480e4ce01eaa
4
+ data.tar.gz: 4785ffd2de0fd2336e0deca7a10805a83eae492f
5
+ SHA512:
6
+ metadata.gz: d3442fa909dde6d0e8971cbfe1bcf514f9500ebd24bfdf2f8be21835b557e65728b0870c2e78b2d01f1c02fb0950f00a15e0eb0e5fc9bc88de5f46005312b813
7
+ data.tar.gz: e8356e90f27286a18698022e230defd1832202fd6b7460b332a592cce934e87fa7645fa814149cab1c0a72f732928c8a036955f6b13758a08f88d6f295d376b5
data/.gitignore ADDED
@@ -0,0 +1,34 @@
1
+ *.gem
2
+ *.rbc
3
+ /.config
4
+ /coverage/
5
+ /InstalledFiles
6
+ /pkg/
7
+ /spec/reports/
8
+ /test/tmp/
9
+ /test/version_tmp/
10
+ /tmp/
11
+
12
+ ## Specific to RubyMotion:
13
+ .dat*
14
+ .repl_history
15
+ build/
16
+
17
+ ## Documentation cache and generated files:
18
+ /.yardoc/
19
+ /_yardoc/
20
+ /doc/
21
+ /rdoc/
22
+
23
+ ## Environment normalisation:
24
+ /.bundle/
25
+ /lib/bundler/man/
26
+
27
+ # for a library or gem, you might want to ignore these files since the code is
28
+ # intended to run in multiple environments; otherwise, check them in:
29
+ # Gemfile.lock
30
+ # .ruby-version
31
+ # .ruby-gemset
32
+
33
+ # unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
34
+ .rvmrc
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ -f doc --color
data/.rvmrc.example ADDED
@@ -0,0 +1 @@
1
+ rvm 2.1.2@zss --create
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in zss.gemspec
4
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,70 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ zss (0.0.0)
5
+ activesupport
6
+ ffi-rzmq
7
+ hashie
8
+ msgpack
9
+
10
+ GEM
11
+ remote: https://rubygems.org/
12
+ specs:
13
+ activesupport (4.1.4)
14
+ i18n (~> 0.6, >= 0.6.9)
15
+ json (~> 1.7, >= 1.7.7)
16
+ minitest (~> 5.1)
17
+ thread_safe (~> 0.1)
18
+ tzinfo (~> 1.1)
19
+ coderay (1.1.0)
20
+ diff-lcs (1.2.5)
21
+ docile (1.1.5)
22
+ ffi (1.9.3)
23
+ ffi-rzmq (2.0.1)
24
+ ffi-rzmq-core (>= 1.0.1)
25
+ ffi-rzmq-core (1.0.3)
26
+ ffi (~> 1.9)
27
+ hashie (3.1.0)
28
+ i18n (0.6.9)
29
+ json (1.8.1)
30
+ method_source (0.8.2)
31
+ minitest (5.3.5)
32
+ msgpack (0.5.8)
33
+ multi_json (1.10.1)
34
+ pry (0.10.0)
35
+ coderay (~> 1.1.0)
36
+ method_source (~> 0.8.1)
37
+ slop (~> 3.4)
38
+ rake (10.3.2)
39
+ rspec (3.0.0)
40
+ rspec-core (~> 3.0.0)
41
+ rspec-expectations (~> 3.0.0)
42
+ rspec-mocks (~> 3.0.0)
43
+ rspec-core (3.0.2)
44
+ rspec-support (~> 3.0.0)
45
+ rspec-expectations (3.0.2)
46
+ diff-lcs (>= 1.2.0, < 2.0)
47
+ rspec-support (~> 3.0.0)
48
+ rspec-mocks (3.0.2)
49
+ rspec-support (~> 3.0.0)
50
+ rspec-support (3.0.2)
51
+ simplecov (0.8.2)
52
+ docile (~> 1.1.0)
53
+ multi_json
54
+ simplecov-html (~> 0.8.0)
55
+ simplecov-html (0.8.0)
56
+ slop (3.5.0)
57
+ thread_safe (0.3.4)
58
+ tzinfo (1.2.1)
59
+ thread_safe (~> 0.1)
60
+
61
+ PLATFORMS
62
+ ruby
63
+
64
+ DEPENDENCIES
65
+ bundler (~> 1.6)
66
+ pry
67
+ rake
68
+ rspec
69
+ simplecov
70
+ zss!
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2014 Pedro Januário
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,84 @@
1
+ [![Build Status](https://travis-ci.org/pjanuario/zmq-service-suite-ruby.svg?branch=master)](https://travis-ci.org/pjanuario/zmq-service-suite-ruby)
2
+ [![Code Climate](https://codeclimate.com/github/pjanuario/zmq-service-suite-ruby.png)](https://codeclimate.com/github/pjanuario/zmq-service-suite-ruby)
3
+ [![Coverage](http://img.shields.io/codeclimate/coverage/github/pjanuario/zmq-service-suite-ruby.svg)](https://codeclimate.com/github/pjanuario/zmq-service-suite-ruby)
4
+ [![Dependency Status](https://gemnasium.com/pjanuario/zmq-service-suite-ruby.svg)](https://gemnasium.com/pjanuario/zmq-service-suite-ruby)
5
+
6
+ # ZMQ SOA Suite - Ruby Client &amp; Service
7
+
8
+ For now protocol description is under node js implementation and will be moved soon to a proper place.
9
+ https://github.com/pjanuario/zmq-service-suite
10
+
11
+ ## Installation
12
+
13
+ Add this line to your application's Gemfile:
14
+
15
+ gem 'zss'
16
+
17
+ And then execute:
18
+
19
+ $ bundle
20
+
21
+ Or install it yourself as:
22
+
23
+ $ gem install zss
24
+
25
+ **NOTE:**
26
+
27
+ You need to have [0MQ installed](http://zeromq.org/area:download).
28
+
29
+ If you use MacOS just do
30
+
31
+ $ brew install zeromq
32
+
33
+
34
+ ## ZSS Client
35
+
36
+ ```ruby
37
+ require 'zss'
38
+
39
+ # default Client config
40
+ config = {
41
+ frontend: 'tcp://127.0.0.1:5560',
42
+ identity: 'client',
43
+ timeout: 1000 # in ms
44
+ }
45
+
46
+ # it uses default configs
47
+ PongClient = ZSS::Client.new(:pong)
48
+
49
+ # it uses configs
50
+ # who can override just a single property
51
+ PongClient = ZSS::Client.new(:pong, config)
52
+
53
+ # call Pong service on verb PING with "payload"
54
+ PongClient.ping("payload")
55
+ #or
56
+ PongClient.call("ping", "payload")
57
+
58
+ # call Pong service on verb PING with "payload" and headers
59
+ PongClient.ping("payload", headers: { something: "data" })
60
+ # or
61
+ PongClient.call("ping", "payload", headers: { something: "data" })
62
+
63
+ # call Pong service on verb PING with "payload"
64
+ PongClient.ping_pong("payload")
65
+ # or
66
+ PongClient.call("ping/pong", "payload")
67
+
68
+ ```
69
+
70
+ ## Contributing
71
+
72
+ 1. Fork it
73
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
74
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
75
+ 4. Push to the branch (`git push origin my-new-feature`)
76
+ 5. Create new Pull Request
77
+
78
+ ## Running Specs
79
+
80
+ $ rspec
81
+
82
+ ## Coverage Report
83
+
84
+ $ open ./coverage/index.html
data/lib/zss.rb ADDED
@@ -0,0 +1,16 @@
1
+
2
+ require 'active_support/string_inquirer'
3
+ require 'active_support/core_ext/object'
4
+ require 'active_support/core_ext/hash/indifferent_access'
5
+
6
+ require_relative 'zss/version'
7
+ require_relative 'zss/environment'
8
+ require_relative 'zss/configuration'
9
+ require_relative 'zss/message'
10
+ require_relative 'zss/error'
11
+
12
+
13
+ module ZSS
14
+ extend self
15
+
16
+ end
@@ -0,0 +1,9 @@
1
+ module ZSS
2
+ class Configuration
3
+
4
+ def self.default
5
+ Hashie::Mash.new frontend: 'tcp://127.0.0.1:5560'
6
+ end
7
+
8
+ end
9
+ end
@@ -0,0 +1,12 @@
1
+ module ZSS
2
+ module Environment
3
+
4
+ extend self
5
+
6
+ def env
7
+ environment = ENV['ZSS_ENV'] || 'development'
8
+ ActiveSupport::StringInquirer.new environment
9
+ end
10
+
11
+ end
12
+ end
data/lib/zss/error.rb ADDED
@@ -0,0 +1,15 @@
1
+ module ZSS
2
+ class Error < ::StandardError
3
+
4
+ attr_reader :code, :developer_message, :user_message
5
+
6
+ def initialize code, payload
7
+ @code = code.to_i
8
+ @developer_message = payload.developerMessage
9
+ @user_message = payload.userMessage
10
+ super @developer_message
11
+ set_backtrace caller
12
+ end
13
+
14
+ end
15
+ end
@@ -0,0 +1,99 @@
1
+ require 'msgpack'
2
+ require 'hashie'
3
+
4
+ require_relative 'message/message_type'
5
+ require_relative 'message/message_address'
6
+
7
+ module ZSS
8
+ class Message
9
+
10
+ PROTOCOL_VERSION = "ZSS:0.0"
11
+
12
+ attr_accessor :identity,
13
+ :protocol,
14
+ :type,
15
+ :rid,
16
+ :address,
17
+ :headers,
18
+ :status,
19
+ :payload
20
+
21
+ def initialize(args = {})
22
+
23
+ @identity = args[:identity]
24
+ @protocol = args[:protocol] || PROTOCOL_VERSION
25
+ @type = args[:type] || Type::REQ
26
+ @rid = args[:rid] || SecureRandom.uuid
27
+ @address = args[:address]
28
+ @headers = args[:headers] || {}
29
+ @status = args[:status]
30
+ @payload = args[:payload]
31
+
32
+ end
33
+
34
+ def self.parse(frames)
35
+
36
+ frames.unshift(nil) if frames.length == 7
37
+
38
+ msg = Message.new(
39
+ identity: frames.shift,
40
+ protocol: frames.shift,
41
+ type: frames.shift,
42
+ rid: frames.shift,
43
+ address: Address.new(
44
+ MessagePack.unpack(frames.shift).with_indifferent_access
45
+ ),
46
+ headers: Hashie::Mash.new(MessagePack.unpack(frames.shift)),
47
+ status: frames.shift.to_i,
48
+ payload: MessagePack.unpack(frames.shift),
49
+ )
50
+
51
+ if msg.payload.kind_of? Hash
52
+ msg.payload = Hashie::Mash.new(msg.payload)
53
+ end
54
+
55
+ msg
56
+ end
57
+
58
+ def to_s
59
+ <<-out
60
+ FRAME 0:
61
+ IDENTITY : #{identity}
62
+ FRAME 1:
63
+ PROTOCOL : #{protocol}
64
+ FRAME 2:
65
+ TYPE : #{type}
66
+ FRAME 3:
67
+ RID : #{rid}
68
+ FRAME 4:
69
+ SID : #{address.sid}
70
+ VERB : #{address.verb}
71
+ SVERSION : #{address.sversion}
72
+ FRAME 5:
73
+ HEADERS : #{headers.to_h}
74
+ FRAME 6:
75
+ STATUS : #{status}
76
+ FRAME 7:
77
+ PAYLOAD : #{payload}
78
+ out
79
+ end
80
+
81
+ def to_frames
82
+ [
83
+ identity,
84
+ protocol,
85
+ type,
86
+ rid,
87
+ address.instance_values.to_msgpack,
88
+ headers.to_h.to_msgpack,
89
+ status.to_s,
90
+ payload.to_msgpack
91
+ ]
92
+ end
93
+
94
+ def is_error?
95
+ status != 200
96
+ end
97
+
98
+ end
99
+ end
@@ -0,0 +1,12 @@
1
+ module ZSS
2
+
3
+ class Message
4
+
5
+ class Type
6
+ REQ = "REQ"
7
+ REP = "REP"
8
+ end
9
+
10
+ end
11
+
12
+ end
@@ -0,0 +1,20 @@
1
+ module ZSS
2
+
3
+ class Message
4
+
5
+ class Address
6
+ attr_accessor :sid,
7
+ :sversion,
8
+ :verb
9
+
10
+ def initialize args = {}
11
+ @sid = args[:sid].try(:upcase)
12
+ @verb = args[:verb].try(:upcase)
13
+ @sversion = args[:sversion] || '*'
14
+ end
15
+
16
+ end
17
+
18
+ end
19
+
20
+ end
@@ -0,0 +1,3 @@
1
+ module ZSS
2
+ VERSION = '0.0.0'
3
+ end
@@ -0,0 +1,52 @@
1
+ require 'ffi-rzmq'
2
+ require 'msgpack'
3
+
4
+ module BrokerHelper
5
+
6
+ LOG_BROKER_INFO = false
7
+
8
+ def run_broker(endpoint)
9
+
10
+ Thread.new do
11
+ puts "broker running" if LOG_BROKER_INFO
12
+
13
+ Thread.handle_interrupt(RuntimeError => :immediate) do
14
+
15
+ begin
16
+ context = ZMQ::Context.create
17
+ socket = context.socket ZMQ::ROUTER
18
+ socket.setsockopt(ZMQ::LINGER, 0)
19
+ socket.connect(endpoint)
20
+ puts "broker connected" if LOG_BROKER_INFO
21
+
22
+ socket.recv_strings(frames = [])
23
+
24
+ puts "broker received #{frames}" if LOG_BROKER_INFO
25
+
26
+ if block_given?
27
+ msg = ZSS::Message.parse(frames)
28
+
29
+ yield(msg)
30
+
31
+ frames = msg.to_frames
32
+ socket.send_strings(frames)
33
+
34
+ puts "broker sending #{frames}" if LOG_BROKER_INFO
35
+ end
36
+
37
+ Thread.stop
38
+
39
+ rescue => e
40
+ puts "WTF => #{e}"
41
+ ensure
42
+ # You can write resource deallocation code safely.
43
+ puts "broker stoping" if LOG_BROKER_INFO
44
+ socket.close if socket
45
+ context.terminate if context
46
+ end
47
+ end
48
+
49
+ end
50
+
51
+ end
52
+ end
@@ -0,0 +1,14 @@
1
+ ENV['ZSS_ENV'] ||= 'test'
2
+
3
+ require 'simplecov'
4
+ SimpleCov.start do
5
+ add_filter '/spec/'
6
+ end
7
+
8
+ $:.push '.'
9
+
10
+ require 'rspec'
11
+ require 'pry'
12
+ require 'zss'
13
+
14
+ Dir['spec/support/**/*.rb'].each &method(:require)
@@ -0,0 +1,17 @@
1
+ require 'spec_helper'
2
+
3
+ describe ZSS::Environment do
4
+
5
+ it('returns environment string') do
6
+ expect(subject.env).to eq('test')
7
+ end
8
+
9
+ it('returns true when query by current env') do
10
+ expect(subject.env.test?).to be true
11
+ end
12
+
13
+ it('returns false when query for different env') do
14
+ expect(subject.env.production?).to be false
15
+ end
16
+
17
+ end
@@ -0,0 +1,27 @@
1
+ require 'spec_helper'
2
+
3
+ describe ZSS::Error do
4
+
5
+ let! :response do
6
+ Hashie::Mash.new(userMessage: "user info", developerMessage: "dev info")
7
+ end
8
+
9
+ subject do
10
+ described_class.new(500, response)
11
+ end
12
+
13
+ it('returns a fullfilled error.message') do
14
+ expect(subject.code).to eq(500)
15
+ expect(subject.developer_message).to eq("dev info")
16
+ expect(subject.user_message).to eq("user info")
17
+ end
18
+
19
+ it('returns error with dev info as error.message') do
20
+ expect(subject.message).to eq("dev info")
21
+ end
22
+
23
+ it('returns error with stacktrace') do
24
+ expect(subject.backtrace).not_to be_nil
25
+ end
26
+
27
+ end
@@ -0,0 +1,23 @@
1
+ require 'spec_helper'
2
+
3
+ describe ZSS::Message::Address do
4
+
5
+ describe('#ctor') do
6
+
7
+ it('returns a address object with default version') do
8
+ actual = described_class.new sid: "service", verb: "verb"
9
+ expect(actual.sid).to eq("SERVICE")
10
+ expect(actual.verb).to eq("VERB")
11
+ expect(actual.sversion).to eq("*")
12
+ end
13
+
14
+ it('returns a address object with specific version') do
15
+ actual = described_class.new sid: "service", verb: "verb", sversion: 'v.1'
16
+ expect(actual.sid).to eq("SERVICE")
17
+ expect(actual.verb).to eq("VERB")
18
+ expect(actual.sversion).to eq("v.1")
19
+ end
20
+
21
+ end
22
+
23
+ end
@@ -0,0 +1,186 @@
1
+ require 'spec_helper'
2
+ require 'msgpack'
3
+
4
+ describe ZSS::Message do
5
+
6
+ let(:address) { ZSS::Message::Address.new(sid: "service", verb: "verb") }
7
+
8
+ let(:headers) { { headerval: "something" } }
9
+
10
+ let :frames do
11
+ [
12
+ "identity",
13
+ ZSS::Message::PROTOCOL_VERSION,
14
+ ZSS::Message::Type::REP,
15
+ "RID",
16
+ address.instance_values.to_msgpack,
17
+ headers.to_msgpack,
18
+ 200,
19
+ "data".to_msgpack
20
+ ]
21
+ end
22
+
23
+ let(:message) { described_class.parse(frames) }
24
+
25
+ describe('#ctor') do
26
+
27
+ it('returns a fullfilled message with defaults') do
28
+ allow(SecureRandom).to receive(:uuid) { "uuid" }
29
+
30
+ actual = described_class.new({
31
+ address: address,
32
+ headers: headers,
33
+ payload: "some data"
34
+ })
35
+
36
+ expect(actual.identity).to be_nil
37
+ expect(actual.protocol).to eq(ZSS::Message::PROTOCOL_VERSION)
38
+ expect(actual.type).to eq(ZSS::Message::Type::REQ)
39
+ expect(actual.rid).to eq("uuid")
40
+ expect(actual.address).to eq(address)
41
+ expect(actual.headers).to eq(headers)
42
+ expect(actual.payload).to eq("some data")
43
+ end
44
+
45
+ end
46
+
47
+ describe('#parse') do
48
+
49
+ context('without identity') do
50
+
51
+ let :frames do
52
+ [
53
+ ZSS::Message::PROTOCOL_VERSION,
54
+ ZSS::Message::Type::REP,
55
+ "RID",
56
+ address.instance_values.to_msgpack,
57
+ headers.to_msgpack,
58
+ "200",
59
+ "data".to_msgpack
60
+ ]
61
+ end
62
+
63
+ it('returns a fullfilled message') do
64
+
65
+ address.sversion = "sversion"
66
+
67
+ actual = described_class.parse(frames)
68
+
69
+ expect(actual.identity).to be_nil
70
+ expect(actual.protocol).to eq(ZSS::Message::PROTOCOL_VERSION)
71
+ expect(actual.type).to eq(ZSS::Message::Type::REP)
72
+ expect(actual.rid).to eq("RID")
73
+ expect(actual.address.sid).to eq(address.sid)
74
+ expect(actual.address.verb).to eq(address.verb)
75
+ expect(actual.address.sversion).to eq(address.sversion)
76
+ expect(actual.headers["headerval"]).to eq(headers[:headerval])
77
+ expect(actual.status).to eq(200)
78
+ expect(actual.payload).to eq("data")
79
+ end
80
+
81
+ end
82
+
83
+ context('with identity') do
84
+
85
+ it('returns a fullfilled message') do
86
+
87
+ actual = described_class.parse(frames)
88
+
89
+ expect(actual.identity).to eq("identity")
90
+ expect(actual.protocol).to eq(ZSS::Message::PROTOCOL_VERSION)
91
+ expect(actual.type).to eq(ZSS::Message::Type::REP)
92
+ expect(actual.rid).to eq("RID")
93
+ expect(actual.address.sid).to eq(address.sid)
94
+ expect(actual.address.verb).to eq(address.verb)
95
+ expect(actual.address.sversion).to eq(address.sversion)
96
+ expect(actual.headers["headerval"]).to eq(headers[:headerval])
97
+ expect(actual.status).to eq(200)
98
+ expect(actual.payload).to eq("data")
99
+ end
100
+
101
+ end
102
+
103
+ it('returns a message with hashie headers') do
104
+
105
+ actual = described_class.parse(frames)
106
+
107
+ expect(actual.headers["headerval"]).to eq(headers[:headerval])
108
+ expect(actual.headers[:headerval]).to eq(headers[:headerval])
109
+ expect(actual.headers.headerval).to eq(headers[:headerval])
110
+ end
111
+
112
+ it('returns a message with hashie payload') do
113
+ frames[7] = { something: "data" }.to_msgpack
114
+ actual = described_class.parse(frames)
115
+ expect(actual.payload.something).to eq("data")
116
+ expect(actual.payload[:something]).to eq("data")
117
+ expect(actual.payload["something"]).to eq("data")
118
+ end
119
+
120
+ end
121
+
122
+ describe('#to_s') do
123
+ let :string_representation do
124
+ <<-out
125
+ FRAME 0:
126
+ IDENTITY : #{message.identity}
127
+ FRAME 1:
128
+ PROTOCOL : #{message.protocol}
129
+ FRAME 2:
130
+ TYPE : #{message.type}
131
+ FRAME 3:
132
+ RID : #{message.rid}
133
+ FRAME 4:
134
+ SID : #{message.address.sid}
135
+ VERB : #{message.address.verb}
136
+ SVERSION : #{message.address.sversion}
137
+ FRAME 5:
138
+ HEADERS : #{message.headers.to_h}
139
+ FRAME 6:
140
+ STATUS : #{message.status}
141
+ FRAME 7:
142
+ PAYLOAD : #{message.payload}
143
+ out
144
+ end
145
+
146
+ it('returns a string with formated frame') do
147
+ expect(message.to_s).to eq(string_representation)
148
+ end
149
+ end
150
+
151
+ describe('.to_frames') do
152
+
153
+ let :output_frames do
154
+ [
155
+ "identity",
156
+ ZSS::Message::PROTOCOL_VERSION,
157
+ ZSS::Message::Type::REP,
158
+ "RID",
159
+ address.instance_values.to_msgpack,
160
+ headers.to_msgpack,
161
+ "200",
162
+ "data".to_msgpack
163
+ ]
164
+ end
165
+
166
+ it('returns message in frames') do
167
+ expect(message.to_frames).to eq(output_frames)
168
+ end
169
+
170
+ end
171
+
172
+ describe('.is_error') do
173
+
174
+ it('returns false when status is 200') do
175
+ message.status = 200
176
+ expect(message.is_error?).to eq false
177
+ end
178
+
179
+ it('returns true when status is not 200') do
180
+ message.status = 500
181
+ expect(message.is_error?).to eq true
182
+ end
183
+
184
+ end
185
+
186
+ end
data/zss.gemspec ADDED
@@ -0,0 +1,30 @@
1
+ lib = File.expand_path('../lib', __FILE__)
2
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
+ require './lib/zss/version'
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = 'zss'
7
+ spec.version = ZSS::VERSION
8
+ spec.authors = ["Pedro Januário"]
9
+ spec.email = ["prnjanuario@gmail.com"]
10
+ spec.description = %q{ZeroMQ SOA Suite}
11
+ spec.summary = %q{ZeroMQ SOA Suite}
12
+ spec.homepage = "https://github.com/pjanuario/zmq-service-suite-ruby"
13
+ spec.license = "MIT"
14
+
15
+ spec.files = `git ls-files`.split($/)
16
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
17
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
18
+ spec.require_paths = ["lib"]
19
+
20
+ spec.add_development_dependency 'bundler', '~> 1.6'
21
+ spec.add_development_dependency 'rake'
22
+ spec.add_development_dependency 'rspec'
23
+ spec.add_development_dependency 'pry'
24
+ spec.add_development_dependency 'simplecov'
25
+
26
+ spec.add_dependency 'msgpack'
27
+ spec.add_dependency 'ffi-rzmq'
28
+ spec.add_dependency 'activesupport'
29
+ spec.add_dependency 'hashie'
30
+ end
metadata ADDED
@@ -0,0 +1,198 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: zss
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Pedro Januário
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-07-03 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.6'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.6'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: pry
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: simplecov
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: msgpack
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: ffi-rzmq
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :runtime
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: activesupport
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :runtime
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ - !ruby/object:Gem::Dependency
126
+ name: hashie
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - ">="
130
+ - !ruby/object:Gem::Version
131
+ version: '0'
132
+ type: :runtime
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - ">="
137
+ - !ruby/object:Gem::Version
138
+ version: '0'
139
+ description: ZeroMQ SOA Suite
140
+ email:
141
+ - prnjanuario@gmail.com
142
+ executables: []
143
+ extensions: []
144
+ extra_rdoc_files: []
145
+ files:
146
+ - ".gitignore"
147
+ - ".rspec"
148
+ - ".rvmrc.example"
149
+ - Gemfile
150
+ - Gemfile.lock
151
+ - LICENSE
152
+ - README.md
153
+ - lib/zss.rb
154
+ - lib/zss/configuration.rb
155
+ - lib/zss/environment.rb
156
+ - lib/zss/error.rb
157
+ - lib/zss/message.rb
158
+ - lib/zss/message/message_address.rb
159
+ - lib/zss/message/message_type.rb
160
+ - lib/zss/version.rb
161
+ - spec/spec_broker_helper.rb
162
+ - spec/spec_helper.rb
163
+ - spec/unit/environment_spec.rb
164
+ - spec/unit/error_spec.rb
165
+ - spec/unit/message_address_spec.rb
166
+ - spec/unit/message_spec.rb
167
+ - zss.gemspec
168
+ homepage: https://github.com/pjanuario/zmq-service-suite-ruby
169
+ licenses:
170
+ - MIT
171
+ metadata: {}
172
+ post_install_message:
173
+ rdoc_options: []
174
+ require_paths:
175
+ - lib
176
+ required_ruby_version: !ruby/object:Gem::Requirement
177
+ requirements:
178
+ - - ">="
179
+ - !ruby/object:Gem::Version
180
+ version: '0'
181
+ required_rubygems_version: !ruby/object:Gem::Requirement
182
+ requirements:
183
+ - - ">="
184
+ - !ruby/object:Gem::Version
185
+ version: '0'
186
+ requirements: []
187
+ rubyforge_project:
188
+ rubygems_version: 2.2.2
189
+ signing_key:
190
+ specification_version: 4
191
+ summary: ZeroMQ SOA Suite
192
+ test_files:
193
+ - spec/spec_broker_helper.rb
194
+ - spec/spec_helper.rb
195
+ - spec/unit/environment_spec.rb
196
+ - spec/unit/error_spec.rb
197
+ - spec/unit/message_address_spec.rb
198
+ - spec/unit/message_spec.rb