cirneco 0.9.25 → 0.9.26
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +8 -8
- data/README.md +13 -0
- data/lib/cirneco/api.rb +13 -0
- data/lib/cirneco/doi.rb +26 -0
- data/lib/cirneco/utils.rb +20 -0
- data/lib/cirneco/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1cc8643645d23b3d2995639c6ee153e006547918e4fffa0cd64063a9628722b0
|
4
|
+
data.tar.gz: f66ce1ea88a7b0f3b80fa3625d50bcc1f48e5a97761baab5f7b36f9e1a2bbfac
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 902fdaeccbd4f869e97ed44fbbd91fa77d7430e25ab9612a8e446c278f0402db241cc54a07772490a8a80d2227dda5f299837a83621f25796c528ad6bfba146d
|
7
|
+
data.tar.gz: 636c9bf5ea8b5f9049241ded6fc0d7a16ab08372b4b2d5a2d46d3de440ce62512d4effe5a10f7ac0d275749ec1b9a8e338fcb71fd35a00371123c6e57d1d79e0
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
cirneco (0.9.
|
4
|
+
cirneco (0.9.26)
|
5
5
|
activesupport (>= 4.2.5, < 6)
|
6
6
|
base32-url (~> 0.5)
|
7
7
|
bergamasco (~> 0.3)
|
@@ -36,7 +36,7 @@ GEM
|
|
36
36
|
safe_yaml (~> 1.0, >= 1.0.4)
|
37
37
|
bibtex-ruby (4.4.7)
|
38
38
|
latex-decode (~> 0.0)
|
39
|
-
bolognese (0.
|
39
|
+
bolognese (0.14.1)
|
40
40
|
activesupport (>= 4.2.5, < 6)
|
41
41
|
benchmark_methods (~> 0.7)
|
42
42
|
bibtex-ruby (~> 4.1)
|
@@ -66,13 +66,13 @@ GEM
|
|
66
66
|
diff-lcs (1.3)
|
67
67
|
docile (1.1.5)
|
68
68
|
dotenv (2.5.0)
|
69
|
-
ebnf (1.1.
|
70
|
-
rdf (
|
69
|
+
ebnf (1.1.3)
|
70
|
+
rdf (~> 3.0)
|
71
71
|
sxp (~> 1.0)
|
72
72
|
excon (0.62.0)
|
73
73
|
faraday (0.15.2)
|
74
74
|
multipart-post (>= 1.2, < 3)
|
75
|
-
faraday-encoding (0.0.
|
75
|
+
faraday-encoding (0.0.5)
|
76
76
|
faraday
|
77
77
|
faraday_middleware (0.12.2)
|
78
78
|
faraday (>= 0.7.4, < 1.0)
|
@@ -129,7 +129,7 @@ GEM
|
|
129
129
|
rack-test (0.8.3)
|
130
130
|
rack (>= 1.0, < 3)
|
131
131
|
rake (12.3.1)
|
132
|
-
rdf (3.0.
|
132
|
+
rdf (3.0.3)
|
133
133
|
hamster (~> 3.0)
|
134
134
|
link_header (~> 0.0, >= 0.0.8)
|
135
135
|
rdf-aggregate-repo (2.2.1)
|
@@ -148,7 +148,7 @@ GEM
|
|
148
148
|
rdf-turtle (2.2.2)
|
149
149
|
ebnf (~> 1.1)
|
150
150
|
rdf (>= 2.2, < 4.0)
|
151
|
-
rdf-xsd (3.0.
|
151
|
+
rdf-xsd (3.0.1)
|
152
152
|
rdf (~> 3.0)
|
153
153
|
rspec (3.8.0)
|
154
154
|
rspec-core (~> 3.8.0)
|
@@ -204,4 +204,4 @@ DEPENDENCIES
|
|
204
204
|
webmock (~> 3.0, >= 3.0.1)
|
205
205
|
|
206
206
|
BUNDLED WITH
|
207
|
-
1.16.
|
207
|
+
1.16.4
|
data/README.md
CHANGED
@@ -127,6 +127,19 @@ Hide DOIs with metadata for all markdown files in a folder
|
|
127
127
|
cirneco doi hide /source/posts
|
128
128
|
```
|
129
129
|
|
130
|
+
## Bulk Operations
|
131
|
+
|
132
|
+
Transfer a list of DOIs. A list of DOIs must be provided in a file
|
133
|
+
|
134
|
+
```
|
135
|
+
10.5438/5aep-2n86
|
136
|
+
10.5438/cd2b-xj80
|
137
|
+
```
|
138
|
+
|
139
|
+
```shell
|
140
|
+
cirneco doi transfer --target DATACITE.DATACITE --jwt {YOUR-JSON-WEB-TOKEN} ./doi_transfer.txt
|
141
|
+
```
|
142
|
+
|
130
143
|
## Development
|
131
144
|
|
132
145
|
We use rspec for unit testing:
|
data/lib/cirneco/api.rb
CHANGED
@@ -21,6 +21,19 @@ module Cirneco
|
|
21
21
|
Maremma.put(url, content_type: 'application/xml;charset=UTF-8', data: options[:data], username: options[:username], password: options[:password])
|
22
22
|
end
|
23
23
|
|
24
|
+
def transfer_doi(doi, options={})
|
25
|
+
return OpenStruct.new(body: { "errors" => [{ "title" => "JWT or Username or password missing" }] }) unless options[:jwt].present? || (options[:username].present? && options[:password].present?)
|
26
|
+
|
27
|
+
api_url = options[:sandbox] ? 'https://api.test.datacite.org' : 'https://api.datacite.org'
|
28
|
+
|
29
|
+
url = URI.encode("#{api_url}/dois/#{doi}")
|
30
|
+
if options[:jwt].present?
|
31
|
+
Maremma.patch(url, content_type: 'application/vnd.api+json;charset=UTF-8', data: options[:data], bearer: options[:jwt])
|
32
|
+
else
|
33
|
+
Maremma.patch(url, content_type: 'application/vnd.api+json;charset=UTF-8', data: options[:data], username: options[:username], password: options[:password])
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
24
37
|
def get_metadata(doi, options={})
|
25
38
|
return OpenStruct.new(body: { "errors" => [{ "title" => "Username or password missing" }] }) unless options[:username].present? && options[:password].present?
|
26
39
|
|
data/lib/cirneco/doi.rb
CHANGED
@@ -112,5 +112,31 @@ module Cirneco
|
|
112
112
|
puts "Checksum for #{doi} is not valid"
|
113
113
|
end
|
114
114
|
end
|
115
|
+
|
116
|
+
desc "transfer DOIs", "transfer list of DOIs"
|
117
|
+
method_option :target, :type => :string
|
118
|
+
method_option :username, :default => ENV['MDS_USERNAME']
|
119
|
+
method_option :password, :default => ENV['MDS_PASSWORD']
|
120
|
+
method_option :sandbox, :type => :boolean, :force => false
|
121
|
+
method_option :jwt, :default => ENV['JWT']
|
122
|
+
def transfer(file)
|
123
|
+
count = 0
|
124
|
+
File.foreach(file) do |line|
|
125
|
+
doi = line.rstrip
|
126
|
+
next unless doi.present?
|
127
|
+
meta = generate_transfer_template(options)
|
128
|
+
|
129
|
+
response = transfer_doi(doi, options.merge(data: meta.to_json))
|
130
|
+
|
131
|
+
if [200, 201].include?(response.status)
|
132
|
+
puts "#{doi} Transfered to #{options[:target]}."
|
133
|
+
count += 1
|
134
|
+
else
|
135
|
+
puts "Error: " + response.body["errors"].first.fetch("title", "An error occured")
|
136
|
+
end
|
137
|
+
end
|
138
|
+
|
139
|
+
puts "#{count} DOIs transfered."
|
140
|
+
end
|
115
141
|
end
|
116
142
|
end
|
data/lib/cirneco/utils.rb
CHANGED
@@ -18,6 +18,26 @@ module Cirneco
|
|
18
18
|
response
|
19
19
|
end
|
20
20
|
|
21
|
+
def generate_transfer_template(options={})
|
22
|
+
response = {
|
23
|
+
"data" => {
|
24
|
+
"type" => "dois",
|
25
|
+
"attributes" => {
|
26
|
+
"mode" => "transfer"
|
27
|
+
},
|
28
|
+
"relationships"=> {
|
29
|
+
"client"=> {
|
30
|
+
"data"=> {
|
31
|
+
"type"=> "clients",
|
32
|
+
"id"=> options[:target].downcase
|
33
|
+
}
|
34
|
+
}
|
35
|
+
}
|
36
|
+
}
|
37
|
+
}
|
38
|
+
response
|
39
|
+
end
|
40
|
+
|
21
41
|
def decode_doi(doi)
|
22
42
|
prefix, string = doi.split('/', 2)
|
23
43
|
Base32::URL.decode(string, checksum: true).to_i
|
data/lib/cirneco/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cirneco
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.9.
|
4
|
+
version: 0.9.26
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Martin Fenner
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-09-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: maremma
|