siege_siege 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/siege_siege.rb +1 -1
- data/lib/siege_siege/configuration.rb +6 -5
- data/lib/siege_siege/line_log.rb +3 -2
- data/lib/siege_siege/result.rb +8 -4
- data/lib/siege_siege/runner.rb +3 -1
- data/lib/siege_siege/url.rb +5 -1
- data/lib/siege_siege/version.rb +1 -1
- data/server.rb +5 -0
- data/siege_siege.gemspec +3 -3
- metadata +8 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 70866f87a2fcd4cca4caac9056972a42e7ece940
|
4
|
+
data.tar.gz: a0e7f3ab530526ae952e1335759cb4e782f27d0d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fdc897705ac132d4ed5d3d6139116c638e9e87d493ac870cf1ebee963b5ee37b8b48b5d88b9d07486ddfe94597a2a1939842c76ca55cb14dfb0d69ee5004ed3e
|
7
|
+
data.tar.gz: 73e03d95df77e5177f6b71486fc6176de42df5021b08de12787216f0722f9a201fd1f65d6cf7a3e78c6f30af8f35cd51ba39a16795972ae31eee90a3214234e7
|
data/lib/siege_siege.rb
CHANGED
@@ -1,4 +1,3 @@
|
|
1
|
-
require 'siege_siege/version'
|
2
1
|
require 'open3'
|
3
2
|
require 'tempfile'
|
4
3
|
require 'csv'
|
@@ -6,6 +5,7 @@ require 'pp'
|
|
6
5
|
require 'active_support'
|
7
6
|
require 'active_support/core_ext'
|
8
7
|
|
8
|
+
require 'siege_siege/version'
|
9
9
|
require 'siege_siege/average_log'
|
10
10
|
require 'siege_siege/configuration'
|
11
11
|
require 'siege_siege/line_log'
|
@@ -66,12 +66,13 @@ module SiegeSiege
|
|
66
66
|
end
|
67
67
|
|
68
68
|
def rc
|
69
|
-
RC_MAP.inject('') do |a, (key,
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
else
|
69
|
+
RC_MAP.inject('') do |a, (key, default)|
|
70
|
+
value = @configuration[key]
|
71
|
+
inserting = value.nil? ? default : value
|
72
|
+
if inserting.nil?
|
74
73
|
a
|
74
|
+
else
|
75
|
+
a << "#{key.to_s.gsub('_', '-')} = #{inserting}\n"
|
75
76
|
end
|
76
77
|
end
|
77
78
|
end
|
data/lib/siege_siege/line_log.rb
CHANGED
@@ -1,13 +1,14 @@
|
|
1
1
|
module SiegeSiege
|
2
|
-
class LineLog < Struct.new(:
|
2
|
+
class LineLog < Struct.new(:protocol, :status, :secs, :bytes, :url, :id, :date, :siege_url)
|
3
3
|
def initialize(*)
|
4
4
|
super
|
5
5
|
|
6
|
-
raise InvalidLine unless
|
6
|
+
raise InvalidLine unless date
|
7
7
|
|
8
8
|
self.secs = secs.to_f
|
9
9
|
self.bytes = bytes.to_i
|
10
10
|
self.id = id.to_i
|
11
|
+
self.date = DateTime.parse(date)
|
11
12
|
end
|
12
13
|
|
13
14
|
def take_in_detail(url_map)
|
data/lib/siege_siege/result.rb
CHANGED
@@ -1,14 +1,19 @@
|
|
1
1
|
module SiegeSiege
|
2
2
|
class Result
|
3
|
+
|
4
|
+
|
3
5
|
def initialize(command, urls, raw, raw_result)
|
4
6
|
@command = command
|
5
7
|
@raw = raw
|
6
8
|
@raw_result = raw_result
|
9
|
+
|
10
|
+
offset = 0
|
7
11
|
@url_map = urls.each_with_index.inject({}) do |a, (url, index)|
|
8
|
-
a.merge!(index => url)
|
12
|
+
a.merge!((index + offset) => url).tap do
|
13
|
+
# if the http method is POST, skip one step (why?)
|
14
|
+
offset += 1 if url.post?
|
15
|
+
end
|
9
16
|
end
|
10
|
-
|
11
|
-
#puts raw
|
12
17
|
end
|
13
18
|
|
14
19
|
def total_result
|
@@ -36,7 +41,6 @@ module SiegeSiege
|
|
36
41
|
.gsub(/\e.+?m/, '')
|
37
42
|
.gsub('[', '')
|
38
43
|
.gsub(']', '')
|
39
|
-
.gsub(' ', '')
|
40
44
|
.split("\n")
|
41
45
|
.map { |line| LineLog.new(*line.split(',')).take_in_detail(@url_map) rescue nil }
|
42
46
|
.compact
|
data/lib/siege_siege/runner.rb
CHANGED
@@ -16,8 +16,10 @@ module SiegeSiege
|
|
16
16
|
verbose: true,
|
17
17
|
rc: @rc_file.path,
|
18
18
|
csv: true,
|
19
|
-
display_id:
|
19
|
+
display_id: false,
|
20
20
|
quiet: false,
|
21
|
+
follow_location: false,
|
22
|
+
timestamp: false,
|
21
23
|
file: raw_configuration[:url] ? nil : @urls_file.path
|
22
24
|
)
|
23
25
|
).tap do |conf|
|
data/lib/siege_siege/url.rb
CHANGED
data/lib/siege_siege/version.rb
CHANGED
data/server.rb
CHANGED
@@ -12,5 +12,10 @@ WEBrick::HTTPServer.new(
|
|
12
12
|
Logger: WEBrick::Log::new("/dev/null", 7)
|
13
13
|
).tap do |server|
|
14
14
|
Signal.trap(:INT) { server.shutdown }
|
15
|
+
|
16
|
+
server.mount_proc('/redirect') do |req, res|
|
17
|
+
res.set_redirect(WEBrick::HTTPStatus::MovedPermanently, '/')
|
18
|
+
end
|
19
|
+
|
15
20
|
server.start
|
16
21
|
end
|
data/siege_siege.gemspec
CHANGED
@@ -21,7 +21,7 @@ Gem::Specification.new do |spec|
|
|
21
21
|
|
22
22
|
spec.add_dependency 'activesupport'
|
23
23
|
|
24
|
-
spec.add_development_dependency "bundler", "
|
25
|
-
spec.add_development_dependency "rake", "
|
26
|
-
spec.add_development_dependency "rspec", "
|
24
|
+
spec.add_development_dependency "bundler", ">= 1.11"
|
25
|
+
spec.add_development_dependency "rake", ">= 10.0"
|
26
|
+
spec.add_development_dependency "rspec", ">= 3.0"
|
27
27
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: siege_siege
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- mmmpa
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-10-
|
11
|
+
date: 2016-10-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -28,42 +28,42 @@ dependencies:
|
|
28
28
|
name: bundler
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - "
|
31
|
+
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '1.11'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- - "
|
38
|
+
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '1.11'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: rake
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- - "
|
45
|
+
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: '10.0'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- - "
|
52
|
+
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '10.0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: rspec
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- - "
|
59
|
+
- - ">="
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: '3.0'
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- - "
|
66
|
+
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '3.0'
|
69
69
|
description: siege wrapper
|