m2config 0.5.2 → 0.5.3

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: 8dfeb1a86a0a6cdf4af5bb69f36298d1baa1f97b
4
- data.tar.gz: f8fdfff8b5ab0941d27ce01519195936ea1c2ce3
3
+ metadata.gz: 8ff07c47abc8681428c309b6f7149d88bdfeab2f
4
+ data.tar.gz: 406ebf7f14b7d323cac91cc6b89601969c7bac7e
5
5
  SHA512:
6
- metadata.gz: adf30e48ee1e39f25e694ade3172cc29464d34dd3c15221ec145df190e17c362758d7bc00b551362e798ef11b2f4a87bf75483713d6c56dbbe9ba0cef0bface4
7
- data.tar.gz: 0952a47d1daceaf5cf1eb94b92d053d385f8597a84917de9050a819c4ebf3d1121123962b20febdb883ce6bfd517854667a2518be37e32c7a2ff8b50ed826d4f
6
+ metadata.gz: 5c71a0cd31e62607ee4de5f8d786c989b916433dea9b4ecc65b4e38e26e31f65cbcfe65b31e9a2f4e9479c66c911244b8fe3af692a163cc0d1e816fe41d547cf
7
+ data.tar.gz: a8f4be0037c8a953495530eb57bca1dc0aa3300ebdf2b8b881d00683423a86f1f41bcc2755a9dda9c16eda60d3f73cc1fc2cf2ad677c92eddf9c1d23c3e2aa05
@@ -2,9 +2,14 @@ module M2Config
2
2
  class Handler < Sequel::Model(:handler)
3
3
  plugin :validation_helpers
4
4
 
5
+ ID_REGEX = /^[-a-zA-Z0-9]+$/
6
+
5
7
  def initialize( fields )
6
8
  raise ArgumentError, "The send and receive endpoints can not be the same" if
7
9
  fields[:send_spec] == fields[:recv_spec]
10
+ raise ArgumentError, "Handler send and recv IDs must only use -a-zA-Z0-9" if
11
+ !(fields[:send_ident] =~ ID_REGEX &&
12
+ fields[:send_ident] =~ ID_REGEX)
8
13
  fields[:recv_ident] ||= ""
9
14
  super(fields, false)
10
15
  save
@@ -1,3 +1,3 @@
1
1
  module M2Config
2
- VERSION = "0.5.2"
2
+ VERSION = "0.5.3"
3
3
  end
data/spec/handler_spec.rb CHANGED
@@ -7,34 +7,43 @@ describe M2Config::Handler do
7
7
  it "needs the ØMQ addresses and a send identifier" do
8
8
  M2Config::Handler.new({ send_spec:"tcp://10.0.0.1:8989",
9
9
  recv_spec:"tcp://10.0.0.1:9898",
10
- send_ident: "dev.example.com ID"})
10
+ send_ident: "dev-example-comID"})
11
11
  res = CFG.db[:handler].first
12
12
  res[:send_spec].should eq("tcp://10.0.0.1:8989")
13
13
  res[:recv_spec].should eq("tcp://10.0.0.1:9898")
14
- res[:send_ident].should eq("dev.example.com ID")
14
+ res[:send_ident].should eq("dev-example-comID")
15
15
  end
16
16
 
17
17
  it "turns nil into empty string when recv_ident is not set" do
18
18
  M2Config::Handler.new({ send_spec:"tcp://10.0.0.1:8989",
19
19
  recv_spec:"tcp://10.0.0.1:9898",
20
- send_ident: "dev.example.com ID"})
20
+ send_ident: "dev-example-comID"})
21
21
  res = CFG.db[:handler].first
22
22
  res[:recv_ident].should be_empty
23
23
  end
24
24
 
25
- describe "helps you spot common mistakes" do
25
+ describe "helps you spot common mistakes:" do
26
26
  it "yells when the addresses are the same" do
27
27
  expect do
28
28
  M2Config::Handler.new({send_spec:"tcp://10.0.0.1:8989", recv_spec:"tcp://10.0.0.1:8989", send_ident: "dev.example.com ID"})
29
29
  end.to raise_exception(ArgumentError, /send and receive endpoints can not be the same/i)
30
30
  end
31
31
 
32
+ it "yells when the send ID does not respect Mongrel2's constraints (UUID = (alpha | digit | '-')+ )" do
33
+ expect do
34
+ M2Config::Handler.new({send_spec:"tcp://10.0.0.1:8988", recv_spec:"tcp://10.0.0.1:8989", send_ident: "dev.example.com ID"})
35
+ end.to raise_exception(ArgumentError, /Handler send and recv IDs must only use -a-zA-Z0-9/i)
36
+ expect do
37
+ M2Config::Handler.new({send_spec:"tcp://10.0.0.1:8988", recv_spec:"tcp://10.0.0.1:8989", recv_ident: "dev.example.com ID"})
38
+ end.to raise_exception(ArgumentError, /Handler send and recv IDs must only use -a-zA-Z0-9/i)
39
+ end
40
+
32
41
  end
33
42
  end
34
43
 
35
44
  describe '#type' do
36
45
  it 'returns its type' do
37
- M2Config::Handler.new({send_spec:"tcp://10.0.0.1:8988", recv_spec:"tcp://10.0.0.1:8989", send_ident: "dev.example.com ID"}).type.should eq("handler")
46
+ M2Config::Handler.new({send_spec:"tcp://10.0.0.1:8988", recv_spec:"tcp://10.0.0.1:8989", send_ident: "dev-example-comID"}).type.should eq("handler")
38
47
  end
39
48
  end
40
49
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: m2config
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.2
4
+ version: 0.5.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Arnaud Meuret
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-09-20 00:00:00.000000000 Z
11
+ date: 2013-10-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sqlite3
@@ -152,7 +152,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
152
152
  version: '0'
153
153
  requirements: []
154
154
  rubyforge_project:
155
- rubygems_version: 2.0.0
155
+ rubygems_version: 2.0.3
156
156
  signing_key:
157
157
  specification_version: 4
158
158
  summary: Manage your Mongrel2 configuration database using handy model classes that