dato 0.3.17 → 0.3.18

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: 5312e73132db1c3e40025457a136c2a19277c678
4
- data.tar.gz: 841bf4766c9ccdf46e579ae90404db20030638c4
3
+ metadata.gz: 45883210ac90fc2276bd26e334681558f175918f
4
+ data.tar.gz: 2a821e2b293057fc1a0675a0df829225f2a3c75b
5
5
  SHA512:
6
- metadata.gz: 5ce372671115413972baa6db2fef3eef123e18445604f13f2f376dade987c1dcf8c85486e203eda7edfa27f38718104b3259da6c7b9f0204673dd4a9316e8b5d
7
- data.tar.gz: 7fceeea2f83645aecee686869e3531725ff1b8f7b97409274625b940df62f3d8b2bcfce70f7e65fe632445188c87d48afe2397ecbc50ce180f3bda9fc0aa2f16
6
+ metadata.gz: ba2db4547fc55b31a9baf71098551bc11e9d35ffd39f3ab7b3362eb1e2a9864dc86cb72f25de02bb2f6d54a16f55e8ad4b23486e9fe9af6553dea2d86cde6ab2
7
+ data.tar.gz: 5e6b1d9fcfc323182fcbba4d3d17f50762494fb91686bf0d2b502ca4b596ef94c77fa1c312ba7b4db359b36a0f2732573d496875c4acaa090956308e964c8698
@@ -2,6 +2,7 @@
2
2
  require 'forwardable'
3
3
  require 'active_support/inflector/transliterate'
4
4
  require 'active_support/hash_with_indifferent_access'
5
+ require 'dato/utils/locale_value'
5
6
 
6
7
  Dir[File.dirname(__FILE__) + '/field_type/*.rb'].each do |file|
7
8
  require file
@@ -125,11 +126,7 @@ module Dato
125
126
 
126
127
  value = if field.localized
127
128
  obj = entity.send(method) || {}
128
-
129
- locale_with_value = I18n.fallbacks[I18n.locale]
130
- .find { |locale| obj[locale] }
131
-
132
- obj[locale_with_value || I18n.locale]
129
+ Utils::LocaleValue.find(obj)
133
130
  else
134
131
  entity.send(method)
135
132
  end
@@ -2,6 +2,7 @@
2
2
  require 'forwardable'
3
3
  require 'active_support/inflector/transliterate'
4
4
  require 'active_support/hash_with_indifferent_access'
5
+ require 'dato/utils/locale_value'
5
6
 
6
7
  module Dato
7
8
  module Local
@@ -56,10 +57,7 @@ module Dato
56
57
  value = if localized
57
58
  obj = entity.send(method) || {}
58
59
 
59
- locale_with_value = I18n.fallbacks[I18n.locale]
60
- .find { |locale| obj[locale] }
61
-
62
- obj[locale_with_value || I18n.locale]
60
+ Utils::LocaleValue.find(obj)
63
61
  else
64
62
  entity.send(method)
65
63
  end
@@ -0,0 +1,14 @@
1
+ require 'i18n/backend/fallbacks'
2
+
3
+ module Dato
4
+ module Utils
5
+ module LocaleValue
6
+ def self.find(obj)
7
+ locale_with_value = I18n.fallbacks[I18n.locale]
8
+ .find { |locale| obj[locale] }
9
+
10
+ obj[locale_with_value || I18n.locale]
11
+ end
12
+ end
13
+ end
14
+ end
data/lib/dato/version.rb CHANGED
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module Dato
3
- VERSION = '0.3.17'
3
+ VERSION = '0.3.18'
4
4
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dato
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.17
4
+ version: 0.3.18
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stefano Verna
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-09-07 00:00:00.000000000 Z
11
+ date: 2017-09-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -433,6 +433,7 @@ files:
433
433
  - lib/dato/upload/file.rb
434
434
  - lib/dato/upload/image.rb
435
435
  - lib/dato/utils/favicon_tags_builder.rb
436
+ - lib/dato/utils/locale_value.rb
436
437
  - lib/dato/utils/meta_tags/article_modified_time.rb
437
438
  - lib/dato/utils/meta_tags/article_publisher.rb
438
439
  - lib/dato/utils/meta_tags/base.rb