coaster 1.4.15 → 1.4.17
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/coaster/core_ext/date.rb +12 -8
- data/lib/coaster/core_ext/month.rb +22 -5
- data/lib/coaster/core_ext/standard_error/sentry.rb +6 -1
- data/lib/coaster/core_ext/time.rb +15 -0
- data/lib/coaster/core_ext.rb +1 -0
- data/lib/coaster/serialized_properties.rb +22 -11
- data/lib/coaster/version.rb +1 -1
- data/test/test_month.rb +15 -0
- data/test/test_standard_error.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 54a4cd4285f5c47fe270fbff49fb6b639a69c05bcff645a40508f6a720469148
|
4
|
+
data.tar.gz: f5514b63f55b49a84e95a439f9c1baacec5798e080cf8f06ab5b9744d2b10b53
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 60c173a2b09beeb1af679dc2b15f33a0df489f8da04a656ee4f2decf80366b0907e52a598d4a39ac605171a2d54cb3d84fad7dac7585340f4bf7de60646e6e1d
|
7
|
+
data.tar.gz: 4a25b83caa173276193da30ba43b4e2f9e68e3bee74b640e8185aea78c1a396b45ac6d1180fc52ebeca4c17a9e617f9c24ba25fb18c1092d5be60d45bb5e4627
|
@@ -1,12 +1,16 @@
|
|
1
1
|
class Date
|
2
|
-
def to_time_range(timezone =
|
3
|
-
if timezone
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
2
|
+
def to_time_range(timezone = ::Time.zone)
|
3
|
+
timezone = ActiveSupport::TimeZone[timezone] if timezone.is_a?(String)
|
4
|
+
b_day = in_time_zone(timezone)
|
5
|
+
b_day...(b_day + 1.day)
|
6
|
+
end
|
7
|
+
|
8
|
+
def beginning_of_range(timezone = ::Time.zone)
|
9
|
+
to_time_range(timezone).begin
|
10
|
+
end
|
11
|
+
|
12
|
+
def end_of_range(timezone = ::Time.zone)
|
13
|
+
to_time_range(timezone).end
|
10
14
|
end
|
11
15
|
|
12
16
|
def prev_specific_date(day_num)
|
@@ -82,20 +82,37 @@ class Month
|
|
82
82
|
last_date.day
|
83
83
|
end
|
84
84
|
|
85
|
-
def
|
86
|
-
|
85
|
+
def _timezone(timezone)
|
86
|
+
tz = timezone || self.timezone
|
87
|
+
tz = ActiveSupport::TimeZone[tz] if tz.is_a?(String)
|
88
|
+
tz
|
89
|
+
end
|
90
|
+
|
91
|
+
def beginning_of_month(timezone = nil)
|
92
|
+
tz = _timezone(timezone)
|
93
|
+
first_date.in_time_zone(tz)
|
87
94
|
end
|
88
95
|
|
89
96
|
def end_of_month
|
90
|
-
|
97
|
+
tz = _timezone(timezone)
|
98
|
+
last_date.in_time_zone(tz).end_of_day
|
91
99
|
end
|
92
100
|
|
93
101
|
def date_for_day(number)
|
94
102
|
Date.new(year, month, number)
|
95
103
|
end
|
96
104
|
|
97
|
-
def to_time_range
|
98
|
-
|
105
|
+
def to_time_range(timezone = nil)
|
106
|
+
tz = _timezone(timezone)
|
107
|
+
beginning_of_month(tz)...(later.beginning_of_month(tz))
|
108
|
+
end
|
109
|
+
|
110
|
+
def beginning_of_range(timezone = nil)
|
111
|
+
to_time_range(timezone).begin
|
112
|
+
end
|
113
|
+
|
114
|
+
def end_of_range(timezone = nil)
|
115
|
+
to_time_range(timezone).end
|
99
116
|
end
|
100
117
|
|
101
118
|
def to_date_range
|
@@ -1,5 +1,6 @@
|
|
1
1
|
class StandardError
|
2
2
|
attr_writer :raven
|
3
|
+
attr_reader :sentry_event
|
3
4
|
|
4
5
|
alias_method :initialize_original, :initialize
|
5
6
|
def initialize(message = nil, cause = $!)
|
@@ -42,7 +43,7 @@ class StandardError
|
|
42
43
|
return if options.key?(:report) && !options[:report]
|
43
44
|
return unless report?
|
44
45
|
nt = notes(options)
|
45
|
-
Sentry.capture_exception(self, level: nt[:level]) do |scope|
|
46
|
+
@sentry_event = Sentry.capture_exception(self, level: nt[:level]) do |scope|
|
46
47
|
scope.user.merge!(nt[:user] || {})
|
47
48
|
scope.tags.merge!(nt[:tags])
|
48
49
|
scope.extra.merge!(nt[:extra])
|
@@ -54,6 +55,10 @@ class StandardError
|
|
54
55
|
Sentry.logger.error(msg)
|
55
56
|
end
|
56
57
|
|
58
|
+
def sentry_event_id
|
59
|
+
@sentry_event&.event_id
|
60
|
+
end
|
61
|
+
|
57
62
|
# options
|
58
63
|
# :logger
|
59
64
|
# :cleaner
|
@@ -0,0 +1,15 @@
|
|
1
|
+
class Time
|
2
|
+
def to_time_range(timezone = ::Time.zone)
|
3
|
+
timezone = ActiveSupport::TimeZone[timezone] if timezone.is_a?(String)
|
4
|
+
s = self.in_time_zone(timezone).change(usec: 0)
|
5
|
+
s...(s + 1.second)
|
6
|
+
end
|
7
|
+
|
8
|
+
def beginning_of_range(timezone = ::Time.zone)
|
9
|
+
to_time_range(timezone).begin
|
10
|
+
end
|
11
|
+
|
12
|
+
def end_of_range(timezone = ::Time.zone)
|
13
|
+
to_time_range(timezone).end
|
14
|
+
end
|
15
|
+
end
|
data/lib/coaster/core_ext.rb
CHANGED
@@ -25,16 +25,16 @@ module Coaster
|
|
25
25
|
cm || key.to_s
|
26
26
|
end
|
27
27
|
|
28
|
-
def serialized_property(serialize_column, key, type: nil, comment: nil, getter: nil, setter: nil, setter_callback: nil, default: nil)
|
28
|
+
def serialized_property(serialize_column, key, type: nil, comment: nil, getter: nil, setter: nil, setter_callback: nil, default: nil, rescuer: nil)
|
29
29
|
raise DuplicatedProperty, "#{self.name}##{key} duplicated\n#{caller[0..5].join("\n")}" if serialized_property_settings[key.to_sym]
|
30
|
-
serialized_property_settings[key.to_sym] = {type: type, comment: comment, getter: getter, setter: setter, setter_callback: setter_callback, default: default}
|
31
|
-
_typed_serialized_property(serialize_column, key, type: type, getter: getter, setter: setter, setter_callback: setter_callback, default: default)
|
30
|
+
serialized_property_settings[key.to_sym] = {type: type, comment: comment, getter: getter, setter: setter, setter_callback: setter_callback, default: default, rescuer: rescuer}
|
31
|
+
_typed_serialized_property(serialize_column, key, type: type, getter: getter, setter: setter, setter_callback: setter_callback, default: default, rescuer: rescuer)
|
32
32
|
end
|
33
33
|
|
34
|
-
def serialized_properties(serialize_column, *keys, type: nil, getter: nil, setter: nil, setter_callback: nil, default: nil)
|
34
|
+
def serialized_properties(serialize_column, *keys, type: nil, getter: nil, setter: nil, setter_callback: nil, default: nil, rescuer: nil)
|
35
35
|
keys.flatten.each do |key|
|
36
36
|
key_name = key
|
37
|
-
prop_hash = {type: type, getter: getter, setter: setter, setter_callback: setter_callback, default: default}
|
37
|
+
prop_hash = {type: type, getter: getter, setter: setter, setter_callback: setter_callback, default: default, rescuer: rescuer}
|
38
38
|
if key.is_a? Hash
|
39
39
|
key_name = key[:key]
|
40
40
|
prop_hash = {type: type, getter: getter, setter: setter, setter_callback: setter_callback, default: default}.merge(key)
|
@@ -46,7 +46,7 @@ module Coaster
|
|
46
46
|
|
47
47
|
private
|
48
48
|
|
49
|
-
def _typed_serialized_property(serialize_column, key, type: nil, getter: nil, setter: nil, setter_callback: nil, default: nil)
|
49
|
+
def _typed_serialized_property(serialize_column, key, type: nil, getter: nil, setter: nil, setter_callback: nil, default: nil, rescuer: nil)
|
50
50
|
case type
|
51
51
|
when String then
|
52
52
|
# String은 나중에 eval해서 가져옴,
|
@@ -55,14 +55,25 @@ module Coaster
|
|
55
55
|
if type.is_a?(String)
|
56
56
|
begin
|
57
57
|
type = eval(type)
|
58
|
-
raise InvalidProperty, "#{self.name}##{key} type string is return string #{type}" if type.is_a?(String)
|
58
|
+
raise InvalidProperty, m: "#{self.name}##{key} type string is return string #{type}", type: type if type.is_a?(String)
|
59
59
|
rescue InvalidProperty => e
|
60
|
-
|
60
|
+
if rescuer
|
61
|
+
type = rescuer.call(e)
|
62
|
+
else
|
63
|
+
raise
|
64
|
+
end
|
61
65
|
rescue => e
|
62
|
-
|
66
|
+
e.attributes[:type] = type
|
67
|
+
if rescuer
|
68
|
+
type = rescuer.call(e)
|
69
|
+
else
|
70
|
+
raise InvalidProperty, "#{self.name}##{key} eval failed: type:[#{type}] [#{e.class.name}] #{e.message}"
|
71
|
+
end
|
72
|
+
end
|
73
|
+
if type
|
74
|
+
serialized_property_setting(key.to_sym)[:type] = type
|
75
|
+
_typed_serialized_property serialize_column, key, type: type, getter: getter, setter: setter, setter_callback: setter_callback, default: default
|
63
76
|
end
|
64
|
-
serialized_property_setting(key.to_sym)[:type] = type
|
65
|
-
_typed_serialized_property serialize_column, key, type: type, getter: getter, setter: setter, setter_callback: setter_callback, default: default
|
66
77
|
end
|
67
78
|
}
|
68
79
|
when Array then
|
data/lib/coaster/version.rb
CHANGED
data/test/test_month.rb
CHANGED
@@ -73,5 +73,20 @@ module Coaster
|
|
73
73
|
h = {Month.now => 1}
|
74
74
|
assert_equal h[Month.now], 1
|
75
75
|
end
|
76
|
+
|
77
|
+
def test_range_timezone
|
78
|
+
m = Month.parse('202001', timezone: 'Asia/Seoul')
|
79
|
+
assert_equal m.beginning_of_range('Asia/Seoul'), Date.parse('20200101').in_time_zone('Asia/Seoul')
|
80
|
+
assert_equal m.end_of_range('Asia/Seoul'), Date.parse('20200201').in_time_zone('Asia/Seoul')
|
81
|
+
assert m.to_time_range.exclude_end?
|
82
|
+
d = Date.parse('20200101')
|
83
|
+
assert_equal d.beginning_of_range('Asia/Seoul'), Date.parse('20200101').in_time_zone('Asia/Seoul')
|
84
|
+
assert_equal d.end_of_range('Asia/Seoul'), Date.parse('20200102').in_time_zone('Asia/Seoul')
|
85
|
+
assert d.to_time_range.exclude_end?
|
86
|
+
t = Time.parse('20200101 12:12:12.123456')
|
87
|
+
assert_equal t.beginning_of_range('Asia/Seoul'), Time.parse('20200101 12:12:12').in_time_zone('Asia/Seoul')
|
88
|
+
assert_equal t.end_of_range('Asia/Seoul'), Time.parse('20200101 12:12:13').in_time_zone('Asia/Seoul')
|
89
|
+
assert t.to_time_range.exclude_end?
|
90
|
+
end
|
76
91
|
end
|
77
92
|
end
|
data/test/test_standard_error.rb
CHANGED
@@ -316,7 +316,7 @@ LOG
|
|
316
316
|
assert_equal 'NameError', e.to_hash['type']
|
317
317
|
assert_equal 999999, e.to_hash['status']
|
318
318
|
assert_equal 500, e.to_hash['http_status']
|
319
|
-
assert_equal "standard error translation (
|
319
|
+
assert_equal "standard error translation (bc1746 #{bt})", e.user_message
|
320
320
|
assert_match(/undefined local variable or method `aa'/, e.to_hash['message'])
|
321
321
|
end
|
322
322
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: coaster
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.4.
|
4
|
+
version: 1.4.17
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- buzz jung
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-11-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: oj
|
@@ -201,6 +201,7 @@ files:
|
|
201
201
|
- lib/coaster/core_ext/standard_error/raven.rb
|
202
202
|
- lib/coaster/core_ext/standard_error/sentry.rb
|
203
203
|
- lib/coaster/core_ext/string.rb
|
204
|
+
- lib/coaster/core_ext/time.rb
|
204
205
|
- lib/coaster/git.rb
|
205
206
|
- lib/coaster/git/options.rb
|
206
207
|
- lib/coaster/git/repository.rb
|