Module: YSlow
- Defined in:
- lib/yslow.rb,
lib/yslow/result.rb,
lib/yslow/version.rb
Defined Under Namespace
Classes: Result
Constant Summary collapse
- VERSION =
"0.0.2"
Class Method Summary collapse
Class Method Details
.path(value = nil) ⇒ Object
13 14 15 16 |
# File 'lib/yslow.rb', line 13 def self.path value=nil @@path = value unless value.nil? @@path ||= File.("yslow.js", File.dirname(__FILE__)) end |
.phantomjs(value = nil) ⇒ Object
8 9 10 11 |
# File 'lib/yslow.rb', line 8 def self.phantomjs value=nil @@phantomjs = value unless value.nil? @@phantomjs ||= Phantomjs.path end |
.run(url, command = []) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/yslow.rb', line 18 def self.run url, command=[] command.push(url) # Unshift the json format option. This is so the gem user can override it if they need XML. command.unshift("json") command.unshift("--format") command.unshift(self.path) command.unshift(self.phantomjs) err, out, status = nil ::Open3.popen3(command.join(" ")) do |i, o, e, t| err = e.read.chomp out = o.read.chomp status = t.value.to_i end Result.new({ :status => status, :stdout => out, :stderr => err }) end |