Commit 49c4d27
Changed files (2)
lib
saml
kit
lib/saml/kit/cli/metadata.rb
@@ -14,6 +14,11 @@ module Saml
end
end
+ desc "show entity_id", "show the metadata associated with an entityId"
+ def show(entity_id)
+ say registry.metadata_for(entity_id).to_xml(pretty: true), :green
+ end
+
private
def registry
lib/saml/kit/cli/yaml_registry.rb
@@ -7,23 +7,40 @@ module Saml
end
def register(metadata)
- @items.transaction do
- @items[metadata.entity_id] = metadata.to_xml
+ with_transaction do |db|
+ db[metadata.entity_id] = metadata.to_xml
end
metadata
end
def metadata_for(entity_id)
- Saml::Kit::Metadata.from(@items[entity_id])
+ with_transaction do |db|
+ Saml::Kit::Metadata.from(db[entity_id])
+ end
end
def each
- @items.transaction do
- @items.roots.each do |key|
+ with_transaction do |db|
+ db.roots.each do |key|
yield metadata_for(key)
end
end
end
+
+ private
+
+ def with_transaction
+ if @in_transaction
+ yield @items
+ else
+ @items.transaction do
+ @in_transaction = true
+ yield @items
+ ensure
+ @in_transaction = false
+ end
+ end
+ end
end
end
end