documentcloud 0.5.0 → 0.5.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 1a2ba9016818c201c571162ff42d1938061fb0c5
4
- data.tar.gz: 34da50fa8a060bf8362ab4caf368619c044b1d9c
2
+ SHA256:
3
+ metadata.gz: f9246d4e52daa3300321aab26de5f74ceaa1bd3e8db55e36f646bfaf0b4d145b
4
+ data.tar.gz: 52db5f9feb9c8ecbda730d8ed81d10d88c5192cc273df9cce8f4bcf0bcb7a697
5
5
  SHA512:
6
- metadata.gz: 3ffa8a59036e54a0959825e82a91e5450cb63962f66db7178054e5b4f554a61c7b73dd5c549e21a899d6115ac3b2d364a7070968d4a18bf1761b0439013044e8
7
- data.tar.gz: 0506b8d8b85e603597158475a36f6cf6f1f784fe91a3d718fc30e576ef04430c96efb2a02579e228afbee899f6b628b2d1b588c8d03a44a7551f20d707c137e0
6
+ metadata.gz: 284d55daeac7b16db5da94f413302651414488295aaf41b7cf00e74999604a57ae824cade9f80a6884d1b42ec811d6d94ab0f09a9d1f775107305d2e8ad65074
7
+ data.tar.gz: c17739b957b99d71e2e038e644595b75e12a15821a70e56ba94d550ac417e90aa90a54d67ac783c98cf27757324e1297b738544adbafcea2bd1bb336359589f8
data/README.md CHANGED
@@ -1,34 +1,55 @@
1
- DocumentCloud RubyGem
2
- =====================
3
-
1
+ # DocumentCloud RubyGem #
4
2
  [![Gem Version](https://badge.fury.io/rb/documentcloud.png)](http://badge.fury.io/rb/documentcloud)
3
+ [![Build Status](https://travis-ci.org/mileszim/documentcloud.svg?branch=master)](https://travis-ci.org/mileszim/documentcloud)
5
4
 
6
5
  Rubygem for interacting with the DocumentCloud API
7
6
 
8
7
 
8
+ ## Install ##
9
+ Add to your Gemfile
10
+ ``` ruby
11
+ gem 'documentcloud', '~> 0.5.0'
12
+ ```
9
13
 
10
- ## Usage
14
+ ## Authentication ##
11
15
 
12
- ```gem install documentcloud``` or put in your gemfile and ```bundle install```
16
+ #### Ruby applications or Rails < 5.1 ####
17
+ Use a gem like dotenv or manually add them:
13
18
 
14
- then
19
+ ``` bash
20
+ $ DOCUMENTCLOUD_EMAIL='myemail@emailprovider.tld' \
21
+ DOCUMENTCLOUD_PASSWORD='my super secure password' \
22
+ ruby main.rb
23
+ ```
24
+
25
+ You can then initialize using `ENV['DOCUMENTCLOUD_EMAIL']` (and pass) in either client or for rails, an initializer:
26
+
27
+ Add file `config/intializers/documentcloud.rb`:
15
28
  ``` ruby
16
- require 'documentcloud'
29
+ DocumentCloud.configure do |config|
30
+ config.email = ENV['DOCUMENTCLOUD_EMAIL']
31
+ config.password = ENV['DOCUMENTCLOUD_PASSWORD']
32
+ end
17
33
  ```
18
- if not in Rails
19
34
 
20
- To authenticate, initialize the configuration and pass in a block:
21
35
 
36
+ #### Rails >= 5.1 ####
37
+ Add file `config/intializers/documentcloud.rb`:
22
38
  ``` ruby
23
39
  DocumentCloud.configure do |config|
24
- config.email = 'my_email@somedomain.com'
25
- config.password = 'my_secret_password'
40
+ config.email = Rails.application.credentials.documentcloud[:email]
41
+ config.password = Rails.application.credentials.documentcloud[:password]
26
42
  end
27
43
  ```
28
44
 
45
+ ##### Rails 5.1 #####
46
+ [Add your documentcloud credentials using Rails 5.1 encrypted secrets](https://www.engineyard.com/blog/encrypted-rails-secrets-on-rails-5.1)
47
+
48
+ ##### Rails 5.2 #####
49
+ [Add your documentcloud credentials using Rails 5.2 encrypted secrets](https://medium.com/cedarcode/rails-5-2-credentials-9b3324851336)
29
50
 
30
- ### Search
31
51
 
52
+ ### Search ###
32
53
  All search results return Document objects that has methods and accessors for the information.
33
54
 
34
55
  ``` ruby
@@ -40,8 +61,7 @@ puts search.documents[0].pdf
40
61
  ```
41
62
 
42
63
 
43
- ### Upload
44
-
64
+ ### Upload ###
45
65
  You can upload a document by providing a ruby File object, or a string with the url to a file.
46
66
 
47
67
  ``` ruby
@@ -53,12 +73,10 @@ remote_doc = DocumentCloud.upload('http://somesite.com/file.pdf', 'Document Titl
53
73
  Both return a document object which can then be used.
54
74
 
55
75
 
56
- ## Objects
57
-
76
+ ## Objects ##
58
77
  This gem creates several objects built from the JSON response in order to provide convenience methods and accessors.
59
78
 
60
- ### Document
61
-
79
+ ### Document ###
62
80
  Document objects wrap any document JSON. They are returned in search results, upload, and document methods.
63
81
 
64
82
  ``` ruby
@@ -87,7 +105,7 @@ doc.entities # Returns a hash of entities and their relevance
87
105
  doc.image(page, size) # Returns the image of a page at the specified size
88
106
  ```
89
107
 
90
- ### Search Results
108
+ ### Search Results ###
91
109
  SearchResults objects return information about the search, and an array of Document objects
92
110
 
93
111
  ``` ruby
@@ -103,11 +121,11 @@ results.documents # Array of documents of results:
103
121
  results.documents[0].title # First result title
104
122
  ```
105
123
 
106
- ### Projects
124
+ ### Projects ###
107
125
  Projects returns an array of Project objects which contain a list of Documents and
108
126
  metadata about the project.
109
127
 
110
- ```ruby
128
+ ``` ruby
111
129
  projects = DocumentCloud.projects
112
130
 
113
131
  project = projects.first
@@ -119,35 +137,41 @@ project.description
119
137
  project.documents # Returns an array of Document objects
120
138
  ```
121
139
 
122
- ### Entities
140
+ ### Entities ###
123
141
  Entities takes a document id and returns a hash of entities, which
124
142
  include a value and relevance for each type of entity.
125
143
 
126
- ```ruby
144
+ ``` ruby
127
145
  entities = DocumentCloud.entities(2072158)
128
146
 
129
147
  # example output
130
148
  {
131
- :person=>[{:value=>"Pita Sharples", :relevance=>0.112}],
132
- :organization=>[{:value=>"Māori Party", :relevance=>0.48}],
133
- :place=>[],
134
- :term=>
135
- [{:value=>"finance costs", :relevance=>0.552},
136
- {:value=>"public services", :relevance=>0.526}],
137
- :email=>[],
138
- :phone=>[],
139
- :city=>[],
140
- :state=>[],
141
- :country=>
142
- [{:value=>"New Zealand", :relevance=>0.628},
143
- {:value=>"Australia", :relevance=>0.302},
144
- {:value=>"United States", :relevance=>0.295},
145
- {:value=>"United Kingdom", :relevance=>0.295},
146
- {:value=>"China", :relevance=>0.294}]
147
- }
149
+ :person => [
150
+ { :value => "Pita Sharples", :relevance => 0.112 }
151
+ ],
152
+ :organization => [
153
+ { :value => "Māori Party", :relevance => 0.48 }
154
+ ],
155
+ :place => [],
156
+ :term => [
157
+ { :value => "finance costs", :relevance => 0.552 },
158
+ { :value => "public services", :relevance => 0.526 }
159
+ ],
160
+ :email => [],
161
+ :phone => [],
162
+ :city => [],
163
+ :state => [],
164
+ :country => [
165
+ { :value => "New Zealand", :relevance => 0.628 },
166
+ { :value => "Australia", :relevance => 0.302 },
167
+ { :value => "United States", :relevance => 0.295 },
168
+ { :value => "United Kingdom", :relevance => 0.295 },
169
+ { :value => "China", :relevance => 0.294 }
170
+ ]
171
+ }
148
172
  ```
149
173
 
150
174
 
151
- ## Information
175
+ ## Information ##
152
176
 
153
177
  DocumentCloud API info: http://www.documentcloud.org/help/api
@@ -1,23 +1,27 @@
1
1
  # coding: utf-8
2
- lib = File.expand_path('../lib', __FILE__)
2
+ lib = File.expand_path("../lib", __FILE__)
3
3
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
- require 'document_cloud/version'
4
+ require "document_cloud/version"
5
5
 
6
6
  Gem::Specification.new do |spec|
7
- spec.add_dependency "rest-client", "~> 1.8"
8
- spec.add_dependency 'multi_json', '~> 1.8'
9
-
10
- spec.name = 'documentcloud'
7
+ spec.name = "documentcloud"
11
8
  spec.version = DocumentCloud::Version
12
9
  spec.description = "Rubygem for interacting with the DocumentCloud API"
13
10
  spec.summary = spec.description
14
11
  spec.authors = ["Miles Zimmerman"]
15
- spec.email = ['mileszim@protonmail.com']
16
- spec.homepage = 'https://github.com/mileszim/documentcloud'
17
- spec.licenses = ['MIT']
12
+ spec.email = ["mileszim@protonmail.com"]
13
+ spec.homepage = "https://github.com/mileszim/documentcloud"
14
+ spec.licenses = ["MIT"]
18
15
 
19
16
  spec.files = %w(LICENSE README.md documentcloud.gemspec)
20
17
  spec.files += Dir.glob("lib/**/*.rb")
21
18
 
22
- spec.require_paths = ['lib']
19
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
20
+
21
+ spec.require_paths = ["lib"]
22
+
23
+ spec.add_dependency "rest-client", "~> 1.8"
24
+ spec.add_dependency "multi_json", "~> 1.8"
25
+
26
+ spec.add_development_dependency "rspec", "~> 3.8"
23
27
  end
@@ -2,7 +2,7 @@ module DocumentCloud
2
2
  class Version
3
3
  MAJOR = 0 unless defined? DocumentCloud::Version::MAJOR
4
4
  MINOR = 5 unless defined? DocumentCloud::Version::MINOR
5
- PATCH = 0 unless defined? DocumentCloud::Version::PATCH
5
+ PATCH = 1 unless defined? DocumentCloud::Version::PATCH
6
6
  PRE = nil unless defined? DocumentCloud::Version::PRE
7
7
 
8
8
  class << self
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: documentcloud
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.5.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Miles Zimmerman
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-12-03 00:00:00.000000000 Z
11
+ date: 2018-08-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rest-client
@@ -38,6 +38,20 @@ dependencies:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
40
  version: '1.8'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '3.8'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '3.8'
41
55
  description: Rubygem for interacting with the DocumentCloud API
42
56
  email:
43
57
  - mileszim@protonmail.com
@@ -87,7 +101,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
87
101
  version: '0'
88
102
  requirements: []
89
103
  rubyforge_project:
90
- rubygems_version: 2.6.14
104
+ rubygems_version: 2.7.6
91
105
  signing_key:
92
106
  specification_version: 4
93
107
  summary: Rubygem for interacting with the DocumentCloud API