m2config 0.9.0 → 0.9.1

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: f3c76efc6317bc7fe641bd3c978cff4f78cd30c5
4
- data.tar.gz: beea61d1cb3737e3bec50ad83ee8e3a79bd7ee00
3
+ metadata.gz: afd22b0a55c4bab36dab2e2b4513ece7ee7d8298
4
+ data.tar.gz: 91c4d8efc772ee183fedacc2539f4b8052126435
5
5
  SHA512:
6
- metadata.gz: 9d40a5251991dbe74307fefe85635deefe7b78b2b524b1d2d498cc1f7407c27094304020b5f6775217e5fa99341ece612e094938a4cb138b3b86f00ce2efb4c0
7
- data.tar.gz: 125c81887b1b5d5fad1154bc1d6a80055c35b9a58069f36a0ee4359b22ebc2aa00e49d6b567d1aa53cd92dc4377e9cec58c887c36ce36309c3d25dc1ee5be394
6
+ metadata.gz: 7446db6384946fc6e03ac1b8c8dabc5e9adb42ac21ea864b60d1aaf3601563a08b40f735a21e6acef3180d9f4956b8d368a84eafd04c07a9814b3b4aac296ca9
7
+ data.tar.gz: b29931e593e44eaa2af9fe3e94a1db86878475aff8d2249a8ebcd9983b07ba4343569068b161e47d4f2efe3dc9b48e6cb23fd60958a155746033ce3be40a8450
data/Gemfile CHANGED
@@ -5,8 +5,8 @@ gemspec
5
5
  group :dev do
6
6
  gem 'guard'
7
7
  gem 'rb-inotify'
8
- gem 'rspec', '~> 2.13'
9
- gem 'guard-rspec'
8
+ gem 'rspec', '~> 3'
9
+ # gem 'guard-rspec'
10
10
  gem 'libnotify'
11
11
  gem 'pry'
12
12
  gem 'pry-nav'
@@ -30,14 +30,15 @@ CREATE TABLE route (id INTEGER PRIMARY KEY,
30
30
  target_type TEXT);
31
31
  CREATE TABLE server (id INTEGER PRIMARY KEY,
32
32
  uuid TEXT,
33
- default_host TEXT,
34
- bind_addr TEXT DEFAULT "0.0.0.0",
35
- port INTEGER,
36
- chroot TEXT DEFAULT '/var/www',
37
33
  access_log TEXT,
38
34
  error_log TEXT,
35
+ chroot TEXT DEFAULT '/var/www',
39
36
  pid_file TEXT,
40
37
  control_port TEXT DEFAULT "",
38
+ default_host TEXT,
39
+ name TEXT DEFAULT '',
40
+ bind_addr TEXT DEFAULT "0.0.0.0",
41
+ port INTEGER,
41
42
  use_ssl INTEGER default 0);
42
43
  CREATE TABLE setting (id INTEGER PRIMARY KEY, key TEXT, value TEXT);
43
44
  CREATE TABLE statistic (id SERIAL,
@@ -6,6 +6,7 @@ module M2Config
6
6
  CONTROL_PORT = ''
7
7
  CHROOT = './'
8
8
  DEFAULT_HOST = 'localhost'
9
+ NAME = 'main'
9
10
  BIND_ADDR = '0.0.0.0'
10
11
  PORT = 6767
11
12
  USE_SSL = 0
@@ -19,9 +20,11 @@ module M2Config
19
20
  fields[:pid_file] ||= PID_FILE
20
21
  fields[:chroot] ||= CHROOT
21
22
  fields[:default_host] ||= DEFAULT_HOST
23
+ fields[:name] ||= NAME
22
24
  fields[:bind_addr] ||= BIND_ADDR
23
25
  fields[:port] ||= PORT
24
26
  fields[:use_ssl] ||= USE_SSL
27
+ fields[:control_port] ||= CONTROL_PORT
25
28
  super fields, false
26
29
  save
27
30
  end
@@ -1,3 +1,3 @@
1
1
  module M2Config
2
- VERSION = "0.9.0"
2
+ VERSION = "0.9.1"
3
3
  end
@@ -5,17 +5,17 @@ describe M2Config::Dir do
5
5
  describe "::new" do
6
6
  it "needs to know the base path to handle" do
7
7
  M2Config::Dir.new({base:"images/"})
8
- CFG.db[:directory].first[:base].should eq("images/")
8
+ expect(CFG.db[:directory].first[:base]).to eq("images/")
9
9
  end
10
10
 
11
11
  it "defaults to application/octet-stream for the default content type" do
12
12
  M2Config::Dir.new({base:"images/"})
13
- CFG.db[:directory].first[:default_ctype].should eq("application/octet-stream")
13
+ expect(CFG.db[:directory].first[:default_ctype]).to eq("application/octet-stream")
14
14
  end
15
15
 
16
16
  it "defaults to index.html for the index file" do
17
17
  dir = M2Config::Dir.new({base:"/"})
18
- CFG.db[:directory].first[:index_file].should eq("index.html")
18
+ expect(CFG.db[:directory].first[:index_file]).to eq("index.html")
19
19
  end
20
20
 
21
21
  describe "helps you spot common mistakes" do
@@ -40,7 +40,7 @@ describe M2Config::Dir do
40
40
 
41
41
  describe '#type' do
42
42
  it 'returns its type' do
43
- M2Config::Dir.new({base:"/"}).type.should eq("dir")
43
+ expect(M2Config::Dir.new({base:"/"}).type).to eq("dir")
44
44
  end
45
45
  end
46
46
 
@@ -9,9 +9,9 @@ describe M2Config::Handler do
9
9
  recv_spec:"tcp://10.0.0.1:9898",
10
10
  send_ident: "dev.example.com ID"})
11
11
  res = CFG.db[:handler].first
12
- res[:send_spec].should eq("tcp://10.0.0.1:8989")
13
- res[:recv_spec].should eq("tcp://10.0.0.1:9898")
14
- res[:send_ident].should eq("dev.example.com ID")
12
+ expect(res[:send_spec]).to eq("tcp://10.0.0.1:8989")
13
+ expect(res[:recv_spec]).to eq("tcp://10.0.0.1:9898")
14
+ expect(res[:send_ident]).to eq("dev.example.com ID")
15
15
  end
16
16
 
17
17
  it "turns nil into empty string when recv_ident is not set" do
@@ -19,7 +19,7 @@ describe M2Config::Handler do
19
19
  recv_spec:"tcp://10.0.0.1:9898",
20
20
  send_ident: "dev.example.com ID"})
21
21
  res = CFG.db[:handler].first
22
- res[:recv_ident].should be_empty
22
+ expect(res[:recv_ident]).to be_empty
23
23
  end
24
24
 
25
25
  describe "helps you spot common mistakes" do
@@ -34,7 +34,7 @@ describe M2Config::Handler do
34
34
 
35
35
  describe '#type' do
36
36
  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")
37
+ expect(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).to eq("handler")
38
38
  end
39
39
  end
40
40
  end
@@ -9,21 +9,21 @@ describe M2Config::Host do
9
9
  it "needs to know the domain name served" do
10
10
  M2Config::Host.new({matching:"example.com", name: "ex"})
11
11
  res = CFG.db[:host].first
12
- res[:matching].should eq("example.com")
12
+ expect(res[:matching]).to eq("example.com")
13
13
  end
14
14
 
15
15
  it "can use the uuid of a server" do
16
16
  host = M2Config::Host.new({matching:"example.com", name: "ex", srvUuid: @srv.uuid})
17
17
  res = CFG.db[:host].where(id: host.id).first
18
- res[:server_id].should eq(@srv.id)
19
- res[:matching].should eq("example.com")
18
+ expect(res[:server_id]).to eq(@srv.id)
19
+ expect(res[:matching]).to eq("example.com")
20
20
  end
21
21
 
22
22
  it "can use a server instance" do
23
23
  host = M2Config::Host.new({matching:"example.com", name: "ex", srv: @srv})
24
24
  res = CFG.db[:host].where(id: host.id).first
25
- res[:server_id].should eq(@srv.id)
26
- res[:matching].should eq("example.com")
25
+ expect(res[:server_id]).to eq(@srv.id)
26
+ expect(res[:matching]).to eq("example.com")
27
27
  end
28
28
 
29
29
  it "enforces mongrel2 constraint about nil name" do
@@ -40,7 +40,7 @@ describe M2Config::Host do
40
40
  dirR = M2Config::Route.new({path:"/blog", target: dirH})
41
41
  host.add_route dirR
42
42
  res = CFG.db[:route].first
43
- res[:host_id].should eq(host.id)
43
+ expect(res[:host_id]).to eq(host.id)
44
44
  end
45
45
  end
46
46
 
@@ -51,7 +51,7 @@ describe M2Config::Host do
51
51
  dir2 = M2Config::Dir.new({base: "images/"})
52
52
  host.add_route M2Config::Route.new({path:"/blog1", target: dir1})
53
53
  host.add_route M2Config::Route.new({path:"/blog1", target: dir2})
54
- host.check_routes.should be_false
54
+ expect(host.check_routes).to be_falsey
55
55
  end
56
56
 
57
57
  it 'returns true if all routes have different paths' do
@@ -62,12 +62,12 @@ describe M2Config::Host do
62
62
  r2 = M2Config::Route.new({path:"/images", target: dir2})
63
63
  host.add_route r1
64
64
  host.add_route r2
65
- host.check_routes.should be_true
65
+ expect(host.check_routes).to be_truthy
66
66
  end
67
67
 
68
68
  it 'withstands the idea of not having any routes' do # , {focus: true}
69
69
  host = M2Config::Host.new({matching:"example.com", name: "ex"})
70
- host.check_routes.should be_true
70
+ expect(host.check_routes).to be_truthy
71
71
  end
72
72
  end
73
73
 
@@ -6,12 +6,12 @@ describe M2Config do
6
6
 
7
7
  describe "::new" do
8
8
  it 'creates a default database when name absent' do
9
- File.should exist DEFAULT_DB_NAME
9
+ expect(File).to exist DEFAULT_DB_NAME
10
10
  end
11
11
 
12
12
  it 'learns the DB schema from the official schema dump' do
13
13
  for table in TABLES do
14
- M2Config::Config.tables.should include table
14
+ expect(M2Config::Config.tables).to include table
15
15
  end
16
16
  end
17
17
 
@@ -22,15 +22,15 @@ describe M2Config do
22
22
  end
23
23
 
24
24
  it 'populates the MIME table with a nice set of mappings' do
25
- M2Config::MimeType[extension:".html"].mimetype.should eq("text/html")
26
- M2Config::MimeType[extension:".css"].mimetype.should eq("text/css")
25
+ expect(M2Config::MimeType[extension:".html"].mimetype).to eq("text/html")
26
+ expect(M2Config::MimeType[extension:".css"].mimetype).to eq("text/css")
27
27
  end
28
28
  end
29
29
 
30
30
  describe '#[]=' do
31
31
  it 'creates or modifies the value of a setting' do
32
32
  CFG["zeromq.threads"] = 8
33
- CFG.db[:setting].where(key:"zeromq.threads").first[:value].should eq("8")
33
+ expect(CFG.db[:setting].where(key:"zeromq.threads").first[:value]).to eq("8")
34
34
  end
35
35
  end
36
36
 
@@ -16,7 +16,8 @@ describe M2Config::MimeType do
16
16
  end
17
17
 
18
18
  it 'allows you to force the redefinition of an existing extension' do
19
- pending
19
+ skip
20
+ fail
20
21
  end
21
22
  end
22
23
 
@@ -26,7 +27,7 @@ describe M2Config::MimeType do
26
27
  CFG.db[:mimetype].delete
27
28
  M2Config::MimeType.populate_table()
28
29
  # M2Config::MimeType.populate_table(nil,ignoreDoubles=true)
29
- M2Config::MimeType[extension:'.css'].mimetype.should eq('text/css')
30
+ expect(M2Config::MimeType[extension:'.css'].mimetype).to eq('text/css')
30
31
  end
31
32
 
32
33
  it 'checks for doubles unless asked not to' do
@@ -43,8 +44,8 @@ describe M2Config::MimeType do
43
44
  it 'accepts an array of MIME::Types if the whole list is too much' do
44
45
  CFG.db[:mimetype].delete
45
46
  M2Config::MimeType.populate_table [MIME::Type.new(['text/plain', 'zed'])]
46
- M2Config::MimeType[extension:'.zed'].mimetype.should eq('text/plain')
47
- M2Config::MimeType[extension:'.css'].should eq(nil)
47
+ expect(M2Config::MimeType[extension:'.zed'].mimetype).to eq('text/plain')
48
+ expect(M2Config::MimeType[extension:'.css']).to eq(nil)
48
49
  end
49
50
 
50
51
  it 'frowns when asked to populate a non-empty table' do
@@ -8,14 +8,14 @@ describe M2Config::Proxy do
8
8
  it "needs an address and a port number" do
9
9
  M2Config::Proxy.new({addr:"legacy.local", port: 8080})
10
10
  res = CFG.db[:proxy].first
11
- res[:addr].should eq("legacy.local")
12
- res[:port].should eq(8080)
11
+ expect(res[:addr]).to eq("legacy.local")
12
+ expect(res[:port]).to eq(8080)
13
13
  end
14
14
  end
15
15
 
16
16
  describe '#type' do
17
17
  it 'returns its type' do
18
- M2Config::Proxy.new({addr:"legacy.local", port: 8080}).type.should eq("proxy")
18
+ expect(M2Config::Proxy.new({addr:"legacy.local", port: 8080}).type).to eq("proxy")
19
19
  end
20
20
  end
21
21
 
@@ -7,9 +7,9 @@ describe M2Config::Route do
7
7
  dirH = M2Config::Dir.new({base: "static/"})
8
8
  M2Config::Route.new({path:"/blog", target: dirH})
9
9
  res = CFG.db[:route].first
10
- res[:path].should eq("/blog")
11
- res[:target_id].should eq(dirH.id)
12
- res[:target_type].should eq(dirH.type)
10
+ expect(res[:path]).to eq("/blog")
11
+ expect(res[:target_id]).to eq(dirH.id)
12
+ expect(res[:target_type]).to eq(dirH.type)
13
13
  end
14
14
  end
15
15
 
@@ -22,9 +22,9 @@ describe M2Config::Route do
22
22
  r2 = M2Config::Route.new({path:"/king", target: dir2, host: host})
23
23
  r3 = M2Config::Route.new({path:"/king", target: dirH, host: host})
24
24
  M2Config::Route.elect!(r2)
25
- host.check_routes.should be_true
25
+ expect(host.check_routes).to be_truthy
26
26
  king = M2Config::Route.where(path: "/king").first
27
- king.target.base.should eq("ManceRayder/")
27
+ expect(king.target.base).to eq("ManceRayder/")
28
28
  end
29
29
 
30
30
  it "leaves routes belonging to a different host untouched" do
@@ -36,11 +36,11 @@ describe M2Config::Route do
36
36
  r2 = M2Config::Route.new({path:"/king", target: dir2, host: host})
37
37
  r3 = M2Config::Route.new({path:"/king", target: dirH, host: host2})
38
38
  M2Config::Route.elect!(r2)
39
- host.check_routes.should be_true
39
+ expect(host.check_routes).to be_truthy
40
40
  king = M2Config::Route.where(path: "/king").first
41
- king.target.base.should eq("ManceRayder/")
41
+ expect(king.target.base).to eq("ManceRayder/")
42
42
  onOtherHost = M2Config::Route.where(path:"/king", target_id: dirH.id, host: host2).first
43
- onOtherHost.should_not be_nil
43
+ expect(onOtherHost).not_to be_nil
44
44
  end
45
45
  end
46
46
 
@@ -51,7 +51,7 @@ describe M2Config::Route do
51
51
  r = M2Config::Route.new({path:"/blog", target: dirH})
52
52
  r.host = host.id
53
53
  res = CFG.db[:route].first
54
- res[:host_id].should eq(host.id)
54
+ expect(res[:host_id]).to eq(host.id)
55
55
  end
56
56
 
57
57
  it "can take a Host instance" do
@@ -60,7 +60,7 @@ describe M2Config::Route do
60
60
  r = M2Config::Route.new({path:"/blog", target: dirH})
61
61
  r.host = host
62
62
  res = CFG.db[:route].first
63
- res[:host_id].should eq(host.id)
63
+ expect(res[:host_id]).to eq(host.id)
64
64
  end
65
65
  end
66
66
 
@@ -69,7 +69,7 @@ describe M2Config::Route do
69
69
  dirH = M2Config::Dir.new({base: "static/"})
70
70
  r = M2Config::Route.new({path:"/blog", target: dirH})
71
71
  r.host = M2Config::Host.new({matching:"example.com", name: "ex"})
72
- r.host.matching.should eq("example.com")
72
+ expect(r.host.matching).to eq("example.com")
73
73
  end
74
74
  end
75
75
 
@@ -80,8 +80,8 @@ describe M2Config::Route do
80
80
  newTarget = M2Config::Proxy.new({addr:"127.0.0.1", port: 15970})
81
81
  r.target = newTarget
82
82
  res = CFG.db[:route].first
83
- res[:target_id].should eq(newTarget.id)
84
- res[:target_type].should eq(newTarget.type)
83
+ expect(res[:target_id]).to eq(newTarget.id)
84
+ expect(res[:target_type]).to eq(newTarget.type)
85
85
  end
86
86
  end
87
87
 
@@ -89,7 +89,7 @@ describe M2Config::Route do
89
89
  it 'returns the Target object' do
90
90
  dirH = M2Config::Dir.new({base: "static/"})
91
91
  r = M2Config::Route.new({path:"/blog", target: dirH})
92
- r.target.base.should eq dirH.base
92
+ expect(r.target.base).to eq dirH.base
93
93
  end
94
94
  end
95
95
 
@@ -9,15 +9,16 @@ describe M2Config::Server do
9
9
  describe '::new' do
10
10
  it 'creates a server entry with reasonable default settings' do
11
11
  res = CFG.db[:server].first
12
- res[:access_log].should eq(M2Config::Server::ACCESS_LOG)
13
- res[:error_log].should eq(M2Config::Server::ERROR_LOG)
14
- res[:pid_file].should eq(M2Config::Server::PID_FILE)
15
- res[:control_port].should eq(M2Config::Server::CONTROL_PORT)
16
- res[:chroot].should eq(M2Config::Server::CHROOT)
17
- res[:default_host].should eq(M2Config::Server::DEFAULT_HOST)
18
- res[:bind_addr].should eq(M2Config::Server::BIND_ADDR)
19
- res[:port].should eq(M2Config::Server::PORT)
20
- res[:use_ssl].should eq(M2Config::Server::USE_SSL)
12
+ expect(res[:access_log]).to eq(M2Config::Server::ACCESS_LOG)
13
+ expect(res[:error_log]).to eq(M2Config::Server::ERROR_LOG)
14
+ expect(res[:pid_file]).to eq(M2Config::Server::PID_FILE)
15
+ expect(res[:control_port]).to eq(M2Config::Server::CONTROL_PORT)
16
+ expect(res[:chroot]).to eq(M2Config::Server::CHROOT)
17
+ expect(res[:default_host]).to eq(M2Config::Server::DEFAULT_HOST)
18
+ expect(res[:name]).to eq(M2Config::Server::NAME)
19
+ expect(res[:bind_addr]).to eq(M2Config::Server::BIND_ADDR)
20
+ expect(res[:port]).to eq(M2Config::Server::PORT)
21
+ expect(res[:use_ssl]).to eq(M2Config::Server::USE_SSL)
21
22
  end
22
23
 
23
24
  end
@@ -25,7 +26,7 @@ describe M2Config::Server do
25
26
  describe '::first (from Sequel::Model)' do
26
27
  it 'returns the first server found in the database' do
27
28
  srv = M2Config::Server.first
28
- srv.id.should eq(@srv.id)
29
+ expect(srv.id).to eq(@srv.id)
29
30
  end
30
31
 
31
32
  it 'raises if there is more than one server' do
@@ -38,7 +39,7 @@ describe M2Config::Server do
38
39
  it 'accepts an existing Host instance' do
39
40
  @srv.add_host @host
40
41
  res = CFG.db[:host].where(id: @host.id).first
41
- res[:server_id].should eq(@srv.id)
42
+ expect(res[:server_id]).to eq(@srv.id)
42
43
  end
43
44
  end
44
45
  end
@@ -7,14 +7,14 @@ describe M2Config::Setting do
7
7
  it "stores the given value under the given key" do
8
8
  M2Config::Setting.new("answer",42)
9
9
  res = CFG.db[:setting].first
10
- res[:value].should eq("42")
10
+ expect(res[:value]).to eq("42")
11
11
  end
12
12
 
13
13
  it "updates the existing value if the given key is already present" do
14
14
  M2Config::Setting.new("answer",41)
15
15
  M2Config::Setting.new("answer",42)
16
16
  res = CFG.db[:setting].first
17
- res[:value].should eq("42")
17
+ expect(res[:value]).to eq("42")
18
18
  end
19
19
  end
20
20
  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.9.0
4
+ version: 0.9.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Arnaud Meuret
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-09-10 00:00:00.000000000 Z
11
+ date: 2015-09-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sqlite3