spire 0.4.10 → 0.4.11

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.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.4.10
1
+ 0.4.11
@@ -5,10 +5,12 @@ module Spire
5
5
 
6
6
  class MainController
7
7
  attr_accessor :buffer
8
+ attr_reader :request
8
9
 
9
- def initialize(request)
10
+ def initialize(request, app_root)
10
11
  @buffer = Buffer.new
11
12
  @request = request
13
+ @app_root = app_root
12
14
  end
13
15
 
14
16
  def get_buffer
@@ -26,8 +28,7 @@ module Spire
26
28
  end
27
29
 
28
30
  if opts[:view]
29
- file_path = File.expand_path(__FILE__)
30
- file_path["lib/spire/class/MainController.rb"] = "app/views/#{opts[:view]}"
31
+ file_path = @app_root + "/views/#{opts[:view]}"
31
32
  return 404 unless File.exists?(file_path)
32
33
  contents = IO.read(file_path)
33
34
  extension = File.extname(file_path)
@@ -22,9 +22,7 @@ module Spire
22
22
  end
23
23
 
24
24
  def exists?(url)
25
- if @maps[url] == {}
26
- return false
27
- else
25
+ unless @maps[url] == {}
28
26
  return true
29
27
  end
30
28
  end
@@ -1,7 +1,9 @@
1
1
  module Spire
2
2
  class Router
3
- def initialize(map)
3
+ def initialize(map, app_root)
4
4
  @map = map
5
+ app_root["config.ru"] = "app"
6
+ @app_root = app_root
5
7
  end
6
8
 
7
9
  def route(env)
@@ -25,11 +27,8 @@ module Spire
25
27
  end
26
28
 
27
29
  def run(maps_to, request)
28
- path = File.expand_path(__FILE__)
29
- path["lib/spire/router.rb"] = "app/controllers"
30
-
31
- require "#{path}/#{maps_to[:controller].capitalize}Controller.rb"
32
- @class = Kernel.const_get(maps_to[:controller].capitalize).new(request)
30
+ require "#{@app_root}/controllers/#{maps_to[:controller].capitalize}Controller.rb"
31
+ @class = Kernel.const_get(maps_to[:controller].capitalize).new(request, @app_root)
33
32
 
34
33
  result = @class.method(maps_to[:action]).call
35
34
  buffer = @class.get_buffer
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "spire"
8
- s.version = "0.4.10"
8
+ s.version = "0.4.11"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Scott Nicol"]
12
- s.date = "2012-08-29"
12
+ s.date = "2012-08-30"
13
13
  s.description = "Light rack-based framework with controllers, HAML/ERB views, router & error handler"
14
14
  s.email = "scott@scottnicol.co.uk"
15
15
  s.executables = ["spire"]
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: spire
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.10
4
+ version: 0.4.11
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-08-29 00:00:00.000000000 Z
12
+ date: 2012-08-30 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rack
@@ -132,7 +132,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
132
132
  version: '0'
133
133
  segments:
134
134
  - 0
135
- hash: 3764740053052310701
135
+ hash: -1340064074791021364
136
136
  required_rubygems_version: !ruby/object:Gem::Requirement
137
137
  none: false
138
138
  requirements: