Sha256: 6f47117564475de18667b243021b0d532aaec9b481c1c5d2c65776084d74d11f
Contents?: true
Size: 1.28 KB
Versions: 1
Compression:
Stored size: 1.28 KB
Contents
require 'httparty' require 'json' module Mortise class Checker attr_reader :url, :tenon_uri, :key, :tenon_app_id def initialize(url, key, options = {}) options = defaults.merge(options) @url = url @key = key @tenon_uri = options[:tenon_uri] @tenon_app_id = options[:tenon_app_id] end def raw @raw ||= JSON.parse response.body end def issues @issues ||= raw['resultSet'].map { |issue| Mortise::Issue.new(issue) } end def errors @errors ||= issues.select { |issue| issue.certainty >= 80 } end def warnings @warnings ||= issues.select { |issue| issue.certainty < 80 } end private def defaults { tenon_uri: 'https://tenon.io/api/', tenon_app_id: Mortise::TENON_APP_ID } end def response fail(ERRORS[tenon_response.code], tenon_response.body) if tenon_response.code != 200 tenon_response end def tenon_response @tenon_response ||= HTTParty.post(tenon_uri, body: { url: url, key: key, appID: tenon_app_id }, headers: { 'Content-Type' => 'application/x-www-form-urlencoded', 'Cache-Control' => 'no-cache' }) end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
mortise-0.3.0 | lib/mortise/checker.rb |