hellobase 0.1.14 → 0.1.18

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: 925574afb7726175b0a972403d9e805692779cbbb8f6e87ff8fbe911a135df28
4
- data.tar.gz: a2ca4330eca04f5b069e00f7c4fdcca8d245c394044c34eefd922c2619d3ce72
3
+ metadata.gz: c845087b29c43d1b30d6b890516a532baa1c6848d57ee4dc0ba8be27837bea1b
4
+ data.tar.gz: 77adb590420eb53377250526052986e60c468a460bb308c3404e42fbf0c03f14
5
5
  SHA512:
6
- metadata.gz: 41a29344cdece20c0f7ec4485d7db02f7297775892032763083f62fc3d823cf0253efeb09266ae50866c715cf7e089ce9215ba14cdec494d1625c63b58a514d6
7
- data.tar.gz: be6935db61dfb6320d9a3bcbb5a00b6326c27bcce4a7a850322e0aad7180fdb0fe5f49000d3791512a1a7ddc85b347e37dd21431f384f8d697b4dd4643a5177f
6
+ metadata.gz: cc84120eca87a3faeea1a8a8fe8b7da9ff8af48e77ff0cb13e73b76a6e498ee167af925be81062af45dca9d6be3b6a9a425dc7da8465f2ecd9a769aa16c80ec1
7
+ data.tar.gz: 632211e4b6007b5c1f42ec54c9797843a87b616b0917d4ca2ca7c5d562b4a66c84adf7e75f4c53249500d07a13dbd34201af4fba5265c89ad3be8e1de703ef09
@@ -20,7 +20,7 @@ Time.singleton_class.prepend(
20
20
 
21
21
  def new(*args)
22
22
  # only allow ActiveSupport::TimeZone to use Time.new
23
- unless caller_locations(1, 1)[0].path.end_with? 'active_support/values/time_zone.rb'
23
+ unless caller_locations.any? {|loc| loc.path.end_with? '/active_support/values/time_zone.rb' }
24
24
  raise Hellobase::Error.new(:datetime_new, nil)
25
25
  end
26
26
 
@@ -1,7 +1,7 @@
1
1
  require 'bigdecimal'
2
2
  require 'date'
3
- require 'active_support/core_ext/date'
4
- require 'active_support/core_ext/time'
3
+ require 'active_support'
4
+ require 'active_support/core_ext'
5
5
  require 'active_support/duration'
6
6
  require 'tod'
7
7
 
@@ -7,55 +7,52 @@ require 'active_admin/inputs'
7
7
  class DatepickerWithTimeInput
8
8
  include ::Formtastic::Inputs::Base
9
9
 
10
- def self.virtual_attributes(attr)
11
- [:"_dpwt_#{attr}_d", :"_dpwt_#{attr}_h", :"_dpwt_#{attr}_m"]
10
+ def self.virtual_attributes(base)
11
+ [:"_dpwt_#{base}_d", :"_dpwt_#{base}_h", :"_dpwt_#{base}_m"]
12
12
  end
13
13
 
14
- def self.define_virtual_attributes(klass, attr)
15
- return if klass.respond_to? :_dpwt_defined
14
+ def self.define_virtual_attributes(klass, base)
15
+ attrs = virtual_attributes(base)
16
+ ivars = attrs.map {|a| :"@#{a}" }
17
+ method = :"_dpwt_set_#{base}"
16
18
 
17
- klass.class_eval <<-RUBY
18
- def self._dpwt_defined; end
19
-
20
- def _dpwt_#{attr}_d
21
- self.#{attr}&.strftime('%Y-%m-%d')
19
+ klass.class_eval do
20
+ define_method attrs[0] do
21
+ send(base)&.strftime('%Y-%m-%d')
22
22
  end
23
23
 
24
- def _dpwt_#{attr}_h
25
- self.#{attr}&.strftime('%H')
24
+ define_method attrs[1] do
25
+ send(base)&.strftime('%H')
26
26
  end
27
27
 
28
- def _dpwt_#{attr}_m
29
- self.#{attr}&.strftime('%M')
28
+ define_method attrs[2] do
29
+ send(base)&.strftime('%M')
30
30
  end
31
31
 
32
- def _dpwt_#{attr}_d=(val)
33
- @_dpwt_#{attr}_d = val
34
- _dpwt_set_#{attr}
32
+ attrs.each_with_index do |a, i|
33
+ define_method :"#{a}=" do |val|
34
+ instance_variable_set ivars[i], val
35
+ send(method)
35
36
 
36
- val
37
+ val
38
+ end
37
39
  end
38
40
 
39
- def _dpwt_#{attr}_h=(val)
40
- @_dpwt_#{attr}_h = val
41
- _dpwt_set_#{attr}
42
-
43
- val
41
+ define_method method do
42
+ send :"#{base}=",
43
+ ivars.any? {|v| instance_variable_get(v).blank? } ?
44
+ nil :
45
+ [
46
+ instance_variable_get(ivars[0]),
47
+ [
48
+ instance_variable_get(ivars[1]),
49
+ instance_variable_get(ivars[2])
50
+ ].join(':')
51
+ ].join(' ')
44
52
  end
45
53
 
46
- def _dpwt_#{attr}_m=(val)
47
- @_dpwt_#{attr}_m = val
48
- _dpwt_set_#{attr}
49
-
50
- val
51
- end
52
-
53
- private
54
-
55
- def _dpwt_set_#{attr}
56
- self.#{attr} = @_dpwt_#{attr}_d.blank? || @_dpwt_#{attr}_h.blank? || @_dpwt_#{attr}_m.blank? ? nil : [@_dpwt_#{attr}_d, [@_dpwt_#{attr}_h, @_dpwt_#{attr}_m].join(':')].join(' ')
57
- end
58
- RUBY
54
+ private method
55
+ end
59
56
  end
60
57
 
61
58
  def to_html
@@ -1,3 +1,3 @@
1
1
  module Hellobase
2
- VERSION = '0.1.14'
2
+ VERSION = '0.1.18'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hellobase
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.14
4
+ version: 0.1.18
5
5
  platform: ruby
6
6
  authors:
7
7
  - Anthony Wang
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-11-14 00:00:00.000000000 Z
11
+ date: 2021-11-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activeadmin
@@ -178,7 +178,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
178
178
  - !ruby/object:Gem::Version
179
179
  version: '0'
180
180
  requirements: []
181
- rubygems_version: 3.0.8
181
+ rubygems_version: 3.2.32
182
182
  signing_key:
183
183
  specification_version: 4
184
184
  summary: Ruby runtime environment for Hellobase