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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f8575062ca1a56040a8b6d95e04a0b32663326f1
4
- data.tar.gz: 9c5da81b4f793717852b5be5b953a88f1ee20b71
3
+ metadata.gz: c63d39d911bf3128f4977e8689046491a4cd7fd2
4
+ data.tar.gz: 1d0b468a7f9074dff62a4f5ea7ac24899a9110e2
5
5
  SHA512:
6
- metadata.gz: 16e61487cbd77588ca95f3c50d18cec28cb96bd6e4ca0ce2ed257c956305e17b5288d52a042d9ca1b228453210c95dc61e5be39d719364587e5096ba62cee62c
7
- data.tar.gz: 99a3fca771361d7d2e5f94556de2c319e14f74fbeb5ed7368985aa401ea9def436e25a545130f2fd9591aa0be36a1105d7b454d453123cc75f8268ed9d7aa915
6
+ metadata.gz: dc76a156939794d41df9c0c3c7af34c7ab90d2eaeea6ce199c2d0ce693031e66523d6dd688a77128812c21b9940cf3091a062f0137d232f6e0ead3693d3bdb22
7
+ data.tar.gz: 5b9ef60d80b7c69f2f0d988b9886e4a4b2e22bb851c9f576b322a62d573a91ffb2e88b8bfa6cf9259793c626182c41e36acbbaf2b64de628f1eea007ee212b77
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- maltese (0.1.6)
4
+ maltese (0.1.7)
5
5
  activesupport (~> 4.2, >= 4.2.5)
6
6
  fog-aws (~> 0.7.6)
7
7
  maremma (~> 3.5)
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, default: ENV['SITEMAP_BUCKET']
22
- method_option :from_date, type: :string, default: (Time.now.to_date - 1.day).iso8601
23
- method_option :until_date, type: :string, default: Time.now.to_date.iso8601
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
@@ -1,6 +1,6 @@
1
1
  module Maltese
2
2
  class Sitemap
3
- attr_reader :sitemap_bucket, :sitemap_url, :from_date, :until_date
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
- "http://#{sitemap_bucket}.s3.amazonaws.com/"
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, options={})
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)
@@ -1,3 +1,3 @@
1
1
  module Maltese
2
- VERSION = "0.1.6"
2
+ VERSION = "0.1.7"
3
3
  end
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(:cli_options) { { push_url: push_url,
14
- access_token: access_token,
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 = { push_url: push_url,
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