documentcloud 0.1.1 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +15 -0
- data/README.md +31 -2
- data/lib/document_cloud/api/destroy.rb +22 -0
- data/lib/document_cloud/api/document.rb +1 -1
- data/lib/document_cloud/api/update.rb +32 -0
- data/lib/document_cloud/client.rb +15 -0
- data/lib/document_cloud/version.rb +2 -2
- metadata +6 -11
checksums.yaml
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
---
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: !binary |-
|
4
|
+
ZDM0YWJjYjM3NzQ2Y2U0OTEzMWQyNDk0MTY0Yjg4NDZmMGJhYjdjZQ==
|
5
|
+
data.tar.gz: !binary |-
|
6
|
+
NzQ1MTkxYTI4YzFiZTE3Y2RhOGVjMWYwYmExOWU3MjllODY2MzU3NA==
|
7
|
+
SHA512:
|
8
|
+
metadata.gz: !binary |-
|
9
|
+
ZDY0Y2U3NzZlMzIzMzgzMmRmYjQ5ZDk5M2JlZDZhZjcyNzNhNjQzNzUxNGI2
|
10
|
+
ZDQyNGQ4NTcxN2VhZWIyOTYwYWE5M2Y3YmZkYmQ4Yzg3ZGEyYTU0ZDI2MWI2
|
11
|
+
ZWQwMjYyYTIzZDUzZjE1NDdmNjhhMDNkOWQxMjBhZWU3ODhiYWE=
|
12
|
+
data.tar.gz: !binary |-
|
13
|
+
ZjkzZjJhNGY0MDJlMDZhMzJjZTFmZDU5ZWM1N2MwZDY4M2EzNmJiMjhkNmUz
|
14
|
+
NDkwMzJhZDY0ZGIyZjQ5ZDFlMTZmMTEzMjg0NGVkM2UyNjg1NWFkYzk5ZTZm
|
15
|
+
NTgyYTMwYzRmY2JhMTc0NGQ1YWE0ZjExNTVlZDViOGI0MWM0Mzc=
|
data/README.md
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
DocumentCloud RubyGem
|
2
2
|
=====================
|
3
3
|
|
4
|
-
Rubygem for interacting with the DocumentCloud API
|
4
|
+
Rubygem for interacting with the DocumentCloud API.
|
5
5
|
|
6
6
|
|
7
7
|
## Usage
|
@@ -44,6 +44,35 @@ remote_doc = DocumentCloud.upload('http://somesite.com/file.pdf', 'Document Titl
|
|
44
44
|
Both return a document object which can then be used.
|
45
45
|
|
46
46
|
|
47
|
-
###
|
47
|
+
### Document
|
48
|
+
|
49
|
+
Fetch a document by passing the document id.
|
50
|
+
|
51
|
+
``` ruby
|
52
|
+
doc = DocumentCloud.document('1234-document-id')
|
53
|
+
```
|
54
|
+
|
55
|
+
|
56
|
+
|
57
|
+
### Update
|
58
|
+
|
59
|
+
Update a document by providing the file id, and any parameters you want to change.
|
60
|
+
|
61
|
+
``` ruby
|
62
|
+
updated_doc = DocumentCloud.update('1234-file-name', title: 'Changed Document Title')
|
63
|
+
```
|
64
|
+
|
65
|
+
|
66
|
+
### Destroy
|
67
|
+
|
68
|
+
Destroy a document simply by passing the document id.
|
69
|
+
|
70
|
+
``` ruby
|
71
|
+
DocumentCloud.destroy('1234-file-name')
|
72
|
+
```
|
73
|
+
|
74
|
+
|
75
|
+
|
76
|
+
## Information
|
48
77
|
|
49
78
|
DocumentCloud API info: http://www.documentcloud.org/help/api
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module DocumentCloud
|
2
|
+
module API
|
3
|
+
module Destroy
|
4
|
+
include DocumentCloud::API::Utils
|
5
|
+
DOCUMENT_PATH = "/documents"
|
6
|
+
|
7
|
+
# Delete a document
|
8
|
+
#
|
9
|
+
# @param id [String] The document id
|
10
|
+
def destroy(id)
|
11
|
+
delete(document_path(id))
|
12
|
+
end
|
13
|
+
|
14
|
+
private
|
15
|
+
|
16
|
+
def document_path(document_id)
|
17
|
+
"#{DOCUMENT_PATH}/#{document_id.to_s}.json"
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
module DocumentCloud
|
2
|
+
module API
|
3
|
+
module Update
|
4
|
+
include DocumentCloud::API::Utils
|
5
|
+
DOCUMENT_PATH = "/documents"
|
6
|
+
|
7
|
+
# Update a document
|
8
|
+
#
|
9
|
+
# @see http://www.documentcloud.org/help/api
|
10
|
+
# @param id [String] The document id
|
11
|
+
# @param options [Hash] Customizable set of options
|
12
|
+
# @param options [String] :title The document's cannonical title
|
13
|
+
# @param options [String] :source The source who produced the document
|
14
|
+
# @param options [String] :description A paragraph of detailed description
|
15
|
+
# @param options [String] :related_article The URL of the article associated with the document
|
16
|
+
# @param options [String] :published_url The URL of the page on which the document will be embedded
|
17
|
+
# @param options [String] :access One of 'public', 'private', 'organization', defaults to 'private'
|
18
|
+
# @param options [Hash] :data A hash of arbitrary key/value data pairs
|
19
|
+
# @returns [DocumentCloud::Document] The document uploaded
|
20
|
+
def update(id, options={})
|
21
|
+
build_object DocumentCloud::Document, put(document_path(id), options)
|
22
|
+
end
|
23
|
+
|
24
|
+
private
|
25
|
+
|
26
|
+
def document_path(document_id)
|
27
|
+
"#{DOCUMENT_PATH}/#{document_id.to_s}.json"
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -3,6 +3,8 @@ require_relative 'api/utils'
|
|
3
3
|
require_relative 'api/search'
|
4
4
|
require_relative 'api/upload'
|
5
5
|
require_relative 'api/document'
|
6
|
+
require_relative 'api/update'
|
7
|
+
require_relative 'api/destroy'
|
6
8
|
|
7
9
|
module DocumentCloud
|
8
10
|
class Client
|
@@ -10,6 +12,8 @@ module DocumentCloud
|
|
10
12
|
include DocumentCloud::API::Search
|
11
13
|
include DocumentCloud::API::Upload
|
12
14
|
include DocumentCloud::API::Document
|
15
|
+
include DocumentCloud::API::Update
|
16
|
+
include DocumentCloud::API::Destroy
|
13
17
|
include DocumentCloud::Configurable
|
14
18
|
|
15
19
|
def initialize(options={})
|
@@ -23,10 +27,21 @@ module DocumentCloud
|
|
23
27
|
RestClient.get request_base+path, {params: params}
|
24
28
|
end
|
25
29
|
|
30
|
+
# Perform HTTP POST request
|
26
31
|
def post(path, params={})
|
27
32
|
RestClient.post request_base+path, params
|
28
33
|
end
|
29
34
|
|
35
|
+
# Perform HTTP PUT request
|
36
|
+
def put(path, params={})
|
37
|
+
RestClient.put request_base+path, params
|
38
|
+
end
|
39
|
+
|
40
|
+
# Perform HTTP DELETE request
|
41
|
+
def delete(path)
|
42
|
+
RestClient.delete request_base+path
|
43
|
+
end
|
44
|
+
|
30
45
|
private
|
31
46
|
|
32
47
|
def request_base
|
@@ -1,8 +1,8 @@
|
|
1
1
|
module DocumentCloud
|
2
2
|
class Version
|
3
3
|
MAJOR = 0 unless defined? DocumentCloud::Version::MAJOR
|
4
|
-
MINOR =
|
5
|
-
PATCH =
|
4
|
+
MINOR = 2 unless defined? DocumentCloud::Version::MINOR
|
5
|
+
PATCH = 0 unless defined? DocumentCloud::Version::PATCH
|
6
6
|
PRE = nil unless defined? DocumentCloud::Version::PRE
|
7
7
|
|
8
8
|
class << self
|
metadata
CHANGED
@@ -1,8 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: documentcloud
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
5
|
-
prerelease:
|
4
|
+
version: 0.2.0
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Miles Zimmerman
|
@@ -14,7 +13,6 @@ dependencies:
|
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: rest-client
|
16
15
|
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
16
|
requirements:
|
19
17
|
- - ~>
|
20
18
|
- !ruby/object:Gem::Version
|
@@ -22,7 +20,6 @@ dependencies:
|
|
22
20
|
type: :runtime
|
23
21
|
prerelease: false
|
24
22
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
23
|
requirements:
|
27
24
|
- - ~>
|
28
25
|
- !ruby/object:Gem::Version
|
@@ -30,7 +27,6 @@ dependencies:
|
|
30
27
|
- !ruby/object:Gem::Dependency
|
31
28
|
name: multi_json
|
32
29
|
requirement: !ruby/object:Gem::Requirement
|
33
|
-
none: false
|
34
30
|
requirements:
|
35
31
|
- - ~>
|
36
32
|
- !ruby/object:Gem::Version
|
@@ -38,7 +34,6 @@ dependencies:
|
|
38
34
|
type: :runtime
|
39
35
|
prerelease: false
|
40
36
|
version_requirements: !ruby/object:Gem::Requirement
|
41
|
-
none: false
|
42
37
|
requirements:
|
43
38
|
- - ~>
|
44
39
|
- !ruby/object:Gem::Version
|
@@ -53,8 +48,10 @@ files:
|
|
53
48
|
- LICENSE
|
54
49
|
- README.md
|
55
50
|
- documentcloud.gemspec
|
51
|
+
- lib/document_cloud/api/destroy.rb
|
56
52
|
- lib/document_cloud/api/document.rb
|
57
53
|
- lib/document_cloud/api/search.rb
|
54
|
+
- lib/document_cloud/api/update.rb
|
58
55
|
- lib/document_cloud/api/upload.rb
|
59
56
|
- lib/document_cloud/api/utils.rb
|
60
57
|
- lib/document_cloud/client.rb
|
@@ -67,27 +64,25 @@ files:
|
|
67
64
|
homepage: https://github.com/mileszim/documentcloud
|
68
65
|
licenses:
|
69
66
|
- MIT
|
67
|
+
metadata: {}
|
70
68
|
post_install_message:
|
71
69
|
rdoc_options: []
|
72
70
|
require_paths:
|
73
71
|
- lib
|
74
72
|
required_ruby_version: !ruby/object:Gem::Requirement
|
75
|
-
none: false
|
76
73
|
requirements:
|
77
74
|
- - ! '>='
|
78
75
|
- !ruby/object:Gem::Version
|
79
76
|
version: '0'
|
80
77
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
81
|
-
none: false
|
82
78
|
requirements:
|
83
79
|
- - ! '>='
|
84
80
|
- !ruby/object:Gem::Version
|
85
81
|
version: '0'
|
86
82
|
requirements: []
|
87
83
|
rubyforge_project:
|
88
|
-
rubygems_version: 1.
|
84
|
+
rubygems_version: 2.1.10
|
89
85
|
signing_key:
|
90
|
-
specification_version:
|
86
|
+
specification_version: 4
|
91
87
|
summary: Rubygem for interacting with the DocumentCloud API
|
92
88
|
test_files: []
|
93
|
-
has_rdoc:
|