dspace_rest_client 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 3a5caf190284294ce02a942a3d72941bfdd452e0
4
+ data.tar.gz: a2f03710acec47e549750ec8883fa3506ddf8e3c
5
+ SHA512:
6
+ metadata.gz: 0dcaae58f9183bc3b8c68d6775443da62f5b423902bf7eaaf95e7ba108769fa1d7b0d45e44e8fda227e31522d2fccabbc82accae889936101fbd130916f20d30
7
+ data.tar.gz: bfd559a9ed06a3c6fa02ec20bad5210b2b3469f58d5eefc4e6a4f65b1bc94ed4d2808f2bc720c43f9db57d9e072bdbbd3caaa5b22f43bbe918092b704bd9e251
@@ -0,0 +1,59 @@
1
+ require 'rest-client'
2
+
3
+ class DspaceClient
4
+ attr_reader :rest_client
5
+
6
+ def initialize(url)
7
+ @url = url
8
+ @rest_client = build_rest_client url
9
+ end
10
+
11
+ def repository
12
+ @dspace_repository ||= build_repository @rest_client
13
+ end
14
+
15
+ def login(username, password)
16
+ user = JSON.generate({
17
+ email: username,
18
+ password: password
19
+ })
20
+
21
+ # send login request to server and receive the token
22
+ authenticated_token = @rest_client['/login'].post user
23
+
24
+ # overwrite the rest_client and dspace_repository
25
+ @rest_client = build_rest_client @url, rest_dspace_token: authenticated_token
26
+ @dspace_repository = build_repository @rest_client
27
+
28
+ return (!authenticated_token.nil?)
29
+ end
30
+
31
+ def logout
32
+ response = JSON.parse @rest_client['/logout'].post []
33
+ end
34
+
35
+ def status
36
+ response = JSON.parse @rest_client['/status'].get
37
+ end
38
+
39
+ def test
40
+ response = JSON.parse(@rest_client['/test'].get)
41
+ end
42
+
43
+ private
44
+
45
+ def build_repository(rest_client)
46
+ DSpaceRest::Repositories::DspaceRepository.new rest_client
47
+ end
48
+
49
+ def build_rest_client(url, headers={})
50
+ RestClient::Resource.new(url,
51
+ verify_ssl: OpenSSL::SSL::VERIFY_NONE,
52
+ headers: headers.merge(
53
+ content_type: :json,
54
+ accept: :json
55
+ )
56
+ )
57
+ end
58
+
59
+ end
@@ -0,0 +1,15 @@
1
+ # More logical way to require 'dspace-rest-client'
2
+ require File.dirname(__FILE__) + '/dspace_client'
3
+ require File.dirname(__FILE__) + '/dspacerest/bitstream'
4
+ require File.dirname(__FILE__) + '/dspacerest/collection'
5
+ require File.dirname(__FILE__) + '/dspacerest/community'
6
+ require File.dirname(__FILE__) + '/dspacerest/item'
7
+ require File.dirname(__FILE__) + '/dspacerest/metadata'
8
+ require File.dirname(__FILE__) + '/dspacerest/repositories/abstract_repository'
9
+ require File.dirname(__FILE__) + '/dspacerest/repositories/bitstream_repository'
10
+ require File.dirname(__FILE__) + '/dspacerest/repositories/collection_repository'
11
+ require File.dirname(__FILE__) + '/dspacerest/repositories/community_repository'
12
+ require File.dirname(__FILE__) + '/dspacerest/repositories/dspace_repository'
13
+ require File.dirname(__FILE__) + '/dspacerest/repositories/item_repository'
14
+ require File.dirname(__FILE__) + '/dspacerest/strategies/uploads/curl_strategy'
15
+ require File.dirname(__FILE__) + '/dspacerest/strategies/uploads/rest_strategy'
@@ -0,0 +1,50 @@
1
+ module DSpaceRest
2
+ class Bitstream
3
+
4
+ attr_accessor :name, :bundle_name,
5
+ :description, :format, :mime_type
6
+
7
+ attr_reader :id, :type, :link, :size_bytes,
8
+ :parent_object, :retrieve_link, :check_sum,
9
+ :sequence_id, :policies
10
+
11
+ def initialize args
12
+ @id = args['id'] || ""
13
+ @name = args['name'] || ""
14
+ @type = args['type'] || ""
15
+ @link = args['link'] || ""
16
+ @bundle_name = args['bundleName'] || ""
17
+ @description = args['description'] || ""
18
+ @format = args['format'] || ""
19
+ @mime_type = args['mimeType'] || ""
20
+ @size_bytes = args['sizeBytes'] || ""
21
+ @parent_object = args['parentObject'] || ""
22
+ @retrieve_link = args['retrieveLink'] || ""
23
+ @check_sum = args['checkSum'] || ""
24
+ @sequence_id = args['sequenceId'] || ""
25
+ @policies = args['policies'] || ""
26
+ @expand = args['expand'] || ""
27
+ end
28
+
29
+ def to_h
30
+ h = Hash.new
31
+ h['id'] = @id
32
+ h['name'] = @name
33
+ h['type'] = @type
34
+ h['link'] = @link
35
+ h['bundleName'] = @bundle_name
36
+ h['description'] = @description
37
+ h['format'] = @format
38
+ h['mimeType'] = @mime_type
39
+ h['sizeBytes'] = @size_bytes
40
+ h['parentObject'] = @parent_object
41
+ h['retrieveLink'] = @retrieve_link
42
+ h['checkSum'] = @check_sum
43
+ h['sequenceId'] = @sequence_id
44
+ h['policies'] = @policies
45
+ h['expand'] = @expand
46
+ h
47
+ end
48
+
49
+ end
50
+ end
@@ -0,0 +1,52 @@
1
+ module DSpaceRest
2
+ class Collection
3
+
4
+ attr_accessor :name, :logo, :license, :copyright_text,
5
+ :introductory_text, :short_description, :sidebar_text
6
+
7
+ attr_reader :id, :handle, :type, :link, :parent_community,
8
+ :parent_community_list, :items,
9
+ :number_iems, :sub_communities, :collections, :expand
10
+
11
+ def initialize args
12
+ @id = args['id']
13
+ @name = args['name']
14
+ @handle = args['handle']
15
+ @type = args['type']
16
+ @link = args['link']
17
+ @logo = args['logo']
18
+ @parent_community = args['parentCommunity']
19
+ @parent_community_list = args['parentCommunityList']
20
+ @items = args['items']
21
+ @license = args['license']
22
+ @copyright_text = args['copyrightText']
23
+ @introductory_text = args['introductoryText']
24
+ @short_description = args['shortDescription']
25
+ @sidebar_text = args['sidebarText']
26
+ @number_items = args['countItems']
27
+ @expand = args['expand']
28
+ end
29
+
30
+ def to_h
31
+ h = Hash.new
32
+ h["id"] = @id
33
+ h["name"] = @name
34
+ h["handle"] = @handle
35
+ h["type"] = @type
36
+ h["link"] = @link
37
+ h["logo"] = @logo
38
+ h["parentCommunity"] = @parent_community
39
+ h["parentCommunityList"] = @parent_community_list
40
+ h["items"] = @items
41
+ h["license"] = @license
42
+ h["copyrightText"] = @copyright_text
43
+ h["introductoryText"] = @introductory_text
44
+ h["shortDescription"] = @short_description
45
+ h["sidebarText"] = @sidebar_text
46
+ h["numberItems"] = @number_items
47
+ h["expand"] = @expand
48
+ h
49
+ end
50
+
51
+ end
52
+ end
@@ -0,0 +1,49 @@
1
+ module DSpaceRest
2
+ class Community
3
+
4
+ attr_accessor :name, :logo, :copyright_text,
5
+ :introductory_text, :short_description, :sidebar_text
6
+
7
+ attr_reader :id, :handle, :type, :link, :parent_community,
8
+ :count_items, :sub_communities, :collections, :expand
9
+
10
+ def initialize(args={})
11
+ @id = args['id']
12
+ @name = args['name']
13
+ @handle = args['handle']
14
+ @type = args['type']
15
+ @link = args['link']
16
+ @logo = args['logo']
17
+ @parent_community = args['parentCommunity']
18
+ @copyright_text = args['copyrightText']
19
+ @introductory_text = args['introductoryText']
20
+ @short_description = args['shortDescription']
21
+ @sidebar_text = args['sidebarText']
22
+ @count_items = args['countItems']
23
+ @sub_communities = args['subcommunities']
24
+ @collections = args['collections']
25
+ @expand = args['expand']
26
+ end
27
+
28
+ def to_h
29
+ h = Hash.new
30
+ h["handle"] = @handle
31
+ h["name"] = @name
32
+ h["id"] = @id
33
+ h["type"] = @type
34
+ h["link"] = @link
35
+ h["logo"] = @logo
36
+ h["parentCommunity"] = @parent_community
37
+ h["copyrightText"] = @copyright_text
38
+ h["introductoryText"] = @introductory_text
39
+ h["shortDescription"] = @short_description
40
+ h["sidebarText"] = @sidebar_text
41
+ h["countItems"] = @count_items
42
+ h["subcommunities"] = @sub_communities
43
+ h["collections"] = @collections
44
+ h["expand"] = @expand
45
+ h
46
+ end
47
+
48
+ end
49
+ end
@@ -0,0 +1,78 @@
1
+ require 'curb'
2
+
3
+ module DSpaceRest
4
+ class Item
5
+
6
+ attr_accessor :name, :archived, :withdrawn
7
+
8
+ attr_reader :id, :handle, :type, :link, :last_modified,
9
+ :parent_collection, :parent_collection_list, :bit_streams,
10
+ :expand, :metadata
11
+
12
+ def initialize args
13
+ @id = args['id'] || ""
14
+ @name = args['name'] || ""
15
+ @handle = args['handle'] || ""
16
+ @type = args['type'] || ""
17
+ @link = args['link'] || ""
18
+ @last_modified = args['lastModified'] || ""
19
+ @parent_collection = args['parentCollection'] || ""
20
+ @parent_collection_list = args['parentCollectionList'] || ""
21
+ @parent_community_list = args['parentCommunityList'] || ""
22
+ @bit_streams = args['bitstreams'] || ""
23
+ @archived = args['archived'] || ""
24
+ @withdrawn = args['withdrawn'] || ""
25
+ @expand = args['expand'] || ""
26
+ @metadata = []
27
+ end
28
+
29
+ def to_h
30
+ h = Hash.new
31
+ h["id"] = @id
32
+ h["name"] = @name
33
+ h["handle"] = @handle
34
+ h["type"] = @type
35
+ h["link"] = @link
36
+ h["lastModified"] = @last_modified
37
+ h["parentCollection"] = @parent_collection
38
+ h["parentCollectionList"] = @parent_collection_list
39
+ h["parentCommunityList"] = @parent_community_list
40
+ h["bitstreams"] = @bit_streams
41
+ h["archived"] = @archived
42
+ h["withdrawn"] = @withdrawn
43
+ h["expand"] = @expand
44
+
45
+ if !@metadata.empty?
46
+ h["metadata"] = metadata2hash @metadata
47
+ end
48
+
49
+ h
50
+ end
51
+
52
+ def add_metadata(key, value, language)
53
+ m = {}
54
+ m['key'] = key
55
+ m['value'] = value
56
+ m['language'] = language || ""
57
+
58
+ @metadata << DSpaceRest::Metadata.new(m)
59
+ @metadata
60
+ end
61
+
62
+ def reset_metadata
63
+ @metadata = []
64
+ end
65
+
66
+ private
67
+
68
+ def metadata2hash(metadata)
69
+ hash = []
70
+ @metadata.each do |m|
71
+ hash << m.to_h
72
+ end
73
+
74
+ hash
75
+ end
76
+
77
+ end
78
+ end
@@ -0,0 +1,17 @@
1
+ module DSpaceRest
2
+ class Metadata
3
+
4
+ attr_accessor :key, :value, :language
5
+
6
+ def initialize args
7
+ @key = args['key']
8
+ @value = args['value']
9
+ @language = args['language']
10
+ end
11
+
12
+ def to_h
13
+ return {"key" => @key, "value" => @value, "language" => @language}
14
+ end
15
+
16
+ end
17
+ end
@@ -0,0 +1,12 @@
1
+ module DSpaceRest
2
+ module Repositories
3
+ class AbstractRepository
4
+ attr_reader :rest_client
5
+
6
+ def initialize(rest_client)
7
+ @rest_client = rest_client
8
+ end
9
+
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,49 @@
1
+ module DSpaceRest
2
+ module Repositories
3
+ class BitstreamRepository < AbstractRepository
4
+
5
+ # Bitstreams are files. They have a filename, size (in bytes), and a file format.
6
+ # Typically in DSpace, the Bitstream will the "full text" article, or some other media.
7
+ # Some files are the actual file that was uploaded (tagged with bundleName:ORIGINAL),
8
+ # others are DSpace-generated files that are derivatives or renditions, such as text-extraction, or thumbnails.
9
+ # You can download files/bitstreams.
10
+ # DSpace doesn't really limit the type of files that it takes in, so this could be PDF, JPG, audio, video, zip,
11
+ # or other.
12
+ # Also, the logo for a Collection or a Community, is also a Bitstream.
13
+
14
+ # √ GET /bitstreams - Return all bitstreams in DSpace.
15
+ # √ GET /bitstreams/{bitstream id} - Return bitstream.
16
+ # GET /bitstreams/{bitstream id}/policy - Return bitstream policies.
17
+ # √ GET /bitstreams/{bitstream id}/retrieve - Return data of bitstream.
18
+ # POST /bitstreams/{bitstream id}/policy - Add policy to item. You must post a ResourcePolicy
19
+ # PUT /bitstreams/{bitstream id}/data - Update data/file of bitstream. You must put the data
20
+ # √ PUT /bitstreams/{bitstream id} - Update metadata of bitstream. You must put a Bitstream, does not alter the file/data
21
+ # DELETE /bitstreams/{bitstream id} - Delete bitstream from DSpace.
22
+ # DELETE /bitstreams/{bitstream id}/policy/{policy_id} - Delete bitstream policy.
23
+
24
+ def get_bitstream_by_id(id)
25
+ response = rest_client["/bitstreams/#{id}"].get
26
+ DSpaceRest::Bitstream.new(JSON.parse(response))
27
+ end
28
+
29
+ def get_all_bitstreams
30
+ response = rest_client["/bitstreams"].get
31
+ bit_streams = []
32
+ JSON.parse(response).each do |bits|
33
+ bit_streams << DSpaceRest::Bitstream.new(bits)
34
+ end
35
+ bit_streams
36
+ end
37
+
38
+ def retrieve_data(bitstream)
39
+ response = rest_client["/bitstreams/#{bitstream.id}/retrieve"].get
40
+ end
41
+
42
+ def update(bitstream)
43
+ valid_keys=['name', 'description', 'sequenceId']
44
+ form = JSON.generate(bitstream.to_h.select { |k, v| valid_keys.include? k })
45
+ response = rest_client["/bitstreams/#{bitstream.id}"].put form
46
+ end
47
+ end
48
+ end
49
+ end
@@ -0,0 +1,64 @@
1
+ module DSpaceRest
2
+ module Repositories
3
+ class CollectionRepository < AbstractRepository
4
+ # Collections in DSpace are containers of Items
5
+
6
+ # √ GET /communities/{communityId}/collections - Returns array of collections of community.
7
+ # √ GET /collections - Return all collections of DSpace in array.
8
+ # √ GET /collections/{collectionId} - Return collection with id.
9
+ # √ GET /collections/{collectionId}/items - Return all items of collection.
10
+ # √ POST /communities/{communityId}/collections - Create new collections in community. You must post Collection.
11
+ # √ POST /collections/{collectionId}/items - Create posted item in collection. You must post an Item
12
+ # POST /collections/find-collection - Find collection by passed name.
13
+ # PUT /collections/{collectionId} - Update collection. You must put Collection.
14
+ # DELETE /collections/{collectionId} - Delete collection from DSpace.
15
+ # DELETE /collections/{collectionId}/items/{itemId} - Delete item in collection.
16
+ # DELETE /communities/{communityId}/collections/{collectionId} - Delete collection in community.
17
+
18
+ def get_collection_items(collection)
19
+ response = rest_client["/collections/#{collection.id}/items"].get
20
+ items = []
21
+ JSON.parse(response).each do |item|
22
+ items << DSpaceRest::Item.new(item)
23
+ end
24
+ items
25
+ end
26
+
27
+ def get_collection_by_id(id)
28
+ response = rest_client["/collections/#{id}"].get
29
+ DSpaceRest::Collection.new(JSON.parse(response))
30
+ end
31
+
32
+ def get_all_collections
33
+ response = rest_client["/collections"].get
34
+ collections = []
35
+ JSON.parse(response).each do |coll|
36
+ collections << DSpaceRest::Collection.new(coll)
37
+ end
38
+ collections
39
+ end
40
+
41
+ def get_collections_of(community)
42
+ response = rest_client["/communities/#{community.id}/collections"].get
43
+ collections = []
44
+ JSON.parse(response).each do |coll|
45
+ collections << DSpaceRest::Collection.new(coll)
46
+ end
47
+ collections
48
+ end
49
+
50
+ def create_collection_for(community, collection)
51
+ form = JSON.generate(collection.to_h)
52
+ response = rest_client["/communities/#{community.id}/collections"].post form
53
+ DSpaceRest::Collection.new(JSON.parse(response))
54
+ end
55
+
56
+ def create_item_for(collection, item)
57
+ form = JSON.generate({"metadata" => item.to_h["metadata"]})
58
+ response = rest_client["/collections/#{collection.id}/items"].post form
59
+ DSpaceRest::Item.new(JSON.parse(response))
60
+ end
61
+
62
+ end
63
+ end
64
+ end
@@ -0,0 +1,62 @@
1
+ module DSpaceRest
2
+ module Repositories
3
+ class CommunityRepository < AbstractRepository
4
+ # Communities in DSpace are used for organization and hierarchy, and are containers that hold sub-Communities and Collections.
5
+
6
+ # √ GET /communities - Returns array of all communities in DSpace.
7
+ # √ GET /communities/top-communities - Returns array of all top communities in DSpace
8
+ # √ GET /communities/{communityId} - Returns community
9
+ # √ GET /communities/{communityId}/communities - Returns array of subcommunities of community.
10
+ # √ POST /communities - Create new community at top level. You must post community.
11
+ # √ POST /communities/{communityId}/communities - Create new subcommunity in community. You must post Community.
12
+ # PUT /communities/{communityId} - Update community. You must put Community
13
+ # DELETE /communities/{communityId} - Delete community.
14
+ # DELETE /communities/{communityId}/communities/{communityId2} - Delete subcommunity in community.
15
+
16
+ def get_community_by_id(id)
17
+ response = rest_client["/communities/#{id}"].get
18
+ DSpaceRest::Community.new(JSON.parse(response))
19
+ end
20
+
21
+ def get_all_communities
22
+ response = rest_client["/communities"].get
23
+ communities = []
24
+ JSON.parse(response).each do |comm|
25
+ communities << DSpaceRest::Community.new(comm)
26
+ end
27
+ communities
28
+ end
29
+
30
+ def get_top_communities
31
+ response = rest_client["/communities/top-communities"].get
32
+ communities = []
33
+ JSON.parse(response).each do |comm|
34
+ communities << DSpaceRest::Community.new(comm)
35
+ end
36
+ communities
37
+ end
38
+
39
+ def get_subcommunities_of(community)
40
+ response = rest_client["/communities/#{community.id}/communities"].get
41
+ communities = []
42
+ JSON.parse(response).each do |comm|
43
+ communities << DSpaceRest::Community.new(comm)
44
+ end
45
+ communities
46
+ end
47
+
48
+ def create_community(community)
49
+ form = JSON.generate(community.to_h)
50
+ response = rest_client["/communities"].post form
51
+ end
52
+
53
+ def create_subcommunity_of(community, subcommunity)
54
+ form = JSON.generate(subcommunity.to_h)
55
+ response = rest_client["/communities/#{community.id}/communities"].post form
56
+
57
+ DSpaceRest::Community.new(JSON.parse(response))
58
+ end
59
+
60
+ end
61
+ end
62
+ end
@@ -0,0 +1,27 @@
1
+ module DSpaceRest
2
+ module Repositories
3
+ class DspaceRepository < AbstractRepository
4
+
5
+ def bitstream_repository
6
+ BitstreamRepository.new rest_client
7
+ end
8
+
9
+ def collection_repository
10
+ CollectionRepository.new rest_client
11
+ end
12
+
13
+ def community_repository
14
+ CommunityRepository.new rest_client
15
+ end
16
+
17
+ def item_repository
18
+ ItemRepository.new rest_client
19
+ end
20
+
21
+ def metadata_repository
22
+ MetadataRepository.new rest_client
23
+ end
24
+
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,68 @@
1
+ module DSpaceRest
2
+ module Repositories
3
+ class ItemRepository < AbstractRepository
4
+ # Items in DSpace represent a "work" and combine metadata and files, known as Bitstreams
5
+
6
+ # √ GET /items - Return list of items.
7
+ # √ GET /items/{item id} - Return item.
8
+ # √ GET /items/{item id}/metadata - Return item metadata.
9
+ # √ GET /items/{item id}/bitstreams - Return item bitstreams.
10
+ # POST /items/find-by-metadata-field - Find items by metadata entry. You must post a MetadataEntry. DS-2501 - wrong SQL in REST /items/find-by-metadata-field CLOSED
11
+ # √ POST /items/{item id}/metadata - Add metadata to item. You must post an array of MetadataEntry
12
+ # √ POST /items/{item id}/bitstreams - Add bitstream to item. You must post a Bitstream
13
+ # √ PUT /items/{item id}/metadata - Update metadata in item. You must put a MetadataEntry
14
+ # √ DELETE /items/{item id} - Delete item.
15
+ # DELETE /items/{item id}/metadata - Clear item metadata.
16
+ # DELETE /items/{item id}/bitstreams/{bitstream id} - Delete item bitstream.
17
+
18
+
19
+ def get_all_items
20
+ response = rest_client["/items"].get
21
+ items = []
22
+ JSON.parse(response).each do |item|
23
+ items << DSpaceRest::Item.new(item)
24
+ end
25
+ items
26
+ end
27
+
28
+ def get_item_by_id(id)
29
+ response = rest_client["/items/#{id}"].get
30
+ DSpaceRest::Item.new(JSON.parse(response))
31
+ end
32
+
33
+ def get_metadata_of(item)
34
+ response = rest_client["/items/#{item.id}/metadata"].get
35
+ metadata = []
36
+ JSON.parse(response).each do |m|
37
+ metadata << DSpaceRest::Metadata.new(m)
38
+ end
39
+ metadata
40
+ end
41
+
42
+ def get_bitstreams_of(item)
43
+ response = rest_client["/items/#{item.id}/bitstreams"].get
44
+ bitstreams = []
45
+ JSON.parse(response).each do |bits|
46
+ bitstreams << DSpaceRest::Bitstream.new(bits)
47
+ end
48
+ bitstreams
49
+ end
50
+
51
+
52
+ def create_metadata_for(item)
53
+ form = JSON.generate(self.to_h["metadata"])
54
+ response = rest_client["/items/#{item.id}/metadata"].put form
55
+ end
56
+
57
+ def create_bitstream_for(item, file, upload_strategy)
58
+ response = upload_strategy.upload("/items/#{item.id}/bitstreams", file)
59
+ DSpaceRest::Bitstream.new(JSON.parse(response))
60
+ end
61
+
62
+ def delete(item)
63
+ response = rest_client["/items/#{item.id}"].delete
64
+ end
65
+
66
+ end
67
+ end
68
+ end
@@ -0,0 +1,27 @@
1
+ #require 'curl'
2
+
3
+ module DSpaceRest
4
+ module Strategies
5
+ module Uploads
6
+ class CurlStrategy
7
+
8
+ def initialize(host_url, token)
9
+ @host_url = host_url
10
+ @token = token
11
+ end
12
+
13
+ def upload(endpoint, file)
14
+ c = Curl::Easy.new(@host_url.concat(endpoint))
15
+ c.headers['Accept'] = 'application/json'
16
+ c.headers['rest-dspace-token'] = @token
17
+
18
+ c.multipart_form_post = true
19
+ c.ssl_verify_peer = false
20
+ c.http_post(Curl::PostField.file('file', file))
21
+
22
+ c.body_str
23
+ end
24
+ end
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,17 @@
1
+ module DSpaceRest
2
+ module Strategies
3
+ module Uploads
4
+ class RestStrategy
5
+
6
+ def initialize(rest_client)
7
+ @rest_client = rest_client
8
+ end
9
+
10
+ def upload(endpoint, file)
11
+ @rest_client[endpoint].post File.read(file)
12
+ end
13
+
14
+ end
15
+ end
16
+ end
17
+ end
metadata ADDED
@@ -0,0 +1,94 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: dspace_rest_client
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Mauricio Giacomini Girardello
8
+ - Bruno N. Zanette
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2015-04-17 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: rest-client
16
+ requirement: !ruby/object:Gem::Requirement
17
+ requirements:
18
+ - - ">="
19
+ - !ruby/object:Gem::Version
20
+ version: '1.7'
21
+ - - "<"
22
+ - !ruby/object:Gem::Version
23
+ version: '2'
24
+ type: :runtime
25
+ prerelease: false
26
+ version_requirements: !ruby/object:Gem::Requirement
27
+ requirements:
28
+ - - ">="
29
+ - !ruby/object:Gem::Version
30
+ version: '1.7'
31
+ - - "<"
32
+ - !ruby/object:Gem::Version
33
+ version: '2'
34
+ - !ruby/object:Gem::Dependency
35
+ name: curb
36
+ requirement: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: 0.8.6
41
+ type: :runtime
42
+ prerelease: false
43
+ version_requirements: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: 0.8.6
48
+ description: DSpace REST-API Client for Ruby! Implements all DSpace REST-API endpoints
49
+ requests.
50
+ email: c3sl@c3sl.ufpr.br
51
+ executables: []
52
+ extensions: []
53
+ extra_rdoc_files: []
54
+ files:
55
+ - lib/dspace_client.rb
56
+ - lib/dspace_rest_client.rb
57
+ - lib/dspacerest/bitstream.rb
58
+ - lib/dspacerest/collection.rb
59
+ - lib/dspacerest/community.rb
60
+ - lib/dspacerest/item.rb
61
+ - lib/dspacerest/metadata.rb
62
+ - lib/dspacerest/repositories/abstract_repository.rb
63
+ - lib/dspacerest/repositories/bitstream_repository.rb
64
+ - lib/dspacerest/repositories/collection_repository.rb
65
+ - lib/dspacerest/repositories/community_repository.rb
66
+ - lib/dspacerest/repositories/dspace_repository.rb
67
+ - lib/dspacerest/repositories/item_repository.rb
68
+ - lib/dspacerest/strategies/uploads/curl_strategy.rb
69
+ - lib/dspacerest/strategies/uploads/rest_strategy.rb
70
+ homepage: https://gitlab.c3sl.ufpr.br/c3sl/dspace-rest-client
71
+ licenses:
72
+ - GNU General Public License
73
+ metadata: {}
74
+ post_install_message:
75
+ rdoc_options: []
76
+ require_paths:
77
+ - lib
78
+ required_ruby_version: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ required_rubygems_version: !ruby/object:Gem::Requirement
84
+ requirements:
85
+ - - ">="
86
+ - !ruby/object:Gem::Version
87
+ version: '0'
88
+ requirements: []
89
+ rubyforge_project:
90
+ rubygems_version: 2.4.6
91
+ signing_key:
92
+ specification_version: 4
93
+ summary: DSpace REST-API Client for Ruby!
94
+ test_files: []