Module: Locabulary
- Defined in:
- lib/locabulary.rb,
lib/locabulary/item.rb,
lib/locabulary/items.rb,
lib/locabulary/schema.rb,
lib/locabulary/utility.rb,
lib/locabulary/version.rb,
lib/locabulary/services.rb,
lib/locabulary/exceptions.rb,
lib/locabulary/items/base.rb,
lib/locabulary/json_creator.rb,
lib/locabulary/hierarchy_processor.rb,
lib/locabulary/facet_wrapper_for_item.rb,
lib/locabulary/items/administrative_unit.rb,
lib/locabulary/services/item_for_service.rb,
lib/locabulary/services/all_items_for_service.rb,
lib/locabulary/services/active_items_for_service.rb,
lib/locabulary/services/active_hierarchical_roots_service.rb,
lib/locabulary/services/build_ordered_hierarchical_tree_service.rb
Overview
:nodoc:
Defined Under Namespace
Modules: Exceptions, Item, Items Classes: FacetWrapperForItem, JsonCreator
Constant Summary collapse
- Schema =
Responsible for providing a defined and clear schema for each of the locabulary items.
Dry::Validation.Schema do required(:predicate_name).filled(format?: /\A[a-z_]+\Z/) required(:values).each do required(:term_label).filled(:str?) optional(:description).maybe(:str?) optional(:grouping).maybe(:str?) optional(:affiliation).maybe(:str?) optional(:default_presentation_sequence).maybe(:int?) required(:activated_on).filled(format?: /\A\d{4}-\d{2}-\d{2}\Z/) optional(:deactivated_on).maybe(format?: /\A\d{4}-\d{2}-\d{2}\Z/) end end
- VERSION =
'0.8.1'.freeze
Class Method Summary collapse
-
.active_hierarchical_roots(options = {}) ⇒ Array<Locabulary::Items::Base>
Responsible for transforming the flat data for the given :predicate_name into a hierarchy.
-
.active_items_for(options = {}) ⇒ Array<Locabulary::Items::Base>
Responsible for extracting a non-hierarchical sorted array of active Locabulary::Items::Base objects for the given predicate_name.
-
.active_label_for_uri(options = {}) ⇒ String
For the given :predicate_name and :term_uri return a best fitting human readable label.
-
.active_labels_for(options = {}) ⇒ Array<String>
Return an Array of term labels for the given :predicate_name.
-
.all_items_for(options = {}) ⇒ Array<Locabulary::Items::Base>
Responsible for extracting a non-hierarchical sorted array of Locabulary::Items::Base objects for the given predicate_name.
-
.build_ordered_hierarchical_tree(options = {}) ⇒ Array<FacetWrapperForItem>
Responsible for building a hierarchical tree from faceted items, and ordering the nodes as per the presentation sequence for the associated predicate_name.
-
.item_for(options = {}) ⇒ Locabulary::Items::Base
For the given :predicate_name and :term_label find an item.
Class Method Details
.active_hierarchical_roots(options = {}) ⇒ Array<Locabulary::Items::Base>
Responsible for transforming the flat data for the given :predicate_name into a hierarchy.
70 71 72 |
# File 'lib/locabulary.rb', line 70 def self.active_hierarchical_roots( = {}) Services.call(:active_hierarchical_roots, ) end |
.active_items_for(options = {}) ⇒ Array<Locabulary::Items::Base>
Responsible for extracting a non-hierarchical sorted array of active Locabulary::Items::Base objects for the given predicate_name.
40 41 42 |
# File 'lib/locabulary.rb', line 40 def self.active_items_for( = {}) Services.call(:active_items_for, ) end |
.active_label_for_uri(options = {}) ⇒ String
For the given :predicate_name and :term_uri return a best fitting human readable label.
105 106 107 108 109 110 |
# File 'lib/locabulary.rb', line 105 def self.active_label_for_uri( = {}) term_uri = .fetch(:term_uri) object = active_items_for().detect { |obj| obj.term_uri == term_uri } return object.term_label if object term_uri end |
.active_labels_for(options = {}) ⇒ Array<String>
Return an Array of term labels for the given :predicate_name
123 124 125 |
# File 'lib/locabulary.rb', line 123 def self.active_labels_for( = {}) active_items_for().map(&:term_label) end |
.all_items_for(options = {}) ⇒ Array<Locabulary::Items::Base>
Responsible for extracting a non-hierarchical sorted array of Locabulary::Items::Base objects for the given predicate_name.
54 55 56 |
# File 'lib/locabulary.rb', line 54 def self.all_items_for( = {}) Services.call(:all_items_for, ) end |
.build_ordered_hierarchical_tree(options = {}) ⇒ Array<FacetWrapperForItem>
Responsible for building a hierarchical tree from faceted items, and ordering the nodes as per the presentation sequence for the associated predicate_name.
25 26 27 |
# File 'lib/locabulary.rb', line 25 def self.build_ordered_hierarchical_tree( = {}) Services.call(:build_ordered_hierarchical_tree, ) end |
.item_for(options = {}) ⇒ Locabulary::Items::Base
For the given :predicate_name and :term_label find an item. We prefer to find an active item, but will settle for a non-active item.
88 89 90 |
# File 'lib/locabulary.rb', line 88 def self.item_for( = {}) Services.call(:item_for, ) end |