cuba 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
data/cuba.gemspec CHANGED
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = "cuba"
3
- s.version = "0.0.3"
3
+ s.version = "0.0.4"
4
4
  s.summary = "Rum based microframework for web applications."
5
5
  s.description = "Cuba is a light wrapper for Rum, a microframework for Rack applications."
6
6
  s.authors = ["Michel Martens"]
data/lib/cuba.rb CHANGED
@@ -3,7 +3,10 @@ require "cuba/ron"
3
3
 
4
4
  module Cuba
5
5
  def self.define(&block)
6
- @app = Ron.new(&block)
6
+ @app = Rack::Builder.new do
7
+ use Rack::Session::Cookie
8
+ run Cuba::Ron.new(&block)
9
+ end
7
10
  end
8
11
 
9
12
  def self.call(env)
data/lib/cuba/ron.rb CHANGED
@@ -13,5 +13,9 @@ module Cuba
13
13
  Tilt::HamlTemplate.new("#{template}.haml")
14
14
  }.render(self, locals)
15
15
  end
16
+
17
+ def session
18
+ @session ||= env['rack.session']
19
+ end
16
20
  end
17
21
  end
data/lib/cuba/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Cuba
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
data/test/cuba_test.rb CHANGED
@@ -1,4 +1,4 @@
1
- $:.unshift(File.join("..", "lib"))
1
+ $:.unshift(File.dirname(__FILE__) + "/../lib/")
2
2
 
3
3
  require "cuba"
4
4
  require "cuba/test"
@@ -18,12 +18,17 @@ Cuba.define do
18
18
  end
19
19
 
20
20
  on default do
21
- res.redirect "/login"
21
+ if session[:user]
22
+ res.write "Hey #{session[:user]}!"
23
+ else
24
+ res.redirect "/login"
25
+ end
22
26
  end
23
27
  end
24
28
 
25
29
  on post, path("login") do
26
30
  on param("user") do |user|
31
+ session[:user] = user
27
32
  res.write "Got #{user}"
28
33
  end
29
34
  end
@@ -40,6 +45,10 @@ Cuba.test "Sample Site" do
40
45
  click_button "Login"
41
46
 
42
47
  assert_contain "Got Michel"
48
+
49
+ visit "/"
50
+
51
+ assert_contain "Hey Michel!"
43
52
  end
44
53
  end
45
54
  end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 0
8
- - 3
9
- version: 0.0.3
8
+ - 4
9
+ version: 0.0.4
10
10
  platform: ruby
11
11
  authors:
12
12
  - Michel Martens
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-04-28 00:00:00 -03:00
17
+ date: 2010-05-08 00:00:00 -03:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency