spire 0.1.10 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (5) hide show
  1. data/README.rdoc +68 -0
  2. data/VERSION +1 -1
  3. data/lib/spire/router.rb +4 -1
  4. data/spire.gemspec +1 -1
  5. metadata +12 -12
data/README.rdoc CHANGED
@@ -2,4 +2,72 @@
2
2
 
3
3
  Light controller-only rack framework with a dash of views.
4
4
 
5
+ = Installation
5
6
 
7
+ gem install spire
8
+ spire -c project_name
9
+ cd project_name && rackup
10
+
11
+ This will install spire, create a project called 'project_name' in the same directory it's run in, and then start the site.
12
+
13
+ = Usage
14
+
15
+ == Routes
16
+
17
+ Routes are used in the config.ru, they work like the old-style Rails routes:
18
+ run Spire::Router.new(path, {
19
+ "default" => "index#index", # the default route!
20
+ "/index" => "index#index",
21
+ })
22
+ The "default" route is what is opened when someone goes to '/' on your address.
23
+ "/index" => "index#index",
24
+ This would match the '/index' request to the IndexController (in app/controllers) and execute the index method in that controller.
25
+ "/foo/bar" => "foo#bar"
26
+ That would when '/foo/bar' is requested return the response found in the FooController and the value in Bar that's returned.
27
+
28
+ == Controllers
29
+
30
+ Controllers are named to tie with the routes (read above). They are stored in:
31
+ project_name/app/controllers/
32
+ And must be defined like so:
33
+ class Test < Spire::MainController
34
+
35
+ end
36
+ as a skeleton controller for the framework to use. An example response would look like this:
37
+ class Index < Spire::MainController
38
+ def index
39
+ Spire::Response.new("This is just a response")
40
+ end
41
+ end
42
+ This would display a html page with that text. The Response.new initiator could be used like so:
43
+ Spire::Response.new("<h1>This is a test page</h1>, "text/html", 200)
44
+ Where the first argument is the output, second argument is the content-type and the last the status/response code.
45
+
46
+ == Views
47
+
48
+ === HAML
49
+ HAML templates can be rendered like so:
50
+ Spire::Response.new(render("index", "haml", ["Welcome to Spire!",
51
+ "This is a base app to extend your own on. Have fun!"]))
52
+ This would load the index.haml view in:
53
+ project_name/app/views/index.haml
54
+ The first argument in the render method above is the file name, the second being the file type, and the last is the content to pass to the view. In the above example, it's an array of two strings.
55
+ To access the data in the view, you have to use the 'data' variable like so:
56
+ %title= data[0]
57
+ %h1= data[1]
58
+ This above example would use the first array entry from our render method as a title, and the second array entry for a nice big header.
59
+
60
+ === HTML
61
+ HTML are static templates to be used in your project/app, they can't use variables, nor can they execute ruby code. They can be rendered using:
62
+ Spire::Response.new(render("index", "html"))
63
+ Which would load the 'index.html' file from:
64
+ project_name/app/views/index.html
65
+ The first argument is the file name, the second being the extension.
66
+
67
+ = Coming soon...
68
+ More documentation will be coming soon as more features are being added
69
+ === Error Handler
70
+ === SASS Support
71
+ === Improved Response handler
72
+ === Lots of bugfixes
73
+ === Some secret goodes!
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.10
1
+ 0.2.0
data/lib/spire/router.rb CHANGED
@@ -13,6 +13,8 @@ module Spire
13
13
  end
14
14
 
15
15
  def route
16
+ @controller_value = nil
17
+ @action_value = nil
16
18
  if @request[:controller] == nil
17
19
  route = @routes['default'].split("#")
18
20
  @controller_value = route[0].capitalize
@@ -36,8 +38,9 @@ module Spire
36
38
  end
37
39
  unless @controller_value
38
40
  return Response.new('404 - Page or route not found!')
41
+ else
42
+ return self.run
39
43
  end
40
- return self.run
41
44
  end
42
45
 
43
46
  def run
data/spire.gemspec CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "spire"
8
- s.version = "0.1.10"
8
+ s.version = "0.2.0"
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"]
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.1.10
4
+ version: 0.2.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -13,7 +13,7 @@ date: 2011-09-27 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rack
16
- requirement: &70334205602660 !ruby/object:Gem::Requirement
16
+ requirement: &70198527649580 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: 1.3.0
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70334205602660
24
+ version_requirements: *70198527649580
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: haml
27
- requirement: &70334205602160 !ruby/object:Gem::Requirement
27
+ requirement: &70198527648940 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: 3.1.0
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *70334205602160
35
+ version_requirements: *70198527648940
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: bundler
38
- requirement: &70334205601600 !ruby/object:Gem::Requirement
38
+ requirement: &70198527642920 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ~>
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: 1.0.0
44
44
  type: :development
45
45
  prerelease: false
46
- version_requirements: *70334205601600
46
+ version_requirements: *70198527642920
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: jeweler
49
- requirement: &70334205601120 !ruby/object:Gem::Requirement
49
+ requirement: &70198527641760 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ~>
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: 1.6.4
55
55
  type: :development
56
56
  prerelease: false
57
- version_requirements: *70334205601120
57
+ version_requirements: *70198527641760
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: rcov
60
- requirement: &70334205600620 !ruby/object:Gem::Requirement
60
+ requirement: &70198527640160 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ! '>='
@@ -65,7 +65,7 @@ dependencies:
65
65
  version: '0'
66
66
  type: :development
67
67
  prerelease: false
68
- version_requirements: *70334205600620
68
+ version_requirements: *70198527640160
69
69
  description: ! "Light rack-based framework with controllers, static views and a router
70
70
  \n with templating engine support coming soon"
71
71
  email: scott@scottnicol.co.uk
@@ -105,7 +105,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
105
105
  version: '0'
106
106
  segments:
107
107
  - 0
108
- hash: 2817838242833963823
108
+ hash: -1664516455746204772
109
109
  required_rubygems_version: !ruby/object:Gem::Requirement
110
110
  none: false
111
111
  requirements: