russial 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: 186b8998cca76a8469e61d13b82f9005775c56c4
4
- data.tar.gz: b3038cd63bc665a3d10c3bdbc03fcc17f2c54a1c
3
+ metadata.gz: eaa2f6bb22f0f86b19bc1f27632baab3313fd9cb
4
+ data.tar.gz: 4d600788443661ef6452df4bb434f00c05f54239
5
5
  SHA512:
6
- metadata.gz: 4bb11eaa2466a061824c78ecf07848b6714c391a1f91b4803770d8a57be3913beff399f838f3a6c49aa3f31edc1d2a045703f194ad833b5ac974404c0e09fcf4
7
- data.tar.gz: a9088ac669c29c8ea5640638ea4fc9e2e17a7ebaab72377aa8426052d1ef2908745a547167c472c6034c6af96c193bd8b39398268c0e7349411d5a92f7666a26
6
+ metadata.gz: ca4587917b10915b91cc548cfd9470a6143db12b35a83b2eb59c3f1da6fb665e22102006cdaa1231bc0d74901532100c29039fb3b3df6b4507d749c978a8f708
7
+ data.tar.gz: 29faed5856062f3a45f8184f106050fac831493aa5426173e3f881a1bc21fc1062df234f326b554e7b43a27dca183843cc1fdb1747c8be39c6f5b1bbef152a86
data/lib/russial.rb CHANGED
@@ -1,22 +1,24 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ # :nocov:
3
4
  begin
4
5
  require "backport_dig" unless {}.respond_to?(:dig)
5
6
  rescue LoadError
6
7
  puts "Please, install `backport_dig` gem or upgrade your Ruby version."
7
8
  exit
8
9
  end
10
+ # :nocov:
9
11
 
10
12
  require "russial/version"
11
13
  require "russial/config"
12
14
  require "russial/config/configuration"
13
- require "russial/dictionary/default_scope"
15
+ require "russial/dictionary/defaults"
14
16
  require "russial/dictionary/dynamic_methods"
15
17
  require "russial/dictionary/initializer"
16
18
  require "russial/dictionary/i18n"
17
19
 
18
20
  class Russial
19
- include Dictionary::DefaultScope
21
+ include Dictionary::Defaults
20
22
  include Dictionary::I18n if defined?(I18n)
21
23
  prepend Dictionary::DynamicMethods
22
24
  prepend Dictionary::Initializer
@@ -0,0 +1,34 @@
1
+ # frozen_string_literal: true
2
+ class Russial
3
+ module Dictionary
4
+ module Defaults
5
+ def default_scope
6
+ @default_scope ||= keys.first.scope
7
+ end
8
+
9
+ def default_value
10
+ @default_value ||= send(keys.first.name)
11
+ end
12
+
13
+ def result
14
+ dictionary.dig(*default_scope, path.last)
15
+ end
16
+
17
+ def to_s
18
+ default_value.to_s
19
+ end
20
+
21
+ private
22
+
23
+ def method_missing(name, *args, &block)
24
+ return super unless default_value.respond_to?(name)
25
+
26
+ default_value.send(name)
27
+ end
28
+
29
+ def respond_to_missing?(name, include_private = false)
30
+ default_value.respond_to?(name) || super
31
+ end
32
+ end
33
+ end
34
+ end
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  class Russial
3
- VERSION = "0.7.0"
3
+ VERSION = "0.8.0"
4
4
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: russial
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
  - Mesto.ru
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-03-29 00:00:00.000000000 Z
11
+ date: 2017-03-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -115,7 +115,7 @@ files:
115
115
  - lib/russial.rb
116
116
  - lib/russial/config.rb
117
117
  - lib/russial/config/configuration.rb
118
- - lib/russial/dictionary/default_scope.rb
118
+ - lib/russial/dictionary/defaults.rb
119
119
  - lib/russial/dictionary/dynamic_methods.rb
120
120
  - lib/russial/dictionary/i18n.rb
121
121
  - lib/russial/dictionary/initializer.rb
@@ -1,14 +0,0 @@
1
- # frozen_string_literal: true
2
- class Russial
3
- module Dictionary
4
- module DefaultScope
5
- def default_scope
6
- @default_scope ||= keys.first.scope
7
- end
8
-
9
- def result
10
- dictionary.dig(*default_scope, path.last)
11
- end
12
- end
13
- end
14
- end