README.md 1.49 KB
Newer Older
1
# DSpace REST Client
2

3 4 5
## Installation

Add this line to your application's Gemfile:
6 7

```ruby
8
gem 'dspace_rest_client'
9
```
10

11
And then execute:
12

13
    $ bundle
14

15
Or install it yourself as:
16

17
    $ gem install dspace_rest_client
18

19
## Get started
20

21
Some requests requires user authentication.
22

23 24 25 26 27 28 29
```ruby
require 'dspace'
client = Dspace::Client.new(dspace_api: 'https://demo.dspace.org/')

if !client.is_running?
  raise 'Can\'t connect to DSpace API.'
end
30

31 32 33 34 35
# authenticate
client.login 'dspacedemo+admin@gmail.com', 'dspace'

# create an community
client.communities.create(Dspace::Community.new({'name' => 'Testando'}))
36 37 38

# get a bitstream and your file
bitstream = client.bitstreams.find(id: 20, expand: 'parent')
39
tmp_file = client.bitstreams.retrieve(id: 20) #<Tempfile:/tmp/..._teste.jpg>
40 41 42 43 44 45 46 47

# creating a new bitstream for some item
file = File.new('/your/path/Pictures/Celular/some_book.pdf', 'r')
bitstream = client.items.add_bitstream(file, id: 11, name: 'some_book.pdf', description: 'testing upload a pdf book')

# updating bitstream metadata
bitstream.name = 'new_book_name.pdf'
client.bitstreams.update(bitstream, id: bitstream.id)
48 49
```

50 51
To see more examples, visit our Wiki.

52
## Development
53

54
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rspec spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
55

56
## Contributing
57

58
Bug reports and pull requests are welcome. This project is intended to be a safe, welcoming space for collaboration.