sanford 0.12.0 → 0.13.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -69,6 +69,14 @@ module Sanford
69
69
  @server_data.logger
70
70
  end
71
71
 
72
+ def router
73
+ @server_data.router
74
+ end
75
+
76
+ def template_source
77
+ @server_data.template_source
78
+ end
79
+
72
80
  def listen(*args)
73
81
  args = [ @server_data.ip, @server_data.port ] if args.empty?
74
82
  @dat_tcp_server.listen(*args) do |server_socket|
@@ -29,8 +29,12 @@ module Sanford
29
29
  @engines[input_ext.to_s] = engine_class.new(engine_opts)
30
30
  end
31
31
 
32
- def engine_for?(template_name)
33
- @engines.keys.include?(get_template_ext(template_name))
32
+ def engine_for?(ext)
33
+ @engines.keys.include?(ext)
34
+ end
35
+
36
+ def engine_for_template?(template_name)
37
+ self.engine_for?(get_template_ext(template_name))
34
38
  end
35
39
 
36
40
  def render(template_path, service_handler, locals)
@@ -1,3 +1,3 @@
1
1
  module Sanford
2
- VERSION = "0.12.0"
2
+ VERSION = "0.13.0"
3
3
  end
data/sanford.gemspec CHANGED
@@ -18,7 +18,7 @@ Gem::Specification.new do |gem|
18
18
  gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
19
19
  gem.require_paths = ["lib"]
20
20
 
21
- gem.add_dependency("dat-tcp", ["~> 0.5"])
21
+ gem.add_dependency("dat-tcp", ["~> 0.6"])
22
22
  gem.add_dependency("ns-options", ["~> 1.1"])
23
23
  gem.add_dependency("sanford-protocol", ["~> 0.10"])
24
24
 
@@ -143,7 +143,7 @@ module Sanford::Server
143
143
  should have_imeths :name, :ip, :port
144
144
  should have_imeths :file_descriptor, :client_file_descriptors
145
145
  should have_imeths :configured_ip, :configured_port
146
- should have_imeths :pid_file, :logger
146
+ should have_imeths :pid_file, :logger, :router, :template_source
147
147
  should have_imeths :listen, :start, :pause, :stop, :halt
148
148
  should have_imeths :paused?
149
149
 
@@ -171,12 +171,17 @@ module Sanford::Server
171
171
  assert_not_nil @dat_tcp_server_spy.serve_proc
172
172
  end
173
173
 
174
- should "know its name, pid file and logger" do
174
+ should "know its name, pid file" do
175
175
  assert_equal subject.server_data.name, subject.name
176
176
  assert_equal subject.server_data.ip, subject.configured_ip
177
177
  assert_equal subject.server_data.port, subject.configured_port
178
178
  assert_equal subject.server_data.pid_file, subject.pid_file
179
- assert_equal subject.server_data.logger, subject.logger
179
+ end
180
+
181
+ should "know its logger, router and template source" do
182
+ assert_equal subject.server_data.logger, subject.logger
183
+ assert_equal subject.server_data.router, subject.router
184
+ assert_equal subject.server_data.template_source, subject.template_source
180
185
  end
181
186
 
182
187
  should "call listen on its dat tcp server using `listen`" do
@@ -26,7 +26,8 @@ class Sanford::TemplateSource
26
26
  subject{ @source }
27
27
 
28
28
  should have_readers :path, :engines
29
- should have_imeths :engine, :engine_for?, :render
29
+ should have_imeths :engine, :engine_for?, :engine_for_template?
30
+ should have_imeths :render
30
31
 
31
32
  should "know its path" do
32
33
  assert_equal @source_path.to_s, subject.path
@@ -86,10 +87,14 @@ class Sanford::TemplateSource
86
87
  end
87
88
 
88
89
  should "know if it has an engine registered for a given template name" do
89
- assert_false subject.engine_for?('test_template')
90
+ assert_false subject.engine_for?(Factory.string)
91
+ assert_false subject.engine_for?('test')
92
+ assert_false subject.engine_for_template?(Factory.string)
93
+ assert_false subject.engine_for_template?('test_template')
90
94
 
91
95
  subject.engine 'test', @test_engine
92
- assert_true subject.engine_for?('test_template')
96
+ assert_true subject.engine_for?('test')
97
+ assert_true subject.engine_for_template?('test_template')
93
98
  end
94
99
 
95
100
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sanford
3
3
  version: !ruby/object:Gem::Version
4
- hash: 47
4
+ hash: 43
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
- - 12
8
+ - 13
9
9
  - 0
10
- version: 0.12.0
10
+ version: 0.13.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Collin Redding
@@ -16,7 +16,7 @@ autorequire:
16
16
  bindir: bin
17
17
  cert_chain: []
18
18
 
19
- date: 2014-12-05 00:00:00 Z
19
+ date: 2015-02-04 00:00:00 Z
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
22
22
  requirement: &id001 !ruby/object:Gem::Requirement
@@ -24,11 +24,11 @@ dependencies:
24
24
  requirements:
25
25
  - - ~>
26
26
  - !ruby/object:Gem::Version
27
- hash: 1
27
+ hash: 7
28
28
  segments:
29
29
  - 0
30
- - 5
31
- version: "0.5"
30
+ - 6
31
+ version: "0.6"
32
32
  type: :runtime
33
33
  name: dat-tcp
34
34
  version_requirements: *id001