Sha256: 0f653c20cf29a11c4404985e9a10f768b8ed432b141896572e6d4d9bbf962e6c

Contents?: true

Size: 1 KB

Versions: 1

Compression:

Stored size: 1 KB

Contents

class StyleStats
  class CLI
    class << self
      def run(files, option)
        @options = option
        stylestats = StyleStats.new(files, options)
        stylestats.render
      rescue StyleStats::RequestError
        puts '[ERROR] getaddrinfo ENOTFOUND'
      rescue StyleStats::ContentError
        puts '[ERROR] Content type is not HTML or CSS!'
      rescue StyleStats::InvalidError
        puts '[ERROR] Argument is invalid'
      end

      private
      def options
        {
          format: @options[:format],
          user_agent: user_agent
        }
      end

      def user_agent
        case @options[:user_agent]
        when 'ios'
          'Mozilla/5.0 (iPhone; CPU iPhone OS 8_0 like Mac OS X) AppleWebKit/600.1.4 Version/8.0 Safari/600.1.4'
        when 'android'
          'Mozilla/5.0 (Linux; Android 4.4.2; Nexus 5 Build/KOT49H) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/32.0.1700.99 Mobile Safari/537.36'
        else
          @options[:user_agent]
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
style_stats-0.1.0 lib/style_stats/cli.rb