maltese 0.1.6 → 0.1.7
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 +4 -4
- data/Gemfile.lock +1 -1
- data/lib/maltese/cli.rb +3 -3
- data/lib/maltese/sitemap.rb +7 -6
- data/lib/maltese/version.rb +1 -1
- data/spec/cli_spec.rb +4 -12
- data/spec/fixtures/vcr_cassettes/Maltese_CLI/sitemap/should_succeed.yml +21 -21
- data/spec/fixtures/vcr_cassettes/Maltese_Sitemap/push_data/should_report_if_there_are_no_works_returned_by_the_Datacite_Solr_API.yml +13 -13
- data/spec/fixtures/vcr_cassettes/Maltese_Sitemap/push_data/should_report_if_there_are_works_returned_by_the_Datacite_Solr_API.yml +129 -15
- data/spec/fixtures/vcr_cassettes/Maltese_Sitemap/queue_jobs/should_report_if_there_are_works_returned_by_the_Datacite_Solr_API.yml +18 -132
- data/spec/spec_helper.rb +1 -1
- metadata +1 -3
- data/lib/maltese/utils.rb +0 -87
- data/public/sitemap.xml.gz +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c63d39d911bf3128f4977e8689046491a4cd7fd2
|
4
|
+
data.tar.gz: 1d0b468a7f9074dff62a4f5ea7ac24899a9110e2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dc76a156939794d41df9c0c3c7af34c7ab90d2eaeea6ce199c2d0ce693031e66523d6dd688a77128812c21b9940cf3091a062f0137d232f6e0ead3693d3bdb22
|
7
|
+
data.tar.gz: 5b9ef60d80b7c69f2f0d988b9886e4a4b2e22bb851c9f576b322a62d573a91ffb2e88b8bfa6cf9259793c626182c41e36acbbaf2b64de628f1eea007ee212b77
|
data/Gemfile.lock
CHANGED
data/lib/maltese/cli.rb
CHANGED
@@ -18,9 +18,9 @@ module Maltese
|
|
18
18
|
end
|
19
19
|
|
20
20
|
desc "sitemap", "generate sitemap for DataCite Search"
|
21
|
-
method_option :sitemap_bucket, type: :string
|
22
|
-
method_option :from_date, type: :string
|
23
|
-
method_option :until_date, type: :string
|
21
|
+
method_option :sitemap_bucket, type: :string
|
22
|
+
method_option :from_date, type: :string
|
23
|
+
method_option :until_date, type: :string
|
24
24
|
def sitemap
|
25
25
|
sitemap = Maltese::Sitemap.new(options)
|
26
26
|
sitemap.queue_jobs
|
data/lib/maltese/sitemap.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
module Maltese
|
2
2
|
class Sitemap
|
3
|
-
attr_reader :sitemap_bucket, :
|
3
|
+
attr_reader :sitemap_bucket, :from_date, :until_date
|
4
4
|
|
5
5
|
# load ENV variables from container environment if json file exists
|
6
6
|
# see https://github.com/phusion/baseimage-docker#envvar_dumps
|
@@ -11,7 +11,7 @@ module Maltese
|
|
11
11
|
end
|
12
12
|
|
13
13
|
def initialize(attributes={})
|
14
|
-
@sitemap_bucket = attributes[:sitemap_bucket]|| "search.datacite.org"
|
14
|
+
@sitemap_bucket = attributes[:sitemap_bucket].presence|| "search.datacite.org"
|
15
15
|
@from_date = attributes[:from_date].presence || (Time.now.to_date - 1.day).iso8601
|
16
16
|
@until_date = attributes[:until_date].presence || Time.now.to_date.iso8601
|
17
17
|
end
|
@@ -25,11 +25,11 @@ module Maltese
|
|
25
25
|
end
|
26
26
|
|
27
27
|
def sitemaps_host
|
28
|
-
"
|
28
|
+
"https://s3.amazonaws.com/#{sitemap_bucket}/"
|
29
29
|
end
|
30
30
|
|
31
31
|
def sitemaps_path
|
32
|
-
'sitemaps/'
|
32
|
+
ENV['RACK'] == "test" ? 'sitemaps-test' : 'sitemaps/'
|
33
33
|
end
|
34
34
|
|
35
35
|
def timeout
|
@@ -54,7 +54,8 @@ module Maltese
|
|
54
54
|
aws_access_key_id: ENV['AWS_ACCESS_KEY_ID'],
|
55
55
|
aws_secret_access_key: ENV['AWS_SECRET_ACCESS_KEY'],
|
56
56
|
fog_directory: sitemap_bucket,
|
57
|
-
fog_region: ENV['AWS_REGION']
|
57
|
+
fog_region: ENV['AWS_REGION'],
|
58
|
+
path_style: true)
|
58
59
|
end
|
59
60
|
|
60
61
|
def fog_storage
|
@@ -119,7 +120,7 @@ module Maltese
|
|
119
120
|
Maremma.get(query_url, options)
|
120
121
|
end
|
121
122
|
|
122
|
-
def parse_data(result
|
123
|
+
def parse_data(result)
|
123
124
|
return result.body.fetch("errors") if result.body.fetch("errors", nil).present?
|
124
125
|
|
125
126
|
items = result.body.fetch("data", {}).fetch('response', {}).fetch('docs', nil)
|
data/lib/maltese/version.rb
CHANGED
data/spec/cli_spec.rb
CHANGED
@@ -6,12 +6,10 @@ describe Maltese::CLI do
|
|
6
6
|
described_class.new
|
7
7
|
end
|
8
8
|
|
9
|
-
let(:push_url) { ENV['VOLPINO_URL'] }
|
10
|
-
let(:access_token) { ENV['VOLPINO_TOKEN'] }
|
11
9
|
let(:from_date) { "2015-04-07" }
|
12
10
|
let(:until_date) { "2015-04-08" }
|
13
|
-
let(:
|
14
|
-
|
11
|
+
let(:sitemap_bucket) { "search.datacite.org" }
|
12
|
+
let(:cli_options) { { sitemap_bucket: sitemap_bucket,
|
15
13
|
from_date: from_date,
|
16
14
|
until_date: until_date } }
|
17
15
|
|
@@ -19,7 +17,7 @@ describe Maltese::CLI do
|
|
19
17
|
it 'should succeed' do
|
20
18
|
subject.options = cli_options
|
21
19
|
expect { subject.sitemap }.to output(/2522 links/).to_stdout
|
22
|
-
sitemap = Zlib::GzipReader.open("public/sitemap.xml.gz") { |gz| gz.read }
|
20
|
+
sitemap = Zlib::GzipReader.open("public/sitemaps-test/sitemap.xml.gz") { |gz| gz.read }
|
23
21
|
doc = Nokogiri::XML(sitemap)
|
24
22
|
expect(doc.xpath("//xmlns:url").size).to eq(2522)
|
25
23
|
expect(doc.xpath("//xmlns:loc").last.text).to eq("https://search.datacite.org/works/10.6084/M9.FIGSHARE.1371139")
|
@@ -28,16 +26,10 @@ describe Maltese::CLI do
|
|
28
26
|
it 'should succeed with no works' do
|
29
27
|
from_date = "2005-04-07"
|
30
28
|
until_date = "2005-04-08"
|
31
|
-
subject.options = {
|
32
|
-
access_token: access_token,
|
29
|
+
subject.options = { sitemap_bucket: sitemap_bucket,
|
33
30
|
from_date: from_date,
|
34
31
|
until_date: until_date }
|
35
32
|
expect { subject.sitemap }.to output("No works found for date range 2005-04-07 - 2005-04-08.\n").to_stdout
|
36
33
|
end
|
37
|
-
|
38
|
-
# it 'should fail' do
|
39
|
-
# subject.options = cli_options.except(:access_token)
|
40
|
-
# expect { subject.sitemap }.to output(/An error occured: Access token missing.\n/).to_stdout
|
41
|
-
# end
|
42
34
|
end
|
43
35
|
end
|