onoma 0.7.0 → 0.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 19a7cd8318c90bfdb53f6bbd5fb73d88de2c0532
4
- data.tar.gz: 375a7d995be1f542159b52f965b37401ff35d6b2
3
+ metadata.gz: fb4d80adfacee042ec4c281d7559e02c1dbb4f9c
4
+ data.tar.gz: 0f4dd57daf53ec7eb7af7a6d5fd5b5a844558fa1
5
5
  SHA512:
6
- metadata.gz: fd6121f1ef02e4d74693083c97a405d5e0d4bace8acff8ea93605b82178f387f841050cc666b17e9a42b027a251654f98e0a1ab2adb91db8f750b9d3d16029ff
7
- data.tar.gz: dddf37403ee890d1d9e3578e29d620b6a393f1415a18c0ab7e929e49914543d7ffb37a4393efb68674deaa0336005ea91b8cbe42f43203bf2077f96414579894
6
+ metadata.gz: 5f84232fae7225678bb85671d6376fa8564c1c07ffc1ff8e462dbedada396e91f498efee4026cc577d7c9b7ca21763b597b68c0d257b46a38b33d3695a7b48a1
7
+ data.tar.gz: e0218b2acd21e4285d363d54d2c04f915a2e2ade7f46ba9f271c3dfc942df5dffc537bf33b00b3bec6b483a66352590c4fa829409984fc6c035affe2be266ee4
data/db/reference.xml CHANGED
@@ -1,5 +1,5 @@
1
1
  <?xml version="1.0"?>
2
- <nomenclatures xmlns="http://www.ekylibre.org/XML/2013/nomenclatures" version="20220504085540">
2
+ <nomenclatures xmlns="http://www.ekylibre.org/XML/2013/nomenclatures" version="20220704161519">
3
3
  <nomenclature name="abilities" translateable="true">
4
4
  <properties>
5
5
  <property name="parameters" type="choice_list" choices="variety, issue_nature"/>
@@ -1719,7 +1719,7 @@
1719
1719
  <property name="countries" type="item_list" choices="countries"/>
1720
1720
  <property name="number" type="string" required="true" default="2"/>
1721
1721
  <property name="precision" type="integer" required="true" default="2"/>
1722
- <property name="symbol" type="string"/>
1722
+ <property name="symbol" type="string" fallbacks="name"/>
1723
1723
  </properties>
1724
1724
  <items>
1725
1725
  <item name="AED" precision="2" active="true" countries="ae" number="784"/>
@@ -1821,7 +1821,7 @@
1821
1821
  <item name="MNT" precision="2" active="true" countries="mn" number="496"/>
1822
1822
  <item name="MOP" precision="2" active="true" countries="mo" number="446"/>
1823
1823
  <item name="MRO" precision="2" active="true" countries="mr" number="478"/>
1824
- <item name="MUR" precision="2" active="true" countries="mu" number="480"/>
1824
+ <item name="MUR" precision="2" active="true" countries="mu" number="480" symbol="Rs"/>
1825
1825
  <item name="MVR" precision="2" active="true" countries="mv" number="462"/>
1826
1826
  <item name="MWK" precision="2" active="true" countries="mw" number="454"/>
1827
1827
  <item name="MXN" precision="2" active="true" countries="mx" number="484"/>
data/lib/onoma/item.rb CHANGED
@@ -279,6 +279,7 @@ module Onoma
279
279
  if property
280
280
  if value.nil? && property.fallbacks
281
281
  property.fallbacks.each do |fallback|
282
+ value ||= @name if fallback == :name
282
283
  value ||= @attributes[fallback]
283
284
  break if value
284
285
  end
@@ -0,0 +1,36 @@
1
+ module Onoma
2
+ module Migration
3
+ module Actions
4
+ class PropertyChange < Onoma::Migration::Actions::Base
5
+ attr_reader :nomenclature, :name, :changes
6
+ def initialize(element)
7
+ name = element['property'].split('.')
8
+ @nomenclature = name.first
9
+ @name = name.second
10
+
11
+ @changes = {}
12
+ if element.has_attribute?('type')
13
+ changes[:type] = element.attr('type').to_sym
14
+ end
15
+ if element.has_attribute?('fallbacks')
16
+ @changes[:fallbacks] = element.attr('fallbacks').to_s.strip.split(/[[:space:]]*\,[[:space:]]*/).map(&:to_sym)
17
+ end
18
+ if element.has_attribute?('default')
19
+ @changes[:default] = element.attr('default').to_sym
20
+ end
21
+ if element.has_attribute?('required')
22
+ @changes[:required] = element.attr('required').to_s == 'true'
23
+ end
24
+ # @changes[:inherit] = !!(element.attr('inherit').to_s == 'true')
25
+ if element.has_attribute?('choices')
26
+ if type == :choice || type == :choice_list
27
+ @changes[:choices] = element.attr('choices').to_s.strip.split(/[[:space:]]*\,[[:space:]]*/).map(&:to_sym)
28
+ elsif type == :item || type == :item_list
29
+ @changes[:choices] = element.attr('choices').to_s.strip.to_sym
30
+ end
31
+ end
32
+ end
33
+ end
34
+ end
35
+ end
36
+ end
@@ -48,7 +48,7 @@ module Onoma
48
48
  end
49
49
 
50
50
  def property_change(action)
51
- @set.add_property(action.nomenclature, action.name, action.changes)
51
+ @set.change_property(action.nomenclature, action.name, action.changes)
52
52
  end
53
53
 
54
54
  def item_creation(action)
@@ -256,6 +256,22 @@ module Onoma
256
256
  p
257
257
  end
258
258
 
259
+ def change_property(name, updates = {})
260
+ property = property_natures[name]
261
+
262
+ unless property
263
+ raise "Property #{p.name} doesn't exist in nomenclature #{@name}"
264
+ end
265
+
266
+ updates.each do |k, v|
267
+ begin
268
+ property.send("#{k}=", v)
269
+ rescue NoMethodError => e
270
+ "#{k} attribute doesn't exist for property nature"
271
+ end
272
+ end
273
+ end
274
+
259
275
  def sibling(name)
260
276
  @set.find(name)
261
277
  end
@@ -151,8 +151,9 @@ module Onoma
151
151
  nomenclature.add_property(property_name, type, options)
152
152
  end
153
153
 
154
- def change_property(_nomenclature_name, _property_name, _updates = {})
155
- raise NotImplementedError
154
+ def change_property(nomenclature_name, property_name, updates = {})
155
+ nomenclature = find!(nomenclature_name)
156
+ nomenclature.change_property(property_name, updates)
156
157
  end
157
158
 
158
159
  def remove_property(_nomenclature_name, _property_name, _options = {})
@@ -1,6 +1,7 @@
1
1
  module Onoma
2
2
  class PropertyNature
3
- attr_reader :nomenclature, :name, :type, :fallbacks, :default, :source
3
+ attr_reader :nomenclature
4
+ attr_accessor :name, :type, :fallbacks, :default, :source
4
5
 
5
6
  # New item
6
7
  def initialize(nomenclature, name, type, options = {})
data/lib/onoma/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Onoma
4
- VERSION = '0.7.0'
4
+ VERSION = '0.8.0'
5
5
  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.7.0
4
+ version: 0.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ekylibre developers
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-05-12 00:00:00.000000000 Z
11
+ date: 2022-07-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -153,6 +153,7 @@ files:
153
153
  - lib/onoma/migration/actions/nomenclature_change.rb
154
154
  - lib/onoma/migration/actions/nomenclature_creation.rb
155
155
  - lib/onoma/migration/actions/nomenclature_removal.rb
156
+ - lib/onoma/migration/actions/property_change.rb
156
157
  - lib/onoma/migration/actions/property_creation.rb
157
158
  - lib/onoma/migration/base.rb
158
159
  - lib/onoma/migrator.rb