fino 1.11.1 → 1.11.3

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
  SHA256:
3
- metadata.gz: 677e25b9a4daff0aaf1fa179f2571f954b7afdc495685339c3dbff7183656802
4
- data.tar.gz: 9ca91a58789efec0a8db42c92aa557de41ce1d6f5c812d71477b32f9d76644fd
3
+ metadata.gz: a6d3e54b58da0cbe4ed96091cd1a589d2d90ee2add6b449b335783413afadee5
4
+ data.tar.gz: 97253f72ab9b66603099c6dfd696c3414f4fd6604cef5f0e3b4ea5a392741b4b
5
5
  SHA512:
6
- metadata.gz: dfb43f74199a960f91c72d7e234df8e376eb30a7169b596f0985716e5df63dc09a08af2f834b036d359367139fd8675a62de1dd0ff62337608955c8b1c10550a
7
- data.tar.gz: 55932466337a4bfe50926786810c22f9dc3fe81285f08620699cc5409814ed38651ade65a9caeaae3e6c10d2ecc56cb163f66f2c8cb122343db86f3c677c79e2
6
+ metadata.gz: 6802920f9ed10636aee5715ee41d73937e57ffcda99ac5b006fc6cff7105226b816ebed416934f7fc998eb0027e2ee8880c90d91080b78c49c6344d24d9b67d2
7
+ data.tar.gz: f03d20301d7564007b21ca7be981f70f9fb1e513da726c51e7b9f5fa8817a7b870e4cd32a98c94d85fcf4c2c209d7d2b90312a1bbc0a7f23100c4b34f091807f
@@ -39,17 +39,16 @@ class Fino::Cache::Memory
39
39
 
40
40
  expire_if_ready
41
41
 
42
- missing_keys = keys - hash.keys
42
+ cached = hash.slice(*keys)
43
+ missing_keys = keys - cached.keys
43
44
 
44
45
  if missing_keys.any?
45
- results = block.call(missing_keys)
46
-
47
- results.each do |key, value|
48
- write(key, value)
46
+ block.call(missing_keys).each do |key, value|
47
+ cached[key] = write(key, value)
49
48
  end
50
49
  end
51
50
 
52
- hash.values_at(*keys)
51
+ keys.map { |key| cached[key] }
53
52
  end
54
53
 
55
54
  def delete(key)
@@ -9,10 +9,8 @@ class Fino::Pipe::Cache
9
9
  end
10
10
 
11
11
  def read(setting_definition)
12
- return cache.read(setting_definition.key) if cache.exist?(setting_definition.key)
13
-
14
- pipe.read(setting_definition).tap do |result|
15
- cache.write(setting_definition.key, result)
12
+ cache.fetch(setting_definition.key) do
13
+ pipe.read(setting_definition)
16
14
  end
17
15
  end
18
16
 
@@ -47,17 +47,56 @@ module Fino::Settings::Numeric
47
47
  end
48
48
  end
49
49
 
50
+ class Minutes < Generic
51
+ include Time
52
+
53
+ def initialize = super("Minutes", "min")
54
+
55
+ def base_factor
56
+ 60
57
+ end
58
+ end
59
+
60
+ class Hours < Generic
61
+ include Time
62
+
63
+ def initialize = super("Hours", "hour")
64
+
65
+ def base_factor
66
+ 3600
67
+ end
68
+ end
69
+
70
+ class Days < Generic
71
+ include Time
72
+
73
+ def initialize = super("Days", "day")
74
+
75
+ def base_factor
76
+ 86_400
77
+ end
78
+ end
79
+
80
+ UNITS = {
81
+ "ms" => Milliseconds,
82
+ "milliseconds" => Milliseconds,
83
+ "sec" => Seconds,
84
+ "seconds" => Seconds,
85
+ "min" => Minutes,
86
+ "minutes" => Minutes,
87
+ "hour" => Hours,
88
+ "hours" => Hours,
89
+ "day" => Days,
90
+ "days" => Days
91
+ }.freeze
92
+
50
93
  module_function
51
94
 
52
95
  def for(identifier)
53
- case identifier.to_s
54
- when "ms", "milliseconds"
55
- Milliseconds.new
56
- when "sec", "seconds"
57
- Seconds.new
58
- else
59
- Generic.new(identifier.to_s.capitalize)
60
- end
96
+ klass = UNITS[identifier.to_s]
97
+ return klass.new if klass
98
+
99
+ Generic.new(identifier.to_s.capitalize)
61
100
  end
62
101
  end
63
102
 
data/lib/fino/version.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Fino
4
- VERSION = "1.11.1"
4
+ VERSION = "1.11.3"
5
5
  REQUIRED_RUBY_VERSION = ">= 3.2.0"
6
6
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fino
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.11.1
4
+ version: 1.11.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Egor Iskrenkov