class Mortise::Checker
Attributes
key[R]
tenon_app_id[R]
tenon_uri[R]
url[R]
Public Class Methods
new(url, key, options = {})
click to toggle source
# File lib/mortise/checker.rb, line 8 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
Public Instance Methods
errors()
click to toggle source
# File lib/mortise/checker.rb, line 26 def errors @errors ||= issues.select { |issue| issue.certainty >= 80 } end
issues()
click to toggle source
# File lib/mortise/checker.rb, line 22 def issues @issues ||= raw['resultSet'].map { |issue| Mortise::Issue.new(issue) } end
raw()
click to toggle source
# File lib/mortise/checker.rb, line 18 def raw @raw ||= JSON.parse response.body end
warnings()
click to toggle source
# File lib/mortise/checker.rb, line 30 def warnings @warnings ||= issues.select { |issue| issue.certainty < 80 } end
Private Instance Methods
defaults()
click to toggle source
# File lib/mortise/checker.rb, line 36 def defaults { tenon_uri: 'https://tenon.io/api/', tenon_app_id: Mortise::TENON_APP_ID } end
response()
click to toggle source
# File lib/mortise/checker.rb, line 40 def response fail(ERRORS[tenon_response.code], tenon_response.body) if tenon_response.code != 200 tenon_response end
tenon_response()
click to toggle source
# File lib/mortise/checker.rb, line 46 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