har 0.1.2 → 0.1.3

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
- SHA1:
3
- metadata.gz: fdd3c43bc0fedf96205d3a093d60228097f8ff52
4
- data.tar.gz: fd033bb10905e2fee33ffcbf53c62e7d6763dd1a
2
+ SHA256:
3
+ metadata.gz: cc5b86787cdd8bd084aa569e18c3cbb4c51d844dbe8a0aae0b57a4b134bacbdd
4
+ data.tar.gz: b355c64418e8be8b4a124af5589c53ca54c1b3b152fd2204b690dab2b0e0d14c
5
5
  SHA512:
6
- metadata.gz: 335da8d6919e391085121cba73ea19ac3fe3d79b920fa18f065555292be0b0ba046464cfd04a49706e446308df188b03236c850d41d38d11aa233ec910e33256
7
- data.tar.gz: 53447087bc92b123478bd49007573adacd7502645d349038e90ed775e6b25dc39b297440bbfbfb9258004ea04d198840eba98a1e503e3dc694765f59e25835e0
6
+ metadata.gz: 9eefcce23f82109f605cfe4cf06b6b342ac00bc93ef1d4aca5af6ef17af04ce2d2129c07bf8efbb92946998d0fb5b9708eda9dcd796527068ad1aaf7917ff575
7
+ data.tar.gz: c34a871b539e71343761555b66f4ea352b52366f0786334959506810642908eb6c23211f1d01f8dbadb4ffa8b5b78f2b38b6b0adbb559536e3accb132442f0b9
data/lib/har.rb CHANGED
@@ -7,6 +7,7 @@ require 'har/version'
7
7
  require 'har/serializable'
8
8
  require 'har/schema_type'
9
9
  require 'har/page'
10
+ require 'har/page_timings'
10
11
  require 'har/archive'
11
12
  require 'har/viewer'
12
13
  require 'har/extensions/jschematic/attributes/format'
@@ -11,5 +11,13 @@ module HAR
11
11
  # a little sugar
12
12
  alias_method :timings, :page_timings
13
13
 
14
+ # Filter entries that *finished* before the specified time
15
+ def entries_before(time)
16
+ raise TypeError, "expected Time" unless time.is_a?(Time)
17
+ entries.select do |entry|
18
+ return false unless entry.time
19
+ entry.started_date_time + entry.time / 1000.0 < time
20
+ end
21
+ end
14
22
  end
15
23
  end
@@ -0,0 +1,18 @@
1
+ module HAR
2
+ class PageTimings < SchemaType
3
+ def initialize(input)
4
+ super(input)
5
+ @input = input
6
+ end
7
+
8
+ def custom
9
+ @custom ||= begin
10
+ # TODO: move to `transform_keys` once ruby 2.0.0 support is dropped
11
+ custom_timings = Hash[@input.select { |key| key.start_with?('_') }
12
+ .map { |key, val| [key[1..-1], val] }]
13
+
14
+ OpenStruct.new(custom_timings)
15
+ end
16
+ end
17
+ end
18
+ end
@@ -1,3 +1,3 @@
1
1
  module HAR
2
- VERSION = "0.1.2"
2
+ VERSION = "0.1.3"
3
3
  end
@@ -15,7 +15,8 @@
15
15
  "title":"Google",
16
16
  "pageTimings":{
17
17
  "onContentLoad":90,
18
- "onLoad":245
18
+ "onLoad":245,
19
+ "_customExample":123
19
20
  }
20
21
  }
21
22
  ],
@@ -18,7 +18,20 @@ module HAR
18
18
  it "has a PageTimings instance" do
19
19
  page.timings.should be_kind_of(PageTimings)
20
20
  end
21
- end
22
21
 
22
+ describe "#entries_before" do
23
+ it "requires a DateTime" do
24
+ expect { page.entries_before("a string") }.to raise_error(TypeError)
25
+ end
26
+
27
+ it "filters entries that responded before the specified time" do
28
+ time = page.started_date_time + 0.250
29
+ entries = page.entries_before(time)
30
+ entries.each do |entry|
31
+ (entry.started_date_time + entry.time / 1000.to_f).should < time
32
+ end
33
+ end
34
+ end
35
+ end
23
36
  end # Page
24
37
  end # HAR
@@ -0,0 +1,11 @@
1
+ require File.expand_path("../../spec_helper", __FILE__)
2
+
3
+ module HAR
4
+ describe PageTimings do
5
+ let(:timings) { Archive.from_file(google_path).pages.first.timings }
6
+
7
+ it "defines methods for custom timings" do
8
+ timings.custom.customExample.should == 123
9
+ end
10
+ end # PageTimings
11
+ end # HAR
metadata CHANGED
@@ -1,111 +1,111 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: har
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jari Bakken
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-02-03 00:00:00.000000000 Z
11
+ date: 2019-04-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - '>='
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
19
  version: '0'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - '>='
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: jschematic
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - '>='
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
33
  version: 0.1.0
34
34
  type: :runtime
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: 0.1.0
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: launchy
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - '>='
45
+ - - ">="
46
46
  - !ruby/object:Gem::Version
47
47
  version: 0.3.7
48
48
  type: :runtime
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: 0.3.7
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: '2.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: '2.0'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: coveralls
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - '>='
73
+ - - ">="
74
74
  - !ruby/object:Gem::Version
75
75
  version: '0'
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - '>='
80
+ - - ">="
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0'
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: rake
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
- - - ~>
87
+ - - "~>"
88
88
  - !ruby/object:Gem::Version
89
89
  version: 0.9.2
90
90
  type: :development
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
- - - ~>
94
+ - - "~>"
95
95
  - !ruby/object:Gem::Version
96
96
  version: 0.9.2
97
97
  - !ruby/object:Gem::Dependency
98
98
  name: pry
99
99
  requirement: !ruby/object:Gem::Requirement
100
100
  requirements:
101
- - - '>='
101
+ - - ">="
102
102
  - !ruby/object:Gem::Version
103
103
  version: '0'
104
104
  type: :development
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
- - - '>='
108
+ - - ">="
109
109
  - !ruby/object:Gem::Version
110
110
  version: '0'
111
111
  description: Ruby library to work with HTTP archives
@@ -116,9 +116,9 @@ executables:
116
116
  extensions: []
117
117
  extra_rdoc_files: []
118
118
  files:
119
- - .gitignore
120
- - .rspec
121
- - .travis.yml
119
+ - ".gitignore"
120
+ - ".rspec"
121
+ - ".travis.yml"
122
122
  - Gemfile
123
123
  - LICENSE
124
124
  - README.mdown
@@ -130,6 +130,7 @@ files:
130
130
  - lib/har/error.rb
131
131
  - lib/har/extensions/jschematic/attributes/format.rb
132
132
  - lib/har/page.rb
133
+ - lib/har/page_timings.rb
133
134
  - lib/har/schema_type.rb
134
135
  - lib/har/schemas/browserType.json
135
136
  - lib/har/schemas/cacheEntryType.json
@@ -293,6 +294,7 @@ files:
293
294
  - spec/har/archive_spec.rb
294
295
  - spec/har/entry_spec.rb
295
296
  - spec/har/page_spec.rb
297
+ - spec/har/page_timings_spec.rb
296
298
  - spec/har/viewer_spec.rb
297
299
  - spec/spec_helper.rb
298
300
  homepage: ''
@@ -304,17 +306,17 @@ require_paths:
304
306
  - lib
305
307
  required_ruby_version: !ruby/object:Gem::Requirement
306
308
  requirements:
307
- - - '>='
309
+ - - ">="
308
310
  - !ruby/object:Gem::Version
309
311
  version: '0'
310
312
  required_rubygems_version: !ruby/object:Gem::Requirement
311
313
  requirements:
312
- - - '>='
314
+ - - ">="
313
315
  - !ruby/object:Gem::Version
314
316
  version: '0'
315
317
  requirements: []
316
318
  rubyforge_project: har
317
- rubygems_version: 2.0.14
319
+ rubygems_version: 2.7.9
318
320
  signing_key:
319
321
  specification_version: 4
320
322
  summary: Ruby library to work with HTTP archives
@@ -328,5 +330,6 @@ test_files:
328
330
  - spec/har/archive_spec.rb
329
331
  - spec/har/entry_spec.rb
330
332
  - spec/har/page_spec.rb
333
+ - spec/har/page_timings_spec.rb
331
334
  - spec/har/viewer_spec.rb
332
335
  - spec/spec_helper.rb