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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 61a8221e13d4085e5cfd876ba6f39e42f9bff7d4
4
- data.tar.gz: fe46819a05c8e586cddfb5be20857c25df2ef5ae
3
+ metadata.gz: 70866f87a2fcd4cca4caac9056972a42e7ece940
4
+ data.tar.gz: a0e7f3ab530526ae952e1335759cb4e782f27d0d
5
5
  SHA512:
6
- metadata.gz: 08801251141e63fd9a19a5750f4ecbc6657b99ed7107b714d4b08cda3bab423fd6a781b63c3e650c094564d68cf9cc13cd3a32fc5235a1e9509aae6b43756db8
7
- data.tar.gz: d295da59d3a1e9bcc6817790355947b082f27d13c22ee3b7f5d805b32d284850b3ed4f5aadd64138ea9ba1730f560e83f859a55ba4379b43e1f926da723bc538
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, value)|
70
- inserting = @configuration[key] || value
71
- if inserting
72
- a << "#{key.to_s.gsub('_', '-')} = #{inserting}\n"
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
@@ -1,13 +1,14 @@
1
1
  module SiegeSiege
2
- class LineLog < Struct.new(:week_day, :date, :protocol, :status, :secs, :bytes, :url, :id, :date2, :siege_url)
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 date2
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)
@@ -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
@@ -16,8 +16,10 @@ module SiegeSiege
16
16
  verbose: true,
17
17
  rc: @rc_file.path,
18
18
  csv: true,
19
- display_id: true,
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|
@@ -27,8 +27,12 @@ module SiegeSiege
27
27
  end
28
28
  end
29
29
 
30
+ def post?
31
+ http_method.to_s.downcase == 'post'
32
+ end
33
+
30
34
  def to_siege_url
31
- if http_method && http_method.to_s.downcase == 'post'
35
+ if post?
32
36
  [url, 'POST', parameter_string]
33
37
  else
34
38
  url
@@ -1,3 +1,3 @@
1
1
  module SiegeSiege
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.2"
3
3
  end
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", "~> 1.11"
25
- spec.add_development_dependency "rake", "~> 10.0"
26
- spec.add_development_dependency "rspec", "~> 3.0"
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.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-29 00:00:00.000000000 Z
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