lib/har/viewer.rb in har-0.0.5 vs lib/har/viewer.rb in har-0.0.6
- old
+ new
@@ -8,21 +8,21 @@
def initialize(args)
@running = false
@options = parse(args)
- if @options[:validate]
- args = validate(args)
- end
-
- if args == ["-"]
+ if args == ["-"] || args.empty?
progress("Reading HAR from stdin...") {
@har = Archive.from_file $stdin
}
+
+ validate_if_needed @har
else
+ hars = validate_if_needed(args)
+
progress("Merging HARs...") {
- @har = Archive.by_merging args
+ @har = Archive.by_merging hars
}
end
end
def show
@@ -31,15 +31,19 @@
s.join
end
private
- def validate(hars)
+ def validate_if_needed(hars)
+ return hars unless @options[:validate]
+
progress("Validating archives...") {
- hars = hars.map { |path| Archive.from_file(path) }
- hars.each { |h| h.validate! }
+ Array(hars).map { |har|
+ har = har.kind_of?(Archive) ? har : Archive.from_file(har)
+ har.validate!
- hars
+ har
+ }
}
end
def create_root
progress("Creating viewer...") {