diff --git a/lib/clarifai.rb b/lib/clarifai.rb index 6478736..d9c49c8 100644 --- a/lib/clarifai.rb +++ b/lib/clarifai.rb @@ -1,9 +1,10 @@ -require 'base64' -require 'http' +require "base64" +require "http" class Clarifai KEY = ENV.fetch("CLARIFAI_API_KEY").freeze - API_URL = "https://api.clarifai.com/v2/models/aaa03c23b3724a16a56b629203edc62c/outputs" + API_URL = "https://api.clarifai.com/v2/models/" \ + "aaa03c23b3724a16a56b629203edc62c/outputs".freeze attr_reader :tags @@ -14,18 +15,18 @@ class Clarifai def predict! headers = { "Authorization": "Key #{KEY}", - "Content-Type": "application/json" + "Content-Type": "application/json", } params = { "inputs": [ { "data": { "image": { - "base64": Base64.encode64(File.read(@image_path)) - } - } - } - ] + "base64": Base64.encode64(File.read(@image_path)), + }, + }, + }, + ], } resp = HTTP. diff --git a/spec/lib/clarifai_spec.rb b/spec/lib/clarifai_spec.rb index 5f9d2b0..8fe658b 100644 --- a/spec/lib/clarifai_spec.rb +++ b/spec/lib/clarifai_spec.rb @@ -13,22 +13,22 @@ describe Clarifai do { "id": "ai_PpTcwbdQ", "name": "computer", - "value": 0.96887743 + "value": 0.96887743, }, { "id": "ai_62K34TR4", "name": "technology", - "value": 0.96544206 - } - ] - } - } - ] + "value": 0.96544206, + }, + ], + }, + }, + ], }.to_json WebMock. stub_request(:post, Clarifai::API_URL). - to_return(:status => 200, :body => stub_body) + to_return(status: 200, body: stub_body) clarifai_image = Clarifai.new("spec/fixtures/spectrum.jpg") clarifai_image.predict! @@ -37,5 +37,3 @@ describe Clarifai do end end end - -