onoma 0.3.3 → 0.5.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/.gitlab-ci.yml +14 -0
- data/Gemfile +2 -0
- data/Rakefile +3 -6
- data/bin/rake +29 -0
- data/config/locales/arb.yml +0 -35
- data/config/locales/cmn.yml +0 -32
- data/config/locales/deu.yml +0 -15
- data/config/locales/eng.yml +51 -51
- data/config/locales/fra.yml +92 -254
- data/config/locales/ita.yml +0 -22
- data/config/locales/jpn.yml +0 -32
- data/config/locales/por.yml +0 -21
- data/config/locales/spa.yml +0 -30
- data/db/migrate/20190807125202_add_nature_to_product_natures.xml +326 -0
- data/db/migrate/20190909150402_add_staff_supply_stock_account.xml +4 -0
- data/db/migrate/20190913102036_add_caliber_indicator.xml +4 -0
- data/db/migrate/20191016152118_add_missing_document_templates.xml +6 -0
- data/db/migrate/20191113134626_add_nature_to_new_product_natures.xml +11 -0
- data/db/migrate/20191125133327_add_missing_units_and_indicators.xml +5 -0
- data/db/migrate/20200107095554_add_signed_field_to_document_nature.xml +9 -0
- data/db/migrate/20200421123503_add_type_to_categories_and_variants.xml +1136 -0
- data/db/migrate/20200514092205_add_liter_per_hectoliter_unit.xml +4 -0
- data/db/migrate/20200722091859_triticale_derivative_of.xml +5 -0
- data/db/migrate/20200826000010_add_area_units.xml +4 -0
- data/db/migrate/20200826000020_change_trailer_indicators.xml +5 -0
- data/db/migrate/20200826000030_add_new_production_systems.xml +6 -0
- data/db/migrate/20200826000040_add_viti_abilities.xml +6 -0
- data/db/migrate/20200826000060_create_vine_farming_activity_famillies.xml +4 -0
- data/db/migrate/20200826000070_remove_certifications_and_vitis_varieties.xml +55 -0
- data/db/migrate/20200826000080_add_new_indicators.xml +14 -0
- data/db/migrate/20200826000100_add_viti_procedure_actions.xml +19 -0
- data/db/migrate/20200826000110_add_vine_puning_systems.xml +9 -0
- data/db/migrate/20200826000120_add_vine_procedure_categories.xml +10 -0
- data/db/migrate/20200826000130_update_viti_product_nauture_variant.xml +10 -0
- data/db/migrate/20200925153320_fix_outgoing_payment_list_document_nature.xml +7 -0
- data/db/reference.xml +1001 -1041
- data/lib/onoma.rb +82 -24
- data/lib/onoma/item.rb +19 -3
- data/lib/onoma/migration/actions/base.rb +1 -5
- data/lib/onoma/migration/actions/item_change.rb +1 -5
- data/lib/onoma/migration/actions/item_creation.rb +2 -6
- data/lib/onoma/migration/actions/item_merging.rb +1 -5
- data/lib/onoma/migration/actions/item_removal.rb +1 -1
- data/lib/onoma/migration/actions/nomenclature_change.rb +1 -1
- data/lib/onoma/migration/actions/nomenclature_creation.rb +1 -1
- data/lib/onoma/migration/actions/nomenclature_removal.rb +1 -5
- data/lib/onoma/migration/actions/property_creation.rb +4 -4
- data/lib/onoma/migration/base.rb +38 -0
- data/lib/onoma/migrator.rb +13 -0
- data/lib/onoma/migrator/reference.rb +71 -0
- data/lib/onoma/migrator/translation.rb +76 -0
- data/lib/onoma/models/ability.rb +4 -0
- data/lib/onoma/models/account.rb +4 -0
- data/lib/onoma/models/accounting_system.rb +12 -0
- data/lib/onoma/models/activity_family.rb +4 -0
- data/lib/onoma/models/administrative_area.rb +4 -0
- data/lib/onoma/models/administrative_area_nature.rb +4 -0
- data/lib/onoma/models/analysis_nature.rb +4 -0
- data/lib/onoma/models/animal_life_state.rb +4 -0
- data/lib/onoma/models/cation_exchange_capacity_analysis_method.rb +4 -0
- data/lib/onoma/models/chemical_classification.rb +4 -0
- data/lib/onoma/models/chemical_element.rb +4 -0
- data/lib/onoma/models/country.rb +4 -0
- data/lib/onoma/models/crop_set.rb +4 -0
- data/lib/onoma/models/currency.rb +4 -0
- data/lib/onoma/models/delivery_mode.rb +4 -0
- data/lib/onoma/models/dimension.rb +4 -0
- data/lib/onoma/models/document_category.rb +4 -0
- data/lib/onoma/models/document_nature.rb +4 -0
- data/lib/onoma/models/entity_link_nature.rb +4 -0
- data/lib/onoma/models/event_nature.rb +4 -0
- data/lib/onoma/models/fence_perimeter.rb +4 -0
- data/lib/onoma/models/figure.rb +4 -0
- data/lib/onoma/models/fiscal_position.rb +4 -0
- data/lib/onoma/models/guide_nature.rb +4 -0
- data/lib/onoma/models/identifier_nature.rb +4 -0
- data/lib/onoma/models/indicator.rb +7 -0
- data/lib/onoma/models/issue_nature.rb +4 -0
- data/lib/onoma/models/language.rb +4 -0
- data/lib/onoma/models/mammalia_birth_condition.rb +4 -0
- data/lib/onoma/models/mammalia_reproduction_state.rb +4 -0
- data/lib/onoma/models/molecule.rb +4 -0
- data/lib/onoma/models/net_service.rb +4 -0
- data/lib/onoma/models/opportunity_origin.rb +4 -0
- data/lib/onoma/models/phosphorus_analysis_method.rb +4 -0
- data/lib/onoma/models/plant_life_state.rb +4 -0
- data/lib/onoma/models/plant_reproduction_state.rb +4 -0
- data/lib/onoma/models/plants_growth_level.rb +4 -0
- data/lib/onoma/models/procedure_action.rb +4 -0
- data/lib/onoma/models/procedure_category.rb +4 -0
- data/lib/onoma/models/procedure_nature.rb +4 -0
- data/lib/onoma/models/procedure_role.rb +4 -0
- data/lib/onoma/models/product_nature.rb +4 -0
- data/lib/onoma/models/product_nature_category.rb +4 -0
- data/lib/onoma/models/product_nature_variant.rb +4 -0
- data/lib/onoma/models/production_nature.rb +4 -0
- data/lib/onoma/models/production_system.rb +4 -0
- data/lib/onoma/models/production_usage.rb +4 -0
- data/lib/onoma/models/residue_elimination_method.rb +4 -0
- data/lib/onoma/models/role.rb +4 -0
- data/lib/onoma/models/running_cost.rb +4 -0
- data/lib/onoma/models/sex.rb +4 -0
- data/lib/onoma/models/soil_cultural_state.rb +4 -0
- data/lib/onoma/models/soil_nature.rb +4 -0
- data/lib/onoma/models/spatial_reference_system.rb +4 -0
- data/lib/onoma/models/tax.rb +4 -0
- data/lib/onoma/models/tax_nature.rb +4 -0
- data/lib/onoma/models/unit.rb +4 -0
- data/lib/onoma/models/variety.rb +31 -0
- data/lib/onoma/models/working_set.rb +4 -0
- data/lib/onoma/nomenclature.rb +19 -23
- data/lib/onoma/{database.rb → nomenclature_set.rb} +25 -57
- data/lib/onoma/{property.rb → property_nature.rb} +5 -8
- data/lib/onoma/record/base.rb +15 -0
- data/lib/onoma/reflection.rb +3 -3
- data/lib/onoma/version.rb +3 -1
- data/onoma.gemspec +16 -17
- metadata +110 -24
- data/lib/onoma/migration.rb +0 -122
- data/lib/onoma/migration/actions.rb +0 -9
data/lib/onoma/migration.rb
DELETED
@@ -1,122 +0,0 @@
|
|
1
|
-
require 'active_support/core_ext/string'
|
2
|
-
require 'active_support/core_ext/array'
|
3
|
-
require 'benchmark'
|
4
|
-
|
5
|
-
class ::Hash
|
6
|
-
def simple_print
|
7
|
-
map { |k, v| "#{k}: #{v.inspect}" }.join(', ')
|
8
|
-
end
|
9
|
-
end
|
10
|
-
|
11
|
-
module Onoma
|
12
|
-
# Migration instance represents a migration file
|
13
|
-
class Migration
|
14
|
-
class << self
|
15
|
-
# Parse en XML migration to a Onoma::Migration object
|
16
|
-
def parse(file)
|
17
|
-
# puts "Parse #{file}"
|
18
|
-
f = File.open(file, 'rb')
|
19
|
-
document = Nokogiri::XML(f) do |config|
|
20
|
-
config.strict.nonet.noblanks.noent
|
21
|
-
end
|
22
|
-
f.close
|
23
|
-
root = document.root
|
24
|
-
number = file.basename.to_s.split('_').first.to_i
|
25
|
-
new(number, root['name']) do |m|
|
26
|
-
root.children.each do |child|
|
27
|
-
next unless child.is_a? Nokogiri::XML::Element
|
28
|
-
m.add "Onoma::Migration::Actions::#{child.name.underscore.classify}".constantize.new(child)
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
attr_reader :number, :name
|
35
|
-
|
36
|
-
def initialize(number, name)
|
37
|
-
@number = number
|
38
|
-
@name = name
|
39
|
-
@actions = []
|
40
|
-
yield self if block_given?
|
41
|
-
end
|
42
|
-
|
43
|
-
def label
|
44
|
-
"#{number} #{name}"
|
45
|
-
end
|
46
|
-
|
47
|
-
def add(action)
|
48
|
-
@actions << action
|
49
|
-
end
|
50
|
-
|
51
|
-
def each_action(&block)
|
52
|
-
@actions.each(&block)
|
53
|
-
end
|
54
|
-
|
55
|
-
def inspect
|
56
|
-
"#<#{self.class.name}:#{format('%#x', object_id)} ##{number} #{name.inspect} (#{@actions.size} actions)>"
|
57
|
-
end
|
58
|
-
|
59
|
-
def migrate(conn)
|
60
|
-
puts ''
|
61
|
-
puts "== #{label}: migrating ".ljust(80, '=')
|
62
|
-
duration = Benchmark.measure do
|
63
|
-
each_action do |action|
|
64
|
-
puts "-- #{action.label}"
|
65
|
-
conn.exec_action(action)
|
66
|
-
end
|
67
|
-
conn.version = number
|
68
|
-
end
|
69
|
-
puts "== #{label}: migrated (#{duration.real.round(4)}s)".ljust(80, '=')
|
70
|
-
# puts "Write DB in #{Onoma.reference_path.relative_path_from(Onoma.root)}".yellow
|
71
|
-
if @steps
|
72
|
-
versions_dir = Onoma.root.join('tmp', 'versions')
|
73
|
-
FileUtils.mkdir_p(versions_dir)
|
74
|
-
conn.copy(versions_dir.join("#{number}.xml"))
|
75
|
-
end
|
76
|
-
end
|
77
|
-
end
|
78
|
-
|
79
|
-
# Migrator is a tool class to launch migrations
|
80
|
-
class Migrator
|
81
|
-
class << self
|
82
|
-
def migrate
|
83
|
-
Onoma::Migrator.new(Onoma.reference_path, Onoma.migrations_path).migrate
|
84
|
-
end
|
85
|
-
end
|
86
|
-
|
87
|
-
attr_accessor :database_path, :migrations_path
|
88
|
-
|
89
|
-
def initialize(database_path, migrations_path)
|
90
|
-
@database_path = database_path
|
91
|
-
@migrations_path = migrations_path
|
92
|
-
end
|
93
|
-
|
94
|
-
# Returns list of Onoma::Migration
|
95
|
-
def migrations
|
96
|
-
Dir.glob(@migrations_path.join('*.xml')).sort.collect do |f|
|
97
|
-
Onoma::Migration.parse(Pathname.new(f))
|
98
|
-
end
|
99
|
-
end
|
100
|
-
|
101
|
-
# Returns list of migrations since last done
|
102
|
-
def missing_migrations
|
103
|
-
last_version = connection.version
|
104
|
-
migrations.select do |m|
|
105
|
-
m.number > last_version
|
106
|
-
end
|
107
|
-
end
|
108
|
-
|
109
|
-
def migrate
|
110
|
-
missing_migrations.each do |migration|
|
111
|
-
migration.migrate(connection)
|
112
|
-
end
|
113
|
-
connection.write
|
114
|
-
end
|
115
|
-
|
116
|
-
def connection
|
117
|
-
@connection ||= Database.open(@database_path)
|
118
|
-
end
|
119
|
-
end
|
120
|
-
end
|
121
|
-
|
122
|
-
require 'onoma/migration/actions'
|
@@ -1,9 +0,0 @@
|
|
1
|
-
require 'onoma/migration/actions/base'
|
2
|
-
require 'onoma/migration/actions/item_change'
|
3
|
-
require 'onoma/migration/actions/item_creation'
|
4
|
-
require 'onoma/migration/actions/item_merging'
|
5
|
-
require 'onoma/migration/actions/item_removal'
|
6
|
-
require 'onoma/migration/actions/nomenclature_change'
|
7
|
-
require 'onoma/migration/actions/nomenclature_creation'
|
8
|
-
require 'onoma/migration/actions/nomenclature_removal'
|
9
|
-
require 'onoma/migration/actions/property_creation'
|