diff --git a/Gemfile.lock b/Gemfile.lock index 3958f89..84e3c32 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,7 +1,7 @@ PATH remote: . specs: - unstructured (0.1.0) + unstructured (0.2.0) faraday (~> 2.9.0) faraday-multipart (~> 1.0.4) marcel (~> 1.0.4) diff --git a/bin/console b/bin/console index e80b7d3..9b97526 100755 --- a/bin/console +++ b/bin/console @@ -9,7 +9,7 @@ require "unstructured" client = Unstructured::Client.new( server_url: "http://localhost:8000", - api_key_auth: ENV["UNSTRUCTURED_API_KEY"] + # api_key_auth: ENV["UNSTRUCTURED_API_KEY"] ) client.partition("./README.md") diff --git a/lib/unstructured/object.rb b/lib/unstructured/object.rb index 10ec5dc..6dce3d8 100644 --- a/lib/unstructured/object.rb +++ b/lib/unstructured/object.rb @@ -3,7 +3,10 @@ require "ostruct" module Unstructured class Object + attr_reader :attributes, :raw_data + def initialize(attributes) + @raw_data = attributes @attributes = OpenStruct.new(attributes) end @@ -16,5 +19,9 @@ def method_missing(method, *args, &block) def respond_to_missing?(_method, _include_private = false) true end + + def to_h + @raw_data + end end end diff --git a/lib/unstructured/version.rb b/lib/unstructured/version.rb index 0ea2fcd..26d3d3f 100644 --- a/lib/unstructured/version.rb +++ b/lib/unstructured/version.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true module Unstructured - VERSION = "0.1.1" + VERSION = "0.2.0" end diff --git a/spec/client_spec.rb b/spec/client_spec.rb index 8ce6f3c..0bc8674 100644 --- a/spec/client_spec.rb +++ b/spec/client_spec.rb @@ -45,5 +45,9 @@ expect(client.partition("spec/fixtures/sample.pdf").first.metadata.filetype).to eq(stub_filetype) expect(client.partition("spec/fixtures/sample.pdf").first.metadata.filename).to eq(stub_filename) end + + it "should return a hash when using to_h" do + expect(client.partition("spec/fixtures/sample.pdf").first.to_h).to be_a(Hash) + end end end