lib/pagespeed/parser.rb
# parse the response and print it real pretty
parse the response and print it real pretty
parse the response and print it real pretty
def parse(result)
        result = JSON.parse(result)
        code   = result['responseCode']
        total_score = result['score']
        strategy = result['request']['strategy']
        fail(code, result['title']) unless code == 200
        result['formattedResults']['ruleResults'].each do |name, rule|
          score = rule['ruleScore']
          colorize(score)
          puts " #{pad_score(score)} - #{rule['localizedRuleName']}"
        end
        colorize(total_score)
        puts " \nTotal Score: #{total_score}/100 (#{strategy})"
        decolorize
      end
def parse ( result ) result = JSON . parse ( result ) code = result [ 'responseCode' ] total_score = result [ 'score' ] strategy = result [ 'request' ] [ 'strategy' ] fail ( code , result [ 'title' ] ) unless code == 200 result [ 'formattedResults' ] [ 'ruleResults' ] . each do | name , rule | score = rule [ 'ruleScore' ] colorize ( score ) puts " #{pad_score(score)} - #{rule['localizedRuleName']}" end colorize ( total_score ) puts " \nTotal Score: #{total_score}/100 (#{strategy})" decolorize end
parse the response and print it real pretty
parse the response and print it real pretty
result
<not_specific>