Skip to content

Commit be07b61

Browse files
committed
use granularity constants consistently
1 parent f2ab313 commit be07b61

File tree

3 files changed

+8
-4
lines changed

3 files changed

+8
-4
lines changed

lib/oai/harvester.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@
99
require 'readline'
1010
require 'socket'
1111

12+
if not defined?(OAI::Const::VERBS)
13+
require 'oai/constants'
14+
end
15+
1216
require 'oai/client'
1317
require 'oai/harvester/config'
1418
require 'oai/harvester/harvest'

lib/oai/harvester/config.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
module OAI
66
module Harvester
77

8-
LOW_RESOLUTION = "YYYY-MM-DD"
8+
LOW_RESOLUTION = OAI::Const::Granularity::LOW
99

1010
class Config < OpenStruct
1111

lib/oai/harvester/harvest.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ def harvest(site)
3838
harvest_time = Time.now.utc
3939
end
4040

41-
if "YYYY-MM-DD" == granularity(opts[:url])
41+
if OAI::Const::Granularity::LOW == granularity(opts[:url])
4242
opts[:until] = harvest_time.strftime("%Y-%m-%d")
4343
opts[:from] = @from.strftime("%Y-%m-%d") if @from
4444
else
@@ -139,7 +139,7 @@ def filename(from_time, until_time)
139139
"#{from_time.strftime(format)}_til_#{until_time.strftime(format)}"\
140140
"_at_#{until_time.strftime('%H-%M-%S')}"
141141
end
142-
142+
143143
def granularity(url)
144144
client = OAI::Client.new url
145145
client.identify.granularity
@@ -149,7 +149,7 @@ def granularity(url)
149149
def earliest(url)
150150
client = OAI::Client.new url
151151
identify = client.identify
152-
if "YYYY-MM-DD" == identify.granularity
152+
if OAI::Const::Granularity::LOW == identify.granularity
153153
Time.parse(identify.earliest_datestamp).strftime("%Y-%m-%d")
154154
else
155155
Time.parse(identify.earliest_datestamp).xmlschema

0 commit comments

Comments
 (0)