hx 0.19.0 → 0.20.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. data/VERSION +1 -1
  2. data/lib/hx/cli.rb +16 -3
  3. metadata +3 -3
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.19.0
1
+ 0.20.0
data/lib/hx/cli.rb CHANGED
@@ -28,6 +28,7 @@ require 'pathname'
28
28
  require 'tempfile'
29
29
  require 'webrick'
30
30
  require 'rack'
31
+ require 'rack/mock'
31
32
  require 'rack/handler/webrick'
32
33
  require 'hx/rack/application'
33
34
 
@@ -105,11 +106,23 @@ def self.cmd_serve(site, port=nil)
105
106
  base_url = "http://localhost:#{real_port}/"
106
107
  server.logger.info "Serving on #{base_url}"
107
108
 
108
- # reload the site/config, folding in the new base URL
109
109
  config_file = site.options[:config_file]
110
- site = Hx::Site.load_file(config_file, :base_url => base_url)
110
+ mtime = nil
111
+ site_app = nil
112
+
113
+ app = Proc.new { |env|
114
+ unless site_app and File.mtime(config_file) == mtime
115
+ # reload the site/config, folding in the new base URL
116
+ site = Hx::Site.load_file(config_file, :base_url => base_url)
117
+ mtime = File.mtime(config_file)
118
+ site_app = Hx::Rack::Application.new(site, site.options)
119
+ end
120
+ site_app.call(env)
121
+ }
122
+
123
+ # force application load
124
+ Rack::MockRequest.new(app).get("/")
111
125
 
112
- app = Hx::Rack::Application.new(site, site.options)
113
126
  server.mount('/', ::Rack::Handler::WEBrick, app)
114
127
  %w(INT TERM).each { |s| trap(s) { server.shutdown } }
115
128
  server.start
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hx
3
3
  version: !ruby/object:Gem::Version
4
- hash: 83
4
+ hash: 79
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
- - 19
8
+ - 20
9
9
  - 0
10
- version: 0.19.0
10
+ version: 0.20.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - MenTaLguY