stumb 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
data/lib/stumb.rb CHANGED
@@ -6,7 +6,7 @@ module Stumb
6
6
  autoload :Stamp, 'stumb/stamp'
7
7
  autoload :StampSheet, 'stumb/stamp_sheet'
8
8
 
9
- Version = '0.0.3'
9
+ Version = '0.0.4'
10
10
 
11
11
  def to_app(response, sheet_path = "/sheet", &block)
12
12
  Rack::Builder.new {
@@ -0,0 +1,86 @@
1
+ :ruby
2
+ title = "#{stamps.size} requests - Stumb, stub and show requests."
3
+ !!!
4
+ %html
5
+ %head
6
+ %title&= title
7
+ %script{:src=>"http://ajax.googleapis.com/ajax/libs/jquery/1.3.1/jquery.min.js"}
8
+ %style{:type=>"text/css"}
9
+ :sass
10
+ body
11
+ width: 80%
12
+ margin: auto
13
+
14
+ h1
15
+ font-size: 10px
16
+
17
+ div.stump
18
+ font-size: 10px
19
+ border: 1px solid silver
20
+ padding: 0 1em
21
+
22
+ h2
23
+ font-size: 10px
24
+ color: gray
25
+
26
+ span.method, span.path
27
+ font-size: 16px
28
+ font-weight: normal
29
+ font-family: 'Courier', monospace
30
+
31
+ span.method
32
+ color: #090
33
+
34
+ span.path
35
+ color: black
36
+
37
+ span.time, span.source
38
+ color: blue
39
+
40
+ h3
41
+ font-size: small
42
+ border-bottom: 1px solid green
43
+ background: #cfb
44
+ padding: 2px 0 0 2px
45
+
46
+ .headers table, div.body pre
47
+ border: 1px dashed green
48
+ margin: 1em
49
+ padding: 1em
50
+
51
+ div.body pre
52
+ overflow: auto
53
+ font-size: 12px
54
+ %body
55
+ %h1&= title
56
+ - stamps.reverse.each do |stamp|
57
+ %div.stump{:id => stamp.object_id}
58
+ %h2
59
+ %span.method&= stamp.request.request_method
60
+ %span.path&= stamp.request.fullpath
61
+ on
62
+ %span.time&= stamp.time.iso8601
63
+ from
64
+ %span.source&= stamp.request.ip
65
+ %div
66
+ .headers
67
+ %h3 Headers
68
+ %table
69
+ - stamp.request.env.each do |k,v|
70
+ - next if k =~ /\A[a-z]/
71
+ %tr
72
+ %th&= k
73
+ %td&= v
74
+
75
+ - unless stamp.request.get?
76
+ .body
77
+ %h3 Body
78
+ %pre&= stamp.body.gsub(/(?:\r)?\n/, "\r\n")
79
+
80
+ :javascript
81
+ jQuery(function(){
82
+ $("div.stump .headers h3").click(function(){ $(this).next("table").toggle() });
83
+ $("div.stump .body h3").click(function(){ $(this).next("pre").toggle() });
84
+ $("div.stump .headers table").hide();
85
+ $("div.stump .body pre").hide();
86
+ });
@@ -5,25 +5,16 @@ module Stumb
5
5
  class StampSheet
6
6
  def initialize(stub)
7
7
  @stub = stub
8
- @haml = Haml::Engine.new(<<HAML)
9
- !!!
10
- %html
11
- %head
12
- %body
13
- %h1 Requests
14
- %table
15
- - stamps.each do |stamp|
16
- %tr
17
- %td&= stamp.time.iso8601
18
- %td&= stamp.request.ip
19
- %td&= stamp.request.request_method
20
- %td&= stamp.request.fullpath
21
- %td&= stamp.body
22
- HAML
23
8
  end
24
9
 
25
10
  def call(env)
26
- [200, {"Content-Type" => "text/html"}, @haml.render(@stub)]
11
+ [200, {"Content-Type" => "text/html"}, template.render(@stub)]
12
+ end
13
+
14
+ private
15
+ def template
16
+ path = ::File.expand_path("sheet.html.haml", ::File.dirname(__FILE__))
17
+ Haml::Engine.new(::File.read(path))
27
18
  end
28
19
  end
29
20
  end
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.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - moro
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-10-27 00:00:00 +09:00
12
+ date: 2009-11-05 00:00:00 +09:00
13
13
  default_executable:
14
14
  dependencies: []
15
15
 
@@ -23,6 +23,7 @@ extra_rdoc_files: []
23
23
 
24
24
  files:
25
25
  - Rakefile
26
+ - lib/stumb/sheet.html.haml
26
27
  - lib/stumb/stamp.rb
27
28
  - lib/stumb/stamp_sheet.rb
28
29
  - lib/stumb/stub.rb