gloo-lang 1.3.2 → 1.4.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/VERSION +1 -1
- data/lib/gloo_lang/convert/string_to_date.rb +21 -0
- data/lib/gloo_lang/convert/string_to_time.rb +21 -0
- data/lib/gloo_lang/objs/dt/date.rb +18 -3
- data/lib/gloo_lang/objs/dt/datetime.rb +66 -8
- data/lib/gloo_lang/objs/dt/dt_tools.rb +100 -0
- data/lib/gloo_lang/objs/dt/time.rb +18 -3
- data/lib/gloo_lang/objs/web/http_post.rb +6 -6
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 88ed378c66726646a394b8dd00de44f7d41c7ae31f141d95ece292d827caad81
|
4
|
+
data.tar.gz: 856f6958f2f55e5c4d6c1002d8ea89a297b7070ad55f9bc8b314bca268d57a95
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 94d5ce627bd7958eddb1308c4771b718ebf86f71ad6697bbf8e7031d628f7d478f6e0ec7d0995f0245f35a2f1d55f2495a31809c4f0fe6ca53931cb34864a055
|
7
|
+
data.tar.gz: 4920b8d24b4a13e5906d7c66e39ec3b61553c2bdec049ab7bd24ceac33a46cb9d22bb5c23a75539e503f047d1cd5c5e928923faec1d8b1c6889b3c3ffd94c966
|
data/lib/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.
|
1
|
+
1.4.1
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# Author:: Eric Crane (mailto:eric.crane@mac.com)
|
2
|
+
# Copyright:: Copyright (c) 2023 Eric Crane. All rights reserved.
|
3
|
+
#
|
4
|
+
# Conversion tool: String to Date.
|
5
|
+
#
|
6
|
+
require 'chronic'
|
7
|
+
|
8
|
+
module GlooLang
|
9
|
+
module Convert
|
10
|
+
class StringToDate
|
11
|
+
|
12
|
+
#
|
13
|
+
# Convert the given string value to date.
|
14
|
+
#
|
15
|
+
def convert( value )
|
16
|
+
return Chronic.parse( value )
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# Author:: Eric Crane (mailto:eric.crane@mac.com)
|
2
|
+
# Copyright:: Copyright (c) 2023 Eric Crane. All rights reserved.
|
3
|
+
#
|
4
|
+
# Conversion tool: String to Time.
|
5
|
+
#
|
6
|
+
require 'chronic'
|
7
|
+
|
8
|
+
module GlooLang
|
9
|
+
module Convert
|
10
|
+
class StringToTime
|
11
|
+
|
12
|
+
#
|
13
|
+
# Convert the given string value to time.
|
14
|
+
#
|
15
|
+
def convert( value )
|
16
|
+
return Chronic.parse( value )
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -10,6 +10,7 @@ module GlooLang
|
|
10
10
|
|
11
11
|
KEYWORD = 'date'.freeze
|
12
12
|
KEYWORD_SHORT = 'date'.freeze
|
13
|
+
DEFAULT_FORMAT = '%Y.%m.%d'.freeze
|
13
14
|
|
14
15
|
#
|
15
16
|
# The name of the object type.
|
@@ -25,6 +26,21 @@ module GlooLang
|
|
25
26
|
return KEYWORD_SHORT
|
26
27
|
end
|
27
28
|
|
29
|
+
#
|
30
|
+
# Set the value with any necessary type conversions.
|
31
|
+
#
|
32
|
+
def set_value( new_value )
|
33
|
+
if DtTools.is_dt_type? new_value
|
34
|
+
self.value = new_value
|
35
|
+
else
|
36
|
+
self.value = @engine.converter.convert( new_value, 'Date', nil )
|
37
|
+
end
|
38
|
+
|
39
|
+
if DtTools.is_dt_type? self.value
|
40
|
+
self.value = self.value.strftime( DEFAULT_FORMAT )
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
28
44
|
# ---------------------------------------------------------------------
|
29
45
|
# Messages
|
30
46
|
# ---------------------------------------------------------------------
|
@@ -40,9 +56,8 @@ module GlooLang
|
|
40
56
|
# Set to the current date.
|
41
57
|
#
|
42
58
|
def msg_now
|
43
|
-
|
44
|
-
self.value
|
45
|
-
@engine.heap.it.set_to t
|
59
|
+
self.set_value( DateTime.now )
|
60
|
+
@engine.heap.it.set_to self.value
|
46
61
|
end
|
47
62
|
|
48
63
|
end
|
@@ -3,6 +3,7 @@
|
|
3
3
|
#
|
4
4
|
# A Date and Time object.
|
5
5
|
#
|
6
|
+
require 'active_support/all'
|
6
7
|
|
7
8
|
module GlooLang
|
8
9
|
module Objs
|
@@ -10,6 +11,7 @@ module GlooLang
|
|
10
11
|
|
11
12
|
KEYWORD = 'datetime'.freeze
|
12
13
|
KEYWORD_SHORT = 'dt'.freeze
|
14
|
+
DEFAULT_FORMAT = '%Y.%m.%d %I:%M:%S %P'.freeze
|
13
15
|
|
14
16
|
#
|
15
17
|
# The name of the object type.
|
@@ -29,14 +31,17 @@ module GlooLang
|
|
29
31
|
# Set the value with any necessary type conversions.
|
30
32
|
#
|
31
33
|
def set_value( new_value )
|
32
|
-
|
34
|
+
if DtTools.is_dt_type? new_value
|
35
|
+
self.value = new_value
|
36
|
+
else
|
33
37
|
self.value = @engine.converter.convert( new_value, 'DateTime', nil )
|
34
|
-
return
|
35
38
|
end
|
36
39
|
|
37
|
-
self.value
|
40
|
+
if DtTools.is_dt_type? self.value
|
41
|
+
self.value = self.value.strftime( DEFAULT_FORMAT )
|
42
|
+
end
|
38
43
|
end
|
39
|
-
|
44
|
+
|
40
45
|
# ---------------------------------------------------------------------
|
41
46
|
# Messages
|
42
47
|
# ---------------------------------------------------------------------
|
@@ -45,16 +50,69 @@ module GlooLang
|
|
45
50
|
# Get a list of message names that this object receives.
|
46
51
|
#
|
47
52
|
def self.messages
|
48
|
-
return super + %w[now]
|
53
|
+
return super + %w[now is_today is_future is_past is_yesterday is_tomorrow is_this_week]
|
54
|
+
end
|
55
|
+
|
56
|
+
#
|
57
|
+
# Tell the datetime to check if it is today.
|
58
|
+
#
|
59
|
+
def msg_is_today
|
60
|
+
today = DtTools.is_today?( self.value )
|
61
|
+
@engine.heap.it.set_to today
|
62
|
+
return today
|
63
|
+
end
|
64
|
+
|
65
|
+
#
|
66
|
+
# Tell the datetime to check if it is in the future.
|
67
|
+
#
|
68
|
+
def msg_is_future
|
69
|
+
today = DtTools.is_future?( self.value )
|
70
|
+
@engine.heap.it.set_to today
|
71
|
+
return today
|
72
|
+
end
|
73
|
+
|
74
|
+
#
|
75
|
+
# Tell the datetime to check if it is in the past.
|
76
|
+
#
|
77
|
+
def msg_is_past
|
78
|
+
today = DtTools.is_past?( self.value )
|
79
|
+
@engine.heap.it.set_to today
|
80
|
+
return today
|
81
|
+
end
|
82
|
+
|
83
|
+
#
|
84
|
+
# Tell the datetime to check if it is yesterday.
|
85
|
+
#
|
86
|
+
def msg_is_yesterday
|
87
|
+
today = DtTools.is_yesterday?( self.value )
|
88
|
+
@engine.heap.it.set_to today
|
89
|
+
return today
|
90
|
+
end
|
91
|
+
|
92
|
+
#
|
93
|
+
# Tell the datetime to check if it is tomorrow.
|
94
|
+
#
|
95
|
+
def msg_is_tomorrow
|
96
|
+
today = DtTools.is_tomorrow?( self.value )
|
97
|
+
@engine.heap.it.set_to today
|
98
|
+
return today
|
99
|
+
end
|
100
|
+
|
101
|
+
#
|
102
|
+
# Tell the datetime to check if it is this week.
|
103
|
+
#
|
104
|
+
def msg_is_this_week
|
105
|
+
today = DtTools.is_this_week?( self.value )
|
106
|
+
@engine.heap.it.set_to today
|
107
|
+
return today
|
49
108
|
end
|
50
109
|
|
51
110
|
#
|
52
111
|
# Set to the current date and time.
|
53
112
|
#
|
54
113
|
def msg_now
|
55
|
-
|
56
|
-
self.value
|
57
|
-
@engine.heap.it.set_to t
|
114
|
+
self.set_value( DateTime.now )
|
115
|
+
@engine.heap.it.set_to self.value
|
58
116
|
end
|
59
117
|
|
60
118
|
end
|
@@ -0,0 +1,100 @@
|
|
1
|
+
# Author:: Eric Crane (mailto:eric.crane@mac.com)
|
2
|
+
# Copyright:: Copyright (c) 2020 Eric Crane. All rights reserved.
|
3
|
+
#
|
4
|
+
# A Date and Time object.
|
5
|
+
#
|
6
|
+
|
7
|
+
class DtTools
|
8
|
+
|
9
|
+
# ---------------------------------------------------------------------
|
10
|
+
# Type helpers
|
11
|
+
# ---------------------------------------------------------------------
|
12
|
+
|
13
|
+
#
|
14
|
+
# Is the given object a base Date Time object?
|
15
|
+
# True for DateTime and Time
|
16
|
+
#
|
17
|
+
def self.is_dt_type? obj
|
18
|
+
return true if obj.is_a? ::DateTime
|
19
|
+
return true if obj.is_a? ::Time
|
20
|
+
return false
|
21
|
+
end
|
22
|
+
|
23
|
+
# ---------------------------------------------------------------------
|
24
|
+
# Language helpers
|
25
|
+
# ---------------------------------------------------------------------
|
26
|
+
|
27
|
+
#
|
28
|
+
# Get the beginning of the week.
|
29
|
+
#
|
30
|
+
def self.beginning_of_week
|
31
|
+
return Time.now.beginning_of_week( start_day = :sunday )
|
32
|
+
end
|
33
|
+
|
34
|
+
#
|
35
|
+
# Is the date in the next 10 days?
|
36
|
+
#
|
37
|
+
def self.in_next_ten_days?( dt )
|
38
|
+
return false if DtTools.is_past?( dt )
|
39
|
+
dt < 10.days.from_now.end_of_day
|
40
|
+
end
|
41
|
+
|
42
|
+
#
|
43
|
+
# Is the date in the past?
|
44
|
+
#
|
45
|
+
def self.is_past?( dt )
|
46
|
+
dt < Time.now.beginning_of_day
|
47
|
+
end
|
48
|
+
|
49
|
+
#
|
50
|
+
# Is the date in the future?
|
51
|
+
#
|
52
|
+
def self.is_future?( dt )
|
53
|
+
dt > Time.now.end_of_day
|
54
|
+
end
|
55
|
+
|
56
|
+
#
|
57
|
+
# Is the given date today?
|
58
|
+
#
|
59
|
+
def self.is_today?( dt )
|
60
|
+
return false if dt.blank?
|
61
|
+
dt = Chronic.parse( dt ) if dt.is_a? String
|
62
|
+
return false if dt <= ::Time.now.beginning_of_day
|
63
|
+
return false if dt >= ::Time.now.end_of_day
|
64
|
+
return true
|
65
|
+
end
|
66
|
+
|
67
|
+
#
|
68
|
+
# Is the given date tomorrow?
|
69
|
+
#
|
70
|
+
def self.is_tomorrow?( dt )
|
71
|
+
return false if dt.blank?
|
72
|
+
dt = Chronic.parse( dt ) if dt.is_a? String
|
73
|
+
return false if dt <= ( ::Time.now.beginning_of_day + 1.day )
|
74
|
+
return false if dt >= ( ::Time.now.end_of_day + 1.day )
|
75
|
+
return true
|
76
|
+
end
|
77
|
+
|
78
|
+
#
|
79
|
+
# Is the given date yesterday?
|
80
|
+
#
|
81
|
+
def self.is_yesterday?( dt )
|
82
|
+
return false if dt.blank?
|
83
|
+
dt = Chronic.parse( dt ) if dt.is_a? String
|
84
|
+
return false if dt <= ( ::Time.now.beginning_of_day - 1.day )
|
85
|
+
return false if dt >= ( ::Time.now.end_of_day - 1.day )
|
86
|
+
return true
|
87
|
+
end
|
88
|
+
|
89
|
+
#
|
90
|
+
# Is the given date this week?
|
91
|
+
#
|
92
|
+
def self.is_this_week?( dt )
|
93
|
+
return false if dt.blank?
|
94
|
+
dt = Chronic.parse( dt ) if dt.is_a?( String )
|
95
|
+
return false if dt <= ::Time.now.beginning_of_week( start_day = :sunday )
|
96
|
+
return false if dt >= ::Time.now.end_of_week( start_day = :sunday )
|
97
|
+
return true
|
98
|
+
end
|
99
|
+
|
100
|
+
end
|
@@ -10,6 +10,7 @@ module GlooLang
|
|
10
10
|
|
11
11
|
KEYWORD = 'time'.freeze
|
12
12
|
KEYWORD_SHORT = 'time'.freeze
|
13
|
+
DEFAULT_FORMAT = '%I:%M:%S %P'.freeze
|
13
14
|
|
14
15
|
#
|
15
16
|
# The name of the object type.
|
@@ -25,6 +26,21 @@ module GlooLang
|
|
25
26
|
return KEYWORD_SHORT
|
26
27
|
end
|
27
28
|
|
29
|
+
#
|
30
|
+
# Set the value with any necessary type conversions.
|
31
|
+
#
|
32
|
+
def set_value( new_value )
|
33
|
+
if DtTools.is_dt_type? new_value
|
34
|
+
self.value = new_value
|
35
|
+
else
|
36
|
+
self.value = @engine.converter.convert( new_value, 'Time', nil )
|
37
|
+
end
|
38
|
+
|
39
|
+
if DtTools.is_dt_type? self.value
|
40
|
+
self.value = self.value.strftime( DEFAULT_FORMAT )
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
28
44
|
# ---------------------------------------------------------------------
|
29
45
|
# Messages
|
30
46
|
# ---------------------------------------------------------------------
|
@@ -40,9 +56,8 @@ module GlooLang
|
|
40
56
|
# Set to the current time.
|
41
57
|
#
|
42
58
|
def msg_now
|
43
|
-
|
44
|
-
self.value
|
45
|
-
@engine.heap.it.set_to t
|
59
|
+
self.set_value( DateTime.now )
|
60
|
+
@engine.heap.it.set_to self.value
|
46
61
|
end
|
47
62
|
|
48
63
|
end
|
@@ -114,8 +114,11 @@ module GlooLang
|
|
114
114
|
@engine.log.debug "posting to: #{uri}"
|
115
115
|
body = self.body_as_json
|
116
116
|
@engine.log.debug "posting body: #{body}"
|
117
|
-
|
118
|
-
|
117
|
+
result = GlooLang::Objs::HttpPost.post_json( uri, body, skip_ssl_verify? )
|
118
|
+
@engine.log.debug result.code
|
119
|
+
@engine.log.debug result.message
|
120
|
+
|
121
|
+
self.update_result result.body
|
119
122
|
end
|
120
123
|
|
121
124
|
# ---------------------------------------------------------------------
|
@@ -135,10 +138,7 @@ module GlooLang
|
|
135
138
|
request.content_type = 'application/json'
|
136
139
|
request.body = body
|
137
140
|
|
138
|
-
|
139
|
-
@engine.log.debug result.code
|
140
|
-
@engine.log.debug result.message
|
141
|
-
return result.body
|
141
|
+
return http.request( request ) # returns Net::HTTPResponse object
|
142
142
|
end
|
143
143
|
end
|
144
144
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gloo-lang
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.4.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Eric Crane
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-05-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -214,9 +214,11 @@ files:
|
|
214
214
|
- lib/gloo_lang/app/platform.rb
|
215
215
|
- lib/gloo_lang/app/settings.rb
|
216
216
|
- lib/gloo_lang/convert/converter.rb
|
217
|
+
- lib/gloo_lang/convert/string_to_date.rb
|
217
218
|
- lib/gloo_lang/convert/string_to_datetime.rb
|
218
219
|
- lib/gloo_lang/convert/string_to_decimal.rb
|
219
220
|
- lib/gloo_lang/convert/string_to_integer.rb
|
221
|
+
- lib/gloo_lang/convert/string_to_time.rb
|
220
222
|
- lib/gloo_lang/core/baseo.rb
|
221
223
|
- lib/gloo_lang/core/dictionary.rb
|
222
224
|
- lib/gloo_lang/core/error.rb
|
@@ -264,6 +266,7 @@ files:
|
|
264
266
|
- lib/gloo_lang/objs/data/table.rb
|
265
267
|
- lib/gloo_lang/objs/dt/date.rb
|
266
268
|
- lib/gloo_lang/objs/dt/datetime.rb
|
269
|
+
- lib/gloo_lang/objs/dt/dt_tools.rb
|
267
270
|
- lib/gloo_lang/objs/dt/time.rb
|
268
271
|
- lib/gloo_lang/objs/ror/erb.rb
|
269
272
|
- lib/gloo_lang/objs/ror/eval.rb
|