resync-client 0.1.0 → 0.1.1
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 +7 -0
- data/README.md +27 -30
- data/lib/resync/client/version.rb +1 -1
- data/resync-client.gemspec +1 -1
- metadata +11 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 892297d37e81bd989c01ec1b8727c75944272ef5
|
4
|
+
data.tar.gz: 54e05162319203f118f59c2582ef2522cdf7e869
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e6ae887ca08bda37140982c22c0f8cd6594f243a826464a9178d64e3f48e43340ffa20e50b853e4d09281ac3b831fa92c6ec6c23ad373c4a8ee476fb6a43957f
|
7
|
+
data.tar.gz: a841308856143cff35689d72676e4cb31e32207622b7f35582f56bd2524793ab56412d93236afa3400d6a31c593f74358e36064014ec2a4576023c4b4e3bfd20
|
data/CHANGES.md
ADDED
data/README.md
CHANGED
@@ -2,58 +2,55 @@
|
|
2
2
|
|
3
3
|
A gem providing a Ruby client for the [ResourceSync](http://www.openarchives.org/rs/1.0/resourcesync) web synchronization framework, based on the [resync](https://github.com/dmolesUC3/resync) gem and [Net::HTTP](http://ruby-doc.org/stdlib-2.2.2/libdoc/net/http/rdoc/Net/HTTP.html).
|
4
4
|
|
5
|
-
## Status
|
6
|
-
|
7
|
-
This is a work in progress. We welcome bug reports and feature requests.
|
8
|
-
|
9
5
|
## Usage
|
10
6
|
|
11
7
|
Retrieving the [Source Description](http://www.openarchives.org/rs/1.0/resourcesync#wellknown) for a site:
|
12
8
|
|
13
9
|
```ruby
|
14
|
-
|
10
|
+
client = Resync::Client.new
|
15
11
|
|
16
|
-
|
17
|
-
|
12
|
+
source_desc_uri = 'http://example.org/.well-known/resourcesync'
|
13
|
+
source_desc = client.get_and_parse(source_desc_uri) # => Resync::SourceDescription
|
18
14
|
```
|
19
15
|
|
20
16
|
Retrieving a [Capability List](http://www.openarchives.org/rs/1.0/resourcesync#CapabilityList) from the source description:
|
21
17
|
|
22
18
|
```ruby
|
23
|
-
|
24
|
-
|
19
|
+
cap_list_resource = source_desc.resource_for(capability: 'capabilitylist')
|
20
|
+
cap_list = cap_list_resource.get_and_parse # => Resync::CapabilityList
|
25
21
|
```
|
26
22
|
|
27
23
|
Retrieving a [Change List](http://www.openarchives.org/rs/1.0/resourcesync#ChangeList) and downloading the latest revision of a known resource to a file
|
28
24
|
|
29
25
|
```ruby
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
26
|
+
change_list_resource = cap_list.resource_for(capability: 'changelist')
|
27
|
+
change_list = change_list_resource.get_and_parse # => Resync::ChangeList
|
28
|
+
latest_rev_resource = change_list.latest_for(uri: URI('http://example.com/my-resource'))
|
29
|
+
latest_rev_resource.download_to_file('/tmp/my-resource.txt')
|
34
30
|
```
|
35
31
|
|
36
32
|
Retrieving a [Change Dump](http://www.openarchives.org/rs/1.0/resourcesync#ChangeDump), searching through its manifests for changes to a specified URL, downloading the ZIP package containing that resource, and extracting it from the ZIP package:
|
37
33
|
|
38
34
|
```ruby
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
end
|
53
|
-
end
|
35
|
+
change_dump_resource = cap_list.resource_for(capability: 'changedump')
|
36
|
+
change_dump = change_dump_resource.get_and_parse # => Resync::ChangeDump
|
37
|
+
change_dump.resources.each do |package|
|
38
|
+
manifest_link = package.link_for(rel: 'contents')
|
39
|
+
if manifest_link
|
40
|
+
manifest = manifest_link.get_and_parse # => Resync::ChangeDumpManifest
|
41
|
+
latest_resource = manifest.latest_for(uri: URI('http://example.com/my-resource'))
|
42
|
+
if latest_resource
|
43
|
+
timestamp = latest_resource.modified_time.strftime('%s%3N')
|
44
|
+
zip_package = package.zip_package # => Resync::ZipPackage (downloaded to temp file)
|
45
|
+
bitstream = zip_package.bitstream_for(latest_resource) # => Resync::Bitstream
|
46
|
+
content = bitstream.content # => String (extracted from ZIP file)
|
47
|
+
File.open("/tmp/my-resource-#{timestamp}.txt") { |f| f.write(content) }
|
54
48
|
end
|
49
|
+
end
|
50
|
+
end
|
55
51
|
```
|
56
52
|
|
57
|
-
##
|
53
|
+
## Status
|
54
|
+
|
55
|
+
This is a work in progress -- bug reports and feature requests are welcome. It's still a prototype, and hasn't really been tested except with [resync-simulator](https://github.com/resync/resync-simulator) -- and that not much beyond what you'll find in [example.rb](example.rb). So expect some trouble. `:)`
|
58
56
|
|
59
|
-
`resync-client` hasn't really been tested except with [resync-simulator](https://github.com/resync/resync-simulator), and that not much beyond what you'll find in [example.rb](example.rb), so expect trouble.
|
data/resync-client.gemspec
CHANGED
@@ -22,7 +22,7 @@ Gem::Specification.new do |spec|
|
|
22
22
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
23
23
|
spec.require_paths = ['lib']
|
24
24
|
|
25
|
-
spec.add_dependency 'resync', '~> 0.1.
|
25
|
+
spec.add_dependency 'resync', '~> 0.1', '>= 0.1.1'
|
26
26
|
spec.add_dependency 'rubyzip', '~> 1.1.7'
|
27
27
|
|
28
28
|
spec.add_development_dependency 'equivalent-xml', '~> 0.6.0'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: resync-client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
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-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: resync
|
@@ -16,14 +16,20 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 0.1
|
19
|
+
version: '0.1'
|
20
|
+
- - ">="
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: 0.1.1
|
20
23
|
type: :runtime
|
21
24
|
prerelease: false
|
22
25
|
version_requirements: !ruby/object:Gem::Requirement
|
23
26
|
requirements:
|
24
27
|
- - "~>"
|
25
28
|
- !ruby/object:Gem::Version
|
26
|
-
version: 0.1
|
29
|
+
version: '0.1'
|
30
|
+
- - ">="
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: 0.1.1
|
27
33
|
- !ruby/object:Gem::Dependency
|
28
34
|
name: rubyzip
|
29
35
|
requirement: !ruby/object:Gem::Requirement
|
@@ -147,6 +153,7 @@ files:
|
|
147
153
|
- ".rubocop.yml"
|
148
154
|
- ".ruby-version"
|
149
155
|
- ".travis.yml"
|
156
|
+
- CHANGES.md
|
150
157
|
- Gemfile
|
151
158
|
- LICENSE.md
|
152
159
|
- README.md
|