geo_combine 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rspec +2 -0
- data/.travis.yml +3 -0
- data/Gemfile +2 -0
- data/README.md +14 -0
- data/Rakefile +20 -0
- data/geo_combine.gemspec +2 -0
- data/lib/geo_combine/fgdc.rb +14 -0
- data/lib/geo_combine/geoblacklight.rb +25 -0
- data/lib/geo_combine/iso19139.rb +12 -0
- data/lib/geo_combine/version.rb +1 -1
- data/lib/geo_combine.rb +35 -2
- data/lib/xslt/fgdc2geoBL.xsl +588 -0
- data/lib/xslt/iso2geoBL.xsl +539 -0
- data/spec/fixtures/xml_docs.rb +1725 -0
- data/spec/helpers.rb +13 -0
- data/spec/lib/geo_combine/fgdc_spec.rb +22 -0
- data/spec/lib/geo_combine/geoblacklight_spec.rb +16 -0
- data/spec/lib/geo_combine/iso19139_spec.rb +21 -0
- data/spec/lib/geo_combine_spec.rb +22 -0
- data/spec/spec_helper.rb +99 -0
- metadata +53 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 66720182889b98a3b1ef96cbdf22f454a90550bf
|
4
|
+
data.tar.gz: 5ec28f72313b22ba934b0ee3e093fedbfcc0c4d7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 89d15e4a3612d245b017cbcd901a460670e55c6c4c49add06b29da0e56ae3a2c8a4d2fbecf28fa1cfb5e41768da9817b029219007df823343a2cb8b16d84e98e
|
7
|
+
data.tar.gz: ced995dcb3f7cefb677ee22cfb95c09c99293875e509cb197f53d9aaf2c63e269dce9fe7011a90c2bd0b2a794a0be4b06336c5b5b095c10d19b16eac11140e13
|
data/.rspec
ADDED
data/.travis.yml
ADDED
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -19,6 +19,20 @@ Or install it yourself as:
|
|
19
19
|
$ gem install geo_combine
|
20
20
|
|
21
21
|
## Usage
|
22
|
+
GeoCombine can be used as a set of rake tasks for cloning, updating, and indexing OpenGeoMetdata metdata. It can also be used as a Ruby library for converting metdata.
|
23
|
+
|
24
|
+
### Transforming metadata
|
25
|
+
|
26
|
+
```ruby
|
27
|
+
# Create a new ISO19139 object
|
28
|
+
> iso_metadata = GeoCombine::Iso19139.new('./tmp/edu.stanford.purl/bb/338/jh/0716/iso19139.xml')
|
29
|
+
|
30
|
+
# Convert it to GeoBlacklight
|
31
|
+
> iso_metadata.to_geoblacklight
|
32
|
+
|
33
|
+
# Convert that to JSON
|
34
|
+
> iso_metadata.to_geoblacklight.to_json
|
35
|
+
```
|
22
36
|
|
23
37
|
### Clone all OpenGeoMetadata repositories
|
24
38
|
|
data/Rakefile
CHANGED
@@ -1,3 +1,23 @@
|
|
1
1
|
require 'bundler/gem_tasks'
|
2
2
|
|
3
3
|
Dir.glob('lib/tasks/*.rake').each { |r| load r}
|
4
|
+
|
5
|
+
desc 'Run console for development'
|
6
|
+
task :console do
|
7
|
+
require 'irb'
|
8
|
+
require 'irb/completion'
|
9
|
+
require 'irb/ext/save-history'
|
10
|
+
require 'geo_combine'
|
11
|
+
ARGV.clear
|
12
|
+
IRB.start
|
13
|
+
end
|
14
|
+
|
15
|
+
begin
|
16
|
+
require 'rspec/core/rake_task'
|
17
|
+
|
18
|
+
RSpec::Core::RakeTask.new(:spec)
|
19
|
+
|
20
|
+
task :default => :spec
|
21
|
+
rescue LoadError
|
22
|
+
# no rspec available
|
23
|
+
end
|
data/geo_combine.gemspec
CHANGED
@@ -19,7 +19,9 @@ Gem::Specification.new do |spec|
|
|
19
19
|
spec.require_paths = ["lib"]
|
20
20
|
|
21
21
|
spec.add_dependency 'rsolr'
|
22
|
+
spec.add_dependency 'nokogiri'
|
22
23
|
|
23
24
|
spec.add_development_dependency "bundler", "~> 1.7"
|
24
25
|
spec.add_development_dependency "rake", "~> 10.0"
|
26
|
+
spec.add_development_dependency 'rspec'
|
25
27
|
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
module GeoCombine
|
2
|
+
|
3
|
+
##
|
4
|
+
# FIXME: FGDC parsing, transformations are still experimental
|
5
|
+
class Fgdc < Metadata
|
6
|
+
|
7
|
+
##
|
8
|
+
# Returns a Nokogiri::XSLT object containing the FGDC to GeoBlacklight XSL
|
9
|
+
# @return (Nokogiri::XSLT)
|
10
|
+
def xsl
|
11
|
+
Nokogiri::XSLT(File.read('./lib/xslt/fgdc2geoBL.xsl'))
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module GeoCombine
|
2
|
+
class Geoblacklight < Metadata
|
3
|
+
|
4
|
+
##
|
5
|
+
# Returns a string of JSON from a GeoBlacklight hash
|
6
|
+
# @return (String)
|
7
|
+
def to_json
|
8
|
+
to_hash.to_json
|
9
|
+
end
|
10
|
+
|
11
|
+
##
|
12
|
+
# Returns a hash from a GeoBlacklight object
|
13
|
+
# @return (Hash)
|
14
|
+
def to_hash
|
15
|
+
hash = {}
|
16
|
+
@metadata.css('field').each do |field|
|
17
|
+
(hash[field.attributes['name'].value] ||= []) << field.children.text
|
18
|
+
end
|
19
|
+
hash.collect do |key, value|
|
20
|
+
hash[key] = value.count > 1 ? { key => value } : { key => value[0] }
|
21
|
+
end
|
22
|
+
hash
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
data/lib/geo_combine/version.rb
CHANGED
data/lib/geo_combine.rb
CHANGED
@@ -1,7 +1,40 @@
|
|
1
|
-
require '
|
1
|
+
require 'nokogiri'
|
2
2
|
|
3
3
|
module GeoCombine
|
4
4
|
|
5
|
+
##
|
6
|
+
# TODO: Create a parse method that can interpret the type of metadata being
|
7
|
+
# passed in.
|
8
|
+
#
|
9
|
+
# def self.parse metadata
|
10
|
+
# end
|
11
|
+
|
12
|
+
##
|
13
|
+
# Abstract class for GeoCombine objects
|
14
|
+
class Metadata
|
15
|
+
attr_reader :metadata
|
16
|
+
|
17
|
+
##
|
18
|
+
# Creates a new GeoCombine::Metadata object, where metadata parameter is can
|
19
|
+
# be a File path or String of XML
|
20
|
+
# @param (String) metadata can be a File path
|
21
|
+
# "./tmp/edu.stanford.purl/bb/338/jh/0716/iso19139.xml" or a String of XML
|
22
|
+
# metadata
|
23
|
+
def initialize metadata
|
24
|
+
metadata = File.read metadata if File.readable? metadata
|
25
|
+
metadata = Nokogiri::XML(metadata) if metadata.instance_of? String
|
26
|
+
@metadata = metadata
|
27
|
+
end
|
28
|
+
|
29
|
+
##
|
30
|
+
# Perform an XSLT tranformation on metadata using an object's XSL
|
31
|
+
def to_geoblacklight
|
32
|
+
GeoCombine::Geoblacklight.new(xsl.transform(@metadata))
|
33
|
+
end
|
34
|
+
end
|
5
35
|
end
|
6
36
|
|
7
|
-
|
37
|
+
require 'geo_combine/fgdc'
|
38
|
+
require 'geo_combine/geoblacklight'
|
39
|
+
require 'geo_combine/iso19139'
|
40
|
+
require 'geo_combine/version'
|