stumb 0.0.4 → 0.1.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 (4) hide show
  1. data/Rakefile +1 -1
  2. data/lib/stumb.rb +10 -5
  3. data/lib/stumb/servlet.rb +18 -0
  4. metadata +14 -4
data/Rakefile CHANGED
@@ -55,7 +55,7 @@ spec = Gem::Specification.new do |s|
55
55
  s.require_path = "lib"
56
56
  s.test_files = Dir["test/*_test.rb"]
57
57
 
58
- #s.add_dependency('activesupport', '>=1.3.1')
58
+ s.add_dependency('sinatra', '>=0.9.4')
59
59
  #s.required_ruby_version = '>= 1.8.2'
60
60
 
61
61
  s.files = %w(Rakefile) +
@@ -5,19 +5,24 @@ module Stumb
5
5
  autoload :Stub, 'stumb/stub'
6
6
  autoload :Stamp, 'stumb/stamp'
7
7
  autoload :StampSheet, 'stumb/stamp_sheet'
8
+ autoload :Servlet, 'stumb/servlet'
8
9
 
9
- Version = '0.0.4'
10
+ Version = '0.1.0'
10
11
 
11
- def to_app(response, sheet_path = "/sheet", &block)
12
+ def to_app(sheet_path = "/sheet", &block)
12
13
  Rack::Builder.new {
13
14
  use Rack::ShowExceptions
14
15
 
15
- stub = Stub.new(*response)
16
+ stub = Stub.new(200, {}, "")
16
17
  sheet = StampSheet.new(stub)
17
18
 
18
19
  map(sheet_path) { run sheet }
19
- yield self, stub if block_given?
20
- map("/") { run stub }
20
+
21
+ sinatra = Class.new(Servlet)
22
+ sinatra.storage = stub
23
+ sinatra.class_eval(&block)
24
+
25
+ map("/") { run sinatra }
21
26
  }
22
27
  end
23
28
  module_function :to_app
@@ -0,0 +1,18 @@
1
+ require 'sinatra'
2
+
3
+ module Stumb
4
+ class Servlet < Sinatra::Base
5
+ def self.store(req)
6
+ @store.stamps << Stamp.new(req.dup)
7
+ end
8
+
9
+ def self.storage=(store)
10
+ @store = store
11
+ end
12
+
13
+ def stump!
14
+ self.class.store(@request)
15
+ end
16
+ end
17
+ end
18
+
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: stumb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - moro
@@ -9,10 +9,19 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-11-05 00:00:00 +09:00
12
+ date: 2009-11-09 00:00:00 +09:00
13
13
  default_executable:
14
- dependencies: []
15
-
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: sinatra
17
+ type: :runtime
18
+ version_requirement:
19
+ version_requirements: !ruby/object:Gem::Requirement
20
+ requirements:
21
+ - - ">="
22
+ - !ruby/object:Gem::Version
23
+ version: 0.9.4
24
+ version:
16
25
  description: store and show stubbed web-request.
17
26
  email: moronatural@gmail.com
18
27
  executables: []
@@ -23,6 +32,7 @@ extra_rdoc_files: []
23
32
 
24
33
  files:
25
34
  - Rakefile
35
+ - lib/stumb/servlet.rb
26
36
  - lib/stumb/sheet.html.haml
27
37
  - lib/stumb/stamp.rb
28
38
  - lib/stumb/stamp_sheet.rb