har 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
data/bin/har CHANGED
@@ -1,4 +1,9 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  require "har"
4
- HAR::Viewer.new(ARGV).show
4
+
5
+ begin
6
+ HAR::Viewer.new(ARGV).show
7
+ rescue HAR::Error => ex
8
+ abort "\n\n#{ex.message}"
9
+ end
@@ -15,7 +15,7 @@ Gem::Specification.new do |s|
15
15
  s.rubyforge_project = "har"
16
16
 
17
17
  s.add_dependency "json"
18
- s.add_dependency "json-schema"
18
+ s.add_dependency "json-schema", ">= 0.1.10"
19
19
  s.add_dependency "launchy"
20
20
 
21
21
  s.add_development_dependency "rspec", "~> 2.0"
data/lib/har.rb CHANGED
@@ -2,11 +2,7 @@ require 'json'
2
2
  require 'json-schema'
3
3
  require 'time'
4
4
 
5
- module HAR
6
- class Error < StandardError; end
7
- class ValidationError < StandardError; end
8
- end
9
-
5
+ require 'har/error'
10
6
  require 'har/version'
11
7
  require 'har/serializable'
12
8
  require 'har/schema_type'
@@ -10,6 +10,19 @@ module HAR
10
10
  from_string File.read(path), path
11
11
  end
12
12
 
13
+ def self.by_merging(hars)
14
+ hars = hars.dup
15
+
16
+ result = hars.shift
17
+ result = from_file(result) unless result.kind_of? self
18
+
19
+ hars.each do |har|
20
+ result.merge! har.kind_of?(self) ? har : from_file(har)
21
+ end
22
+
23
+ result
24
+ end
25
+
13
26
  attr_reader :uri
14
27
 
15
28
  def initialize(input, uri = nil)
@@ -0,0 +1,4 @@
1
+ module HAR
2
+ class Error < StandardError; end
3
+ class ValidationError < Error; end
4
+ end
@@ -8,10 +8,6 @@ module HAR
8
8
  @entries = entries
9
9
  end
10
10
 
11
- def title
12
- @data.fetch 'title'
13
- end
14
-
15
11
  # a little sugar
16
12
  alias_method :timings, :page_timings
17
13
 
@@ -1,3 +1,3 @@
1
1
  module HAR
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
@@ -10,7 +10,11 @@ module HAR
10
10
  @running = false
11
11
  @options = parse(args)
12
12
 
13
- @har = merge archives_from(args)
13
+ if @options[:validate]
14
+ args = validate(args)
15
+ end
16
+
17
+ @har = Archive.by_merging(args)
14
18
  end
15
19
 
16
20
  def show
@@ -21,16 +25,13 @@ module HAR
21
25
 
22
26
  private
23
27
 
24
- def archives_from(hars)
25
- hars = hars.map { |path| Archive.from_file(path) }
26
-
27
- if @options[:validate]
28
- progress("Validating archives...") do
29
- hars.each { |h| h.validate! }
30
- end
31
- end
28
+ def validate(hars)
29
+ progress("Validating archives...") {
30
+ hars = hars.map { |path| Archive.from_file(path) }
31
+ hars.each { |h| h.validate! }
32
32
 
33
- hars
33
+ hars
34
+ }
34
35
  end
35
36
 
36
37
  def create_root
@@ -17,6 +17,11 @@ module HAR
17
17
  ar.uri.should_not be_nil
18
18
  ar.uri.should include("browser-blocking-time")
19
19
  end
20
+
21
+ it "creates a single archive by merging the given paths" do
22
+ ar = Archive.by_merging good_hars.first(2)
23
+ ar.pages.size.should == 3
24
+ end
20
25
  end
21
26
 
22
27
  context "fetching data" do
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 0
8
- - 2
9
- version: 0.0.2
8
+ - 3
9
+ version: 0.0.3
10
10
  platform: ruby
11
11
  authors:
12
12
  - Jari Bakken
@@ -40,7 +40,9 @@ dependencies:
40
40
  - !ruby/object:Gem::Version
41
41
  segments:
42
42
  - 0
43
- version: "0"
43
+ - 1
44
+ - 10
45
+ version: 0.1.10
44
46
  type: :runtime
45
47
  version_requirements: *id002
46
48
  - !ruby/object:Gem::Dependency
@@ -90,6 +92,7 @@ files:
90
92
  - har.gemspec
91
93
  - lib/har.rb
92
94
  - lib/har/archive.rb
95
+ - lib/har/error.rb
93
96
  - lib/har/page.rb
94
97
  - lib/har/schema_type.rb
95
98
  - lib/har/schemas/browserType