Skip to content

Commit

Permalink
adds in basic tasks for harvesting opengeometadata
Browse files Browse the repository at this point in the history
  • Loading branch information
mejackreed committed Feb 5, 2015
1 parent 454fa42 commit 1fe5de8
Show file tree
Hide file tree
Showing 6 changed files with 74 additions and 11 deletions.
28 changes: 25 additions & 3 deletions README.md
@@ -1,6 +1,6 @@
# GeoCombine

TODO: Write a gem description
A Ruby toolkit for managing geospatial metadata

## Installation

Expand All @@ -20,11 +20,33 @@ Or install it yourself as:

## Usage

TODO: Write usage instructions here
### Clone all OpenGeoMetadata repositories

```sh
$ rake geocombine:clone
```

Will clone all edu.* OpenGeoMetadata repositories into `./tmp`

### Pull all OpenGeoMetadata repositories

```sh
$ rake geocombine:pull
```

Runs `git pull origin master` on all cloned repositories in `./tmp`

### Index all of the GeoBlacklight documents

```sh
$ rake geocombine:index
```

Indexs all of the `geoblacklight.xml` files in cloned repositories to a Solr index running at http://127.0.0.1:8983/solr

## Contributing

1. Fork it ( https://github.com/[my-github-username]/geo_combine/fork )
1. Fork it ( https://github.com/[my-github-username]/GeoCombine/fork )
2. Create your feature branch (`git checkout -b my-new-feature`)
3. Commit your changes (`git commit -am 'Add some feature'`)
4. Push to the branch (`git push origin my-new-feature`)
Expand Down
3 changes: 2 additions & 1 deletion Rakefile
@@ -1,2 +1,3 @@
require "bundler/gem_tasks"
require 'bundler/gem_tasks'

Dir.glob('lib/tasks/*.rake').each { |r| load r}
10 changes: 6 additions & 4 deletions geo_combine.gemspec
Expand Up @@ -6,18 +6,20 @@ require 'geo_combine/version'
Gem::Specification.new do |spec|
spec.name = "geo_combine"
spec.version = GeoCombine::VERSION
spec.authors = ["TODO: Write your name"]
spec.authors = ["Jack Reed"]
spec.email = ["pjreed@stanford.edu"]
spec.summary = %q{TODO: Write a short summary. Required.}
spec.description = %q{TODO: Write a longer description. Optional.}
spec.summary = %q{A Ruby toolkit for managing geospatial metadata}
spec.description = %q{A Ruby toolkit for managing geospatial metadata}
spec.homepage = ""
spec.license = "MIT"
spec.license = "Apache"

spec.files = `git ls-files -z`.split("\x0")
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
spec.require_paths = ["lib"]

spec.add_dependency 'rsolr'

spec.add_development_dependency "bundler", "~> 1.7"
spec.add_development_dependency "rake", "~> 10.0"
end
6 changes: 4 additions & 2 deletions lib/geo_combine.rb
@@ -1,5 +1,7 @@
require "geo_combine/version"
require 'geo_combine/version'

module GeoCombine
# Your code goes here...

end

load File.expand_path('../tasks/geo_combine.rake', __FILE__)
2 changes: 1 addition & 1 deletion lib/geo_combine/version.rb
@@ -1,3 +1,3 @@
module GeoCombine
VERSION = "0.0.1"
VERSION = '0.0.1'
end
36 changes: 36 additions & 0 deletions lib/tasks/geo_combine.rake
@@ -0,0 +1,36 @@
require 'find'
require 'net/http'
require 'json'
require 'rsolr'

namespace :geocombine do
desc 'Clone all OpenGeoMetadata repositories'
task :clone do
ogm_api_uri = URI('https://api.github.com/orgs/opengeometadata/repos')
ogm_repos = JSON.parse(Net::HTTP.get(ogm_api_uri)).map{ |repo| repo['git_url']}
ogm_repos.each do |repo|
if repo =~ /^git:\/\/github.com\/OpenGeoMetadata\/edu.*/
system "cd tmp && git clone #{repo}"
end
end
end
desc '"git pull" OpenGeoMetadata repositories'
task :pull do
Dir.glob('tmp/*').map{ |dir| system "cd #{dir} && git pull origin master" if dir =~ /.*edu.*./ }
end
desc 'Index all of the GeoBlacklight documents'
task :index do
solr = RSolr.connect :url => 'http://127.0.0.1:8983/solr'
Find.find('tmp') do |path|
if path =~ /.*geoblacklight.xml$/
doc = File.read(path)
begin
solr.update data: doc
solr.commit
rescue RSolr::Error::Http => error
puts error
end
end
end
end
end

0 comments on commit 1fe5de8

Please sign in to comment.