dataverse 0.1.0 → 0.1.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
2
  SHA256:
3
- metadata.gz: 218801f555a41f3c5a6b5f780903c8558c5df6d1b149470e649a763bf2f7fd39
4
- data.tar.gz: 498a782ecc5c745fa4b23c2bae2cd599b73a855dec072e91a1f96a254db9c8be
3
+ metadata.gz: 8a378998e229002001b0b68f0c9d2cb90244106ef05720aed7a6d9899fc7b599
4
+ data.tar.gz: 1e60cab628d4b6e5b1307ed3aa8631b2c2d99efb268a887729c33713caaf8543
5
5
  SHA512:
6
- metadata.gz: 6cd333801c73346653ca2a9780f9cf99d22bb2d2e343d424dff73e48a6789dd87487309a8d7ae72b905bc6c9512de2f84d12f08e188c8a2d0cf1f18add2344c2
7
- data.tar.gz: 65ad0e6cf95d2a557195414226da5fa751dde28e3111370beb46c5f24b00b65781ba40183d8b3dbee3fe568eab3520bf355920aa975e215326d20af5695978af
6
+ metadata.gz: e6f8171213b9de61b5b5854e594f1e125e4c6e6ecd03c16461f022dde1e2e56bddf8ad3d219f352a8e37f2fe1ddd7427757c6c921746806ae476cdcc64aa0193
7
+ data.tar.gz: fde1a04400885bb74e5164ee49b0f4f645a3ec2253ece76f345ab3cd95c0d9af86e1201b2655f2855fc7c475abb48099bfa130f642baab3cc53744f9d1f471e9
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- dataverse (0.1.0)
4
+ dataverse (0.1.1)
5
5
  rest-client (~> 2.0)
6
6
 
7
7
  GEM
@@ -48,6 +48,7 @@ GEM
48
48
  unf_ext (0.0.7.7)
49
49
 
50
50
  PLATFORMS
51
+ ruby
51
52
  x86_64-linux
52
53
 
53
54
  DEPENDENCIES
data/README.md CHANGED
@@ -1,8 +1,6 @@
1
- # Dataverse
1
+ # Dataverse API gem
2
2
 
3
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/dataverse`. To experiment with that code, run `bin/console` for an interactive prompt.
4
-
5
- TODO: Delete this and the text above, and describe your gem
3
+ This gem wraps the Dataverse API in a set of Ruby classes. You can use the classes to perform the API calls and process the result on the Ruby objects. It builds upon the rest-client gem to perform the low-level REST API calls. For more information about Dataverse and the API, see https://dataverse.org/ and https://guides.dataverse.org/en/latest/api/index.html
6
4
 
7
5
  ## Installation
8
6
 
@@ -14,15 +12,23 @@ gem 'dataverse'
14
12
 
15
13
  And then execute:
16
14
 
17
- $ bundle install
15
+ ```
16
+ $ bundle install
17
+ ```
18
18
 
19
19
  Or install it yourself as:
20
20
 
21
- $ gem install dataverse
21
+ ```
22
+ $ gem install dataverse
23
+ ```
22
24
 
23
25
  ## Usage
24
26
 
25
- This gem wraps the Dataverse.org API in a set of Ruby classes. You can use the classes to perform the API calls and process the result on the Ruby objects. It builds upon the rest-client gem to perform the low-level REST API calls.
27
+ First load the library with
28
+
29
+ ```ruby
30
+ require 'dataverse'
31
+ ```
26
32
 
27
33
  In order to configure the API calls, you need to define at least two environment variables:
28
34
 
@@ -30,29 +36,31 @@ In order to configure the API calls, you need to define at least two environment
30
36
  - API_TOKEN: a token to identify and authorize the user. Note that for some API calls a superuser token may be required.
31
37
  - RESTCLIENT_LOG: if defined, will log the REST API calls to the given file. Set to 'stdout' if you want to log to screen.
32
38
 
39
+ You can set these environment variables in a .env file and use the dotenv gem to load the variables. The file .env.template is provided as a starting point for you.
40
+
33
41
  ## Dataverse::Dataverse
34
42
 
35
- The class that captures the api dealing with dataverses.
43
+ The class that captures the api dealing with Dataverse collections.
36
44
 
37
- ### Accessing an existing dataverse
45
+ ### Accessing an existing Dataverse collection
38
46
 
39
- You can create a new instance by supplying the id or alias of an existing dataverse to the constructor:
47
+ You can create a new instance by supplying the id or alias of an existing Dataverse collection to the constructor:
40
48
 
41
49
  ```ruby
42
50
  Dataverse::Dataverse.id('my_dataverse')
43
51
  # => #<Dataverse::Dataverse:0x0...>
44
52
  ```
45
53
 
46
- You can pass the value ':root' or use the #root class method if you want to access the root dataverse.
54
+ You can pass the value ':root' or use the #root class method if you want to access the Dataverse root collection.
47
55
 
48
56
  ```ruby
49
57
  Dataverse::Dataverse.id(':root') == Dataverse::Dataverse.root
50
58
  # => true
51
59
  ```
52
60
 
53
- ### Creating a new dataverse
61
+ ### Creating a new Dataverse collection
54
62
 
55
- To create a new dataverse, you should first open an instance for the parent dataverse, then call the #create method on it, supplying either a Hash, a file name or a JSON string.
63
+ To create a new Dataverse collection, you should first open an instance for the parent Dataverse collection, then call the #create method on it, supplying either a Hash, a file name or a JSON string.
56
64
 
57
65
  ```ruby
58
66
  parent_dv = Dataverse::Dataverse.id('parent_dv')
@@ -77,14 +85,14 @@ Dataverse::Dataverse::TYPES
77
85
  # "UNCATEGORIZED"]
78
86
  ```
79
87
 
80
- All the metadata of an existing dataverse can be retrieved as a Hash with the #rdm_data method:
88
+ All the metadata of an existing Dataverse collection can be retrieved as a Hash with the #rdm_data method:
81
89
 
82
90
  ```ruby
83
91
  parent_dv.rdm_data
84
92
  # => {"id"=>5, "alias"=>"parent_dv", ...}
85
93
  ```
86
94
 
87
- The resulting Hash can be saved to a file and used to create a new dataverse:
95
+ The resulting Hash can be saved to a file and used to create a new Dataverse collection:
88
96
 
89
97
  ```ruby
90
98
  data = parent_dv.rdm_data.dup
@@ -95,14 +103,14 @@ new_dv = parent_dv.create(filename)
95
103
  # => #<Dataverse::Dataverse:0x0...>
96
104
  ```
97
105
 
98
- ### Deleting a dataverse
106
+ ### Deleting a Dataverse collection
99
107
 
100
108
  ```ruby
101
109
  new_dv.delete
102
110
  # => {"message" => "Dataverse 15 deleted"}
103
111
  ```
104
112
 
105
- ### Publishing a dataverse
113
+ ### Publishing a Dataverse collection
106
114
 
107
115
  ```ruby
108
116
  new_dv.publish
@@ -112,11 +120,11 @@ new_dv.publish
112
120
  # => Dataverse::Error: Dataverse new_dv has already been published
113
121
  ```
114
122
 
115
- Note that if a dataverse was already published, the call will raise a Dataverse::Error exception.
123
+ Note that if a Dataverse collection was already published, the call will raise a Dataverse::Error exception.
116
124
 
117
- ### Access dataverse properties
125
+ ### Access properties of a Dataverse collection
118
126
 
119
- The Dataverse properties can be accessed similar to a Hash:
127
+ The properties of a Dataverse collection can be accessed similar to a Hash:
120
128
 
121
129
  ```ruby
122
130
  parent_dv.keys
@@ -159,7 +167,7 @@ data
159
167
  # => {"alias" => "new_dv", ...}
160
168
  ```
161
169
 
162
- The id or alias that was used to instantiate the Dataverse:
170
+ The id or alias that was used to instantiate the Dataverse collection:
163
171
 
164
172
  ```ruby
165
173
  parent_dv.id
@@ -179,7 +187,7 @@ parent_dv['alias']
179
187
  # => "parent_dv"
180
188
  ```
181
189
 
182
- ### Report the data file size of a Dataverse (in bytes)
190
+ ### Report the data file size of a Dataverse collection (in bytes)
183
191
 
184
192
  ```ruby
185
193
  parent_dv.size
@@ -188,14 +196,14 @@ parent_dv.size
188
196
 
189
197
  ### Browsing
190
198
 
191
- Get an array of child dataverses and datasets:
199
+ Get an array of child Dataverse collections and datasets:
192
200
 
193
201
  ```ruby
194
202
  parent_dv.children
195
203
  # => [#<Dataverse::Dataverse:0x0...>, #<Dataverse::Dataset:0x0...>]
196
204
  ```
197
205
 
198
- Iterate over all child dataverses recursively:
206
+ Iterate over all child Dataverse collections recursively:
199
207
 
200
208
  ```ruby
201
209
  parent_dv.each_dataverse do |dv|
@@ -209,8 +217,8 @@ end
209
217
  Iterate over all child datasets recursively:
210
218
 
211
219
  ```ruby
212
- parent_dv.each_dataverse do |dv|
213
- puts dv.size
220
+ parent_dv.each_dataset do |ds|
221
+ puts ds.size
214
222
  end
215
223
  # => 123456
216
224
  # => 456123
@@ -223,7 +231,7 @@ The class that encapsulates the dataset related API.
223
231
 
224
232
  ### Accessing an existing dataset
225
233
 
226
- A new Dataset instance can be obtained from the parent Dataverse's #children call or can be directly instantiated if you know the dataset's id or persistent identifier:
234
+ A new Dataset instance can be obtained from the parent Dataverse collection's #children call or can be directly instantiated if you know the dataset's id or persistent identifier:
227
235
 
228
236
  ```ruby
229
237
  ds = parent_dv.children[1]
@@ -238,7 +246,7 @@ Dataverse::Dataset.pid('doi:10.5072/FK2/J8SJZB')
238
246
 
239
247
  ### Creating a new dataset
240
248
 
241
- A new dataset can only be created on an existing dataverse. You should supply either a Hash, a file name or a JSON string to the #create_dataset method.
249
+ A new dataset can only be created on an existing Dataverse collection. You should supply either a Hash, a file name or a JSON string to the #create_dataset method.
242
250
 
243
251
  ```ruby
244
252
  ds = parent_dv.create_dataset(
@@ -259,7 +267,7 @@ data = ds.raw_data
259
267
  # => {"datasetVersion" => {"metadataBlocks" => {"citation" => {...}}}}
260
268
  ```
261
269
 
262
- The resulting Hash can be used to create a new dataverse, either directly or by saving it to a file.
270
+ The resulting Hash can be used to create a new dataset, either directly or by saving it to a file.
263
271
 
264
272
  ```ruby
265
273
  data = ds.raw_data
@@ -274,7 +282,7 @@ new_ds = parent_dv.create_dataset(filename)
274
282
 
275
283
  ### Importing a dataset
276
284
 
277
- The #import_dataset method on a dataverse allows to import an existing dataset. The dataset should be registred and its persisten identifier should be supplied in the pid argument. The data argument is similar to the #create_dataset method.
285
+ The #import_dataset method on a Dataverse collection allows to import an existing dataset. The dataset should be registred and its persisten identifier should be supplied in the pid argument. The data argument is similar to the #create_dataset method.
278
286
 
279
287
  ```ruby
280
288
  data = 'dataset.json'
@@ -415,7 +423,7 @@ data = ds.export_metadata('schema.org')
415
423
  # => {"@context"=>"http://schema.org", "@type"=>"Dataset", ...}
416
424
  ```
417
425
 
418
- The resulting Hash can be used to create a new dataverse, either directly or by saving it to a file.
426
+ The resulting Hash can be used to create a new dataset, either directly or by saving it to a file.
419
427
 
420
428
  ```ruby
421
429
  data = ds.raw_data
@@ -595,4 +603,4 @@ The gem is available as open source under the terms of the [MIT License](https:/
595
603
 
596
604
  ## Code of Conduct
597
605
 
598
- Everyone interacting in the Dataverse project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/libis/dataverse_api/blob/master/CODE_OF_CONDUCT.md).
606
+ Everyone interacting in the Dataverse API project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/libis/dataverse_api/blob/master/CODE_OF_CONDUCT.md).
@@ -25,7 +25,7 @@ module Dataverse
25
25
  end
26
26
 
27
27
  def delete
28
- url = raise Error.new 'Can only delete draft version' unless draft_version
28
+ raise Error.new 'Can only delete draft version' unless draft_version
29
29
  versions
30
30
  result = call('versions/:draft', method: :delete)
31
31
  @version_data.delete(:draft)
@@ -61,7 +61,7 @@ module Dataverse
61
61
  end
62
62
 
63
63
  def size
64
- data = call("storagesize". params: {includCached: 'true'})
64
+ data = call("storagesize", params: {includCached: 'true'})
65
65
  data['message'][/[,\d]+/].delete(',').to_i
66
66
  end
67
67
 
@@ -255,7 +255,7 @@ module Dataverse
255
255
  end
256
256
 
257
257
  def version_data(version)
258
- data = @version_data[resolve_version(version)].transform_keys {|k| k == 'id' ? 'versionId' : k}
258
+ @version_data[resolve_version(version)].transform_keys { |k| k == 'id' ? 'versionId' : k }
259
259
  end
260
260
 
261
261
  private
@@ -127,7 +127,7 @@ module Dataverse
127
127
  end
128
128
 
129
129
  def export_metadata(md_type)
130
- format = case md_type.to_s
130
+ case md_type.to_s
131
131
  when 'rdm'
132
132
  return rdm_data
133
133
  else
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Dataverse
4
- VERSION = "0.1.0"
4
+ VERSION = "0.1.1"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dataverse
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kris Dekeyser
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-04-06 00:00:00.000000000 Z
11
+ date: 2021-05-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rest-client
@@ -73,7 +73,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
73
73
  - !ruby/object:Gem::Version
74
74
  version: '0'
75
75
  requirements: []
76
- rubygems_version: 3.2.15
76
+ rubygems_version: 3.1.4
77
77
  signing_key:
78
78
  specification_version: 4
79
79
  summary: Dataverse API.