-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #25 from sul-dlss/show-action-naomi
show action initial implementation
- Loading branch information
Showing
7 changed files
with
96 additions
and
4 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
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
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,12 +1,33 @@ | ||
require 'moab/stanford' | ||
|
||
# API to retrieve data from Moab Object Store | ||
class MoabStorageController < ApplicationController | ||
|
||
def index | ||
storage_root = 'spec/fixtures/moab_storage_root' | ||
@stored_druids = Dir.glob("#{storage_root}/**/[a-z][a-z]*[0-9]").map {|d| d.split("/").last} | ||
@stored_druids = druids_from_storage_root | ||
respond_to do |format| | ||
format.xml { render xml: @stored_druids } | ||
format.all { render json: @stored_druids, content_type: 'application/json' } | ||
end | ||
end | ||
|
||
def show | ||
version_metadata_file = Stanford::StorageServices.version_metadata(params['id']) | ||
vm = Moab::VersionMetadata.parse(version_metadata_file.read) | ||
# FIXME: moab gem likely has a better way to get the latest version (github issue #24) | ||
@output = { current_version: vm.versions.last.version_id } | ||
respond_to do |format| | ||
format.xml { render xml: @output } | ||
format.all { render json: @output, content_type: 'application/json' } | ||
end | ||
end | ||
|
||
private | ||
|
||
def druids_from_storage_root | ||
druids ||= begin | ||
@storage_root ||= "#{Moab::Config.storage_roots}/#{Moab::Config.storage_trunk}" | ||
Dir.glob("#{@storage_root}/**/[a-z][a-z]*[0-9]").map {|d| d.split("/").last} | ||
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
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,5 +1,7 @@ | ||
Rails.application.routes.draw do | ||
get 'moab_storage/index' | ||
|
||
get 'moab_storage/show/:id', to: 'moab_storage#show' | ||
|
||
# For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html | ||
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