cirneco 0.8.9 → 0.8.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8c54d706925809957c6b2e13498ef108a1dd6f97
4
- data.tar.gz: b749d9f09ce922be14766ec1e088ddd3a44af503
3
+ metadata.gz: 38d157f3d9e0e894960de042f6b8f6073630ef84
4
+ data.tar.gz: 93e74d210a239655c572c127ee3f1293ea3d1b6a
5
5
  SHA512:
6
- metadata.gz: 1c101766fe5bf96673fc4b2fbfd602f6d71c5ca93541aa5557c95fbd2b3f7725eb98f752806212f31d2c2b89511e1a9b1175a8ac07dbe080b09eceb093432808
7
- data.tar.gz: 2a03c0d808979285bcf72e704bdc2ee23624cc3e2ad675eff0ea201f1256654dc4b78dd2b1251a4f934fb29cd88a5731733708ba334ff9e7e27218e000464225
6
+ metadata.gz: d560c71918c3697a2ee12092fd4afe25c926f06110c81745b591c401a81506a56efb0db744c2e87715bde25c7618132549721a0ee7cfe803d3b08891618c1947
7
+ data.tar.gz: 0a4be3110277f083fe05792e6bd0c74171f91181693ca0a119dbdcfa3fb21632b32a499213e9c4000f31d7d662a02155eebf1f9c13558193571274f83adf9d08
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- cirneco (0.8.9)
4
+ cirneco (0.8.10)
5
5
  activesupport (~> 4.2, >= 4.2.5)
6
6
  base32-crockford-checksum (~> 0.2.2)
7
7
  bergamasco (~> 0.3)
@@ -333,15 +333,18 @@ module Cirneco
333
333
  url = response.headers.fetch("Location", "")
334
334
  end
335
335
 
336
- uri = Addressable::URI.parse(url.gsub(/\/$/, ""))
337
- filename = (File.basename(uri.path, ".html").presence || "index") + ".html"
338
-
339
- if filename == "index.html"
340
- source_path = Dir.pwd + options[:source_dir].to_s + filename + ".erb"
341
- build_path = Dir.pwd + options[:build_dir].to_s + filename
336
+ url.slice!(Dir.pwd + options[:build_dir].to_s)
337
+ uri = Addressable::URI.parse(url.gsub(/index\.html$/, "").gsub(/\/$/, ""))
338
+ basename = File.basename(uri.path, ".html").presence || "index"
339
+
340
+ if basename.starts_with?("index")
341
+ filename = basename + ".html.erb"
342
+ source_path = Dir.pwd + options[:source_dir].to_s + filename
343
+ build_path = Dir.pwd + options[:build_dir].to_s + basename + ".html"
342
344
  else
343
- source_path = Dir.pwd + options[:source_dir].to_s + options[:posts_dir].to_s + filename + ".md"
344
- build_path = Dir.pwd + options[:build_dir].to_s + options[:posts_dir].to_s + filename
345
+ filename = basename + ".html.md"
346
+ source_path = Dir.pwd + options[:source_dir].to_s + options[:posts_dir].to_s + filename
347
+ build_path = Dir.pwd + options[:build_dir].to_s + basename + "/index.html"
345
348
  end
346
349
  [filename, build_path, source_path]
347
350
  end
@@ -1,3 +1,3 @@
1
1
  module Cirneco
2
- VERSION = "0.8.9"
2
+ VERSION = "0.8.10"
3
3
  end
@@ -10,7 +10,7 @@ describe Cirneco::Doi do
10
10
  let(:prefix) { ENV['PREFIX'] }
11
11
  let(:doi) { "10.5072/0000-03VC" }
12
12
  let(:url) { "http://www.datacite.org" }
13
- let(:filename) { 'cool-dois.html' }
13
+ let(:filename) { 'cool-dois/index.html' }
14
14
  let(:filepath) { fixture_path + filename }
15
15
  let(:username) { ENV['MDS_USERNAME'] }
16
16
  let(:password) { ENV['MDS_PASSWORD'] }
@@ -89,37 +89,37 @@ describe Cirneco::Doi do
89
89
  context "mint and hide DOIs", vcr: true, :order => :defined do
90
90
  it 'mints a doi' do
91
91
  subject.options = mint_options
92
- expect { subject.mint filepath }.to output("DOI 10.5072/0000-03VC minted for #{filename}\n").to_stdout
92
+ expect { subject.mint filepath }.to output("DOI 10.5072/0000-03VC minted for cool-dois.html.md\n").to_stdout
93
93
  end
94
94
 
95
95
  it 'hides a doi' do
96
- filename = 'cool-dois-minted.html'
96
+ filename = 'cool-dois-minted/index.html'
97
97
  filepath = fixture_path + filename
98
98
  subject.options = mint_options.merge(filepath: filepath)
99
- expect { subject.hide filepath }.to output("DOI 10.5072/0000-03WD hidden for #{filename}\n").to_stdout
99
+ expect { subject.hide filepath }.to output("DOI 10.5072/0000-03WD hidden for cool-dois-minted.html.md\n").to_stdout
100
100
  end
101
101
 
102
102
  it 'mints and hides a doi' do
103
103
  subject.options = mint_options
104
- expect { subject.mint_and_hide filepath }.to output("DOI 10.5072/0000-03VC minted and hidden for #{filename}\n").to_stdout
104
+ expect { subject.mint_and_hide filepath }.to output("DOI 10.5072/0000-03VC minted and hidden for cool-dois.html.md\n").to_stdout
105
105
  end
106
106
 
107
107
  it 'mints dois for list of urls' do
108
108
  filepath = fixture_path + 'index.html'
109
109
  subject.options = mint_options
110
- expect { subject.mint filepath }.to output("DOI 10.5072/0000-03VC minted for cool-dois.html\nDOI 10.5072/0000-00SS minted for index.html\n").to_stdout
110
+ expect { subject.mint filepath }.to output("DOI 10.5072/0000-03VC minted for cool-dois.html.md\nDOI 10.5072/0000-00SS minted for index.html.erb\n").to_stdout
111
111
  end
112
112
 
113
113
  it 'hides dois for list of urls' do
114
114
  filepath = fixture_path + 'index.html'
115
115
  subject.options = mint_options
116
- expect { subject.hide filepath }.to output("No DOI for cool-dois.html\nNo DOI for index.html\n").to_stdout
116
+ expect { subject.hide filepath }.to output("No DOI for cool-dois.html.md\nNo DOI for index.html.erb\n").to_stdout
117
117
  end
118
118
 
119
119
  it 'mints and hides dois for list of urls' do
120
120
  filepath = fixture_path + 'index.html'
121
121
  subject.options = mint_options
122
- expect { subject.mint_and_hide filepath }.to output("DOI 10.5072/0000-03VC minted and hidden for cool-dois.html\nDOI 10.5072/0000-00SS minted and hidden for index.html\n").to_stdout
122
+ expect { subject.mint_and_hide filepath }.to output("DOI 10.5072/0000-03VC minted and hidden for cool-dois.html.md\nDOI 10.5072/0000-00SS minted and hidden for index.html.erb\n").to_stdout
123
123
  end
124
124
  end
125
125
  end
@@ -60,7 +60,7 @@ http_interactions:
60
60
  Server:
61
61
  - openresty/1.11.2.1
62
62
  Date:
63
- - Mon, 02 Jan 2017 09:16:14 GMT
63
+ - Mon, 02 Jan 2017 11:18:15 GMT
64
64
  Content-Type:
65
65
  - text/html;charset=UTF-8
66
66
  Connection:
@@ -81,7 +81,7 @@ http_interactions:
81
81
  encoding: UTF-8
82
82
  string: OK (10.5072/0000-03VC)
83
83
  http_version:
84
- recorded_at: Mon, 02 Jan 2017 09:16:14 GMT
84
+ recorded_at: Mon, 02 Jan 2017 11:18:15 GMT
85
85
  - request:
86
86
  method: put
87
87
  uri: https://mds-sandbox.datacite.org/doi/10.5072/0000-03VC
@@ -107,7 +107,7 @@ http_interactions:
107
107
  Server:
108
108
  - openresty/1.11.2.1
109
109
  Date:
110
- - Mon, 02 Jan 2017 09:16:15 GMT
110
+ - Mon, 02 Jan 2017 11:18:15 GMT
111
111
  Content-Type:
112
112
  - text/html;charset=UTF-8
113
113
  Connection:
@@ -126,5 +126,5 @@ http_interactions:
126
126
  encoding: UTF-8
127
127
  string: OK
128
128
  http_version:
129
- recorded_at: Mon, 02 Jan 2017 09:16:15 GMT
129
+ recorded_at: Mon, 02 Jan 2017 11:18:15 GMT
130
130
  recorded_with: VCR 3.0.3
@@ -60,7 +60,7 @@ http_interactions:
60
60
  Server:
61
61
  - openresty/1.11.2.1
62
62
  Date:
63
- - Mon, 02 Jan 2017 09:16:13 GMT
63
+ - Mon, 02 Jan 2017 11:18:14 GMT
64
64
  Content-Type:
65
65
  - text/html;charset=UTF-8
66
66
  Connection:
@@ -81,7 +81,7 @@ http_interactions:
81
81
  encoding: UTF-8
82
82
  string: OK (10.5072/0000-03VC)
83
83
  http_version:
84
- recorded_at: Mon, 02 Jan 2017 09:16:13 GMT
84
+ recorded_at: Mon, 02 Jan 2017 11:18:14 GMT
85
85
  - request:
86
86
  method: put
87
87
  uri: https://mds-sandbox.datacite.org/doi/10.5072/0000-03VC
@@ -107,7 +107,7 @@ http_interactions:
107
107
  Server:
108
108
  - openresty/1.11.2.1
109
109
  Date:
110
- - Mon, 02 Jan 2017 09:16:14 GMT
110
+ - Mon, 02 Jan 2017 11:18:14 GMT
111
111
  Content-Type:
112
112
  - text/html;charset=UTF-8
113
113
  Connection:
@@ -126,5 +126,5 @@ http_interactions:
126
126
  encoding: UTF-8
127
127
  string: OK
128
128
  http_version:
129
- recorded_at: Mon, 02 Jan 2017 09:16:14 GMT
129
+ recorded_at: Mon, 02 Jan 2017 11:18:14 GMT
130
130
  recorded_with: VCR 3.0.3
@@ -21,7 +21,7 @@ http_interactions:
21
21
  Server:
22
22
  - openresty/1.11.2.1
23
23
  Date:
24
- - Mon, 02 Jan 2017 09:16:06 GMT
24
+ - Mon, 02 Jan 2017 11:19:24 GMT
25
25
  Content-Type:
26
26
  - text/html;charset=UTF-8
27
27
  Connection:
@@ -40,5 +40,5 @@ http_interactions:
40
40
  encoding: UTF-8
41
41
  string: OK
42
42
  http_version:
43
- recorded_at: Mon, 02 Jan 2017 09:16:06 GMT
43
+ recorded_at: Mon, 02 Jan 2017 11:19:24 GMT
44
44
  recorded_with: VCR 3.0.3
@@ -60,7 +60,7 @@ http_interactions:
60
60
  Server:
61
61
  - openresty/1.11.2.1
62
62
  Date:
63
- - Mon, 02 Jan 2017 09:16:05 GMT
63
+ - Mon, 02 Jan 2017 11:19:23 GMT
64
64
  Content-Type:
65
65
  - text/html;charset=UTF-8
66
66
  Connection:
@@ -81,7 +81,7 @@ http_interactions:
81
81
  encoding: UTF-8
82
82
  string: OK (10.5072/0000-03VC)
83
83
  http_version:
84
- recorded_at: Mon, 02 Jan 2017 09:16:05 GMT
84
+ recorded_at: Mon, 02 Jan 2017 11:19:23 GMT
85
85
  - request:
86
86
  method: put
87
87
  uri: https://mds-sandbox.datacite.org/doi/10.5072/0000-03VC
@@ -107,7 +107,7 @@ http_interactions:
107
107
  Server:
108
108
  - openresty/1.11.2.1
109
109
  Date:
110
- - Mon, 02 Jan 2017 09:16:06 GMT
110
+ - Mon, 02 Jan 2017 11:19:23 GMT
111
111
  Content-Type:
112
112
  - text/html;charset=UTF-8
113
113
  Connection:
@@ -126,5 +126,5 @@ http_interactions:
126
126
  encoding: UTF-8
127
127
  string: OK
128
128
  http_version:
129
- recorded_at: Mon, 02 Jan 2017 09:16:06 GMT
129
+ recorded_at: Mon, 02 Jan 2017 11:19:24 GMT
130
130
  recorded_with: VCR 3.0.3
@@ -60,7 +60,7 @@ http_interactions:
60
60
  Server:
61
61
  - openresty/1.11.2.1
62
62
  Date:
63
- - Mon, 02 Jan 2017 09:16:07 GMT
63
+ - Mon, 02 Jan 2017 11:19:25 GMT
64
64
  Content-Type:
65
65
  - text/html;charset=UTF-8
66
66
  Connection:
@@ -81,7 +81,7 @@ http_interactions:
81
81
  encoding: UTF-8
82
82
  string: OK (10.5072/0000-03VC)
83
83
  http_version:
84
- recorded_at: Mon, 02 Jan 2017 09:16:07 GMT
84
+ recorded_at: Mon, 02 Jan 2017 11:19:25 GMT
85
85
  - request:
86
86
  method: put
87
87
  uri: https://mds-sandbox.datacite.org/doi/10.5072/0000-03VC
@@ -107,7 +107,7 @@ http_interactions:
107
107
  Server:
108
108
  - openresty/1.11.2.1
109
109
  Date:
110
- - Mon, 02 Jan 2017 09:16:07 GMT
110
+ - Mon, 02 Jan 2017 11:19:25 GMT
111
111
  Content-Type:
112
112
  - text/html;charset=UTF-8
113
113
  Connection:
@@ -126,5 +126,5 @@ http_interactions:
126
126
  encoding: UTF-8
127
127
  string: OK
128
128
  http_version:
129
- recorded_at: Mon, 02 Jan 2017 09:16:07 GMT
129
+ recorded_at: Mon, 02 Jan 2017 11:19:26 GMT
130
130
  recorded_with: VCR 3.0.3
@@ -117,43 +117,43 @@ describe Cirneco::DataCenter, vcr: true, :order => :defined do
117
117
  end
118
118
 
119
119
  it 'should mint for url' do
120
- filepath = fixture_path + 'cool-dois.html'
120
+ filepath = fixture_path + 'cool-dois/index.html'
121
121
  response = subject.mint_doi_for_url(filepath, options)
122
- expect(response).to eq("DOI 10.5072/0000-03VC minted for cool-dois.html")
122
+ expect(response).to eq("DOI 10.5072/0000-03VC minted for cool-dois.html.md")
123
123
  end
124
124
 
125
125
  it 'should hide for url' do
126
126
  filepath = fixture_path + 'cool-dois-minted.html'
127
127
  response = subject.hide_doi_for_url(filepath, options)
128
- expect(response).to eq("DOI 10.5072/0000-03WD hidden for cool-dois-minted.html")
128
+ expect(response).to eq("DOI 10.5072/0000-03WD hidden for cool-dois-minted.html.md")
129
129
  end
130
130
 
131
131
  it 'should mint and hide for url' do
132
- filepath = fixture_path + 'cool-dois.html'
132
+ filepath = fixture_path + 'cool-dois/index.html'
133
133
  response = subject.mint_and_hide_doi_for_url(filepath, options)
134
- expect(response).to eq("DOI 10.5072/0000-03VC minted and hidden for cool-dois.html")
134
+ expect(response).to eq("DOI 10.5072/0000-03VC minted and hidden for cool-dois.html.md")
135
135
  end
136
136
 
137
137
  it 'should mint for all urls' do
138
138
  filepath = fixture_path + 'index.html'
139
139
  response = subject.mint_dois_for_all_urls(filepath, options)
140
- expect(response).to eq("DOI 10.5072/0000-03VC minted for cool-dois.html\nDOI 10.5072/0000-00SS minted for index.html")
140
+ expect(response).to eq("DOI 10.5072/0000-03VC minted for cool-dois.html.md\nDOI 10.5072/0000-00SS minted for index.html.erb")
141
141
  end
142
142
 
143
143
  it 'should hide for all urls' do
144
144
  filepath = fixture_path + 'index-minted.html'
145
145
  response = subject.hide_dois_for_all_urls(filepath, options)
146
- expect(response).to eq("No DOI for cool-dois.html\nErrors for DOI 10.5072/0000-NW90: Not found\n")
146
+ expect(response).to eq("No DOI for cool-dois.html.md\nErrors for DOI 10.5072/0000-NW90: Not found\n")
147
147
  end
148
148
 
149
149
  it 'should mint and hide for all urls' do
150
150
  filepath = fixture_path + 'index.html'
151
151
  response = subject.mint_and_hide_dois_for_all_urls(filepath, options)
152
- expect(response).to eq("DOI 10.5072/0000-03VC minted and hidden for cool-dois.html\nDOI 10.5072/0000-00SS minted and hidden for index.html")
152
+ expect(response).to eq("DOI 10.5072/0000-03VC minted and hidden for cool-dois.html.md\nDOI 10.5072/0000-00SS minted and hidden for index.html.erb")
153
153
  end
154
154
 
155
155
  it 'should generate metadata for work' do
156
- filepath = fixture_path + 'cool-dois.html'
156
+ filepath = fixture_path + 'cool-dois/index.html'
157
157
  metadata = subject.generate_metadata_for_work(filepath)
158
158
  expect(metadata["url"]).to eq("https://blog.datacite.org/cool-dois/")
159
159
  expect(metadata["creators"]).to eq([{:given_name=>"Martin", :family_name=>"Fenner", :orcid=>"0000-0003-1419-2405"}])
@@ -167,17 +167,17 @@ describe Cirneco::DataCenter, vcr: true, :order => :defined do
167
167
  end
168
168
 
169
169
  it 'should generate metadata for work no JSON-LD' do
170
- filepath = fixture_path + 'cool-dois-no-json-ld.html'
170
+ filepath = fixture_path + 'cool-dois-no-json-ld/index.html'
171
171
  expect(subject.generate_metadata_for_work(filepath)).to eq("Error: no schema.org metadata found")
172
172
  end
173
173
 
174
174
  it 'should generate metadata for work missing required metadata' do
175
- filepath = fixture_path + 'cool-dois-missing-metadata.html'
175
+ filepath = fixture_path + 'cool-dois-missing-metadata/index.html'
176
176
  expect(subject.generate_metadata_for_work(filepath)).to eq("Error: required metadata missing")
177
177
  end
178
178
 
179
179
  it 'should post_metadata_for_work' do
180
- filepath = fixture_path + 'cool-dois.html'
180
+ filepath = fixture_path + 'cool-dois/index.html'
181
181
  metadata = subject.generate_metadata_for_work(filepath)
182
182
  response = subject.post_metadata_for_work(metadata, options)
183
183
  expect(response.body["data"]).to eq("OK")
@@ -185,7 +185,7 @@ describe Cirneco::DataCenter, vcr: true, :order => :defined do
185
185
  end
186
186
 
187
187
  it 'should hide_metadata_for_work' do
188
- filepath = fixture_path + 'cool-dois.html'
188
+ filepath = fixture_path + 'cool-dois/index.html'
189
189
  metadata = subject.generate_metadata_for_work(filepath)
190
190
  response = subject.hide_metadata_for_work(metadata, options)
191
191
  expect(response.body["data"]).to eq("OK")
@@ -205,7 +205,7 @@ describe Cirneco::DataCenter, vcr: true, :order => :defined do
205
205
  it 'https://blog.datacite.org/' do
206
206
  url = 'https://blog.datacite.org/'
207
207
  filename, build_path, source_path = subject.filepath_from_url(url, build_dir: source_dir, source_dir: source_dir)
208
- expect(filename).to eq("index.html")
208
+ expect(filename).to eq("index.html.erb")
209
209
  expect(source_path).to eq(fixture_path + "index.html.erb")
210
210
  expect(build_path).to eq(fixture_path + "index.html")
211
211
  end
@@ -213,7 +213,7 @@ describe Cirneco::DataCenter, vcr: true, :order => :defined do
213
213
  it 'https://blog.datacite.org' do
214
214
  url = 'https://blog.datacite.org'
215
215
  filename, build_path, source_path = subject.filepath_from_url(url, build_dir: source_dir, source_dir: source_dir)
216
- expect(filename).to eq("index.html")
216
+ expect(filename).to eq("index.html.erb")
217
217
  expect(source_path).to eq(fixture_path + "index.html.erb")
218
218
  expect(build_path).to eq(fixture_path + "index.html")
219
219
  end
@@ -221,7 +221,7 @@ describe Cirneco::DataCenter, vcr: true, :order => :defined do
221
221
  it 'index.html' do
222
222
  url = fixture_path + 'index.html'
223
223
  filename, build_path, source_path = subject.filepath_from_url(url, build_dir: source_dir, source_dir: source_dir)
224
- expect(filename).to eq("index.html")
224
+ expect(filename).to eq("index.html.erb")
225
225
  expect(source_path).to eq(fixture_path + "index.html.erb")
226
226
  expect(build_path).to eq(fixture_path + "index.html")
227
227
  end
@@ -229,7 +229,7 @@ describe Cirneco::DataCenter, vcr: true, :order => :defined do
229
229
  it 'index.html basename' do
230
230
  url = 'index.html'
231
231
  filename, build_path, source_path = subject.filepath_from_url(url, build_dir: source_dir, source_dir: source_dir)
232
- expect(filename).to eq("index.html")
232
+ expect(filename).to eq("index.html.erb")
233
233
  expect(source_path).to eq(fixture_path + "index.html.erb")
234
234
  expect(build_path).to eq(fixture_path + "index.html")
235
235
  end
@@ -237,15 +237,17 @@ describe Cirneco::DataCenter, vcr: true, :order => :defined do
237
237
  it 'cool-dois.html' do
238
238
  url = fixture_path + 'cool-dois.html'
239
239
  filename, build_path, source_path = subject.filepath_from_url(url, build_dir: source_dir, source_dir: source_dir)
240
+ expect(filename).to eq("cool-dois.html.md")
240
241
  expect(source_path).to eq(fixture_path + "cool-dois.html.md")
241
- expect(build_path).to eq(fixture_path + "cool-dois.html")
242
+ expect(build_path).to eq(fixture_path + "cool-dois/index.html")
242
243
  end
243
244
 
244
245
  it 'cool-dois.html basename' do
245
246
  url = 'cool-dois.html'
246
247
  filename, build_path, source_path = subject.filepath_from_url(url, build_dir: source_dir, source_dir: source_dir)
248
+ expect(filename).to eq("cool-dois.html.md")
247
249
  expect(source_path).to eq(fixture_path + "cool-dois.html.md")
248
- expect(build_path).to eq(fixture_path + "cool-dois.html")
250
+ expect(build_path).to eq(fixture_path + "cool-dois/index.html")
249
251
  end
250
252
  end
251
253
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cirneco
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.9
4
+ version: 0.8.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Martin Fenner
@@ -347,14 +347,14 @@ files:
347
347
  - spec/doi_spec.rb
348
348
  - spec/fixtures/apa.csl
349
349
  - spec/fixtures/authors.yml
350
- - spec/fixtures/cool-dois-minted.html
351
350
  - spec/fixtures/cool-dois-minted.html.md
352
- - spec/fixtures/cool-dois-missing-metadata.html
351
+ - spec/fixtures/cool-dois-minted/index.html
352
+ - spec/fixtures/cool-dois-missing-metadata/index.html
353
353
  - spec/fixtures/cool-dois-no-accession-number.html.md
354
- - spec/fixtures/cool-dois-no-json-ld.html
355
- - spec/fixtures/cool-dois.html
354
+ - spec/fixtures/cool-dois-no-json-ld/index.html
356
355
  - spec/fixtures/cool-dois.html.md
357
356
  - spec/fixtures/cool-dois.yml
357
+ - spec/fixtures/cool-dois/index.html
358
358
  - spec/fixtures/index-minted.html
359
359
  - spec/fixtures/index.html
360
360
  - spec/fixtures/index.html.erb