request_recorder 0.0.9 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile CHANGED
@@ -2,6 +2,7 @@ source :rubygems
2
2
  gemspec
3
3
 
4
4
  gem "appraisal"
5
+ gem "bump"
5
6
  gem "rake"
6
7
  gem "rspec", "~>2"
7
8
  gem "activerecord"
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- request_recorder (0.0.9)
4
+ request_recorder (0.1.0)
5
5
  activerecord
6
6
  rack
7
7
 
@@ -14,6 +14,7 @@ GEM
14
14
  appraisal (0.4.1)
15
15
  bundler
16
16
  rake
17
+ bump (0.3.5)
17
18
  diff-lcs (1.1.3)
18
19
  fakeredis (0.4.0)
19
20
  redis (~> 3.0.0)
@@ -36,6 +37,7 @@ PLATFORMS
36
37
  DEPENDENCIES
37
38
  activerecord
38
39
  appraisal
40
+ bump
39
41
  fakeredis
40
42
  rake
41
43
  request_recorder!
data/Rakefile CHANGED
@@ -1,4 +1,5 @@
1
1
  require "bundler/gem_tasks"
2
+ require "bump/tasks"
2
3
  require "appraisal"
3
4
 
4
5
  task :spec do
@@ -8,20 +9,3 @@ end
8
9
  task :default do
9
10
  sh "bundle exec rake appraisal:install && bundle exec rake appraisal spec"
10
11
  end
11
-
12
- # extracted from https://github.com/grosser/project_template
13
- rule /^version:bump:.*/ do |t|
14
- file = "lib/request_recorder/version.rb"
15
-
16
- sh "git status | grep 'nothing to commit'" # ensure we are not dirty
17
- index = ["major", "minor", "patch"].index(t.name.split(':').last)
18
- version_file = File.read(file)
19
- old_version, *version_parts = version_file.match(/(\d+)\.(\d+)\.(\d+)/).to_a
20
- version_parts[index] = version_parts[index].to_i + 1
21
- version_parts[2] = 0 if index < 2 # remove patch for minor
22
- version_parts[1] = 0 if index < 1 # remove minor for major
23
- new_version = version_parts * '.'
24
-
25
- File.open(file,"w"){|f| f.write(version_file.sub(old_version, new_version)) }
26
- sh "bundle && git add #{file} Gemfile.lock && git commit -m 'bump version to #{new_version}'"
27
- end
data/Readme.md CHANGED
@@ -20,7 +20,7 @@ Add to your middleware stack:
20
20
  Usage
21
21
  =====
22
22
 
23
- - request a page with `/something?__request_recording=10|my-session-name` -> record next 10 requests from my browser
23
+ - request a page with `/something?request_recorder=10|my-session-name` -> record next 10 requests from my browser
24
24
  - redis 'request_recorder' gets a new entry with all the logging info from rails + activerecord
25
25
  - go to redis or build a nice frontend
26
26
 
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: /Users/mgrosser/code/tools/request_recorder
3
3
  specs:
4
- request_recorder (0.0.8)
4
+ request_recorder (0.0.9)
5
5
  activerecord
6
6
  rack
7
7
 
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: /Users/mgrosser/code/tools/request_recorder
3
3
  specs:
4
- request_recorder (0.0.8)
4
+ request_recorder (0.0.9)
5
5
  activerecord
6
6
  rack
7
7
 
@@ -6,7 +6,7 @@ require "active_record"
6
6
 
7
7
  module RequestRecorder
8
8
  class Middleware
9
- MARKER = "__request_recording"
9
+ MARKER = "request_recorder"
10
10
  MAX_STEPS = 100
11
11
  SEPARATOR = "|"
12
12
  NEED_AUTOFLUSH = (ActiveRecord::VERSION::MAJOR == 2)
@@ -29,7 +29,7 @@ module RequestRecorder
29
29
  end
30
30
 
31
31
  steps_left, id = read_state_from_env(env)
32
- return [500, {}, "__request_recording exceeded maximum value #{MAX_STEPS}"] if steps_left > MAX_STEPS
32
+ return [500, {}, "#{MARKER} exceeded maximum value #{MAX_STEPS}"] if steps_left > MAX_STEPS
33
33
  id = persist_log(id, log)
34
34
  response_with_data_in_cookie(result, steps_left, id)
35
35
  end
@@ -1,3 +1,3 @@
1
1
  module RequestRecorder
2
- VERSION = "0.0.9"
2
+ VERSION = "0.1.0"
3
3
  end
@@ -2,7 +2,7 @@ require "spec_helper"
2
2
 
3
3
  describe RequestRecorder do
4
4
  let(:original_logger){ ActiveSupport::BufferedLogger.new("/dev/null").instance_variable_get("@log") }
5
- let(:activate_logger){ {"QUERY_STRING" => "__request_recording=10"} }
5
+ let(:activate_logger){ {"QUERY_STRING" => "request_recorder=10"} }
6
6
  let(:inner_app){ lambda{|env|
7
7
  Car.first
8
8
  [200, {}, "assadasd"]
@@ -47,12 +47,12 @@ describe RequestRecorder do
47
47
  end
48
48
 
49
49
  it "starts with a given key" do
50
- middleware.call({"QUERY_STRING" => "__request_recording=10|abcdefg"})
50
+ middleware.call({"QUERY_STRING" => "request_recorder=10|abcdefg"})
51
51
  redis.hget(redis_key, "abcdefg").should include "SELECT"
52
52
  end
53
53
 
54
54
  it "blows up if you go over the maximum" do
55
- status, headers, body = middleware.call("QUERY_STRING" => "__request_recording=99999")
55
+ status, headers, body = middleware.call("QUERY_STRING" => "request_recorder=99999")
56
56
  status.should == 500
57
57
  body.should include "maximum"
58
58
  end
@@ -61,12 +61,12 @@ describe RequestRecorder do
61
61
  it "sets cookie in first step" do
62
62
  status, headers, body = middleware.call(activate_logger)
63
63
  generated_id = stored.keys.last
64
- headers["Set-Cookie"].should include "__request_recording=9%7C#{generated_id.gsub(":", "%3A").gsub(" ", "+")}; expires="
64
+ headers["Set-Cookie"].should include "request_recorder=9%7C#{generated_id.gsub(":", "%3A").gsub(" ", "+")}; expires="
65
65
  headers["Set-Cookie"].should include "; HttpOnly"
66
66
  end
67
67
 
68
68
  it "appends to existing log" do
69
- middleware.call("HTTP_COOKIE" => "__request_recording=8|#{existing_request_id}")
69
+ middleware.call("HTTP_COOKIE" => "request_recorder=8|#{existing_request_id}")
70
70
  existing_request = redis.hget(redis_key, existing_request_id)
71
71
  existing_request.should include "SELECT"
72
72
  existing_request.should include "BEFORE"
@@ -75,24 +75,24 @@ describe RequestRecorder do
75
75
  it "creates a new log if redis dies" do
76
76
  existing_request_id # store key
77
77
  redis.flushall
78
- middleware.call("HTTP_COOKIE" => "__request_recording=8|#{existing_request_id}")
78
+ middleware.call("HTTP_COOKIE" => "request_recorder=8|#{existing_request_id}")
79
79
  existing_request = redis.hget(redis_key, existing_request_id)
80
80
  existing_request.should include "SELECT"
81
81
  existing_request.should_not include "BEFORE"
82
82
  end
83
83
 
84
84
  it "decrements cookie on each step" do
85
- status, headers, body = middleware.call("HTTP_COOKIE" => "__request_recording=2|#{existing_request_id};foo=bar")
86
- headers["Set-Cookie"].should include "__request_recording=1%7C#{existing_request_id}; expires="
85
+ status, headers, body = middleware.call("HTTP_COOKIE" => "request_recorder=2|#{existing_request_id};foo=bar")
86
+ headers["Set-Cookie"].should include "request_recorder=1%7C#{existing_request_id}; expires="
87
87
  end
88
88
 
89
89
  it "removes cookie if final step is reached" do
90
- status, headers, body = middleware.call("HTTP_COOKIE" => "__request_recording=1|#{existing_request_id};foo=bar")
91
- headers["Set-Cookie"].should include "__request_recording=; expires="
90
+ status, headers, body = middleware.call("HTTP_COOKIE" => "request_recorder=1|#{existing_request_id};foo=bar")
91
+ headers["Set-Cookie"].should include "request_recorder=; expires="
92
92
  end
93
93
  end
94
94
 
95
- it "should not record if __request_recording is not given" do
95
+ it "should not record if request_recorder is not given" do
96
96
  middleware.call(
97
97
  "QUERY_STRING" => "stuff=hello", "HTTP_COOKIE" => "bar=foo"
98
98
  )
@@ -118,7 +118,7 @@ describe RequestRecorder do
118
118
  stored.size.should == 0
119
119
 
120
120
  # request 1 - start + decrement + log
121
- status, headers, body = middleware.call({"QUERY_STRING" => "__request_recording=3"})
121
+ status, headers, body = middleware.call({"QUERY_STRING" => "request_recorder=3"})
122
122
  stored.size.should == 1
123
123
  stored.values.last.scan("SELECT").size.should == 1
124
124
  cookie = headers["Set-Cookie"].split(";").first
@@ -134,7 +134,7 @@ describe RequestRecorder do
134
134
  stored.size.should == 1
135
135
  stored.values.last.scan("SELECT").size.should == 3
136
136
  cookie = headers["Set-Cookie"].split(";").first
137
- cookie.should == "__request_recording="
137
+ cookie.should == "request_recorder="
138
138
 
139
139
  # request 4 - no more logging
140
140
  status, headers, body = middleware.call({})
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: request_recorder
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.9
4
+ version: 0.1.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-10-21 00:00:00.000000000 Z
12
+ date: 2012-11-03 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rack
@@ -85,7 +85,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
85
85
  version: '0'
86
86
  segments:
87
87
  - 0
88
- hash: 1368709697939297046
88
+ hash: -3301936430759891302
89
89
  required_rubygems_version: !ruby/object:Gem::Requirement
90
90
  none: false
91
91
  requirements:
@@ -94,7 +94,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
94
94
  version: '0'
95
95
  segments:
96
96
  - 0
97
- hash: 1368709697939297046
97
+ hash: -3301936430759891302
98
98
  requirements: []
99
99
  rubyforge_project:
100
100
  rubygems_version: 1.8.24