catalyst 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.2
1
+ 0.0.3
data/catalyst.gemspec CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{catalyst}
8
- s.version = "0.0.2"
8
+ s.version = "0.0.3"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Ari Lerner"]
data/lib/catalyst.rb CHANGED
@@ -4,6 +4,10 @@ require 'moneta'
4
4
  module Catalyst
5
5
  autoload :Runner, 'catalyst/runner'
6
6
 
7
+ def self.run_stack(&block)
8
+ RunStack.new(&block)
9
+ end
10
+
7
11
  class RunStack
8
12
 
9
13
  # Start a RunStack with a block
@@ -26,18 +30,13 @@ module Catalyst
26
30
  self
27
31
  end
28
32
 
29
- # run is just another term for 'use'
30
- def run
31
- @run = app
32
- end
33
-
34
33
  # Turn this RunStack to a Runner
35
34
  def to_app
36
35
  Runner.new(stack)
37
36
  end
38
37
 
39
38
  # Start off the middleware
40
- def call(env)
39
+ def call(env={})
41
40
  to_app.call(env)
42
41
  end
43
42
  end
@@ -7,11 +7,11 @@ module Catalyst
7
7
  @actions = actions.map {|act| setup_action(act) }
8
8
  end
9
9
 
10
- def call(env)
11
- return if @actions.empty?
10
+ def call(env={})
11
+ return if actions.empty?
12
12
 
13
13
  begin
14
- action = @history.unshift(@actions.shift).first
14
+ action = history.unshift(@actions.shift).first
15
15
  action.call(env)
16
16
  rescue Exception => e
17
17
  env["catalyst.error"] = e
@@ -26,8 +26,7 @@ module Catalyst
26
26
  klass.new(self, *args, &block)
27
27
  elsif klass.respond_to?(:call)
28
28
  lambda do |env|
29
- klass.call(env)
30
- self.call(env)
29
+ self.call(klass.call(env))
31
30
  end
32
31
  else
33
32
  raise
@@ -39,5 +39,16 @@ class TestCatalyst < Test::Unit::TestCase
39
39
  assert @@filtered_through_stack
40
40
  end
41
41
 
42
+ should "be able to define a Catalyst run_Stack from the module" do
43
+ @@count = 0
44
+ rs = Catalyst.run_stack do
45
+ use lambda {|env| @@count += 1}
46
+ use lambda {|env| @@count += 1}
47
+ use lambda {|env| @@count += 1}
48
+ end
49
+ rs.call()
50
+ assert_equal @@count, 3
51
+ end
52
+
42
53
  end
43
54
  end
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: catalyst
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.0.2
5
+ version: 0.0.3
6
6
  platform: ruby
7
7
  authors:
8
8
  - Ari Lerner