dina 0.7.2.0 → 0.7.4.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5a0d3f25267c47fba2fa7e0cf5df80602065c1d182578d48522d0f1f81815fef
4
- data.tar.gz: cf53d98747de1528002a5e4c9b88c8e245ff98e2beebfb5d1a9c3047f38bff33
3
+ metadata.gz: 620e59a87be3c3adb55fba2d7d4084a12fbb12a78427ca53de33426ae8510110
4
+ data.tar.gz: 6c2c5daff310c35f43b165156fc06944d44e4a74db84da12af055fb4d0be401d
5
5
  SHA512:
6
- metadata.gz: f80d1a0565a76412d07a4367d4c6b1085c5042fcac24d83d231d5699c071da560219a11451a9928f01df4702233bfe70dfff7bfca267b7e1aac7a0f0b2c443bf
7
- data.tar.gz: d462deb63117f46c998df5ff471d9a809289bce7f411c9b6a50447e71b87c9826e134e881812205003a6c8f03440d7506c33d46cb7401aa66e169ec8c606f1ac
6
+ metadata.gz: 3b5913b6fe291bbcb26b4c5bf298bf4f6307077e006442952ad1937833952074728352cc1f0e1e01a6abfa8f5197b06161ddf1ef674dc29a4012761f46ed231a
7
+ data.tar.gz: dea42bb62339358120b3d890edd22727c81058e30e6b9b3c7443d90e515e10942a12533bc94e52b5d8a6a8578d1ba67e70e6c4e1366672c828a789c1bace37e0
@@ -6,31 +6,16 @@ module Dina
6
6
  @descriptions = []
7
7
  if opts[:descriptions]
8
8
  @descriptions = opts[:descriptions]
9
- end
10
- if opts[:english]
11
- self.english_description = opts[:english]
12
- end
13
- if opts[:french]
14
- self.french_description = opts[:french]
9
+ else
10
+ self.set_description(opts)
15
11
  end
16
12
  end
17
13
 
18
- def english_description=(desc)
19
- descriptions.delete_if{|o| o[:lang] == "en"}
20
- descriptions << { lang: "en", desc: desc }
21
- end
22
-
23
- def english_description
24
- descriptions.select{|o| o[:lang] == "en"}.first[:desc]
25
- end
26
-
27
- def french_description=(desc)
28
- descriptions.delete_if{|o| o[:lang] == "fr"}
29
- descriptions << { lang: "fr", desc: desc }
30
- end
31
-
32
- def french_description
33
- descriptions.select{|o| o[:lang] == "fr"}.first[:desc]
14
+ def set_description(opts = {})
15
+ opts.each do |key, value|
16
+ descriptions.delete_if{|o| o[:lang] == key.to_s}
17
+ descriptions << { lang: key.to_s, desc: value }
18
+ end
34
19
  end
35
20
 
36
21
  def to_hash
@@ -4,7 +4,7 @@ module Dina
4
4
  class MultilingualDescriptionCaster
5
5
  def self.cast(value, default)
6
6
  begin
7
- Dina::MultilingualDescription.new(value).to_hash
7
+ MultilingualDescription.new(value).to_hash
8
8
  rescue ArgumentError
9
9
  { descriptions: [] }
10
10
  end
@@ -6,31 +6,16 @@ module Dina
6
6
  @titles = []
7
7
  if opts[:titles]
8
8
  @titles = opts[:titles]
9
- end
10
- if opts[:english]
11
- self.english_title = opts[:english]
12
- end
13
- if opts[:french]
14
- self.french_title = opts[:french]
9
+ else
10
+ self.set_title(opts)
15
11
  end
16
12
  end
17
13
 
18
- def english_title=(title)
19
- titles.delete_if{|o| o[:lang] == "en"}
20
- titles << { lang: "en", title: title }
21
- end
22
-
23
- def english_title
24
- titles.select{|o| o[:lang] == "en"}.first[:title]
25
- end
26
-
27
- def french_title=(title)
28
- titles.delete_if{|o| o[:lang] == "fr"}
29
- titles << { lang: "fr", title: title }
30
- end
31
-
32
- def french_title
33
- titles.select{|o| o[:lang] == "fr"}.first[:title]
14
+ def set_title(opts ={})
15
+ opts.each do |key, value|
16
+ titles.delete_if{|o| o[:lang] == key.to_s}
17
+ titles << { lang: key.to_s, title: value }
18
+ end
34
19
  end
35
20
 
36
21
  def to_hash
@@ -4,7 +4,7 @@ module Dina
4
4
  class MultilingualTitleCaster
5
5
  def self.cast(value, default)
6
6
  begin
7
- Dina::MultilingualTitle.new(value).to_hash
7
+ MultilingualTitle.new(value).to_hash
8
8
  rescue ArgumentError
9
9
  { titles: [] }
10
10
  end
@@ -4,5 +4,6 @@ module Dina
4
4
  class TokenStoreContentInvalid < DinaException; end
5
5
  class ConfigItemMissing < DinaException; end
6
6
  class ObjectInvalid < DinaException; end
7
+ class PropertyInvalid < ObjectInvalid; end
7
8
  class PropertyValueInvalid < ObjectInvalid; end
8
9
  end
@@ -40,15 +40,37 @@ module Dina
40
40
  super
41
41
  end
42
42
 
43
- def english_description
43
+ # Adds or updates a multilingualDescription with a language key
44
+ #
45
+ # @param opts [Hash] the description expessed as { en: "My description" }
46
+ def set_multilingualDescription(opts = {})
44
47
  if self.respond_to?(:multilingualDescription)
45
- multilingualDescription[:descriptions].select{|o| o[:lang] == "en"}.first[:desc]
48
+ if self.multilingualDescription.nil?
49
+ self.multilingualDescription = opts
50
+ else
51
+ descriptions = multilingualDescription["descriptions"]
52
+ descriptions.delete_if{|o| o["lang"] == opts.keys[0].to_s}
53
+ descriptions << { "lang" => opts.keys[0].to_s, "desc" => opts[opts.keys[0]] }
54
+ end
55
+ else
56
+ raise PropertyInvalid, "#{self.class} does not have the property multilingualDescription"
46
57
  end
47
58
  end
48
59
 
49
- def french_description
50
- if self.respond_to?(:multilingualDescription)
51
- multilingualDescription[:descriptions].select{|o| o[:lang] == "fr"}.first[:desc]
60
+ # Adds or updates a multilingualTitle with a language key
61
+ #
62
+ # @param opts [Hash] the title expessed as { en: "My title" }
63
+ def set_multilingualTitle(opts = {})
64
+ if self.respond_to?(:multilingualTitle)
65
+ if self.multilingualTitle.nil?
66
+ self.multilingualTitle = opts
67
+ else
68
+ titles = multilingualTitle["titles"]
69
+ titles.delete_if{|o| o["lang"] == opts.keys[0].to_s}
70
+ titles << { "lang" => opts.keys[0].to_s, "title" => opts[opts.keys[0]] }
71
+ end
72
+ else
73
+ raise PropertyInvalid, "#{self.class} does not have the property multilingualTitle"
52
74
  end
53
75
  end
54
76
 
@@ -46,22 +46,6 @@ module Dina
46
46
  ]
47
47
  end
48
48
 
49
- def english_description=(desc)
50
- description[:en] = desc
51
- end
52
-
53
- def english_description
54
- description[:en]
55
- end
56
-
57
- def french_description=(desc)
58
- description[:fr] = desc
59
- end
60
-
61
- def french_description
62
- description[:fr]
63
- end
64
-
65
49
  private
66
50
 
67
51
  def on_before_save
@@ -18,6 +18,7 @@ module Dina
18
18
  property :dwcVerbatimSRS, type: :string, default: "WGS84 (EPSG:4326)"
19
19
  property :dwcVerbatimElevation, type: :string
20
20
  property :dwcVerbatimDepth, type: :string
21
+ property :dwcFieldNumber, type: :string
21
22
  property :dwcOtherRecordNumbers, type: :array, default: []
22
23
  property :dwcRecordNumber, type: :string
23
24
  property :dwcCountry, type: :string
data/lib/dina/version.rb CHANGED
@@ -3,7 +3,7 @@ module Dina
3
3
 
4
4
  MAJOR = 0
5
5
  MINOR = 7
6
- PATCH = 2
6
+ PATCH = 4
7
7
  BUILD = 0
8
8
 
9
9
  def self.version
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dina
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.2.0
4
+ version: 0.7.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - David P. Shorthouse
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-01-04 00:00:00.000000000 Z
11
+ date: 2023-01-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json_api_client