Skip to content

Commit 939e20c

Browse files
dkinzerbarmintor
authored andcommitted
Allow for passing until param.
This commit allows the client to harvest a specific range not limited to from until now.
1 parent 7a636dc commit 939e20c

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

lib/oai/harvester/harvest.rb

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,13 @@ module Harvester
66
class Harvest
77
DIRECTORY_LAYOUT = "%Y/%m".freeze
88

9-
def initialize(config = nil, directory = nil, date = nil)
9+
def initialize(config = nil, directory = nil, date = nil, to = nil)
1010
@config = config || Config.load
1111
@directory = directory || @config.storage
1212
@from = date
1313
@from.freeze
14+
@until = to
15+
@until.freeze
1416
@parser = defined?(XML::Document) ? 'libxml' : 'rexml'
1517
end
1618

@@ -30,7 +32,11 @@ def start(sites = nil, interactive = false)
3032

3133
def harvest(site)
3234
opts = build_options_hash(@config.sites[site])
33-
harvest_time = Time.now.utc
35+
if @until
36+
harvest_time = @until.to_time.utc.iso8601
37+
else
38+
harvest_time = Time.now.utc
39+
end
3440

3541
if "YYYY-MM-DD" == granularity(opts[:url])
3642
opts[:until] = harvest_time.strftime("%Y-%m-%d")
@@ -153,4 +159,4 @@ def earliest(url)
153159
end
154160

155161
end
156-
end
162+
end

0 commit comments

Comments
 (0)