onoma 0.3.1 → 0.4.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (121) hide show
  1. checksums.yaml +5 -5
  2. data/.gitignore +3 -0
  3. data/.gitlab-ci.yml +14 -0
  4. data/Gemfile +2 -0
  5. data/Rakefile +3 -6
  6. data/bin/rake +29 -0
  7. data/config/locales/eng.yml +134 -46
  8. data/config/locales/fra.yml +233 -195
  9. data/db/migrate/20170904223101_add_cultivable_zone_registry.xml +4 -0
  10. data/db/migrate/20190718130243_remove_services_expenses.xml +5 -0
  11. data/db/migrate/20190801142431_remove_accounts_from_pcg82.xml +5 -0
  12. data/db/migrate/20190807125202_add_nature_to_product_natures.xml +326 -0
  13. data/db/migrate/20190823091727_fix-cubic-meter-per-hectare-symbol.xml +5 -0
  14. data/db/migrate/20190909150402_add_staff_supply_stock_account.xml +4 -0
  15. data/db/migrate/20190913102036_add_caliber_indicator.xml +4 -0
  16. data/db/migrate/20190917161215_add_missing_mass_area_density_units.xml +21 -0
  17. data/db/migrate/20190917161216_update_quintal_symbol.xml +4 -0
  18. data/db/migrate/20190917161217_adds_more_info_to_units.xml +133 -0
  19. data/db/migrate/20190918074757_add_new_accounts.xml +8 -0
  20. data/db/migrate/20191001122750_add_accounts_fixed_assets_related.xml +10 -0
  21. data/db/migrate/20191016152118_add_missing_document_templates.xml +6 -0
  22. data/db/migrate/20191028175001_add_short_balance_sheet.xml +4 -0
  23. data/db/migrate/20191029131921_add_vine_equipments.xml +117 -0
  24. data/db/migrate/20191112132413_remove_roller_from_product_natures.xml +5 -0
  25. data/db/migrate/20191113134626_add_nature_to_new_product_natures.xml +11 -0
  26. data/db/migrate/20191125133327_add_missing_units_and_indicators.xml +5 -0
  27. data/db/migrate/20200107095554_add_signed_field_to_document_nature.xml +9 -0
  28. data/db/migrate/20200305160358_add_varieties_for_phytosanitary.xml +11 -0
  29. data/db/migrate/20200421123503_add_type_to_categories_and_variants.xml +1136 -0
  30. data/db/migrate/20200514092205_add_liter_per_hectoliter_unit.xml +4 -0
  31. data/db/migrate/20200722091859_triticale_derivative_of.xml +5 -0
  32. data/db/migrate/20200925153320_fix_outgoing_payment_list_document_nature.xml +7 -0
  33. data/db/reference.xml +1434 -1265
  34. data/lib/onoma.rb +82 -24
  35. data/lib/onoma/item.rb +19 -3
  36. data/lib/onoma/migration/actions/base.rb +1 -5
  37. data/lib/onoma/migration/actions/item_change.rb +1 -5
  38. data/lib/onoma/migration/actions/item_creation.rb +2 -6
  39. data/lib/onoma/migration/actions/item_merging.rb +1 -5
  40. data/lib/onoma/migration/actions/item_removal.rb +1 -1
  41. data/lib/onoma/migration/actions/nomenclature_change.rb +1 -1
  42. data/lib/onoma/migration/actions/nomenclature_creation.rb +1 -1
  43. data/lib/onoma/migration/actions/nomenclature_removal.rb +1 -5
  44. data/lib/onoma/migration/actions/property_creation.rb +4 -4
  45. data/lib/onoma/migration/base.rb +38 -0
  46. data/lib/onoma/migrator.rb +13 -0
  47. data/lib/onoma/migrator/reference.rb +71 -0
  48. data/lib/onoma/migrator/translation.rb +76 -0
  49. data/lib/onoma/models/ability.rb +4 -0
  50. data/lib/onoma/models/account.rb +4 -0
  51. data/lib/onoma/models/accounting_system.rb +12 -0
  52. data/lib/onoma/models/activity_family.rb +4 -0
  53. data/lib/onoma/models/administrative_area.rb +4 -0
  54. data/lib/onoma/models/administrative_area_nature.rb +4 -0
  55. data/lib/onoma/models/analysis_nature.rb +4 -0
  56. data/lib/onoma/models/animal_life_state.rb +4 -0
  57. data/lib/onoma/models/cation_exchange_capacity_analysis_method.rb +4 -0
  58. data/lib/onoma/models/certification.rb +4 -0
  59. data/lib/onoma/models/certification_label.rb +4 -0
  60. data/lib/onoma/models/chemical_classification.rb +4 -0
  61. data/lib/onoma/models/chemical_element.rb +4 -0
  62. data/lib/onoma/models/country.rb +4 -0
  63. data/lib/onoma/models/crop_set.rb +4 -0
  64. data/lib/onoma/models/currency.rb +4 -0
  65. data/lib/onoma/models/delivery_mode.rb +4 -0
  66. data/lib/onoma/models/dimension.rb +4 -0
  67. data/lib/onoma/models/document_category.rb +4 -0
  68. data/lib/onoma/models/document_nature.rb +4 -0
  69. data/lib/onoma/models/entity_link_nature.rb +4 -0
  70. data/lib/onoma/models/event_nature.rb +4 -0
  71. data/lib/onoma/models/fence_perimeter.rb +4 -0
  72. data/lib/onoma/models/figure.rb +4 -0
  73. data/lib/onoma/models/fiscal_position.rb +4 -0
  74. data/lib/onoma/models/guide_nature.rb +4 -0
  75. data/lib/onoma/models/identifier_nature.rb +4 -0
  76. data/lib/onoma/models/indicator.rb +7 -0
  77. data/lib/onoma/models/issue_nature.rb +4 -0
  78. data/lib/onoma/models/land.rb +4 -0
  79. data/lib/onoma/models/language.rb +4 -0
  80. data/lib/onoma/models/mammalia_birth_condition.rb +4 -0
  81. data/lib/onoma/models/mammalia_reproduction_state.rb +4 -0
  82. data/lib/onoma/models/molecule.rb +4 -0
  83. data/lib/onoma/models/net_service.rb +4 -0
  84. data/lib/onoma/models/opportunity_origin.rb +4 -0
  85. data/lib/onoma/models/phosphorus_analysis_method.rb +4 -0
  86. data/lib/onoma/models/plant_life_state.rb +4 -0
  87. data/lib/onoma/models/plant_reproduction_state.rb +4 -0
  88. data/lib/onoma/models/plants_growth_level.rb +4 -0
  89. data/lib/onoma/models/procedure_action.rb +4 -0
  90. data/lib/onoma/models/procedure_category.rb +4 -0
  91. data/lib/onoma/models/procedure_nature.rb +4 -0
  92. data/lib/onoma/models/procedure_role.rb +4 -0
  93. data/lib/onoma/models/product_nature.rb +4 -0
  94. data/lib/onoma/models/product_nature_category.rb +4 -0
  95. data/lib/onoma/models/product_nature_variant.rb +4 -0
  96. data/lib/onoma/models/production_nature.rb +4 -0
  97. data/lib/onoma/models/production_system.rb +4 -0
  98. data/lib/onoma/models/production_usage.rb +4 -0
  99. data/lib/onoma/models/residue_elimination_method.rb +4 -0
  100. data/lib/onoma/models/role.rb +4 -0
  101. data/lib/onoma/models/running_cost.rb +4 -0
  102. data/lib/onoma/models/sex.rb +4 -0
  103. data/lib/onoma/models/soil_cultural_state.rb +4 -0
  104. data/lib/onoma/models/soil_nature.rb +4 -0
  105. data/lib/onoma/models/spatial_reference_system.rb +4 -0
  106. data/lib/onoma/models/tax.rb +4 -0
  107. data/lib/onoma/models/tax_nature.rb +4 -0
  108. data/lib/onoma/models/unit.rb +4 -0
  109. data/lib/onoma/models/variety.rb +31 -0
  110. data/lib/onoma/models/working_set.rb +4 -0
  111. data/lib/onoma/nomenclature.rb +19 -23
  112. data/lib/onoma/{database.rb → nomenclature_set.rb} +25 -57
  113. data/lib/onoma/{property.rb → property_nature.rb} +5 -8
  114. data/lib/onoma/record/base.rb +15 -0
  115. data/lib/onoma/reflection.rb +3 -3
  116. data/lib/onoma/version.rb +3 -1
  117. data/onoma.gemspec +16 -17
  118. metadata +119 -30
  119. data/db/db.xml +0 -0
  120. data/lib/onoma/migration.rb +0 -122
  121. data/lib/onoma/migration/actions.rb +0 -9
@@ -0,0 +1,31 @@
1
+ module Onoma
2
+ class Variety < Onoma::Record::Base
3
+ TOPLEVEL_VARIETIES = %w[bioproduct immatter matter product product_group].freeze
4
+
5
+ class << self
6
+ def parent_variety(variety)
7
+ v = find(variety)
8
+
9
+ if v.nil?
10
+ nil
11
+ elsif (toplevel = toplevel_parent(v)).present?
12
+ toplevel.name
13
+ else
14
+ v.name
15
+ end
16
+ end
17
+
18
+ def toplevel_parent(variety)
19
+ ancestors(variety).last
20
+ end
21
+
22
+ def ancestors(variety)
23
+ if variety.parent.nil? || TOPLEVEL_VARIETIES.include?(variety.parent.name)
24
+ []
25
+ else
26
+ [variety.parent, *ancestors(variety.parent)]
27
+ end
28
+ end
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,4 @@
1
+ module Onoma
2
+ class WorkingSet < Onoma::Record::Base
3
+ end
4
+ end
@@ -1,6 +1,3 @@
1
- require 'bigdecimal'
2
- require 'bigdecimal/util'
3
-
4
1
  module Onoma
5
2
  # This class represents a nomenclature
6
3
  class Nomenclature
@@ -12,10 +9,10 @@ module Onoma
12
9
  def initialize(name, options = {})
13
10
  @name = name.to_sym
14
11
  @set = options.delete(:set)
15
- @items = ActiveSupport::HashWithIndifferentAccess.new
12
+ @items = HashWithIndifferentAccess.new
16
13
  @forest_right = 0
17
14
  @roots = []
18
- @properties = ActiveSupport::HashWithIndifferentAccess.new
15
+ @properties = {}.with_indifferent_access
19
16
  @translateable = !options[:translateable].is_a?(FalseClass)
20
17
  @notions = options[:notions] || []
21
18
  end
@@ -116,7 +113,7 @@ module Onoma
116
113
  if element.has_attribute?('default')
117
114
  options[:default] = element.attr('default').to_sym
118
115
  end
119
- options[:required] = !!(element.attr('required').to_s != 'true')
116
+ options[:required] = element.attr('required').to_s == 'true'
120
117
  # options[:inherit] = !!(element.attr('inherit').to_s == 'true')
121
118
  if type == :list
122
119
  type = element.has_attribute?('nomenclature') ? :item_list : :choice_list
@@ -138,7 +135,7 @@ module Onoma
138
135
  raise MissingChoices, "[#{@name}] Property #{name} must have nomenclature as choices"
139
136
  end
140
137
  end
141
- unless Property::TYPES.include?(type)
138
+ unless Onoma::PROPERTY_TYPES.include?(type)
142
139
  raise ArgumentError, "Property #{name} type is unknown: #{type.inspect}"
143
140
  end
144
141
  add_property(name, type, options)
@@ -231,7 +228,7 @@ module Onoma
231
228
 
232
229
  # Add an property to the nomenclature
233
230
  def add_property(name, type, options = {})
234
- p = Property.new(self, name, type, options)
231
+ p = PropertyNature.new(self, name, type, options)
235
232
  if @properties[p.name]
236
233
  raise "Property #{p.name} is already defined in nomenclature #{@name}"
237
234
  end
@@ -248,11 +245,11 @@ module Onoma
248
245
  # Check properties
249
246
  @properties.values.each do |property|
250
247
  if property.choices_nomenclature && !property.inline_choices? && !Onoma[property.choices_nomenclature.to_s]
251
- raise InvalidProperty, "[#{name}] #{property.name} nomenclature property must refer to an existing nomenclature. Got #{property.choices_nomenclature.inspect}. Expecting: #{Onoma.names.inspect}"
248
+ raise InvalidPropertyNature, "[#{name}] #{property.name} nomenclature property must refer to an existing nomenclature. Got #{property.choices_nomenclature.inspect}. Expecting: #{Onoma.names.inspect}"
252
249
  end
253
250
  next unless property.type == :choice && property.default
254
251
  unless property.choices.include?(property.default)
255
- raise InvalidProperty, "The default choice #{property.default.inspect} is invalid (in #{name}##{property.name}). Pick one from #{property.choices.sort.inspect}."
252
+ raise InvalidPropertyNature, "The default choice #{property.default.inspect} is invalid (in #{name}##{property.name}). Pick one from #{property.choices.sort.inspect}."
256
253
  end
257
254
  end
258
255
 
@@ -283,7 +280,7 @@ module Onoma
283
280
  end
284
281
 
285
282
  def inspect
286
- "Nomen::#{name.to_s.classify}"
283
+ "Onoma::#{name.to_s.classify}"
287
284
  end
288
285
 
289
286
  def table_name
@@ -301,8 +298,7 @@ module Onoma
301
298
 
302
299
  # Return human name
303
300
  def human_name(options = {})
304
- I18n.translate("nomenclatures.#{name}.name",
305
- options.merge(default: ["labels.#{name}".to_sym, name.to_s.humanize]))
301
+ I18n.t("nomenclatures.#{Onoma.escape_key(name)}.name", options.merge(default: ["labels.#{Onoma.escape_key(name)}".to_sym, name.to_s.humanize]))
306
302
  end
307
303
  alias humanize human_name
308
304
 
@@ -370,7 +366,7 @@ module Onoma
370
366
 
371
367
  # Returns a list for select, without specified items
372
368
  def select_without(already_imported)
373
- ActiveSupport::Deprecation.warn 'Nomen::Nomenclature#select_without method is deprecated. Please use Nomen::Nomenclature#without method instead.'
369
+ ActiveSupport::Deprecation.warn 'Onoma::Nomenclature#select_without method is deprecated. Please use Onoma::Nomenclature#without method instead.'
374
370
  select_options = @items.values.collect do |item|
375
371
  [item.human_name, item.name.to_s] unless already_imported[item.name.to_s]
376
372
  end
@@ -401,7 +397,7 @@ module Onoma
401
397
  end
402
398
  alias item find
403
399
 
404
- # Return the Item for the given name. Raises Nomen::ItemNotFound if no item
400
+ # Return the Item for the given name. Raises Onoma::ItemNotFound if no item
405
401
  # found in nomenclature
406
402
  def find!(item_name)
407
403
  i = find(item_name)
@@ -412,7 +408,7 @@ module Onoma
412
408
  # Returns +true+ if an item exists in the nomenclature that matches the
413
409
  # name, or +false+ otherwise. The argument can take two forms:
414
410
  # * String/Symbol - Find an item with this primary name
415
- # * Nomen::Item - Find an item with the same name of the item
411
+ # * Onoma::Item - Find an item with the same name of the item
416
412
  def exists?(item)
417
413
  @items[item.respond_to?(:name) ? item.name : item].present?
418
414
  end
@@ -433,8 +429,8 @@ module Onoma
433
429
  end
434
430
 
435
431
  # List items with properties filtering
436
- def where(properties)
437
- list.select do |item|
432
+ def where(properties, collection = list)
433
+ collection.select do |item|
438
434
  valid = true
439
435
  properties.each do |name, value|
440
436
  item_value = item.property(name)
@@ -461,7 +457,7 @@ module Onoma
461
457
  def without(*names)
462
458
  excluded = names.flatten.compact.map(&:to_sym)
463
459
  list.reject do |item|
464
- excluded.include?(item.name)
460
+ excluded.include?(item.name.to_sym)
465
461
  end
466
462
  end
467
463
 
@@ -505,7 +501,7 @@ module Onoma
505
501
  if property = properties[name]
506
502
  if property.type == :choice || property.type == :item
507
503
  if value =~ /\,/
508
- raise InvalidProperty, 'A property nature of choice type cannot contain commas'
504
+ raise InvalidPropertyNature, 'A property nature of choice type cannot contain commas'
509
505
  end
510
506
  value = value.strip.to_sym
511
507
  elsif property.list?
@@ -513,14 +509,14 @@ module Onoma
513
509
  elsif property.type == :boolean
514
510
  value = (value == 'true' ? true : value == 'false' ? false : nil)
515
511
  elsif property.type == :decimal
516
- value = value.to_d
512
+ value = BigDecimal(value)
517
513
  elsif property.type == :integer
518
514
  value = value.to_i
519
515
  elsif property.type == :date
520
- value = (value.blank? ? nil : value.to_date)
516
+ value = (value.blank? ? nil : Date.parse(value))
521
517
  elsif property.type == :symbol
522
518
  unless value =~ /\A\w+\z/
523
- raise InvalidProperty, "A property '#{name}' must contains a symbol. /[a-z0-9_]/ accepted. No spaces. Got #{value.inspect}"
519
+ raise InvalidPropertyNature, "A property '#{name}' must contains a symbol. /[a-z0-9_]/ accepted. No spaces. Got #{value.inspect}"
524
520
  end
525
521
  value = value.to_sym
526
522
  end
@@ -1,27 +1,34 @@
1
1
  module Onoma
2
2
  # This class represents a set of nomenclature like the reference DB
3
- class Database
3
+ class NomenclatureSet
4
4
  attr_accessor :version
5
- attr_reader :path
6
5
 
7
- def initialize(path)
8
- @path = Pathname.new(path)
9
- @nomenclatures = ActiveSupport::HashWithIndifferentAccess.new
6
+ def initialize
7
+ @nomenclatures = {}.with_indifferent_access
10
8
  @version = 0
11
9
  end
12
10
 
13
- def self.open(path)
14
- db = new(path)
15
- db.send(:parse_file, path) if path.exist?
16
- db
17
- end
18
-
19
- def write
20
- File.write(@path, to_xml)
11
+ def load_data_from_xml(nomenclature_name)
12
+ Rails.logger.info "Loading #{nomenclature_name}..."
13
+ start = Time.now
14
+ element = Onoma.reference_document.xpath("/xmlns:nomenclatures/xmlns:nomenclature[@name='#{nomenclature_name}']")
15
+ nomenclature = harvest_nomenclature(element)
16
+ Rails.logger.info "Loaded #{nomenclature_name} in #{(Time.now - start).round(2)} seconds..."
17
+ nomenclature
21
18
  end
22
19
 
23
- def copy(path)
24
- File.write(path, to_xml)
20
+ def self.load_file(file)
21
+ set = new
22
+ f = File.open(file, 'rb')
23
+ document = Nokogiri::XML(f) do |config|
24
+ config.strict.nonet.noblanks.noent
25
+ end
26
+ f.close
27
+ document.root.children.each do |nomenclature|
28
+ set.harvest_nomenclature(nomenclature)
29
+ end
30
+ set.version = document.root['version'].to_i
31
+ set
25
32
  end
26
33
 
27
34
  def nomenclature_names
@@ -105,29 +112,9 @@ module Onoma
105
112
  builder.to_xml
106
113
  end
107
114
 
108
- def exec_action(action)
109
- case action.action_name.to_sym
110
- when :nomenclature_creation
111
- add_nomenclature(action.name, action.options)
112
- when :nomenclature_change
113
- change_nomenclature(action.nomenclature, action.changes)
114
- when :nomenclature_removal
115
- remove_nomenclature(action.nomenclature)
116
- when :property_creation
117
- add_property(action.nomenclature, action.name, action.type, action.options)
118
- when :property_change
119
- add_property(action.nomenclature, action.name, action.changes)
120
- when :item_creation
121
- add_item(action.nomenclature, action.name, action.options)
122
- when :item_change
123
- change_item(action.nomenclature, action.name, action.changes)
124
- when :item_merging
125
- merge_item(action.nomenclature, action.name, action.into)
126
- when :item_removal
127
- remove_item(action.nomenclature, action.name)
128
- else
129
- raise "Unknown action: #{action.action_name}"
130
- end
115
+ def harvest_nomenclature(element)
116
+ nomenclature = Nomenclature.harvest(element, set: self)
117
+ @nomenclatures[nomenclature.name] = nomenclature
131
118
  end
132
119
 
133
120
  def add_nomenclature(name, options = {})
@@ -193,24 +180,5 @@ module Onoma
193
180
  nomenclature = find!(nomenclature_name)
194
181
  nomenclature.remove_item(item_name)
195
182
  end
196
-
197
- protected
198
-
199
- def harvest_nomenclature(element)
200
- nomenclature = Nomenclature.harvest(element, set: self)
201
- @nomenclatures[nomenclature.name] = nomenclature
202
- end
203
-
204
- def parse_file(file)
205
- f = File.open(file, 'rb')
206
- document = Nokogiri::XML(f) do |config|
207
- config.strict.nonet.noblanks.noent
208
- end
209
- f.close
210
- document.root.children.each do |nomenclature|
211
- harvest_nomenclature(nomenclature)
212
- end
213
- self.version = document.root.attr('version').to_i
214
- end
215
183
  end
216
184
  end
@@ -1,8 +1,5 @@
1
1
  module Onoma
2
- class Property
3
- TYPES = %i[boolean item item_list choice choice_list string_list
4
- date decimal integer nomenclature string symbol].freeze
5
-
2
+ class PropertyNature
6
3
  attr_reader :nomenclature, :name, :type, :fallbacks, :default, :source
7
4
 
8
5
  # New item
@@ -10,14 +7,14 @@ module Onoma
10
7
  @nomenclature = nomenclature
11
8
  @name = name.to_sym
12
9
  @type = type
13
- raise "Invalid type: #{@type.inspect}" unless TYPES.include?(@type)
10
+ raise "Invalid type: #{@type.inspect}" unless Onoma::PROPERTY_TYPES.include?(@type)
14
11
  @fallbacks = options[:fallbacks] if options[:fallbacks]
15
12
  @default = options[:default] if options[:default]
16
13
  @required = !!options[:required]
17
14
  @source = options[:choices] if reference? && options[:choices]
18
15
  end
19
16
 
20
- TYPES.each do |type|
17
+ Onoma::PROPERTY_TYPES.each do |type|
21
18
  define_method "#{type}?" do
22
19
  @type == type
23
20
  end
@@ -77,7 +74,7 @@ module Onoma
77
74
  def selection
78
75
  if inline_choices?
79
76
  choices.collect do |c|
80
- [c, c]
77
+ ["nomenclatures.#{@nomenclature.name}.choices.#{name}.#{c}".t, c]
81
78
  end
82
79
  elsif item_reference?
83
80
  @nomenclature.sibling(@source).selection
@@ -86,7 +83,7 @@ module Onoma
86
83
 
87
84
  # Return human name of property
88
85
  def human_name
89
- "nomenclatures.#{nomenclature.name}.properties.#{name}".t(default: ["nomenclatures.#{nomenclature.name}.properties.#{name}".to_sym, "properties.#{name}".to_sym, "enumerize.#{nomenclature.name}.#{name}".to_sym, "labels.#{name}".to_sym, name.humanize])
86
+ I18n.t("nomenclatures.#{nomenclature.name}.property_natures.#{name}", default: ["nomenclatures.#{nomenclature.name}.properties.#{name}".to_sym, "properties.#{name}".to_sym, "enumerize.#{nomenclature.name}.#{name}".to_sym, "labels.#{name}".to_sym, name.humanize])
90
87
  end
91
88
 
92
89
  alias humanize human_name
@@ -0,0 +1,15 @@
1
+ module Onoma
2
+ module Record
3
+ class Base
4
+ class << self
5
+ def method_missing(*args, &block)
6
+ Onoma.find_or_initialize(name.tableize.sub(/\Aonoma\//, '')).send(*args, &block)
7
+ end
8
+
9
+ def respond_to?(method_name)
10
+ Onoma.find_or_initialize(name.tableize.sub(/\Aonoma\//, '')).respond_to?(method_name) || super
11
+ end
12
+ end
13
+ end
14
+ end
15
+ end
@@ -4,7 +4,7 @@ module Onoma
4
4
 
5
5
  # name: things
6
6
  # class_name: Thing
7
- # klass: Nomen::Thing
7
+ # klass: Onoma::Thing
8
8
  def initialize(active_record, name, options = {})
9
9
  @options = options
10
10
  @name = name.to_s
@@ -12,8 +12,8 @@ module Onoma
12
12
  @class_name = options[:class_name] || name.to_s.classify
13
13
  @foreign_key = (options[:foreign_key] || name).to_s
14
14
  @scope = options[:scope]
15
- @nomenclature = class_name.underscore.pluralize
16
- @klass = Onoma.find(@nomenclature)
15
+ @nomenclature = class_name.tableize
16
+ @klass = "Onoma::#{@class_name}".constantize
17
17
  end
18
18
 
19
19
  alias model active_record
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Onoma
2
- VERSION = '0.3.1'.freeze
4
+ VERSION = '0.4.2'
3
5
  end
@@ -1,29 +1,28 @@
1
-
2
- lib = File.expand_path('../lib', __FILE__)
3
- $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
- require 'onoma/version'
1
+ require_relative 'lib/onoma/version'
5
2
 
6
3
  Gem::Specification.new do |spec|
7
- spec.name = 'onoma'
8
- spec.version = Onoma::VERSION
9
- spec.authors = ['Brice TEXIER']
10
- spec.email = ['brice@ekylibre.com']
4
+ spec.name = 'onoma'
5
+ spec.version = Onoma::VERSION
6
+ spec.required_ruby_version = '>= 2.4.4'
7
+ spec.authors = ['Brice TEXIER']
8
+ spec.email = ['brice@ekylibre.com']
11
9
 
12
- spec.summary = 'Provides open nomenclature data in a gem'
13
- spec.description = 'Actual support Open-Nomenclature data and gem for use'
14
- spec.homepage = 'https://github.com/ekylibre/onoma'
15
- spec.license = 'MIT'
10
+ spec.summary = 'Provides open nomenclature data in a gem'
11
+ spec.description = 'Actual support Open-Nomenclature data and gem for use'
12
+ spec.homepage = 'https://gitlab.com/ekylibre/onoma'
13
+ spec.license = 'MIT'
16
14
 
17
- spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
18
- spec.bindir = 'exe'
19
- spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
15
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
16
+ spec.bindir = 'exe'
17
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
20
18
  spec.require_paths = ['lib']
21
19
 
22
20
  spec.add_development_dependency 'bundler', '> 1.15'
23
- spec.add_development_dependency 'colored'
24
21
  spec.add_development_dependency 'rake', '> 12.0'
25
22
  spec.add_development_dependency 'minitest'
26
23
  spec.add_development_dependency 'i18n-tasks'
27
- spec.add_dependency 'activesupport'
24
+
25
+ spec.add_dependency 'activesupport', '>= 4.2'
26
+ spec.add_dependency 'zeitwerk', '~> 2.4.0'
28
27
  spec.add_dependency 'nokogiri', '>= 1.10.4'
29
28
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: onoma
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.4.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brice TEXIER
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-09-05 00:00:00.000000000 Z
11
+ date: 2020-12-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -24,20 +24,6 @@ dependencies:
24
24
  - - ">"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '1.15'
27
- - !ruby/object:Gem::Dependency
28
- name: colored
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - ">="
32
- - !ruby/object:Gem::Version
33
- version: '0'
34
- type: :development
35
- prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - ">="
39
- - !ruby/object:Gem::Version
40
- version: '0'
41
27
  - !ruby/object:Gem::Dependency
42
28
  name: rake
43
29
  requirement: !ruby/object:Gem::Requirement
@@ -86,14 +72,28 @@ dependencies:
86
72
  requirements:
87
73
  - - ">="
88
74
  - !ruby/object:Gem::Version
89
- version: '0'
75
+ version: '4.2'
90
76
  type: :runtime
91
77
  prerelease: false
92
78
  version_requirements: !ruby/object:Gem::Requirement
93
79
  requirements:
94
80
  - - ">="
95
81
  - !ruby/object:Gem::Version
96
- version: '0'
82
+ version: '4.2'
83
+ - !ruby/object:Gem::Dependency
84
+ name: zeitwerk
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: 2.4.0
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: 2.4.0
97
97
  - !ruby/object:Gem::Dependency
98
98
  name: nokogiri
99
99
  requirement: !ruby/object:Gem::Requirement
@@ -116,6 +116,7 @@ extensions: []
116
116
  extra_rdoc_files: []
117
117
  files:
118
118
  - ".gitignore"
119
+ - ".gitlab-ci.yml"
119
120
  - ".travis.yml"
120
121
  - CODE_OF_CONDUCT.md
121
122
  - Gemfile
@@ -123,6 +124,7 @@ files:
123
124
  - README.md
124
125
  - Rakefile
125
126
  - bin/console
127
+ - bin/rake
126
128
  - bin/setup
127
129
  - config/locales/arb.yml
128
130
  - config/locales/cmn.yml
@@ -133,7 +135,6 @@ files:
133
135
  - config/locales/jpn.yml
134
136
  - config/locales/por.yml
135
137
  - config/locales/spa.yml
136
- - db/db.xml
137
138
  - db/migrate/20150813022423_add_data.xml
138
139
  - db/migrate/20150813224145_fix_zea.xml
139
140
  - db/migrate/20150813224155_fix_hordeum.xml
@@ -319,6 +320,7 @@ files:
319
320
  - db/migrate/20170627081533_add_pending_deposit_payments_account_number_for_pt_accounting_system.xml
320
321
  - db/migrate/20170718131724_add_issue_natures.xml
321
322
  - db/migrate/20170803164344_add_procedure_nature_and_category.xml
323
+ - db/migrate/20170904223101_add_cultivable_zone_registry.xml
322
324
  - db/migrate/20170914083358_add_new_product_nature_variants.xml
323
325
  - db/migrate/20170927144852_add_kiwi_varieties.xml
324
326
  - db/migrate/20171106085357_update_account_numbers.xml
@@ -349,12 +351,32 @@ files:
349
351
  - db/migrate/20190611101014_change_deductible_vat_account.xml
350
352
  - db/migrate/20190620092151_fix_conflicts_in_new_accounts.xml
351
353
  - db/migrate/20190625152636_change_mixture_seed_product_nature_variant.xml
354
+ - db/migrate/20190718130243_remove_services_expenses.xml
355
+ - db/migrate/20190801142431_remove_accounts_from_pcg82.xml
356
+ - db/migrate/20190807125202_add_nature_to_product_natures.xml
357
+ - db/migrate/20190823091727_fix-cubic-meter-per-hectare-symbol.xml
358
+ - db/migrate/20190909150402_add_staff_supply_stock_account.xml
359
+ - db/migrate/20190913102036_add_caliber_indicator.xml
360
+ - db/migrate/20190917161215_add_missing_mass_area_density_units.xml
361
+ - db/migrate/20190917161216_update_quintal_symbol.xml
362
+ - db/migrate/20190917161217_adds_more_info_to_units.xml
363
+ - db/migrate/20190918074757_add_new_accounts.xml
364
+ - db/migrate/20191001122750_add_accounts_fixed_assets_related.xml
365
+ - db/migrate/20191016152118_add_missing_document_templates.xml
366
+ - db/migrate/20191028175001_add_short_balance_sheet.xml
367
+ - db/migrate/20191029131921_add_vine_equipments.xml
368
+ - db/migrate/20191112132413_remove_roller_from_product_natures.xml
369
+ - db/migrate/20191113134626_add_nature_to_new_product_natures.xml
370
+ - db/migrate/20191125133327_add_missing_units_and_indicators.xml
371
+ - db/migrate/20200107095554_add_signed_field_to_document_nature.xml
372
+ - db/migrate/20200305160358_add_varieties_for_phytosanitary.xml
373
+ - db/migrate/20200421123503_add_type_to_categories_and_variants.xml
374
+ - db/migrate/20200514092205_add_liter_per_hectoliter_unit.xml
375
+ - db/migrate/20200722091859_triticale_derivative_of.xml
376
+ - db/migrate/20200925153320_fix_outgoing_payment_list_document_nature.xml
352
377
  - db/reference.xml
353
378
  - lib/onoma.rb
354
- - lib/onoma/database.rb
355
379
  - lib/onoma/item.rb
356
- - lib/onoma/migration.rb
357
- - lib/onoma/migration/actions.rb
358
380
  - lib/onoma/migration/actions/base.rb
359
381
  - lib/onoma/migration/actions/item_change.rb
360
382
  - lib/onoma/migration/actions/item_creation.rb
@@ -364,18 +386,86 @@ files:
364
386
  - lib/onoma/migration/actions/nomenclature_creation.rb
365
387
  - lib/onoma/migration/actions/nomenclature_removal.rb
366
388
  - lib/onoma/migration/actions/property_creation.rb
389
+ - lib/onoma/migration/base.rb
390
+ - lib/onoma/migrator.rb
391
+ - lib/onoma/migrator/reference.rb
392
+ - lib/onoma/migrator/translation.rb
393
+ - lib/onoma/models/ability.rb
394
+ - lib/onoma/models/account.rb
395
+ - lib/onoma/models/accounting_system.rb
396
+ - lib/onoma/models/activity_family.rb
397
+ - lib/onoma/models/administrative_area.rb
398
+ - lib/onoma/models/administrative_area_nature.rb
399
+ - lib/onoma/models/analysis_nature.rb
400
+ - lib/onoma/models/animal_life_state.rb
401
+ - lib/onoma/models/cation_exchange_capacity_analysis_method.rb
402
+ - lib/onoma/models/certification.rb
403
+ - lib/onoma/models/certification_label.rb
404
+ - lib/onoma/models/chemical_classification.rb
405
+ - lib/onoma/models/chemical_element.rb
406
+ - lib/onoma/models/country.rb
407
+ - lib/onoma/models/crop_set.rb
408
+ - lib/onoma/models/currency.rb
409
+ - lib/onoma/models/delivery_mode.rb
410
+ - lib/onoma/models/dimension.rb
411
+ - lib/onoma/models/document_category.rb
412
+ - lib/onoma/models/document_nature.rb
413
+ - lib/onoma/models/entity_link_nature.rb
414
+ - lib/onoma/models/event_nature.rb
415
+ - lib/onoma/models/fence_perimeter.rb
416
+ - lib/onoma/models/figure.rb
417
+ - lib/onoma/models/fiscal_position.rb
418
+ - lib/onoma/models/guide_nature.rb
419
+ - lib/onoma/models/identifier_nature.rb
420
+ - lib/onoma/models/indicator.rb
421
+ - lib/onoma/models/issue_nature.rb
422
+ - lib/onoma/models/land.rb
423
+ - lib/onoma/models/language.rb
424
+ - lib/onoma/models/mammalia_birth_condition.rb
425
+ - lib/onoma/models/mammalia_reproduction_state.rb
426
+ - lib/onoma/models/molecule.rb
427
+ - lib/onoma/models/net_service.rb
428
+ - lib/onoma/models/opportunity_origin.rb
429
+ - lib/onoma/models/phosphorus_analysis_method.rb
430
+ - lib/onoma/models/plant_life_state.rb
431
+ - lib/onoma/models/plant_reproduction_state.rb
432
+ - lib/onoma/models/plants_growth_level.rb
433
+ - lib/onoma/models/procedure_action.rb
434
+ - lib/onoma/models/procedure_category.rb
435
+ - lib/onoma/models/procedure_nature.rb
436
+ - lib/onoma/models/procedure_role.rb
437
+ - lib/onoma/models/product_nature.rb
438
+ - lib/onoma/models/product_nature_category.rb
439
+ - lib/onoma/models/product_nature_variant.rb
440
+ - lib/onoma/models/production_nature.rb
441
+ - lib/onoma/models/production_system.rb
442
+ - lib/onoma/models/production_usage.rb
443
+ - lib/onoma/models/residue_elimination_method.rb
444
+ - lib/onoma/models/role.rb
445
+ - lib/onoma/models/running_cost.rb
446
+ - lib/onoma/models/sex.rb
447
+ - lib/onoma/models/soil_cultural_state.rb
448
+ - lib/onoma/models/soil_nature.rb
449
+ - lib/onoma/models/spatial_reference_system.rb
450
+ - lib/onoma/models/tax.rb
451
+ - lib/onoma/models/tax_nature.rb
452
+ - lib/onoma/models/unit.rb
453
+ - lib/onoma/models/variety.rb
454
+ - lib/onoma/models/working_set.rb
367
455
  - lib/onoma/nomenclature.rb
368
- - lib/onoma/property.rb
456
+ - lib/onoma/nomenclature_set.rb
457
+ - lib/onoma/property_nature.rb
458
+ - lib/onoma/record/base.rb
369
459
  - lib/onoma/reference.rb
370
460
  - lib/onoma/reflection.rb
371
461
  - lib/onoma/relation.rb
372
462
  - lib/onoma/version.rb
373
463
  - onoma.gemspec
374
- homepage: https://github.com/ekylibre/onoma
464
+ homepage: https://gitlab.com/ekylibre/onoma
375
465
  licenses:
376
466
  - MIT
377
467
  metadata: {}
378
- post_install_message:
468
+ post_install_message:
379
469
  rdoc_options: []
380
470
  require_paths:
381
471
  - lib
@@ -383,16 +473,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
383
473
  requirements:
384
474
  - - ">="
385
475
  - !ruby/object:Gem::Version
386
- version: '0'
476
+ version: 2.4.4
387
477
  required_rubygems_version: !ruby/object:Gem::Requirement
388
478
  requirements:
389
479
  - - ">="
390
480
  - !ruby/object:Gem::Version
391
481
  version: '0'
392
482
  requirements: []
393
- rubyforge_project:
394
- rubygems_version: 2.5.2.3
395
- signing_key:
483
+ rubygems_version: 3.0.3
484
+ signing_key:
396
485
  specification_version: 4
397
486
  summary: Provides open nomenclature data in a gem
398
487
  test_files: []