cirneco 0.6.1 → 0.6.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +3 -3
- data/lib/cirneco/doi.rb +8 -8
- data/lib/cirneco/utils.rb +14 -13
- data/lib/cirneco/version.rb +1 -1
- data/spec/fixtures/cool-dois.html.md +2 -0
- data/spec/utils_spec.rb +21 -15
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: eaeaad21cf2a466a9c9cd5f263c3023ffbb06d88
|
4
|
+
data.tar.gz: e8a4c0677b9c1b295b08df6cfba35059c245836f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c77a6e9d70d11a4452b7ae5d8167fba20aaeaedfbced8b79008f2b0c4fbe8d1e77095b20198b51b25c756a0a01478cd90a5a607b147415ba8876d48940f42fdd
|
7
|
+
data.tar.gz: 8e995c12b58effd10dea51965c8d2874f1bf925cb4ccf95d033f646b424ccc99ebdb6001522847ce991c70316a6d2d18604ecec4849b7d74b7983340678db5fb
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
cirneco (0.6.
|
4
|
+
cirneco (0.6.2)
|
5
5
|
activesupport (~> 4.2, >= 4.2.5)
|
6
6
|
base32-crockford-checksum (~> 0.2.2)
|
7
7
|
bergamasco (~> 0.2)
|
@@ -22,7 +22,7 @@ GEM
|
|
22
22
|
tzinfo (~> 1.1)
|
23
23
|
addressable (2.3.8)
|
24
24
|
base32-crockford-checksum (0.2.3)
|
25
|
-
bergamasco (0.2.
|
25
|
+
bergamasco (0.2.12)
|
26
26
|
activesupport (~> 4.2, >= 4.2.5)
|
27
27
|
addressable (~> 2.3.8)
|
28
28
|
builder (~> 3.2, >= 3.2.2)
|
@@ -127,4 +127,4 @@ DEPENDENCIES
|
|
127
127
|
webmock (~> 1.22, >= 1.22.3)
|
128
128
|
|
129
129
|
BUNDLED WITH
|
130
|
-
1.
|
130
|
+
1.12.5
|
data/lib/cirneco/doi.rb
CHANGED
@@ -48,32 +48,32 @@ module Cirneco
|
|
48
48
|
end
|
49
49
|
end
|
50
50
|
|
51
|
-
desc "
|
51
|
+
desc "mint DOCUMENTS", "mint documents"
|
52
52
|
method_option :username, :default => ENV['MDS_USERNAME']
|
53
53
|
method_option :password, :default => ENV['MDS_PASSWORD']
|
54
54
|
method_option :prefix, :default => ENV['PREFIX']
|
55
55
|
method_option :sandbox, :default => ENV['SANDBOX']
|
56
|
-
def
|
56
|
+
def mint(filepath)
|
57
57
|
|
58
58
|
if File.directory?(filepath)
|
59
|
-
response =
|
59
|
+
response = mint_dois_for_all_files(filepath, options)
|
60
60
|
else
|
61
|
-
response =
|
61
|
+
response = mint_doi_for_file(filepath, options)
|
62
62
|
end
|
63
63
|
|
64
64
|
puts response
|
65
65
|
end
|
66
66
|
|
67
|
-
desc "
|
67
|
+
desc "hide DOCUMENTS", "hide documents"
|
68
68
|
method_option :username, :default => ENV['MDS_USERNAME']
|
69
69
|
method_option :password, :default => ENV['MDS_PASSWORD']
|
70
70
|
method_option :sandbox, :default => ENV['SANDBOX']
|
71
|
-
def
|
71
|
+
def hide(filepath)
|
72
72
|
|
73
73
|
if File.directory?(filepath)
|
74
|
-
response =
|
74
|
+
response = hide_dois_for_all_files(filepath, options)
|
75
75
|
else
|
76
|
-
response =
|
76
|
+
response = hide_doi_for_file(filepath, options)
|
77
77
|
end
|
78
78
|
|
79
79
|
puts response
|
data/lib/cirneco/utils.rb
CHANGED
@@ -28,12 +28,12 @@ module Cirneco
|
|
28
28
|
end
|
29
29
|
|
30
30
|
# currently only supports markdown files with YAML header
|
31
|
-
def
|
31
|
+
def mint_doi_for_file(filepath, options={})
|
32
32
|
filename = File.basename(filepath)
|
33
33
|
return "File #{filename} ignored: not a markdown file" unless File.extname(filepath) == ".md"
|
34
34
|
|
35
35
|
old_metadata = Bergamasco::Markdown.read_yaml_for_doi_metadata(filepath)
|
36
|
-
return nil if old_metadata["doi"]
|
36
|
+
return nil if old_metadata["doi"] && old_metadata["published"]
|
37
37
|
|
38
38
|
metadata = generate_metadata_for_work(filepath, options)
|
39
39
|
work = register_work_for_metadata(metadata)
|
@@ -44,17 +44,18 @@ module Cirneco
|
|
44
44
|
# new_data = [{ "filename" => filename, "doi" => doi, "date" => Time.now.utc.iso8601 }]
|
45
45
|
# Bergamasco::Markdown.write_yaml(datapath, data + new_data)
|
46
46
|
|
47
|
-
new_metadata = Bergamasco::Markdown.update_file(filepath,
|
48
|
-
"DOI #{new_metadata["doi"]}
|
47
|
+
new_metadata = Bergamasco::Markdown.update_file(filepath, "doi" => metadata["doi"], "published" => true)
|
48
|
+
"DOI #{new_metadata["doi"]} minted for #{filename}"
|
49
49
|
end
|
50
50
|
|
51
51
|
# currently only supports markdown files with YAML header
|
52
|
-
|
52
|
+
# DOIs are never deleted, but we can remove the metadata from the DataCite index
|
53
|
+
def hide_doi_for_file(filepath, options={})
|
53
54
|
filename = File.basename(filepath)
|
54
55
|
return "File #{filename} ignored: not a markdown file" unless File.extname(filepath) == ".md"
|
55
56
|
|
56
57
|
old_metadata = Bergamasco::Markdown.read_yaml_for_doi_metadata(filepath)
|
57
|
-
return nil unless old_metadata["doi"]
|
58
|
+
return nil unless old_metadata["doi"] && old_metadata["published"]
|
58
59
|
|
59
60
|
metadata = generate_metadata_for_work(filepath, options)
|
60
61
|
work = unregister_work_for_metadata(metadata)
|
@@ -65,19 +66,19 @@ module Cirneco
|
|
65
66
|
# new_data = [{ "filename" => filename, "doi" => doi, "date" => Time.now.utc.iso8601 }]
|
66
67
|
# Bergamasco::Markdown.write_yaml(datapath, data + new_data)
|
67
68
|
|
68
|
-
new_metadata = Bergamasco::Markdown.update_file(filepath,
|
69
|
-
"DOI #{old_metadata["doi"]}
|
69
|
+
new_metadata = Bergamasco::Markdown.update_file(filepath, "published" => false)
|
70
|
+
"DOI #{old_metadata["doi"]} hidden for #{filename}"
|
70
71
|
end
|
71
72
|
|
72
|
-
def
|
73
|
+
def mint_dois_for_all_files(folderpath, options={})
|
73
74
|
Dir.glob("#{folderpath}/*.md").map do |filepath|
|
74
|
-
|
75
|
+
mint_doi_for_file(filepath, options)
|
75
76
|
end.compact.join("\n")
|
76
77
|
end
|
77
78
|
|
78
|
-
def
|
79
|
+
def hide_dois_for_all_files(folderpath, options={})
|
79
80
|
Dir.glob("#{folderpath}/*.md").map do |filepath|
|
80
|
-
|
81
|
+
hide_doi_for_file(filepath, options)
|
81
82
|
end.compact.join("\n")
|
82
83
|
end
|
83
84
|
|
@@ -201,7 +202,7 @@ module Cirneco
|
|
201
202
|
work = Cirneco::Work.new(metadata)
|
202
203
|
|
203
204
|
filename = metadata["doi"].split("/", 2).last + ".xml"
|
204
|
-
File.delete(filename)
|
205
|
+
File.delete(filename) if File.exist?(filename)
|
205
206
|
|
206
207
|
work
|
207
208
|
end
|
data/lib/cirneco/version.rb
CHANGED
@@ -7,6 +7,8 @@ tags:
|
|
7
7
|
- doi
|
8
8
|
- featured
|
9
9
|
image: https://blog.datacite.org/images/2016/12/cool-dois.png
|
10
|
+
doi: 10.23725/0000-03VC
|
11
|
+
published: false
|
10
12
|
---
|
11
13
|
In 1998 Tim Berners-Lee coined the term cool URIs [-@https://www.w3.org/Provider/Style/URI], that is URIs that don’t change. We know that URLs referenced in the scholarly literature are often not cool, leading to link rot [@https://doi.org/10.1371/journal.pone.0115253] and making it hard or impossible to find the referenced resource.READMORE
|
12
14
|
|
data/spec/utils_spec.rb
CHANGED
@@ -40,35 +40,41 @@ describe Cirneco::DataCenter, vcr: true, :order => :defined do
|
|
40
40
|
end
|
41
41
|
end
|
42
42
|
|
43
|
-
describe "
|
44
|
-
it 'should
|
43
|
+
describe "mint and hide DOIs" do
|
44
|
+
it 'should mint for file' do
|
45
45
|
filepath = fixture_path + 'cool-dois.html.md'
|
46
46
|
number = 123
|
47
|
-
response = subject.
|
48
|
-
expect(response).to eq("DOI 10.23725/0000-03VC
|
47
|
+
response = subject.mint_doi_for_file(filepath, number: number)
|
48
|
+
expect(response).to eq("DOI 10.23725/0000-03VC minted for cool-dois.html.md")
|
49
49
|
end
|
50
50
|
|
51
|
-
it 'should
|
51
|
+
it 'should hide for file' do
|
52
52
|
filepath = fixture_path + 'cool-dois.html.md'
|
53
|
-
response = subject.
|
54
|
-
expect(response).to eq("DOI 10.23725/0000-03VC
|
53
|
+
response = subject.hide_doi_for_file(filepath)
|
54
|
+
expect(response).to eq("DOI 10.23725/0000-03VC hidden for cool-dois.html.md")
|
55
55
|
end
|
56
56
|
|
57
|
-
it 'should
|
57
|
+
it 'should mint for all files' do
|
58
58
|
number = 123
|
59
|
-
response = subject.
|
60
|
-
expect(response).to eq("DOI 10.23725/0000-03VC
|
59
|
+
response = subject.mint_dois_for_all_files(fixture_path, number: number)
|
60
|
+
expect(response).to eq("DOI 10.23725/0000-03VC minted for cool-dois.html.md")
|
61
61
|
end
|
62
62
|
|
63
|
-
it 'should
|
63
|
+
it 'should hide for all files' do
|
64
64
|
number = 123
|
65
|
-
response = subject.
|
66
|
-
expect(response).to eq("DOI 10.23725/0000-03VC
|
65
|
+
response = subject.hide_dois_for_all_files(fixture_path)
|
66
|
+
expect(response).to eq("DOI 10.23725/0000-03VC hidden for cool-dois.html.md")
|
67
67
|
end
|
68
68
|
|
69
|
-
it 'should ignore non-markdown file for
|
69
|
+
it 'should ignore non-markdown file for mint file' do
|
70
70
|
filepath = fixture_path + 'cool-dois.yml'
|
71
|
-
response = subject.
|
71
|
+
response = subject.mint_doi_for_file(filepath)
|
72
|
+
expect(response).to eq("File cool-dois.yml ignored: not a markdown file")
|
73
|
+
end
|
74
|
+
|
75
|
+
it 'should ignore non-markdown file for hide file' do
|
76
|
+
filepath = fixture_path + 'cool-dois.yml'
|
77
|
+
response = subject.hide_doi_for_file(filepath)
|
72
78
|
expect(response).to eq("File cool-dois.yml ignored: not a markdown file")
|
73
79
|
end
|
74
80
|
|