http_archive 0.0.1 → 0.0.2

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.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- MTFmYzE0ZGM5ZGNjNzdhZmU2ZjJiMWY2OTdkZGYwN2UzNzg4YWE3ZA==
4
+ ZmYyMWJmMTFkODE5MjM4YWY5ZjM5YTJmMjQzYzZkYmU1YWMyNDI3ZA==
5
5
  data.tar.gz: !binary |-
6
- N2E1NTIyOWQ2MWY0NmZlZmFhNGI0MDBhNGU0YmMxMjRkNzMxOWQ4Yw==
6
+ MzIyZjkxNWY1MjM4ZDZiNjY0MDhhMzNjNWFmMWE0ZTFmMTRmNjQyMg==
7
7
  !binary "U0hBNTEy":
8
8
  metadata.gz: !binary |-
9
- NjY0YjU3NDg2NThhYzFmNDYyYmMyOTg3Yzc4YjgyOGMyMDQ1NWQ0YmQ5YjU0
10
- MWRiMGY3MDExMTEzZjU5ZjRjMWRmNjhjZjFjNTNjYjA1ZGM0OWZhNWM3MzE0
11
- NGVkYjJiOWEyZTZlZGVkMmUxYjc0YzRiZmFiNTk2NWM4OGFiYjc=
9
+ ZTcyN2MyNzM2MGU0NTczZTZlOTJkZGUwMzQ0YzQwZWE2MzUzMGY3YjgwZGJj
10
+ ZjZmMDkxYWRhMTc5YWEwZTIzNTY3MjBjODU5ZTgyYmQ1MzdlMDU3YTdkNGQ1
11
+ NmUzZTI5YzUyZGQ2ZGM1ZjVmNDZkODFlZjhlYTA0ZGVkOWMzYmQ=
12
12
  data.tar.gz: !binary |-
13
- ZTcwNmRhYTcxYzEyMDRhZjdiMDQ2YjMyZDdhODY0NjljMjg2Y2FhNGY0MTk0
14
- ODllMzAwM2JlOWMyN2Y4ZTgxNjUyZDA1YmE1NzZhNTY4Njc5OTU4ZDUxMjhi
15
- NTVjOTRhZjU5ODhkMWFiYjZhMmU0NmU3ZjQ2ODA2N2E1ZDk3Yjk=
13
+ MjJmYWYwOWViMzE2YmE3NGZiZTk3NWI2N2I3YmMyZjA0OTRiMjg1MmNkM2Qx
14
+ ZTY2OTRjNWFhYTZkN2FlNmM4ZjE5NTk0MmY1YTRmNDg4OGIyZWRkZmFhYWE4
15
+ ODdjOTc1ZjhiMTcyODMwMzY1MDA5OTdmNjIyNzI1YzliMTUwYzc=
@@ -52,22 +52,39 @@ module HttpArchive
52
52
  # @return [String] A string table representation of the archive data
53
53
  def print_table
54
54
  puts
55
- size = calc_total_size.to_s
56
- load_time = (@pages.first.on_load / 1000.0).to_s
57
55
 
58
- puts("Metrics for: " +"'" + @pages.first.title + "', " + @entries.size.to_s + " Requests, " + size + "MB downloaded. " + "Load time: " + load_time + "s")
59
- puts
56
+ data = get_total_data
57
+ puts("Metrics for: " +"'" + data[0] + "', " + data[1] + " Requests, " + data[2] + "MB downloaded. " + "Load time: " + data[3] + "s")
60
58
 
61
- @entries.each do |entry|
62
- print_row(entry)
63
- end
59
+ puts
60
+ print_rows
64
61
  puts
65
62
  end
66
63
 
67
64
 
68
- private
69
- def print_row(entry)
65
+ # Gets the common data for a page.
66
+ # Convenience method that can be used for bulk reading of page data.
67
+ # @return [Array<page_title, ressource_count, total_download_size, overall_load_time>] An array with page data
68
+ # @example Example of returned Array
69
+ # ["Software is hard", "26", "0.36", "6.745"]
70
+ def get_total_data
71
+ size = calc_total_size.to_s
72
+ load_time = (@pages.first.on_load / 1000.0).to_s
73
+
74
+ [@pages.first.title, @entries.size.to_s, size, load_time]
75
+ end
76
+
77
+
78
+ # Gets the data for a row for all entries.
79
+ # Convenience method that can be used for bulk reading of entry data.
80
+ # @return [Array<Array<html_method, ressource_name, status_name, status_code, ressource_size, load_duration>>] An array with row data
81
+ # @example Example of returned Array
82
+ # [["GET", "/prototype.js?ver=1.6.1", "200", "OK", "139.85", "1.06"], ... ]
83
+ def get_row_data
84
+ rows = []
85
+ @entries.each do |entry|
70
86
  method = entry.request.http_method
87
+ # get part after .com/ if any
71
88
  url = entry.request.url
72
89
  if url.end_with?("/")
73
90
  ressource = entry.request.url
@@ -75,13 +92,25 @@ module HttpArchive
75
92
  r = url.rindex("/")
76
93
  ressource = url[r..-1]
77
94
  end
95
+ # first 30 characters of the ressource name
78
96
  ressource = ressource[0, 30]
79
97
  status = entry.response.status.to_s
80
98
  code = entry.response.status_text
81
99
  size = (entry.response.content['size'] / 1000.0).round(2).to_s
82
100
  duration = (entry.time / 1000.0).to_s
83
101
 
84
- puts "%s %-32s %s %-20s %-10s %s" % [method, ressource, status, code, size + " KB", duration +"s"]
102
+ rows << [method, ressource, status, code, size, duration]
103
+ end
104
+ rows
105
+ end
106
+
107
+
108
+ private
109
+ def print_rows
110
+ rows = get_row_data
111
+ rows.each do |row|
112
+ puts "%s %-32s %s %-20s %-10s %s" % [row[0], row[1], row[2], row[3], row[4] + " KB", row[5] +"s"]
113
+ end
85
114
  end
86
115
 
87
116
  def calc_total_size
@@ -1,3 +1,4 @@
1
1
  module HttpArchive
2
- VERSION = "0.0.1"
2
+ # Gem version
3
+ VERSION = "0.0.2"
3
4
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: http_archive
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alexander Huber
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-06-01 00:00:00.000000000 Z
11
+ date: 2013-06-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -73,10 +73,10 @@ executables: []
73
73
  extensions: []
74
74
  extra_rdoc_files: []
75
75
  files:
76
- - lib/http_archive.rb
77
- - lib/http_archive/archive.rb
78
- - lib/http_archive/classes.rb
79
76
  - lib/http_archive/version.rb
77
+ - lib/http_archive/classes.rb
78
+ - lib/http_archive/archive.rb
79
+ - lib/http_archive.rb
80
80
  homepage: http://github.com/alihuber/http_archive
81
81
  licenses:
82
82
  - MIT