module Onoma
rubocop:disable Style/MissingRespondToMissing
Constants
- NS_SEPARATOR
- PROPERTY_TYPES
- VERSION
- XMLNS
Public Class Methods
[](index)
click to toggle source
Give access to named nomenclatures delegate :[], to: :set
# File lib/onoma.rb, line 106 def [](index) set[index] end
all()
click to toggle source
# File lib/onoma.rb, line 100 def all set.nomenclatures end
database_path()
click to toggle source
# File lib/onoma.rb, line 50 def database_path root.join('db') end
each(&block)
click to toggle source
Browse all nomenclatures
# File lib/onoma.rb, line 134 def each(&block) set.each(&block) end
escape_key(key)
click to toggle source
# File lib/onoma.rb, line 42 def escape_key(key) key.to_s.gsub('.', '-').to_sym end
find(*args)
click to toggle source
Give access to named nomenclatures
# File lib/onoma.rb, line 111 def find(*args) args.extract_options! name = args.shift nomenclature = find_or_initialize(name) if args.empty? return nomenclature elsif args.size == 1 return nomenclature.find(args.shift) if nomenclature end nil end
find_or_initialize(name)
click to toggle source
# File lib/onoma.rb, line 124 def find_or_initialize(name) set[name] || set.load_data_from_xml(name) end
load!()
click to toggle source
Force loading of nomenclatures
# File lib/onoma.rb, line 129 def load! @@set = NomenclatureSet.load_file(reference_path) end
load_locales()
click to toggle source
# File lib/onoma.rb, line 142 def load_locales I18n.load_path.concat(Dir.glob(Onoma.root.join('config', 'locales', '*.yml'))) end
migrations()
click to toggle source
Returns list of Onoma::Migration
# File lib/onoma.rb, line 81 def migrations Dir.glob(migrations_path.join('*.xml')).sort.collect do |f| Onoma::Migration::Base.parse(Pathname.new(f)) end end
migrations_path()
click to toggle source
# File lib/onoma.rb, line 54 def migrations_path database_path.join('migrate') end
missing_migrations()
click to toggle source
Returns list of migrations since last done
# File lib/onoma.rb, line 88 def missing_migrations last_version = reference_version migrations.select do |m| m.number > last_version end end
names()
click to toggle source
Returns the names of the nomenclatures
# File lib/onoma.rb, line 96 def names set.nomenclature_names end
reference_document()
click to toggle source
# File lib/onoma.rb, line 69 def reference_document unless @document f = File.open(reference_path, 'rb') @document = Nokogiri::XML(f) do |config| config.strict.nonet.noblanks.noent end f.close end @document end
reference_path()
click to toggle source
# File lib/onoma.rb, line 58 def reference_path database_path.join('reference.xml') end
reference_version()
click to toggle source
Returns version of DB
# File lib/onoma.rb, line 63 def reference_version return 0 unless reference_path.exist? reference_document.root['version'].to_i end
root()
click to toggle source
# File lib/onoma.rb, line 46 def root Pathname.new(__FILE__).dirname.dirname end
set()
click to toggle source
# File lib/onoma.rb, line 138 def set @@set ||= NomenclatureSet.new end