hx 0.10.0 → 0.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (5) hide show
  1. data/VERSION +1 -1
  2. data/lib/hx.rb +5 -0
  3. data/lib/hx/cli.rb +9 -5
  4. data/lib/hx/path.rb +9 -4
  5. metadata +4 -4
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.10.0
1
+ 0.11.0
data/lib/hx.rb CHANGED
@@ -461,11 +461,16 @@ class Site
461
461
 
462
462
  def load(io, config_path)
463
463
  raw_config = YAML.load(io)
464
+ load_raw(raw_config, config_path)
465
+ end
466
+
467
+ def load_raw(raw_config, config_path)
464
468
  options = {}
465
469
  options[:base_dir] = File.dirname(config_path)
466
470
  for key, value in raw_config.fetch('options', {})
467
471
  options[key.intern] = value
468
472
  end
473
+ options[:config_file] = config_path
469
474
 
470
475
  if raw_config.has_key? 'require'
471
476
  for library in raw_config['require']
@@ -86,10 +86,7 @@ EOS
86
86
  end
87
87
  end
88
88
 
89
- site = nil
90
- options.config_file.open("r") do |stream|
91
- site = Hx::Site.load(stream, options.config_file)
92
- end
89
+ site = Hx::Site.load_file(options.config_file)
93
90
 
94
91
  subcommand = args.shift || "upgen"
95
92
  method_name = "cmd_#{subcommand}".intern
@@ -104,9 +101,16 @@ end
104
101
  def self.cmd_serve(site, port=nil)
105
102
  server = WEBrick::HTTPServer.new({:Port => port || 0})
106
103
  real_port = server.config[:Port]
104
+
107
105
  base_url = "http://localhost:#{real_port}/"
108
106
  server.logger.info "Serving on #{base_url}"
109
- site.options[:base_url] = base_url
107
+
108
+ # reload the site/config, folding in the new base URL
109
+ config_file = site.options[:config_file]
110
+ raw_config = File.open(config_file, 'r') { |s| YAML.load(s) }
111
+ (raw_config['options'] ||= {})['base_url'] = base_url
112
+ site = Hx::Site.load_raw(raw_config, config_file)
113
+
110
114
  app = Hx::Rack::Application.new(site, site.options)
111
115
  server.mount('/', ::Rack::Handler::WEBrick, app)
112
116
  %w(INT TERM).each { |s| trap(s) { server.shutdown } }
@@ -30,11 +30,11 @@ module Selector
30
30
  end
31
31
 
32
32
  def |(other)
33
- Disjunction.new(self, other)
33
+ Disjunction.build(self, other)
34
34
  end
35
35
 
36
36
  def &(other)
37
- Conjunction.new(self, other)
37
+ Conjunction.build(self, other)
38
38
  end
39
39
 
40
40
  def ~()
@@ -92,7 +92,7 @@ end
92
92
  class Conjunction
93
93
  include Connective
94
94
 
95
- def self.new(*selectors)
95
+ def self.build(*selectors)
96
96
  if selectors.any? { |s| All === s }
97
97
  selectors.reject! { |s| All === s }
98
98
  case selectors.size
@@ -100,7 +100,7 @@ class Conjunction
100
100
  when 1; return selectors.first
101
101
  end
102
102
  end
103
- super(*selectors)
103
+ new(*selectors)
104
104
  end
105
105
 
106
106
  def accept_path?(path)
@@ -111,6 +111,11 @@ end
111
111
  class Disjunction
112
112
  include Connective
113
113
 
114
+ def self.build(*selectors)
115
+ return ALL if selectors.any? { |s| All === s }
116
+ new(*selectors)
117
+ end
118
+
114
119
  def accept_path?(path)
115
120
  @selectors.any? { |s| s.accept_path? path }
116
121
  end
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: 55
4
+ hash: 51
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
- - 10
8
+ - 11
9
9
  - 0
10
- version: 0.10.0
10
+ version: 0.11.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - MenTaLguY
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-03-01 00:00:00 -08:00
18
+ date: 2011-03-02 00:00:00 -08:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency