resync 0.2.1 → 0.2.2
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/CHANGES.md +5 -0
- data/lib/resync/change_dump.rb +2 -2
- data/lib/resync/change_dump_index.rb +2 -2
- data/lib/resync/change_dump_manifest.rb +2 -2
- data/lib/resync/change_list.rb +2 -2
- data/lib/resync/change_list_index.rb +2 -2
- data/lib/resync/metadata.rb +1 -1
- data/lib/resync/shared/augmented.rb +23 -0
- data/lib/resync/shared/base_change_index.rb +35 -0
- data/lib/resync/shared/base_change_list.rb +19 -0
- data/lib/resync/version.rb +1 -1
- data/spec/unit/resync/change_dump_index_spec.rb +2 -2
- data/spec/unit/resync/change_dump_manifest_spec.rb +2 -2
- data/spec/unit/resync/change_dump_spec.rb +2 -2
- data/spec/unit/resync/change_list_index_spec.rb +2 -2
- data/spec/unit/resync/change_list_spec.rb +2 -2
- data/spec/unit/resync/shared/base_change_index_examples.rb +66 -0
- data/spec/unit/resync/shared/base_change_list_examples.rb +69 -0
- data/spec/unit/resync/shared/sorted_list_examples.rb +3 -3
- metadata +8 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 30958a3d136a05395b75151c4396cc3a396d8dc0
|
4
|
+
data.tar.gz: 1380f44a55d5305a1cf46988cbbc604f6672ad8f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2262fa5a7028254fb4144772ec3cfe44982596a1cd69f8114afad7a4c9f1db5de0f2de0de7d0f25990ce6cf8c0a3d16fb35eaeb504c3f877fe6a6f2ab31660de
|
7
|
+
data.tar.gz: 885631b5db2dae906e938f2a125c75f7f020d98dfbe2b964bd8ea6fe68ff3e3ba684137fd34ab2ff635ed94639e5c8b482eba457440de410d7830abc6d1c26a3
|
data/CHANGES.md
CHANGED
@@ -1,3 +1,8 @@
|
|
1
|
+
## 0.2.2
|
2
|
+
|
3
|
+
- Added `#changes` method to `ChangeList` and `ChangeDumpManifest`, allowing filtering by change type and modified time
|
4
|
+
- Added `#change_lists` method to `ChangeListIndex`, `ChangeDumpIndex`, and `ChangeDump`, allowing filtering by from and until times
|
5
|
+
|
1
6
|
## 0.2.1
|
2
7
|
|
3
8
|
- Fixed issue where extra whitespace in `<loc/>` tags could prevent URI parsing.
|
data/lib/resync/change_dump.rb
CHANGED
@@ -1,11 +1,11 @@
|
|
1
|
-
require_relative 'shared/
|
1
|
+
require_relative 'shared/base_change_index'
|
2
2
|
require_relative 'xml'
|
3
3
|
|
4
4
|
module Resync
|
5
5
|
# A change dump. See section 13.1,
|
6
6
|
# "{http://www.openarchives.org/rs/1.0/resourcesync#ChangeDump Change Dump}",
|
7
7
|
# in the ResourceSync specification.
|
8
|
-
class ChangeDump <
|
8
|
+
class ChangeDump < BaseChangeIndex
|
9
9
|
include ::XML::Mapping
|
10
10
|
|
11
11
|
# The capability provided by this type.
|
@@ -1,11 +1,11 @@
|
|
1
|
-
require_relative 'shared/
|
1
|
+
require_relative 'shared/base_change_index'
|
2
2
|
require_relative 'shared/sitemap_index'
|
3
3
|
|
4
4
|
module Resync
|
5
5
|
# A change dump index. See under section 13.1,
|
6
6
|
# "{http://www.openarchives.org/rs/1.0/resourcesync#ChangeDumpIndex Change Dump}",
|
7
7
|
# in the ResourceSync specification.
|
8
|
-
class ChangeDumpIndex <
|
8
|
+
class ChangeDumpIndex < BaseChangeIndex
|
9
9
|
include ::XML::Mapping
|
10
10
|
include SitemapIndex
|
11
11
|
|
@@ -1,11 +1,11 @@
|
|
1
|
-
require_relative 'shared/
|
1
|
+
require_relative 'shared/base_change_list'
|
2
2
|
require_relative 'xml'
|
3
3
|
|
4
4
|
module Resync
|
5
5
|
# A change dump manifest. See section 13.2,
|
6
6
|
# "{http://www.openarchives.org/rs/1.0/resourcesync#ChangeDumpManifest Change Dump Manifest}",
|
7
7
|
# in the ResourceSync specification.
|
8
|
-
class ChangeDumpManifest <
|
8
|
+
class ChangeDumpManifest < BaseChangeList
|
9
9
|
include ::XML::Mapping
|
10
10
|
|
11
11
|
# The capability provided by this type.
|
data/lib/resync/change_list.rb
CHANGED
@@ -1,11 +1,11 @@
|
|
1
|
-
require_relative 'shared/
|
1
|
+
require_relative 'shared/base_change_list'
|
2
2
|
require_relative 'xml'
|
3
3
|
|
4
4
|
module Resync
|
5
5
|
# A change list. See section 12.1,
|
6
6
|
# "{http://www.openarchives.org/rs/1.0/resourcesync#ChangeList Change List}",
|
7
7
|
# in the ResourceSync specification.
|
8
|
-
class ChangeList <
|
8
|
+
class ChangeList < BaseChangeList
|
9
9
|
include ::XML::Mapping
|
10
10
|
|
11
11
|
# The capability provided by this type.
|
@@ -1,11 +1,11 @@
|
|
1
|
-
require_relative 'shared/
|
1
|
+
require_relative 'shared/base_change_index'
|
2
2
|
require_relative 'shared/sitemap_index'
|
3
3
|
|
4
4
|
module Resync
|
5
5
|
# A change list index. See section 12.2,
|
6
6
|
# "{http://www.openarchives.org/rs/1.0/resourcesync#ChangeListIndex Change List Index}",
|
7
7
|
# in the ResourceSync specification.
|
8
|
-
class ChangeListIndex <
|
8
|
+
class ChangeListIndex < BaseChangeIndex
|
9
9
|
include ::XML::Mapping
|
10
10
|
include SitemapIndex
|
11
11
|
|
data/lib/resync/metadata.rb
CHANGED
@@ -48,7 +48,7 @@ module Resync
|
|
48
48
|
# a change list (including change list indices, change dumps, etc.)
|
49
49
|
# @param until_time [Time] the end of the time range represented by
|
50
50
|
# a change list (including change list indices, change dumps, etc.)
|
51
|
-
# @param completed_time the datetime at which assembling a resource list
|
51
|
+
# @param completed_time [Time] the datetime at which assembling a resource list
|
52
52
|
# ended (including resource list indices, resource dumps, etc.)
|
53
53
|
# @param modified_time [Time] The date and time when the referenced resource was last modified.
|
54
54
|
# @param length [Integer] The content length of the referenced resource.
|
@@ -73,21 +73,44 @@ module Resync
|
|
73
73
|
links.find { |l| l.rel == rel }
|
74
74
|
end
|
75
75
|
|
76
|
+
# Convenience accessor for the +at_time+ metadata attribute
|
77
|
+
# @return [Time] the datetime at which assembling a resource list
|
78
|
+
# began (including resource list indices, resource dumps, etc.)
|
79
|
+
# @see Metadata#at_time
|
76
80
|
def at_time
|
77
81
|
metadata.at_time if metadata
|
78
82
|
end
|
79
83
|
|
84
|
+
# Convenience accessor for the +from_time+ metadata attribute
|
85
|
+
# @return [Time] the beginning of the time range represented by
|
86
|
+
# a change list (including change list indices, change dumps, etc.)
|
87
|
+
# @see Metadata#from_time
|
80
88
|
def from_time
|
81
89
|
metadata.from_time if metadata
|
82
90
|
end
|
83
91
|
|
92
|
+
# Convenience accessor for the +until_time+ metadata attribute
|
93
|
+
# @return [Time] the end of the time range represented by
|
94
|
+
# a change list (including change list indices, change dumps, etc.)
|
95
|
+
# @see Metadata#until_time
|
84
96
|
def until_time
|
85
97
|
metadata.until_time if metadata
|
86
98
|
end
|
87
99
|
|
100
|
+
# Convenience accessor for the +completed_time+ metadata attribute
|
101
|
+
# @return [Time] the datetime at which assembling a resource list
|
102
|
+
# ended (including resource list indices, resource dumps, etc.)
|
103
|
+
# @see Metadata#completed_time
|
88
104
|
def completed_time
|
89
105
|
metadata.completed_time if metadata
|
90
106
|
end
|
91
107
|
|
108
|
+
# Convenience accessor for the +change+ metadata attribute
|
109
|
+
# @return [Change] the type of change to a resource reported in
|
110
|
+
# a change list (including change list indices, change dumps, etc.)
|
111
|
+
# @see Metadata#change
|
112
|
+
def change
|
113
|
+
metadata.change if metadata
|
114
|
+
end
|
92
115
|
end
|
93
116
|
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
require_relative 'sorted_resource_list'
|
2
|
+
|
3
|
+
module Resync
|
4
|
+
# Adds useful methods to {ChangeListIndex}, {ChangeDumpIndex}, and {ChangeDump}.
|
5
|
+
class BaseChangeIndex < SortedResourceList
|
6
|
+
# Filters the list of change lists by from/until time. The filter can be *strict*, in which
|
7
|
+
# case only those change lists provably in the range are included, or *non-strict*, in which
|
8
|
+
# case only those change lists provably *not* in the range are *excluded*. (This is particularly
|
9
|
+
# useful for {ChangeDump}s, where the +from_time+ and +until_time+ attributes on the individual
|
10
|
+
# bitstream packages are optional.)
|
11
|
+
#
|
12
|
+
# @param in_range [Range<Time>] the range of times to filter by
|
13
|
+
# @param strict [Boolean] +true+ if resources without +from_time+ or +until_time+ should be
|
14
|
+
# excluded, +false+ if they should be included.
|
15
|
+
# @return [Enumerator::Lazy<Resource>] those change lists whose +from_time+ *or* +until_time+
|
16
|
+
# falls within +in_range+
|
17
|
+
def change_lists(in_range:, strict: true)
|
18
|
+
resources.select do |r|
|
19
|
+
strict ? strictly(in_range, r) : loosely(in_range, r)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
private
|
24
|
+
|
25
|
+
def strictly(in_range, resource)
|
26
|
+
from_in_range = resource.from_time ? in_range.cover?(resource.from_time) : false
|
27
|
+
until_in_range = resource.until_time ? in_range.cover?(resource.until_time) : false
|
28
|
+
from_in_range || until_in_range
|
29
|
+
end
|
30
|
+
|
31
|
+
def loosely(in_range, resource)
|
32
|
+
(resource.from_time || resource.until_time) ? strictly(in_range, resource) : true
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require_relative 'sorted_resource_list'
|
2
|
+
|
3
|
+
module Resync
|
4
|
+
# Adds useful methods to {ChangeList} and {ChangeDumpManifest}.
|
5
|
+
class BaseChangeList < SortedResourceList
|
6
|
+
# Filters the list of changes by change type, modification time, or both.
|
7
|
+
# @param of_type [Types::Change] the change type
|
8
|
+
# @param in_range [Range<Time>] the range of modification times
|
9
|
+
# @return [Enumerator::Lazy<Resource>] the matching changes, or all changes
|
10
|
+
# if neither +of_type+ nor +in_range+ is specified.
|
11
|
+
def changes(of_type: nil, in_range: nil)
|
12
|
+
resources.select do |r|
|
13
|
+
is_of_type = of_type ? r.change == of_type : true
|
14
|
+
is_in_range = in_range ? in_range.cover?(r.modified_time) : true
|
15
|
+
is_of_type && is_in_range
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
data/lib/resync/version.rb
CHANGED
@@ -1,8 +1,8 @@
|
|
1
|
-
require_relative 'shared/
|
1
|
+
require_relative 'shared/base_change_index_examples'
|
2
2
|
|
3
3
|
module Resync
|
4
4
|
describe ChangeDumpIndex do
|
5
|
-
it_behaves_like
|
5
|
+
it_behaves_like BaseChangeIndex
|
6
6
|
|
7
7
|
describe 'XML conversion' do
|
8
8
|
describe '#from_xml' do
|
@@ -1,8 +1,8 @@
|
|
1
|
-
require_relative 'shared/
|
1
|
+
require_relative 'shared/base_change_list_examples'
|
2
2
|
|
3
3
|
module Resync
|
4
4
|
describe ChangeDumpManifest do
|
5
|
-
it_behaves_like
|
5
|
+
it_behaves_like BaseChangeList
|
6
6
|
describe 'XML conversion' do
|
7
7
|
describe '#from_xml' do
|
8
8
|
it 'parses an XML string' do
|
@@ -1,8 +1,8 @@
|
|
1
|
-
require_relative 'shared/
|
1
|
+
require_relative 'shared/base_change_index_examples'
|
2
2
|
|
3
3
|
module Resync
|
4
4
|
describe ChangeDump do
|
5
|
-
it_behaves_like
|
5
|
+
it_behaves_like BaseChangeIndex
|
6
6
|
|
7
7
|
describe 'XML conversion' do
|
8
8
|
describe '#from_xml' do
|
@@ -1,8 +1,8 @@
|
|
1
|
-
require_relative 'shared/
|
1
|
+
require_relative 'shared/base_change_index_examples'
|
2
2
|
|
3
3
|
module Resync
|
4
4
|
describe ChangeListIndex do
|
5
|
-
it_behaves_like
|
5
|
+
it_behaves_like BaseChangeIndex
|
6
6
|
|
7
7
|
describe 'XML conversion' do
|
8
8
|
describe '#from_xml' do
|
@@ -1,8 +1,8 @@
|
|
1
|
-
require_relative 'shared/
|
1
|
+
require_relative 'shared/base_change_list_examples'
|
2
2
|
|
3
3
|
module Resync
|
4
4
|
describe ChangeList do
|
5
|
-
it_behaves_like
|
5
|
+
it_behaves_like BaseChangeList
|
6
6
|
|
7
7
|
describe 'XML conversion' do
|
8
8
|
describe '#from_xml' do
|
@@ -0,0 +1,66 @@
|
|
1
|
+
require_relative 'sorted_list_examples'
|
2
|
+
|
3
|
+
module Resync
|
4
|
+
RSpec.shared_examples BaseChangeIndex do
|
5
|
+
it_behaves_like SortedResourceList
|
6
|
+
|
7
|
+
describe '#change_lists' do
|
8
|
+
it 'filters by time range' do
|
9
|
+
resources = []
|
10
|
+
resources[0] = Resource.new(uri: 'http://example.org/changes-0', metadata: Metadata.new(until_time: Time.utc(2000)))
|
11
|
+
resources[1] = Resource.new(uri: 'http://example.org/changes-1', metadata: Metadata.new(from_time: Time.utc(2000), until_time: Time.utc(2001)))
|
12
|
+
resources[2] = Resource.new(uri: 'http://example.org/changes-2', metadata: Metadata.new(from_time: Time.utc(2001), until_time: Time.utc(2002)))
|
13
|
+
resources[3] = Resource.new(uri: 'http://example.org/changes-3', metadata: Metadata.new(from_time: Time.utc(2002)))
|
14
|
+
index = ChangeListIndex.new(resources: resources)
|
15
|
+
|
16
|
+
changes = index.change_lists(in_range: Time.utc(1999)..Time.utc(2000, 7, 1)).to_a
|
17
|
+
expect(changes.size).to eq(2)
|
18
|
+
expect(changes).to include(resources[0])
|
19
|
+
expect(changes).to include(resources[1])
|
20
|
+
|
21
|
+
changes = index.change_lists(in_range: Time.utc(2000, 7, 1)..Time.utc(2001, 7, 1)).to_a
|
22
|
+
expect(changes.size).to eq(2)
|
23
|
+
expect(changes).to include(resources[1])
|
24
|
+
expect(changes).to include(resources[2])
|
25
|
+
|
26
|
+
changes = index.change_lists(in_range: Time.utc(2001, 7, 1)..Time.utc(2003, 7, 1)).to_a
|
27
|
+
expect(changes.size).to eq(2)
|
28
|
+
expect(changes).to include(resources[2])
|
29
|
+
expect(changes).to include(resources[3])
|
30
|
+
end
|
31
|
+
|
32
|
+
it 'ignores resources with neither from nor until time' do
|
33
|
+
resources = []
|
34
|
+
resources[0] = Resource.new(uri: 'http://example.org/changes-0', metadata: Metadata.new(until_time: Time.utc(2000)))
|
35
|
+
resources[1] = Resource.new(uri: 'http://example.org/changes-1', metadata: Metadata.new(from_time: Time.utc(2000), until_time: Time.utc(2001)))
|
36
|
+
resources[2] = Resource.new(uri: 'http://example.org/changes-2', metadata: Metadata.new(from_time: Time.utc(2001), until_time: Time.utc(2002)))
|
37
|
+
resources[3] = Resource.new(uri: 'http://example.org/changes-3', metadata: Metadata.new(from_time: Time.utc(2002)))
|
38
|
+
resources[4] = Resource.new(uri: 'http://example.org/changes-4')
|
39
|
+
resources[5] = Resource.new(uri: 'http://example.org/changes-5')
|
40
|
+
index = ChangeListIndex.new(resources: resources)
|
41
|
+
changes = index.change_lists(in_range: Time.utc(2000, 7, 1)..Time.utc(2001, 7, 1)).to_a
|
42
|
+
expect(changes.size).to eq(2)
|
43
|
+
expect(changes).to include(resources[1])
|
44
|
+
expect(changes).to include(resources[2])
|
45
|
+
end
|
46
|
+
|
47
|
+
it 'includes resources with neither from nor until time when in non-strict mode' do
|
48
|
+
resources = []
|
49
|
+
resources[0] = Resource.new(uri: 'http://example.org/changes-0', metadata: Metadata.new(until_time: Time.utc(2000)))
|
50
|
+
resources[1] = Resource.new(uri: 'http://example.org/changes-1', metadata: Metadata.new(from_time: Time.utc(2000), until_time: Time.utc(2001)))
|
51
|
+
resources[2] = Resource.new(uri: 'http://example.org/changes-2', metadata: Metadata.new(from_time: Time.utc(2001), until_time: Time.utc(2002)))
|
52
|
+
resources[3] = Resource.new(uri: 'http://example.org/changes-3', metadata: Metadata.new(from_time: Time.utc(2002)))
|
53
|
+
resources[4] = Resource.new(uri: 'http://example.org/changes-4')
|
54
|
+
resources[5] = Resource.new(uri: 'http://example.org/changes-5')
|
55
|
+
index = ChangeListIndex.new(resources: resources)
|
56
|
+
changes = index.change_lists(in_range: Time.utc(2000, 7, 1)..Time.utc(2001, 7, 1), strict: false).to_a
|
57
|
+
expect(changes.size).to eq(4)
|
58
|
+
expect(changes).to include(resources[1])
|
59
|
+
expect(changes).to include(resources[2])
|
60
|
+
expect(changes).to include(resources[4])
|
61
|
+
expect(changes).to include(resources[5])
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
end
|
66
|
+
end
|
@@ -0,0 +1,69 @@
|
|
1
|
+
require_relative 'sorted_list_examples'
|
2
|
+
|
3
|
+
module Resync
|
4
|
+
RSpec.shared_examples BaseChangeList do
|
5
|
+
|
6
|
+
# ------------------------------------------------------
|
7
|
+
# Superclass conformance
|
8
|
+
|
9
|
+
it_behaves_like SortedResourceList
|
10
|
+
|
11
|
+
def new_instance(**args)
|
12
|
+
required_args = (defined? required_arguments) ? required_arguments : {}
|
13
|
+
args = required_args.merge(args)
|
14
|
+
described_class.new(**args)
|
15
|
+
end
|
16
|
+
|
17
|
+
# ------------------------------------------------------
|
18
|
+
# Tests
|
19
|
+
|
20
|
+
describe '#changes' do
|
21
|
+
|
22
|
+
it 'returns all changes if called without arguments' do
|
23
|
+
resource0 = Resource.new(uri: 'http://example.org', modified_time: Time.utc(1997, 7, 16, 19, 20, 30.45))
|
24
|
+
resource1 = Resource.new(uri: 'http://example.org', modified_time: Time.utc(1998, 7, 16, 19, 20, 30.45))
|
25
|
+
resource2 = Resource.new(uri: 'http://example.org', modified_time: Time.utc(1998, 8, 16, 19, 20, 30.45))
|
26
|
+
resource3 = Resource.new(uri: 'http://example.org', modified_time: Time.utc(1999, 1, 16, 19, 20, 30.45))
|
27
|
+
list = new_instance(resources: [resource1, resource3, resource2, resource0])
|
28
|
+
expect(list.changes.to_a).to eq([resource0, resource1, resource2, resource3])
|
29
|
+
end
|
30
|
+
|
31
|
+
it 'filters on change type' do
|
32
|
+
resource0 = Resource.new(uri: 'http://example.org', metadata: Metadata.new(change: Types::Change::CREATED), modified_time: Time.utc(1997, 7, 16, 19, 20, 30.45))
|
33
|
+
resource1 = Resource.new(uri: 'http://example.org', metadata: Metadata.new(change: Types::Change::UPDATED), modified_time: Time.utc(1998, 7, 16, 19, 20, 30.45))
|
34
|
+
resource2 = Resource.new(uri: 'http://example.org', metadata: Metadata.new(change: Types::Change::UPDATED), modified_time: Time.utc(1998, 8, 16, 19, 20, 30.45))
|
35
|
+
resource3 = Resource.new(uri: 'http://example.org', metadata: Metadata.new(change: Types::Change::DELETED), modified_time: Time.utc(1999, 1, 16, 19, 20, 30.45))
|
36
|
+
list = new_instance(resources: [resource0, resource1, resource2, resource3])
|
37
|
+
changes = list.changes(of_type: Types::Change::UPDATED)
|
38
|
+
expect(changes.to_a).to eq([resource1, resource2])
|
39
|
+
end
|
40
|
+
|
41
|
+
it 'filters on modified time' do
|
42
|
+
resource0 = Resource.new(uri: 'http://example.org', modified_time: Time.utc(1997, 7, 16, 19, 20, 30.45))
|
43
|
+
resource1 = Resource.new(uri: 'http://example.org', modified_time: Time.utc(1998, 7, 16, 19, 20, 30.45))
|
44
|
+
resource2 = Resource.new(uri: 'http://example.org', modified_time: Time.utc(1998, 8, 16, 19, 20, 30.45))
|
45
|
+
resource3 = Resource.new(uri: 'http://example.org', modified_time: Time.utc(1999, 1, 16, 19, 20, 30.45))
|
46
|
+
list = new_instance(resources: [resource0, resource1, resource2, resource3])
|
47
|
+
range = Time.utc(1998, 1, 1)...Time.utc(1999, 1, 1)
|
48
|
+
changes = list.changes(in_range: range)
|
49
|
+
expect(changes.to_a).to eq([resource1, resource2])
|
50
|
+
end
|
51
|
+
|
52
|
+
it 'filters on combinations' do
|
53
|
+
resources = []
|
54
|
+
resources[0] = Resource.new(uri: 'http://example.org/', modified_time: Time.utc(1999, 1, 1), metadata: Metadata.new(change: Types::Change::CREATED))
|
55
|
+
resources[1] = Resource.new(uri: 'http://example.org/', modified_time: Time.utc(2000, 1, 1), metadata: Metadata.new(change: Types::Change::CREATED))
|
56
|
+
resources[2] = Resource.new(uri: 'http://example.org/', modified_time: Time.utc(1999, 3, 1), metadata: Metadata.new(change: Types::Change::UPDATED))
|
57
|
+
resources[3] = Resource.new(uri: 'http://example.org/', modified_time: Time.utc(1999, 6, 1), metadata: Metadata.new(change: Types::Change::UPDATED))
|
58
|
+
resources[4] = Resource.new(uri: 'http://example.org/', modified_time: Time.utc(2000, 3, 1), metadata: Metadata.new(change: Types::Change::UPDATED))
|
59
|
+
resources[5] = Resource.new(uri: 'http://example.org/', modified_time: Time.utc(2000, 6, 1), metadata: Metadata.new(change: Types::Change::UPDATED))
|
60
|
+
resources[6] = Resource.new(uri: 'http://example.org/', modified_time: Time.utc(1999, 9, 1), metadata: Metadata.new(change: Types::Change::DELETED))
|
61
|
+
resources[7] = Resource.new(uri: 'http://example.org/', modified_time: Time.utc(2000, 9, 1), metadata: Metadata.new(change: Types::Change::DELETED))
|
62
|
+
list = new_instance(resources: resources)
|
63
|
+
changes = list.changes(of_type: Types::Change::UPDATED, in_range: Time.utc(1999, 4, 1)..Time.utc(2000, 4, 1))
|
64
|
+
expect(changes.to_a).to eq([resources[3], resources[4]])
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
end
|
69
|
+
end
|
@@ -31,11 +31,11 @@ module Resync
|
|
31
31
|
resource0 = Resource.new(uri: 'http://example.org', modified_time: Time.utc(1997, 7, 16, 19, 20, 30.45))
|
32
32
|
resource1 = Resource.new(uri: 'http://example.org', modified_time: Time.utc(1998, 7, 16, 19, 20, 30.45))
|
33
33
|
resource2 = Resource.new(uri: 'http://example.org', modified_time: Time.utc(1998, 7, 16, 19, 20, 30.45))
|
34
|
-
|
35
|
-
list = new_instance(resources: [resource1,
|
34
|
+
resource3 = Resource.new(uri: 'http://example.org', modified_time: Time.utc(1998, 1, 16, 19, 20, 30.45))
|
35
|
+
list = new_instance(resources: [resource1, resource3, resource2, resource0])
|
36
36
|
resources = list.resources.to_a
|
37
37
|
expect(resources[0]).to be(resource0)
|
38
|
-
expect(resources[1]).to be(
|
38
|
+
expect(resources[1]).to be(resource3)
|
39
39
|
expect(resources).to include(resource1)
|
40
40
|
expect(resources).to include(resource2)
|
41
41
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: resync
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- David Moles
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-06-
|
11
|
+
date: 2015-06-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: mime-types
|
@@ -183,6 +183,8 @@ files:
|
|
183
183
|
- lib/resync/resource_list.rb
|
184
184
|
- lib/resync/resource_list_index.rb
|
185
185
|
- lib/resync/shared/augmented.rb
|
186
|
+
- lib/resync/shared/base_change_index.rb
|
187
|
+
- lib/resync/shared/base_change_list.rb
|
186
188
|
- lib/resync/shared/base_resource_list.rb
|
187
189
|
- lib/resync/shared/descriptor.rb
|
188
190
|
- lib/resync/shared/sitemap_index.rb
|
@@ -252,6 +254,8 @@ files:
|
|
252
254
|
- spec/unit/resync/resource_list_spec.rb
|
253
255
|
- spec/unit/resync/resource_spec.rb
|
254
256
|
- spec/unit/resync/shared/augmented_examples.rb
|
257
|
+
- spec/unit/resync/shared/base_change_index_examples.rb
|
258
|
+
- spec/unit/resync/shared/base_change_list_examples.rb
|
255
259
|
- spec/unit/resync/shared/base_resource_list_examples.rb
|
256
260
|
- spec/unit/resync/shared/descriptor_examples.rb
|
257
261
|
- spec/unit/resync/shared/descriptor_spec.rb
|
@@ -342,6 +346,8 @@ test_files:
|
|
342
346
|
- spec/unit/resync/resource_list_spec.rb
|
343
347
|
- spec/unit/resync/resource_spec.rb
|
344
348
|
- spec/unit/resync/shared/augmented_examples.rb
|
349
|
+
- spec/unit/resync/shared/base_change_index_examples.rb
|
350
|
+
- spec/unit/resync/shared/base_change_list_examples.rb
|
345
351
|
- spec/unit/resync/shared/base_resource_list_examples.rb
|
346
352
|
- spec/unit/resync/shared/descriptor_examples.rb
|
347
353
|
- spec/unit/resync/shared/descriptor_spec.rb
|