Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1fe5de8
commit 2510026
Showing
18 changed files
with
3,160 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
--color | ||
--require spec_helper |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
language: ruby | ||
rvm: | ||
- 2.1.5 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,23 @@ | ||
require 'bundler/gem_tasks' | ||
|
||
Dir.glob('lib/tasks/*.rake').each { |r| load r} | ||
|
||
desc 'Run console for development' | ||
task :console do | ||
require 'irb' | ||
require 'irb/completion' | ||
require 'irb/ext/save-history' | ||
require 'geo_combine' | ||
ARGV.clear | ||
IRB.start | ||
end | ||
|
||
begin | ||
require 'rspec/core/rake_task' | ||
|
||
RSpec::Core::RakeTask.new(:spec) | ||
|
||
task :default => :spec | ||
rescue LoadError | ||
# no rspec available | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,40 @@ | ||
require 'geo_combine/version' | ||
require 'nokogiri' | ||
|
||
module GeoCombine | ||
|
||
## | ||
# TODO: Create a parse method that can interpret the type of metadata being | ||
# passed in. | ||
# | ||
# def self.parse metadata | ||
# end | ||
|
||
## | ||
# Abstract class for GeoCombine objects | ||
class Metadata | ||
attr_reader :metadata | ||
|
||
## | ||
# Creates a new GeoCombine::Metadata object, where metadata parameter is can | ||
# be a File path or String of XML | ||
# @param (String) metadata can be a File path | ||
# "./tmp/edu.stanford.purl/bb/338/jh/0716/iso19139.xml" or a String of XML | ||
# metadata | ||
def initialize metadata | ||
metadata = File.read metadata if File.readable? metadata | ||
metadata = Nokogiri::XML(metadata) if metadata.instance_of? String | ||
@metadata = metadata | ||
end | ||
|
||
## | ||
# Perform an XSLT tranformation on metadata using an object's XSL | ||
def to_geoblacklight | ||
GeoCombine::Geoblacklight.new(xsl.transform(@metadata)) | ||
end | ||
end | ||
end | ||
|
||
load File.expand_path('../tasks/geo_combine.rake', __FILE__) | ||
require 'geo_combine/fgdc' | ||
require 'geo_combine/geoblacklight' | ||
require 'geo_combine/iso19139' | ||
require 'geo_combine/version' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
module GeoCombine | ||
|
||
## | ||
# FIXME: FGDC parsing, transformations are still experimental | ||
class Fgdc < Metadata | ||
|
||
## | ||
# Returns a Nokogiri::XSLT object containing the FGDC to GeoBlacklight XSL | ||
# @return (Nokogiri::XSLT) | ||
def xsl | ||
Nokogiri::XSLT(File.read('./lib/xslt/fgdc2geoBL.xsl')) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
module GeoCombine | ||
class Geoblacklight < Metadata | ||
|
||
## | ||
# Returns a string of JSON from a GeoBlacklight hash | ||
# @return (String) | ||
def to_json | ||
to_hash.to_json | ||
end | ||
|
||
## | ||
# Returns a hash from a GeoBlacklight object | ||
# @return (Hash) | ||
def to_hash | ||
hash = {} | ||
@metadata.css('field').each do |field| | ||
(hash[field.attributes['name'].value] ||= []) << field.children.text | ||
end | ||
hash.collect do |key, value| | ||
hash[key] = value.count > 1 ? { key => value } : { key => value[0] } | ||
end | ||
hash | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
module GeoCombine | ||
class Iso19139 < Metadata | ||
|
||
## | ||
# Returns a Nokogiri::XSLT object containing the ISO19139 to GeoBlacklight | ||
# XSL | ||
# @return (Nokogiri::XSLT) | ||
def xsl | ||
Nokogiri::XSLT(File.read('./lib/xslt/iso2geoBL.xsl')) | ||
end | ||
end | ||
end |
Oops, something went wrong.