Sha256: 90e085ab99a781faed85af26b5409048a749a820a4590a9e87416b53840ac64d

Contents?: true

Size: 1.79 KB

Versions: 14

Compression:

Stored size: 1.79 KB

Contents

module Onoma
  module Migrator
    class Reference
      def self.run(migration)
        ref = new
        migration.each_action do |action|
          ref.send(action.action_name, action)
        end
        ref.version = migration.number
        puts "Write DB in #{Onoma.reference_path.relative_path_from(Onoma.root)}"
        ref.write
      end

      def initialize
        @set = if Onoma.reference_path.exist?
                 Onoma::NomenclatureSet.load_file(Onoma.reference_path)
               else
                 Onoma::NomenclatureSet.new
               end
      end

      def version
        @set.version
      end

      def version=(number)
        @set.version = number
      end

      def write
        File.write(Onoma.reference_path, @set.to_xml)
      end

      def nomenclature_creation(action)
        @set.add_nomenclature(action.name, action.options)
      end

      def nomenclature_change(action)
        @set.change_nomenclature(action.nomenclature, action.changes)
      end

      def nomenclature_removal(action)
        @set.remove_nomenclature(action.nomenclature)
      end

      def property_creation(action)
        @set.add_property(action.nomenclature, action.name, action.type, action.options)
      end

      def property_change(action)
        @set.change_property(action.nomenclature, action.name, action.changes)
      end

      def item_creation(action)
        @set.add_item(action.nomenclature, action.name, action.options)
      end

      def item_change(action)
        @set.change_item(action.nomenclature, action.name, action.changes)
      end

      def item_merging(action)
        @set.merge_item(action.nomenclature, action.name, action.into)
      end

      def item_removal(action)
        @set.remove_item(action.nomenclature, action.name)
      end
    end
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
onoma-0.9.3 lib/onoma/migrator/reference.rb
onoma-0.9.2 lib/onoma/migrator/reference.rb
onoma-0.9.1 lib/onoma/migrator/reference.rb
onoma-0.9.0 lib/onoma/migrator/reference.rb
onoma-0.8.9 lib/onoma/migrator/reference.rb
onoma-0.8.8 lib/onoma/migrator/reference.rb
onoma-0.8.7 lib/onoma/migrator/reference.rb
onoma-0.8.6 lib/onoma/migrator/reference.rb
onoma-0.8.5 lib/onoma/migrator/reference.rb
onoma-0.8.4 lib/onoma/migrator/reference.rb
onoma-0.8.3 lib/onoma/migrator/reference.rb
onoma-0.8.2 lib/onoma/migrator/reference.rb
onoma-0.8.1 lib/onoma/migrator/reference.rb
onoma-0.8.0 lib/onoma/migrator/reference.rb