gloo 0.3.0 → 0.5.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 +4 -4
- data/.DS_Store +0 -0
- data/.rubocop.yml +73 -0
- data/Gemfile +2 -2
- data/Gemfile.lock +86 -83
- data/Rakefile +7 -6
- data/bin/console +4 -4
- data/gloo.gemspec +22 -18
- data/lib/gloo.rb +6 -6
- data/lib/gloo/app/args.rb +30 -31
- data/lib/gloo/app/engine.rb +80 -30
- data/lib/gloo/app/help.rb +17 -11
- data/lib/gloo/app/info.rb +3 -3
- data/lib/gloo/app/log.rb +17 -17
- data/lib/gloo/app/mode.rb +4 -4
- data/lib/gloo/app/settings.rb +51 -41
- data/lib/gloo/convert/string_to_datetime.rb +21 -0
- data/lib/gloo/convert/string_to_decimal.rb +20 -0
- data/lib/gloo/convert/string_to_integer.rb +20 -0
- data/lib/gloo/core/baseo.rb +7 -7
- data/lib/gloo/core/dictionary.rb +30 -27
- data/lib/gloo/core/error.rb +50 -0
- data/lib/gloo/core/event_manager.rb +17 -23
- data/lib/gloo/core/factory.rb +149 -39
- data/lib/gloo/core/gloo_system.rb +121 -54
- data/lib/gloo/core/heap.rb +15 -13
- data/lib/gloo/core/it.rb +5 -5
- data/lib/gloo/core/literal.rb +7 -7
- data/lib/gloo/core/obj.rb +138 -79
- data/lib/gloo/core/obj_finder.rb +9 -14
- data/lib/gloo/core/op.rb +8 -8
- data/lib/gloo/core/parser.rb +27 -26
- data/lib/gloo/core/pn.rb +68 -52
- data/lib/gloo/core/script.rb +7 -7
- data/lib/gloo/core/tokens.rb +39 -41
- data/lib/gloo/core/verb.rb +30 -19
- data/lib/gloo/exec/dispatch.rb +30 -0
- data/lib/gloo/exec/runner.rb +43 -0
- data/lib/gloo/expr/expression.rb +36 -43
- data/lib/gloo/expr/l_boolean.rb +7 -6
- data/lib/gloo/expr/l_decimal.rb +34 -0
- data/lib/gloo/expr/l_integer.rb +5 -4
- data/lib/gloo/expr/l_string.rb +13 -15
- data/lib/gloo/expr/op_div.rb +5 -5
- data/lib/gloo/expr/op_minus.rb +5 -5
- data/lib/gloo/expr/op_mult.rb +5 -5
- data/lib/gloo/expr/op_plus.rb +7 -7
- data/lib/gloo/objs/basic/alias.rb +111 -0
- data/lib/gloo/objs/basic/boolean.rb +63 -38
- data/lib/gloo/objs/basic/container.rb +71 -12
- data/lib/gloo/objs/basic/decimal.rb +96 -0
- data/lib/gloo/objs/basic/integer.rb +45 -16
- data/lib/gloo/objs/basic/script.rb +62 -38
- data/lib/gloo/objs/basic/string.rb +47 -15
- data/lib/gloo/objs/basic/text.rb +69 -21
- data/lib/gloo/objs/basic/untyped.rb +35 -10
- data/lib/gloo/objs/cli/banner.rb +137 -0
- data/lib/gloo/objs/cli/bar.rb +141 -0
- data/lib/gloo/objs/cli/colorize.rb +54 -24
- data/lib/gloo/objs/cli/confirm.rb +63 -29
- data/lib/gloo/objs/cli/menu.rb +236 -0
- data/lib/gloo/objs/cli/menu_item.rb +128 -0
- data/lib/gloo/objs/cli/pastel.rb +120 -0
- data/lib/gloo/objs/cli/prompt.rb +73 -31
- data/lib/gloo/objs/cli/select.rb +153 -0
- data/lib/gloo/objs/ctrl/each.rb +128 -61
- data/lib/gloo/objs/ctrl/repeat.rb +129 -0
- data/lib/gloo/objs/data/markdown.rb +109 -0
- data/lib/gloo/objs/data/table.rb +168 -0
- data/lib/gloo/objs/dev/git.rb +98 -64
- data/lib/gloo/objs/dt/date.rb +72 -0
- data/lib/gloo/objs/dt/datetime.rb +84 -0
- data/lib/gloo/objs/dt/time.rb +72 -0
- data/lib/gloo/objs/ror/erb.rb +82 -41
- data/lib/gloo/objs/ror/eval.rb +73 -31
- data/lib/gloo/objs/snd/play.rb +71 -0
- data/lib/gloo/objs/snd/say.rb +120 -0
- data/lib/gloo/objs/system/file_handle.rb +129 -48
- data/lib/gloo/objs/system/system.rb +84 -38
- data/lib/gloo/objs/web/http_get.rb +103 -46
- data/lib/gloo/objs/web/http_post.rb +70 -44
- data/lib/gloo/objs/web/json.rb +155 -0
- data/lib/gloo/objs/web/slack.rb +89 -58
- data/lib/gloo/objs/web/teams.rb +88 -53
- data/lib/gloo/objs/web/uri.rb +160 -0
- data/lib/gloo/persist/file_loader.rb +95 -85
- data/lib/gloo/persist/file_saver.rb +12 -12
- data/lib/gloo/persist/file_storage.rb +15 -15
- data/lib/gloo/persist/line_splitter.rb +79 -0
- data/lib/gloo/persist/persist_man.rb +63 -39
- data/lib/gloo/utils/words.rb +2 -2
- data/lib/gloo/verbs/alert.rb +67 -16
- data/lib/gloo/verbs/beep.rb +70 -0
- data/lib/gloo/verbs/cls.rb +67 -0
- data/lib/gloo/verbs/context.rb +61 -21
- data/lib/gloo/verbs/create.rb +52 -21
- data/lib/gloo/verbs/help.rb +186 -27
- data/lib/gloo/verbs/if.rb +55 -21
- data/lib/gloo/verbs/list.rb +55 -24
- data/lib/gloo/verbs/load.rb +47 -12
- data/lib/gloo/verbs/move.rb +128 -0
- data/lib/gloo/verbs/put.rb +90 -34
- data/lib/gloo/verbs/quit.rb +43 -12
- data/lib/gloo/verbs/run.rb +63 -18
- data/lib/gloo/verbs/save.rb +45 -10
- data/lib/gloo/verbs/show.rb +56 -22
- data/lib/gloo/verbs/tell.rb +45 -13
- data/lib/gloo/verbs/unless.rb +56 -21
- data/lib/gloo/verbs/version.rb +42 -12
- data/lib/gloo/verbs/wait.rb +73 -0
- data/lib/run.rb +5 -5
- metadata +90 -12
data/lib/gloo/objs/web/slack.rb
CHANGED
|
@@ -10,73 +10,73 @@ require 'json'
|
|
|
10
10
|
module Gloo
|
|
11
11
|
module Objs
|
|
12
12
|
class Slack < Gloo::Core::Obj
|
|
13
|
-
|
|
14
|
-
KEYWORD = 'slack'
|
|
15
|
-
KEYWORD_SHORT = 'slack'
|
|
16
|
-
URL = 'uri'
|
|
17
|
-
MSG = 'message'
|
|
18
|
-
USER = 'username'
|
|
19
|
-
CHANNEL = 'channel'
|
|
20
|
-
ICON = 'icon_emoji'
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
#
|
|
13
|
+
|
|
14
|
+
KEYWORD = 'slack'.freeze
|
|
15
|
+
KEYWORD_SHORT = 'slack'.freeze
|
|
16
|
+
URL = 'uri'.freeze
|
|
17
|
+
MSG = 'message'.freeze
|
|
18
|
+
USER = 'username'.freeze
|
|
19
|
+
CHANNEL = 'channel'.freeze
|
|
20
|
+
ICON = 'icon_emoji'.freeze
|
|
21
|
+
|
|
22
|
+
ATTACHMENT = 'attachment'.freeze
|
|
23
|
+
TITLE = 'title'.freeze
|
|
24
|
+
TEXT = 'text'.freeze
|
|
25
|
+
|
|
26
|
+
#
|
|
27
27
|
# The name of the object type.
|
|
28
|
-
#
|
|
28
|
+
#
|
|
29
29
|
def self.typename
|
|
30
30
|
return KEYWORD
|
|
31
31
|
end
|
|
32
32
|
|
|
33
|
-
#
|
|
33
|
+
#
|
|
34
34
|
# The short name of the object type.
|
|
35
|
-
#
|
|
35
|
+
#
|
|
36
36
|
def self.short_typename
|
|
37
37
|
return KEYWORD_SHORT
|
|
38
38
|
end
|
|
39
|
-
|
|
40
|
-
#
|
|
39
|
+
|
|
40
|
+
#
|
|
41
41
|
# Get the URI from the child object.
|
|
42
42
|
# Returns nil if there is none.
|
|
43
|
-
#
|
|
44
|
-
def
|
|
43
|
+
#
|
|
44
|
+
def uri_value
|
|
45
45
|
uri = find_child URL
|
|
46
46
|
return nil unless uri
|
|
47
|
+
|
|
47
48
|
return uri.value
|
|
48
49
|
end
|
|
49
50
|
|
|
50
|
-
|
|
51
|
+
#
|
|
51
52
|
# Get the URI from the child object.
|
|
52
53
|
# Returns nil if there is none.
|
|
53
|
-
#
|
|
54
|
-
def
|
|
54
|
+
#
|
|
55
|
+
def attachment_value
|
|
55
56
|
o = find_child ATTACHMENT
|
|
56
57
|
return nil unless o
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
return [{ 'title' => title.value,
|
|
58
|
+
|
|
59
|
+
title = o.find_child TITLE
|
|
60
|
+
text = o.find_child TEXT
|
|
61
|
+
return [ { 'title' => title.value,
|
|
62
|
+
'text' => text.value } ]
|
|
61
63
|
end
|
|
62
|
-
|
|
63
|
-
#
|
|
64
|
-
# Get all the children of the body container and
|
|
64
|
+
|
|
65
|
+
#
|
|
66
|
+
# Get all the children of the body container and
|
|
65
67
|
# convert to JSON that will be sent in the HTTP body.
|
|
66
|
-
#
|
|
67
|
-
def
|
|
68
|
+
#
|
|
69
|
+
def body_as_json
|
|
68
70
|
h = { 'text' => find_child( MSG ).value,
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
h[ 'attachments' ] = o if o
|
|
71
|
+
'username' => find_child( USER ).value,
|
|
72
|
+
'channel' => find_child( CHANNEL ).value,
|
|
73
|
+
'icon_emoji' => find_child( ICON ).value }
|
|
74
|
+
|
|
75
|
+
o = attachment_value
|
|
76
|
+
h[ 'attachments' ] = o if o
|
|
76
77
|
return h.to_json
|
|
77
78
|
end
|
|
78
79
|
|
|
79
|
-
|
|
80
80
|
# ---------------------------------------------------------------------
|
|
81
81
|
# Children
|
|
82
82
|
# ---------------------------------------------------------------------
|
|
@@ -87,40 +87,71 @@ module Gloo
|
|
|
87
87
|
def add_children_on_create?
|
|
88
88
|
return true
|
|
89
89
|
end
|
|
90
|
-
|
|
90
|
+
|
|
91
91
|
# Add children to this object.
|
|
92
|
-
# This is used by containers to add children needed
|
|
92
|
+
# This is used by containers to add children needed
|
|
93
93
|
# for default configurations.
|
|
94
94
|
def add_default_children
|
|
95
95
|
fac = $engine.factory
|
|
96
|
-
fac.
|
|
97
|
-
fac.
|
|
98
|
-
fac.
|
|
99
|
-
fac.
|
|
100
|
-
fac.
|
|
96
|
+
fac.create_string URL, 'https://hooks.slack.com/services/...', self
|
|
97
|
+
fac.create_string MSG, 'textual message', self
|
|
98
|
+
fac.create_string USER, 'Slack Bot', self
|
|
99
|
+
fac.create_string CHANNEL, 'general', self
|
|
100
|
+
fac.create_string ICON, ':ghost:', self
|
|
101
101
|
end
|
|
102
102
|
|
|
103
|
-
|
|
104
103
|
# ---------------------------------------------------------------------
|
|
105
104
|
# Messages
|
|
106
105
|
# ---------------------------------------------------------------------
|
|
107
106
|
|
|
108
|
-
#
|
|
107
|
+
#
|
|
109
108
|
# Get a list of message names that this object receives.
|
|
110
|
-
#
|
|
109
|
+
#
|
|
111
110
|
def self.messages
|
|
112
|
-
return super + [
|
|
111
|
+
return super + [ 'run' ]
|
|
113
112
|
end
|
|
114
|
-
|
|
113
|
+
|
|
115
114
|
# Post the content to the endpoint.
|
|
116
115
|
def msg_run
|
|
117
|
-
uri =
|
|
116
|
+
uri = uri_value
|
|
118
117
|
return unless uri
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
118
|
+
|
|
119
|
+
Gloo::Objs::HttpPost.post_json uri, body_as_json, true
|
|
120
|
+
end
|
|
121
|
+
|
|
122
|
+
# ---------------------------------------------------------------------
|
|
123
|
+
# Help
|
|
124
|
+
# ---------------------------------------------------------------------
|
|
125
|
+
|
|
126
|
+
#
|
|
127
|
+
# Get help for this object type.
|
|
128
|
+
#
|
|
129
|
+
def self.help
|
|
130
|
+
return <<~TEXT
|
|
131
|
+
SLACK OBJECT TYPE
|
|
132
|
+
NAME: slack
|
|
133
|
+
SHORTCUT: slack
|
|
134
|
+
|
|
135
|
+
DESCRIPTION
|
|
136
|
+
Send message to channel in Slack.
|
|
137
|
+
|
|
138
|
+
CHILDREN
|
|
139
|
+
uri - string - 'https://hooks.slack.com/services/...'
|
|
140
|
+
The URI with access to the Slack channel.
|
|
141
|
+
message - string - 'textual message'
|
|
142
|
+
Message to send to Slack.
|
|
143
|
+
username - string - 'Slack Bot'
|
|
144
|
+
Attribute the message to this user.
|
|
145
|
+
channel - string - 'general'
|
|
146
|
+
The name of the channel for the post.
|
|
147
|
+
icon_emoji - string - ':ghost:'
|
|
148
|
+
The emoji to use for the attribution.
|
|
149
|
+
|
|
150
|
+
MESSAGES
|
|
151
|
+
run - Post the message to Slack.
|
|
152
|
+
TEXT
|
|
122
153
|
end
|
|
123
|
-
|
|
154
|
+
|
|
124
155
|
end
|
|
125
156
|
end
|
|
126
157
|
end
|
data/lib/gloo/objs/web/teams.rb
CHANGED
|
@@ -10,63 +10,59 @@ require 'json'
|
|
|
10
10
|
module Gloo
|
|
11
11
|
module Objs
|
|
12
12
|
class Teams < Gloo::Core::Obj
|
|
13
|
-
|
|
14
|
-
KEYWORD = 'teams'
|
|
15
|
-
KEYWORD_SHORT = 'team'
|
|
16
|
-
URL = 'uri'
|
|
17
|
-
MSG = 'message'
|
|
18
|
-
TITLE = 'title'
|
|
19
|
-
COLOR = 'color'
|
|
20
|
-
|
|
21
|
-
#
|
|
13
|
+
|
|
14
|
+
KEYWORD = 'teams'.freeze
|
|
15
|
+
KEYWORD_SHORT = 'team'.freeze
|
|
16
|
+
URL = 'uri'.freeze
|
|
17
|
+
MSG = 'message'.freeze
|
|
18
|
+
TITLE = 'title'.freeze
|
|
19
|
+
COLOR = 'color'.freeze
|
|
20
|
+
|
|
21
|
+
#
|
|
22
22
|
# The name of the object type.
|
|
23
|
-
#
|
|
23
|
+
#
|
|
24
24
|
def self.typename
|
|
25
25
|
return KEYWORD
|
|
26
26
|
end
|
|
27
27
|
|
|
28
|
-
#
|
|
28
|
+
#
|
|
29
29
|
# The short name of the object type.
|
|
30
|
-
#
|
|
30
|
+
#
|
|
31
31
|
def self.short_typename
|
|
32
32
|
return KEYWORD_SHORT
|
|
33
33
|
end
|
|
34
|
-
|
|
35
|
-
#
|
|
34
|
+
|
|
35
|
+
#
|
|
36
36
|
# Get the URI from the child object.
|
|
37
37
|
# Returns nil if there is none.
|
|
38
|
-
#
|
|
39
|
-
def
|
|
38
|
+
#
|
|
39
|
+
def uri_value
|
|
40
40
|
uri = find_child URL
|
|
41
41
|
return nil unless uri
|
|
42
|
+
|
|
42
43
|
return uri.value
|
|
43
44
|
end
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
45
|
+
|
|
46
|
+
# Get the color value.
|
|
47
|
+
def color_value
|
|
48
|
+
c = find_child COLOR
|
|
48
49
|
return nil unless c
|
|
50
|
+
|
|
49
51
|
return c.value
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
#
|
|
53
|
-
# Get all the children of the body container and
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
#
|
|
55
|
+
# Get all the children of the body container and
|
|
54
56
|
# convert to JSON that will be sent in the HTTP body.
|
|
55
|
-
#
|
|
56
|
-
def
|
|
57
|
+
#
|
|
58
|
+
def body_as_json
|
|
57
59
|
h = { 'title' => find_child( TITLE ).value,
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
color = get_color
|
|
62
|
-
if color
|
|
63
|
-
h[ 'themeColor' ] = color
|
|
64
|
-
end
|
|
65
|
-
|
|
60
|
+
'text' => find_child( MSG ).value }
|
|
61
|
+
color = color_value
|
|
62
|
+
h[ 'themeColor' ] = color if color
|
|
66
63
|
return h.to_json
|
|
67
64
|
end
|
|
68
65
|
|
|
69
|
-
|
|
70
66
|
# ---------------------------------------------------------------------
|
|
71
67
|
# Children
|
|
72
68
|
# ---------------------------------------------------------------------
|
|
@@ -77,41 +73,80 @@ module Gloo
|
|
|
77
73
|
def add_children_on_create?
|
|
78
74
|
return true
|
|
79
75
|
end
|
|
80
|
-
|
|
76
|
+
|
|
81
77
|
# Add children to this object.
|
|
82
|
-
# This is used by containers to add children needed
|
|
78
|
+
# This is used by containers to add children needed
|
|
83
79
|
# for default configurations.
|
|
84
80
|
def add_default_children
|
|
85
81
|
fac = $engine.factory
|
|
86
|
-
fac.create
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
82
|
+
fac.create( { :name => URL,
|
|
83
|
+
:type => 'string',
|
|
84
|
+
:value => 'https://outlook.office.com/webhook/...',
|
|
85
|
+
:parent => self } )
|
|
86
|
+
fac.create( { :name => TITLE,
|
|
87
|
+
:type => 'string',
|
|
88
|
+
:value => '',
|
|
89
|
+
:parent => self } )
|
|
90
|
+
fac.create( { :name => COLOR,
|
|
91
|
+
:type => 'color',
|
|
92
|
+
:value => '008000',
|
|
93
|
+
:parent => self } )
|
|
94
|
+
fac.create( { :name => MSG,
|
|
95
|
+
:type => 'string',
|
|
96
|
+
:value => '',
|
|
97
|
+
:parent => self } )
|
|
90
98
|
end
|
|
91
99
|
|
|
92
|
-
|
|
93
100
|
# ---------------------------------------------------------------------
|
|
94
101
|
# Messages
|
|
95
102
|
# ---------------------------------------------------------------------
|
|
96
103
|
|
|
97
|
-
#
|
|
104
|
+
#
|
|
98
105
|
# Get a list of message names that this object receives.
|
|
99
|
-
#
|
|
106
|
+
#
|
|
100
107
|
def self.messages
|
|
101
|
-
return super + [
|
|
108
|
+
return super + [ 'run' ]
|
|
102
109
|
end
|
|
103
|
-
|
|
110
|
+
|
|
104
111
|
# Post the content to the endpoint.
|
|
105
112
|
def msg_run
|
|
106
|
-
uri =
|
|
113
|
+
uri = uri_value
|
|
107
114
|
return unless uri
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
115
|
+
|
|
116
|
+
Gloo::Objs::HttpPost.post_json uri, body_as_json, true
|
|
117
|
+
end
|
|
118
|
+
|
|
119
|
+
# ---------------------------------------------------------------------
|
|
120
|
+
# Help
|
|
121
|
+
# ---------------------------------------------------------------------
|
|
122
|
+
|
|
123
|
+
#
|
|
124
|
+
# Get help for this object type.
|
|
125
|
+
#
|
|
126
|
+
def self.help
|
|
127
|
+
return <<~TEXT
|
|
128
|
+
TEAMS OBJECT TYPE
|
|
129
|
+
NAME: teams
|
|
130
|
+
SHORTCUT: team
|
|
131
|
+
|
|
132
|
+
DESCRIPTION
|
|
133
|
+
Send message to channel in Teams.
|
|
134
|
+
|
|
135
|
+
CHILDREN
|
|
136
|
+
uri - string - 'https://outlook.office.com/webhook/...'
|
|
137
|
+
The URI with access to the Teams channel.
|
|
138
|
+
title - string
|
|
139
|
+
Message title; header.
|
|
140
|
+
color - string - '008000'
|
|
141
|
+
Color theme for the message.
|
|
142
|
+
message - string
|
|
143
|
+
The message to post in Teams.
|
|
144
|
+
|
|
145
|
+
MESSAGES
|
|
146
|
+
run - Post the message to Teams.
|
|
147
|
+
TEXT
|
|
113
148
|
end
|
|
114
|
-
|
|
149
|
+
|
|
115
150
|
end
|
|
116
151
|
end
|
|
117
152
|
end
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
# Author:: Eric Crane (mailto:eric.crane@mac.com)
|
|
2
|
+
# Copyright:: Copyright (c) 2020 Eric Crane. All rights reserved.
|
|
3
|
+
#
|
|
4
|
+
# A URI (URL).
|
|
5
|
+
#
|
|
6
|
+
require 'uri'
|
|
7
|
+
|
|
8
|
+
module Gloo
|
|
9
|
+
module Objs
|
|
10
|
+
class Uri < Gloo::Core::Obj
|
|
11
|
+
|
|
12
|
+
KEYWORD = 'uri'.freeze
|
|
13
|
+
KEYWORD_SHORT = 'url'.freeze
|
|
14
|
+
|
|
15
|
+
#
|
|
16
|
+
# The name of the object type.
|
|
17
|
+
#
|
|
18
|
+
def self.typename
|
|
19
|
+
return KEYWORD
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
#
|
|
23
|
+
# The short name of the object type.
|
|
24
|
+
#
|
|
25
|
+
def self.short_typename
|
|
26
|
+
return KEYWORD_SHORT
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
#
|
|
30
|
+
# Set the value with any necessary type conversions.
|
|
31
|
+
#
|
|
32
|
+
def set_value( new_value )
|
|
33
|
+
self.value = new_value.to_s
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
#
|
|
37
|
+
# Does this object support multi-line values?
|
|
38
|
+
# Initially only true for scripts.
|
|
39
|
+
#
|
|
40
|
+
def multiline_value?
|
|
41
|
+
return false
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
# ---------------------------------------------------------------------
|
|
45
|
+
# Messages
|
|
46
|
+
# ---------------------------------------------------------------------
|
|
47
|
+
|
|
48
|
+
#
|
|
49
|
+
# Get a list of message names that this object receives.
|
|
50
|
+
#
|
|
51
|
+
def self.messages
|
|
52
|
+
basic = %w[open]
|
|
53
|
+
gets = %w[get_scheme get_host get_path]
|
|
54
|
+
more = %w[get_query get_fragment]
|
|
55
|
+
return super + basic + gets + more
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
#
|
|
59
|
+
# Get the URI fragment that comes after the '#'
|
|
60
|
+
# in the URL. Might be used to scroll down in the page.
|
|
61
|
+
#
|
|
62
|
+
def msg_get_fragment
|
|
63
|
+
return unless value
|
|
64
|
+
|
|
65
|
+
o = URI( value ).fragment
|
|
66
|
+
$engine.heap.it.set_to o
|
|
67
|
+
return o
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
#
|
|
71
|
+
# Get the URI query parameters.
|
|
72
|
+
# Example: id=121
|
|
73
|
+
#
|
|
74
|
+
def msg_get_query
|
|
75
|
+
return unless value
|
|
76
|
+
|
|
77
|
+
o = URI( value ).query
|
|
78
|
+
$engine.heap.it.set_to o
|
|
79
|
+
return o
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
#
|
|
83
|
+
# Get the URI path.
|
|
84
|
+
# Example: /posts
|
|
85
|
+
#
|
|
86
|
+
def msg_get_path
|
|
87
|
+
return unless value
|
|
88
|
+
|
|
89
|
+
o = URI( value ).path
|
|
90
|
+
$engine.heap.it.set_to o
|
|
91
|
+
return o
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
#
|
|
95
|
+
# Get the URI host.
|
|
96
|
+
# Example: google.com
|
|
97
|
+
#
|
|
98
|
+
def msg_get_host
|
|
99
|
+
return unless value
|
|
100
|
+
|
|
101
|
+
o = URI( value ).host
|
|
102
|
+
$engine.heap.it.set_to o
|
|
103
|
+
return o
|
|
104
|
+
end
|
|
105
|
+
|
|
106
|
+
#
|
|
107
|
+
# Get the URI Scheme.
|
|
108
|
+
# Example: http
|
|
109
|
+
#
|
|
110
|
+
def msg_get_scheme
|
|
111
|
+
return unless value
|
|
112
|
+
|
|
113
|
+
o = URI( value ).scheme
|
|
114
|
+
$engine.heap.it.set_to o
|
|
115
|
+
return o
|
|
116
|
+
end
|
|
117
|
+
|
|
118
|
+
#
|
|
119
|
+
# Open the URI in the default browser.
|
|
120
|
+
#
|
|
121
|
+
def msg_open
|
|
122
|
+
return unless value
|
|
123
|
+
|
|
124
|
+
cmd = Gloo::Core::GlooSystem.open_for_platform
|
|
125
|
+
cmd_with_param = "#{cmd} \"#{value}\""
|
|
126
|
+
`#{cmd_with_param}`
|
|
127
|
+
end
|
|
128
|
+
|
|
129
|
+
# ---------------------------------------------------------------------
|
|
130
|
+
# Help
|
|
131
|
+
# ---------------------------------------------------------------------
|
|
132
|
+
|
|
133
|
+
#
|
|
134
|
+
# Get help for this object type.
|
|
135
|
+
#
|
|
136
|
+
def self.help
|
|
137
|
+
return <<~TEXT
|
|
138
|
+
URI OBJECT TYPE
|
|
139
|
+
NAME: uri
|
|
140
|
+
SHORTCUT: url
|
|
141
|
+
|
|
142
|
+
DESCRIPTION
|
|
143
|
+
A URI or URL.
|
|
144
|
+
|
|
145
|
+
CHILDREN
|
|
146
|
+
None
|
|
147
|
+
|
|
148
|
+
MESSAGES
|
|
149
|
+
open - open the URL in the default browser
|
|
150
|
+
get_scheme - get the URI scheme; example: http
|
|
151
|
+
get_host - get the URI host; example: google.com
|
|
152
|
+
get_path - get the URI resource path; example: /post
|
|
153
|
+
get_query - get the URI query parameterse; example: id=121
|
|
154
|
+
get_fragment - get the URI fragment
|
|
155
|
+
TEXT
|
|
156
|
+
end
|
|
157
|
+
|
|
158
|
+
end
|
|
159
|
+
end
|
|
160
|
+
end
|