gloo 0.5.4 → 0.7.2
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/.gitignore +1 -0
- data/Gemfile.lock +1 -1
- data/lib/gloo/app/args.rb +48 -6
- data/lib/gloo/app/engine.rb +60 -38
- data/lib/gloo/app/help.rb +137 -16
- data/lib/gloo/app/info.rb +3 -1
- data/lib/gloo/app/log.rb +23 -0
- data/lib/gloo/app/mode.rb +2 -0
- data/lib/gloo/app/settings.rb +98 -47
- data/lib/gloo/convert/converter.rb +35 -0
- data/lib/gloo/convert/string_to_datetime.rb +1 -1
- data/lib/gloo/convert/string_to_decimal.rb +1 -1
- data/lib/gloo/convert/string_to_integer.rb +1 -1
- data/lib/gloo/core/dictionary.rb +99 -22
- data/lib/gloo/core/error.rb +19 -8
- data/lib/gloo/core/event_manager.rb +4 -0
- data/lib/gloo/core/factory.rb +11 -0
- data/lib/gloo/core/gloo_system.rb +1 -1
- data/lib/gloo/core/heap.rb +11 -3
- data/lib/gloo/core/here.rb +36 -0
- data/lib/gloo/core/it.rb +6 -0
- data/lib/gloo/core/literal.rb +5 -0
- data/lib/gloo/core/obj.rb +22 -0
- data/lib/gloo/core/op.rb +7 -0
- data/lib/gloo/core/parser.rb +6 -0
- data/lib/gloo/core/pn.rb +38 -0
- data/lib/gloo/core/tokens.rb +66 -22
- data/lib/gloo/core/verb.rb +12 -0
- data/lib/gloo/exec/action.rb +48 -0
- data/lib/gloo/exec/dispatch.rb +15 -5
- data/lib/gloo/exec/exec_env.rb +74 -0
- data/lib/gloo/exec/runner.rb +4 -2
- data/lib/gloo/{core → exec}/script.rb +21 -9
- data/lib/gloo/exec/stack.rb +78 -0
- data/lib/gloo/expr/expression.rb +26 -4
- data/lib/gloo/expr/l_boolean.rb +6 -0
- data/lib/gloo/expr/l_decimal.rb +5 -0
- data/lib/gloo/expr/l_integer.rb +7 -0
- data/lib/gloo/expr/l_string.rb +7 -0
- data/lib/gloo/expr/op_div.rb +2 -0
- data/lib/gloo/expr/op_minus.rb +2 -0
- data/lib/gloo/expr/op_mult.rb +2 -0
- data/lib/gloo/expr/op_plus.rb +2 -0
- data/lib/gloo/help/app/application.txt +22 -0
- data/lib/gloo/help/app/configuration.txt +7 -0
- data/lib/gloo/help/app/default_help.txt +14 -0
- data/lib/gloo/help/app/logging.txt +16 -0
- data/lib/gloo/help/core/color.txt +31 -0
- data/lib/gloo/help/core/error.txt +33 -0
- data/lib/gloo/help/core/events.txt +21 -0
- data/lib/gloo/help/core/gloo_system.txt +54 -0
- data/lib/gloo/help/core/here.txt +30 -0
- data/lib/gloo/help/core/it.txt +23 -0
- data/lib/gloo/help/core/ops.txt +16 -0
- data/lib/gloo/help/core/pathname.txt +29 -0
- data/lib/gloo/help/objs/basic/alias.txt +36 -0
- data/lib/gloo/help/objs/basic/boolean.txt +28 -0
- data/lib/gloo/help/objs/basic/container.txt +33 -0
- data/lib/gloo/help/objs/basic/decimal.txt +28 -0
- data/lib/gloo/help/objs/basic/integer.txt +27 -0
- data/lib/gloo/help/objs/basic/script.txt +29 -0
- data/lib/gloo/help/objs/basic/string.txt +28 -0
- data/lib/gloo/help/objs/basic/text.txt +27 -0
- data/lib/gloo/help/objs/basic/untyped.txt +22 -0
- data/lib/gloo/help/objs/cli/banner.txt +49 -0
- data/lib/gloo/help/objs/cli/bar.txt +34 -0
- data/lib/gloo/help/objs/cli/colorize.txt +33 -0
- data/lib/gloo/help/objs/cli/confirm.txt +26 -0
- data/lib/gloo/help/objs/cli/menu.txt +44 -0
- data/lib/gloo/help/objs/cli/menu_item.txt +26 -0
- data/lib/gloo/help/objs/cli/pastel.txt +43 -0
- data/lib/gloo/help/objs/cli/prompt.txt +27 -0
- data/lib/gloo/help/objs/cli/select.txt +34 -0
- data/lib/gloo/help/objs/ctrl/each.txt +48 -0
- data/lib/gloo/help/objs/ctrl/repeat.txt +38 -0
- data/lib/gloo/help/objs/data/markdown.txt +25 -0
- data/lib/gloo/help/objs/data/table.txt +46 -0
- data/lib/gloo/help/objs/dev/git_repo.txt +35 -0
- data/lib/gloo/help/objs/dt/date.txt +23 -0
- data/lib/gloo/help/objs/dt/datetime.txt +24 -0
- data/lib/gloo/help/objs/dt/time.txt +23 -0
- data/lib/gloo/help/objs/ror/erb.txt +37 -0
- data/lib/gloo/help/objs/ror/eval.txt +24 -0
- data/lib/gloo/help/objs/snd/play.txt +23 -0
- data/lib/gloo/help/objs/snd/say.txt +28 -0
- data/lib/gloo/help/objs/system/file.txt +41 -0
- data/lib/gloo/help/objs/system/system.txt +32 -0
- data/lib/gloo/help/objs/web/http_get.txt +35 -0
- data/lib/gloo/help/objs/web/http_post.txt +32 -0
- data/lib/gloo/help/objs/web/json.txt +34 -0
- data/lib/gloo/help/objs/web/slack.txt +33 -0
- data/lib/gloo/help/objs/web/teams.txt +30 -0
- data/lib/gloo/help/objs/web/uri.txt +37 -0
- data/lib/gloo/help/verbs/alert.txt +33 -0
- data/lib/gloo/help/verbs/beep.txt +25 -0
- data/lib/gloo/help/verbs/cls.txt +24 -0
- data/lib/gloo/help/verbs/context.txt +43 -0
- data/lib/gloo/help/verbs/create.txt +33 -0
- data/lib/gloo/help/verbs/execute.txt +27 -0
- data/lib/gloo/help/verbs/help.txt +34 -0
- data/lib/gloo/help/verbs/if.txt +37 -0
- data/lib/gloo/help/verbs/list.txt +34 -0
- data/lib/gloo/help/verbs/load.txt +38 -0
- data/lib/gloo/help/verbs/move.txt +42 -0
- data/lib/gloo/help/verbs/put.txt +38 -0
- data/lib/gloo/help/verbs/quit.txt +25 -0
- data/lib/gloo/help/verbs/run.txt +41 -0
- data/lib/gloo/help/verbs/save.txt +26 -0
- data/lib/gloo/help/verbs/show.txt +30 -0
- data/lib/gloo/help/verbs/tell.txt +34 -0
- data/lib/gloo/help/verbs/unless.txt +38 -0
- data/lib/gloo/help/verbs/version.txt +32 -0
- data/lib/gloo/help/verbs/wait.txt +29 -0
- data/lib/gloo/objs/basic/alias.rb +0 -33
- data/lib/gloo/objs/basic/boolean.rb +6 -27
- data/lib/gloo/objs/basic/container.rb +0 -33
- data/lib/gloo/objs/basic/decimal.rb +8 -28
- data/lib/gloo/objs/basic/integer.rb +5 -26
- data/lib/gloo/objs/basic/script.rb +1 -27
- data/lib/gloo/objs/basic/string.rb +6 -26
- data/lib/gloo/objs/basic/text.rb +0 -25
- data/lib/gloo/objs/basic/untyped.rb +0 -26
- data/lib/gloo/objs/cli/banner.rb +0 -29
- data/lib/gloo/objs/cli/bar.rb +0 -29
- data/lib/gloo/objs/cli/colorize.rb +4 -34
- data/lib/gloo/objs/cli/confirm.rb +6 -36
- data/lib/gloo/objs/cli/menu.rb +6 -36
- data/lib/gloo/objs/cli/menu_item.rb +0 -33
- data/lib/gloo/objs/cli/pastel.rb +4 -27
- data/lib/gloo/objs/cli/prompt.rb +4 -28
- data/lib/gloo/objs/cli/select.rb +4 -31
- data/lib/gloo/objs/ctrl/each.rb +33 -33
- data/lib/gloo/objs/ctrl/repeat.rb +8 -29
- data/lib/gloo/objs/data/markdown.rb +0 -25
- data/lib/gloo/objs/data/table.rb +4 -32
- data/lib/gloo/objs/dev/git.rb +12 -30
- data/lib/gloo/objs/dt/date.rb +3 -25
- data/lib/gloo/objs/dt/datetime.rb +4 -26
- data/lib/gloo/objs/dt/time.rb +3 -25
- data/lib/gloo/objs/ror/erb.rb +11 -45
- data/lib/gloo/objs/ror/eval.rb +11 -38
- data/lib/gloo/objs/snd/play.rb +2 -25
- data/lib/gloo/objs/snd/say.rb +9 -31
- data/lib/gloo/objs/system/file_handle.rb +0 -38
- data/lib/gloo/objs/system/system.rb +16 -46
- data/lib/gloo/objs/web/http_get.rb +57 -83
- data/lib/gloo/objs/web/http_post.rb +8 -31
- data/lib/gloo/objs/web/json.rb +11 -31
- data/lib/gloo/objs/web/slack.rb +7 -34
- data/lib/gloo/objs/web/teams.rb +13 -48
- data/lib/gloo/objs/web/uri.rb +0 -29
- data/lib/gloo/persist/file_loader.rb +8 -0
- data/lib/gloo/persist/file_saver.rb +6 -0
- data/lib/gloo/persist/file_storage.rb +2 -0
- data/lib/gloo/persist/line_splitter.rb +2 -0
- data/lib/gloo/persist/persist_man.rb +6 -0
- data/lib/gloo/verbs/alert.rb +30 -44
- data/lib/gloo/verbs/beep.rb +0 -30
- data/lib/gloo/verbs/cls.rb +0 -30
- data/lib/gloo/verbs/context.rb +9 -39
- data/lib/gloo/verbs/create.rb +17 -32
- data/lib/gloo/verbs/execute.rb +52 -0
- data/lib/gloo/verbs/help.rb +151 -115
- data/lib/gloo/verbs/if.rb +46 -44
- data/lib/gloo/verbs/list.rb +36 -54
- data/lib/gloo/verbs/load.rb +8 -37
- data/lib/gloo/verbs/move.rb +12 -51
- data/lib/gloo/verbs/put.rb +28 -52
- data/lib/gloo/verbs/quit.rb +0 -31
- data/lib/gloo/verbs/run.rb +23 -39
- data/lib/gloo/verbs/save.rb +0 -33
- data/lib/gloo/verbs/show.rb +6 -31
- data/lib/gloo/verbs/tell.rb +31 -31
- data/lib/gloo/verbs/unless.rb +47 -46
- data/lib/gloo/verbs/version.rb +0 -30
- data/lib/gloo/verbs/wait.rb +0 -31
- metadata +79 -3
data/lib/gloo/objs/snd/play.rb
CHANGED
|
@@ -36,36 +36,13 @@ module Gloo
|
|
|
36
36
|
return super + [ 'run' ]
|
|
37
37
|
end
|
|
38
38
|
|
|
39
|
+
#
|
|
39
40
|
# Play the audio file.
|
|
41
|
+
#
|
|
40
42
|
def msg_run
|
|
41
43
|
system "afplay #{value}"
|
|
42
44
|
end
|
|
43
45
|
|
|
44
|
-
# ---------------------------------------------------------------------
|
|
45
|
-
# Help
|
|
46
|
-
# ---------------------------------------------------------------------
|
|
47
|
-
|
|
48
|
-
#
|
|
49
|
-
# Get help for this object type.
|
|
50
|
-
#
|
|
51
|
-
def self.help
|
|
52
|
-
return <<~TEXT
|
|
53
|
-
PLAY OBJECT TYPE
|
|
54
|
-
NAME: play
|
|
55
|
-
SHORTCUT: play
|
|
56
|
-
|
|
57
|
-
DESCRIPTION
|
|
58
|
-
Play an audio file, an MP3 for example.
|
|
59
|
-
The value of the play object is the path to the audio file.
|
|
60
|
-
|
|
61
|
-
CHILDREN
|
|
62
|
-
None.
|
|
63
|
-
|
|
64
|
-
MESSAGES
|
|
65
|
-
run - Play the audio file.
|
|
66
|
-
TEXT
|
|
67
|
-
end
|
|
68
|
-
|
|
69
46
|
end
|
|
70
47
|
end
|
|
71
48
|
end
|
data/lib/gloo/objs/snd/say.rb
CHANGED
|
@@ -13,6 +13,7 @@ module Gloo
|
|
|
13
13
|
KEYWORD_SHORT = 'say'.freeze
|
|
14
14
|
VOICE = 'voice'.freeze
|
|
15
15
|
MSG = 'message'.freeze
|
|
16
|
+
DEFAULT_MSG = 'talk to me'.freeze
|
|
16
17
|
|
|
17
18
|
#
|
|
18
19
|
# The name of the object type.
|
|
@@ -52,20 +53,24 @@ module Gloo
|
|
|
52
53
|
# Children
|
|
53
54
|
# ---------------------------------------------------------------------
|
|
54
55
|
|
|
56
|
+
#
|
|
55
57
|
# Does this object have children to add when an object
|
|
56
58
|
# is created in interactive mode?
|
|
57
59
|
# This does not apply during obj load, etc.
|
|
60
|
+
#
|
|
58
61
|
def add_children_on_create?
|
|
59
62
|
return true
|
|
60
63
|
end
|
|
61
64
|
|
|
65
|
+
#
|
|
62
66
|
# Add children to this object.
|
|
63
67
|
# This is used by containers to add children needed
|
|
64
68
|
# for default configurations.
|
|
69
|
+
#
|
|
65
70
|
def add_default_children
|
|
66
71
|
fac = $engine.factory
|
|
67
72
|
fac.create_string VOICE, '', self
|
|
68
|
-
fac.create_string MSG,
|
|
73
|
+
fac.create_string MSG, DEFAULT_MSG, self
|
|
69
74
|
end
|
|
70
75
|
|
|
71
76
|
# ---------------------------------------------------------------------
|
|
@@ -79,42 +84,15 @@ module Gloo
|
|
|
79
84
|
return super + [ 'run' ]
|
|
80
85
|
end
|
|
81
86
|
|
|
82
|
-
#
|
|
87
|
+
#
|
|
88
|
+
# Have the computer 'speak' the message.
|
|
89
|
+
#
|
|
83
90
|
def msg_run
|
|
84
91
|
v = voice_value.empty? ? '' : "-v '#{voice_value}'"
|
|
85
92
|
cmd = "say #{v} '#{msg_value}'"
|
|
86
93
|
system cmd
|
|
87
94
|
end
|
|
88
95
|
|
|
89
|
-
# ---------------------------------------------------------------------
|
|
90
|
-
# Help
|
|
91
|
-
# ---------------------------------------------------------------------
|
|
92
|
-
|
|
93
|
-
#
|
|
94
|
-
# Get help for this object type.
|
|
95
|
-
#
|
|
96
|
-
def self.help
|
|
97
|
-
return <<~TEXT
|
|
98
|
-
SAY OBJECT TYPE
|
|
99
|
-
NAME: say
|
|
100
|
-
SHORTCUT: say
|
|
101
|
-
|
|
102
|
-
DESCRIPTION
|
|
103
|
-
Use the Mac text to speach function to say the .
|
|
104
|
-
From the Mac CLI, run this to get a list of voices:
|
|
105
|
-
say -v '?'
|
|
106
|
-
|
|
107
|
-
CHILDREN
|
|
108
|
-
voice - string
|
|
109
|
-
The Voice to use. If left blank, the default voice will be used.
|
|
110
|
-
message - string - 'talk to me'
|
|
111
|
-
The message to speak.
|
|
112
|
-
|
|
113
|
-
MESSAGES
|
|
114
|
-
run - Speak the message, optionally in the voice specified.
|
|
115
|
-
TEXT
|
|
116
|
-
end
|
|
117
|
-
|
|
118
96
|
end
|
|
119
97
|
end
|
|
120
98
|
end
|
|
@@ -124,44 +124,6 @@ module Gloo
|
|
|
124
124
|
$engine.heap.it.set_to result
|
|
125
125
|
end
|
|
126
126
|
|
|
127
|
-
# ---------------------------------------------------------------------
|
|
128
|
-
# Help
|
|
129
|
-
# ---------------------------------------------------------------------
|
|
130
|
-
|
|
131
|
-
#
|
|
132
|
-
# Get help for this object type.
|
|
133
|
-
#
|
|
134
|
-
def self.help
|
|
135
|
-
return <<~TEXT
|
|
136
|
-
FILE OBJECT TYPE
|
|
137
|
-
NAME: file
|
|
138
|
-
SHORTCUT: dir
|
|
139
|
-
|
|
140
|
-
DESCRIPTION
|
|
141
|
-
Reference to a file or folder (directory) on disk.
|
|
142
|
-
The string value of the file object is the path and name
|
|
143
|
-
of the file.
|
|
144
|
-
|
|
145
|
-
CHILDREN
|
|
146
|
-
None.
|
|
147
|
-
|
|
148
|
-
MESSAGES
|
|
149
|
-
read <into.obj> - Read file and put data in the specified object.
|
|
150
|
-
If the <into.obj> is not specified, the data will be in <it>.
|
|
151
|
-
write <from.obj> - Write the data in the <from.object> into
|
|
152
|
-
the file.
|
|
153
|
-
show - Show the contents of the file.
|
|
154
|
-
page - Show the contents of the file, paginated
|
|
155
|
-
open - Open the file with the default application for the type.
|
|
156
|
-
check_exists - Check to see if the file exists.
|
|
157
|
-
<It> will be true or false.
|
|
158
|
-
check_is_file - Check to see if the file specified is a
|
|
159
|
-
regular file. <It> will be true or false.
|
|
160
|
-
check_is_dir - Check to see if the file specified is a
|
|
161
|
-
diretory. <It> will be true or false.
|
|
162
|
-
TEXT
|
|
163
|
-
end
|
|
164
|
-
|
|
165
127
|
end
|
|
166
128
|
end
|
|
167
129
|
end
|
|
@@ -11,6 +11,7 @@ module Gloo
|
|
|
11
11
|
KEYWORD = 'system'.freeze
|
|
12
12
|
KEYWORD_SHORT = 'sys'.freeze
|
|
13
13
|
CMD = 'command'.freeze
|
|
14
|
+
DEFAULT_CMD = 'date'.freeze
|
|
14
15
|
RESULT = 'result'.freeze
|
|
15
16
|
GET_OUTPUT = 'get_output'.freeze
|
|
16
17
|
|
|
@@ -65,30 +66,25 @@ module Gloo
|
|
|
65
66
|
# Children
|
|
66
67
|
# ---------------------------------------------------------------------
|
|
67
68
|
|
|
69
|
+
#
|
|
68
70
|
# Does this object have children to add when an object
|
|
69
71
|
# is created in interactive mode?
|
|
70
72
|
# This does not apply during obj load, etc.
|
|
73
|
+
#
|
|
71
74
|
def add_children_on_create?
|
|
72
75
|
return true
|
|
73
76
|
end
|
|
74
77
|
|
|
78
|
+
#
|
|
75
79
|
# Add children to this object.
|
|
76
80
|
# This is used by containers to add children needed
|
|
77
81
|
# for default configurations.
|
|
82
|
+
#
|
|
78
83
|
def add_default_children
|
|
79
84
|
fac = $engine.factory
|
|
80
|
-
fac.
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
:parent => self } )
|
|
84
|
-
fac.create( { :name => 'get_output',
|
|
85
|
-
:type => 'boolean',
|
|
86
|
-
:value => true,
|
|
87
|
-
:parent => self } )
|
|
88
|
-
fac.create( { :name => 'result',
|
|
89
|
-
:type => 'string',
|
|
90
|
-
:value => nil,
|
|
91
|
-
:parent => self } )
|
|
85
|
+
fac.create_string CMD, DEFAULT_CMD, self
|
|
86
|
+
fac.create_bool GET_OUTPUT, true, self
|
|
87
|
+
fac.create_string RESULT, nil, self
|
|
92
88
|
end
|
|
93
89
|
|
|
94
90
|
# ---------------------------------------------------------------------
|
|
@@ -102,7 +98,9 @@ module Gloo
|
|
|
102
98
|
return super + [ 'run' ]
|
|
103
99
|
end
|
|
104
100
|
|
|
101
|
+
#
|
|
105
102
|
# Run the system command.
|
|
103
|
+
#
|
|
106
104
|
def msg_run
|
|
107
105
|
if output?
|
|
108
106
|
run_with_output
|
|
@@ -111,6 +109,9 @@ module Gloo
|
|
|
111
109
|
end
|
|
112
110
|
end
|
|
113
111
|
|
|
112
|
+
#
|
|
113
|
+
# Run the command and collect output.
|
|
114
|
+
#
|
|
114
115
|
def run_with_output
|
|
115
116
|
cmd = cmd_value
|
|
116
117
|
return unless cmd
|
|
@@ -119,6 +120,9 @@ module Gloo
|
|
|
119
120
|
set_result result
|
|
120
121
|
end
|
|
121
122
|
|
|
123
|
+
#
|
|
124
|
+
# Run the command and set the result.
|
|
125
|
+
#
|
|
122
126
|
def run_with_result
|
|
123
127
|
cmd = cmd_value
|
|
124
128
|
return unless cmd
|
|
@@ -127,40 +131,6 @@ module Gloo
|
|
|
127
131
|
set_result result
|
|
128
132
|
end
|
|
129
133
|
|
|
130
|
-
# ---------------------------------------------------------------------
|
|
131
|
-
# Help
|
|
132
|
-
# ---------------------------------------------------------------------
|
|
133
|
-
|
|
134
|
-
#
|
|
135
|
-
# Get help for this object type.
|
|
136
|
-
#
|
|
137
|
-
def self.help
|
|
138
|
-
return <<~TEXT
|
|
139
|
-
SYSTEM OBJECT TYPE
|
|
140
|
-
NAME: system
|
|
141
|
-
SHORTCUT: sys
|
|
142
|
-
|
|
143
|
-
DESCRIPTION
|
|
144
|
-
Execute a system command.
|
|
145
|
-
|
|
146
|
-
CHILDREN
|
|
147
|
-
command - string - 'date'
|
|
148
|
-
The command that will be sent to the system.
|
|
149
|
-
get_output - boolean - true
|
|
150
|
-
Should executing the command get the output and put it
|
|
151
|
-
in the result object?
|
|
152
|
-
result - string
|
|
153
|
-
The result of running the command.
|
|
154
|
-
The result will only be set if the 'get_output' child
|
|
155
|
-
is set to true.
|
|
156
|
-
|
|
157
|
-
MESSAGES
|
|
158
|
-
run - Run the system level command.
|
|
159
|
-
Set the result value to the output of the command if the
|
|
160
|
-
'get_output' child is marked as true.
|
|
161
|
-
TEXT
|
|
162
|
-
end
|
|
163
|
-
|
|
164
134
|
end
|
|
165
135
|
end
|
|
166
136
|
end
|
|
@@ -15,6 +15,7 @@ module Gloo
|
|
|
15
15
|
KEYWORD = 'http_get'.freeze
|
|
16
16
|
KEYWORD_SHORT = 'get'.freeze
|
|
17
17
|
URL = 'uri'.freeze
|
|
18
|
+
DEFAULT_URL = 'https://web.site/'.freeze
|
|
18
19
|
PARAMS = 'params'.freeze
|
|
19
20
|
RESULT = 'result'.freeze
|
|
20
21
|
SKIP_SSL_VERIFY = 'skip_ssl_verify'.freeze
|
|
@@ -33,82 +34,29 @@ module Gloo
|
|
|
33
34
|
return KEYWORD_SHORT
|
|
34
35
|
end
|
|
35
36
|
|
|
36
|
-
#
|
|
37
|
-
# Get the URI from the child object.
|
|
38
|
-
# Returns nil if there is none.
|
|
39
|
-
#
|
|
40
|
-
def uri_value
|
|
41
|
-
uri = find_child URL
|
|
42
|
-
return nil unless uri
|
|
43
|
-
|
|
44
|
-
return uri.value
|
|
45
|
-
end
|
|
46
|
-
|
|
47
|
-
#
|
|
48
|
-
# Should we skip SSL verification during the request?
|
|
49
|
-
#
|
|
50
|
-
def skip_ssl_verify?
|
|
51
|
-
skip = find_child SKIP_SSL_VERIFY
|
|
52
|
-
return false unless skip
|
|
53
|
-
|
|
54
|
-
return skip.value
|
|
55
|
-
end
|
|
56
|
-
|
|
57
|
-
#
|
|
58
|
-
# Set the result of the API call.
|
|
59
|
-
#
|
|
60
|
-
def update_result( data )
|
|
61
|
-
r = find_child RESULT
|
|
62
|
-
return nil unless r
|
|
63
|
-
|
|
64
|
-
r.set_value data
|
|
65
|
-
end
|
|
66
|
-
|
|
67
|
-
#
|
|
68
|
-
# Get the URL for the service including all URL params.
|
|
69
|
-
#
|
|
70
|
-
def full_url_value
|
|
71
|
-
p = ''
|
|
72
|
-
params = find_child PARAMS
|
|
73
|
-
params.children.each do |child|
|
|
74
|
-
p << ( p.empty? ? '?' : '&' )
|
|
75
|
-
|
|
76
|
-
child = Gloo::Objs::Alias.resolve_alias( child )
|
|
77
|
-
|
|
78
|
-
# TODO: Quote URL params for safety
|
|
79
|
-
p << "#{child.name}=#{child.value}"
|
|
80
|
-
end
|
|
81
|
-
return "#{uri_value}#{p}"
|
|
82
|
-
end
|
|
83
|
-
|
|
84
37
|
# ---------------------------------------------------------------------
|
|
85
38
|
# Children
|
|
86
39
|
# ---------------------------------------------------------------------
|
|
87
40
|
|
|
41
|
+
#
|
|
88
42
|
# Does this object have children to add when an object
|
|
89
43
|
# is created in interactive mode?
|
|
90
44
|
# This does not apply during obj load, etc.
|
|
45
|
+
#
|
|
91
46
|
def add_children_on_create?
|
|
92
47
|
return true
|
|
93
48
|
end
|
|
94
49
|
|
|
50
|
+
#
|
|
95
51
|
# Add children to this object.
|
|
96
52
|
# This is used by containers to add children needed
|
|
97
53
|
# for default configurations.
|
|
54
|
+
#
|
|
98
55
|
def add_default_children
|
|
99
56
|
fac = $engine.factory
|
|
100
|
-
fac.
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
:parent => self } )
|
|
104
|
-
fac.create( { :name => 'params',
|
|
105
|
-
:type => 'container',
|
|
106
|
-
:value => nil,
|
|
107
|
-
:parent => self } )
|
|
108
|
-
fac.create( { :name => 'result',
|
|
109
|
-
:type => 'string',
|
|
110
|
-
:value => nil,
|
|
111
|
-
:parent => self } )
|
|
57
|
+
fac.create_string URL, DEFAULT_URL, self
|
|
58
|
+
fac.create_can PARAMS, self
|
|
59
|
+
fac.create_string RESULT, nil, self
|
|
112
60
|
end
|
|
113
61
|
|
|
114
62
|
# ---------------------------------------------------------------------
|
|
@@ -122,11 +70,13 @@ module Gloo
|
|
|
122
70
|
return super + [ 'run' ]
|
|
123
71
|
end
|
|
124
72
|
|
|
73
|
+
#
|
|
125
74
|
# Post the content to the endpoint.
|
|
75
|
+
#
|
|
126
76
|
def msg_run
|
|
127
77
|
url = full_url_value
|
|
128
78
|
$log.debug url
|
|
129
|
-
r = Gloo::Objs::HttpGet.invoke_request( url,
|
|
79
|
+
r = Gloo::Objs::HttpGet.invoke_request( url, skip_ssl_verify? )
|
|
130
80
|
update_result r
|
|
131
81
|
end
|
|
132
82
|
|
|
@@ -134,7 +84,9 @@ module Gloo
|
|
|
134
84
|
# Static functions
|
|
135
85
|
# ---------------------------------------------------------------------
|
|
136
86
|
|
|
87
|
+
#
|
|
137
88
|
# Post the content to the endpoint.
|
|
89
|
+
#
|
|
138
90
|
def self.invoke_request( url, skip_ssl_verify = false )
|
|
139
91
|
uri = URI( url )
|
|
140
92
|
params = { use_ssl: uri.scheme == 'https' }
|
|
@@ -149,35 +101,57 @@ module Gloo
|
|
|
149
101
|
end
|
|
150
102
|
|
|
151
103
|
# ---------------------------------------------------------------------
|
|
152
|
-
#
|
|
104
|
+
# Private functions
|
|
153
105
|
# ---------------------------------------------------------------------
|
|
154
106
|
|
|
107
|
+
private
|
|
108
|
+
|
|
155
109
|
#
|
|
156
|
-
# Get
|
|
110
|
+
# Get the URI from the child object.
|
|
111
|
+
# Returns nil if there is none.
|
|
157
112
|
#
|
|
158
|
-
def
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
NAME: http_get
|
|
162
|
-
SHORTCUT: get
|
|
113
|
+
def uri_value
|
|
114
|
+
uri = find_child URL
|
|
115
|
+
return nil unless uri
|
|
163
116
|
|
|
164
|
-
|
|
165
|
-
|
|
117
|
+
return uri.value
|
|
118
|
+
end
|
|
119
|
+
|
|
120
|
+
#
|
|
121
|
+
# Should we skip SSL verification during the request?
|
|
122
|
+
#
|
|
123
|
+
def skip_ssl_verify?
|
|
124
|
+
skip = find_child SKIP_SSL_VERIFY
|
|
125
|
+
return false unless skip
|
|
166
126
|
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
The URI for the HTTP Get request.
|
|
170
|
-
params - container
|
|
171
|
-
Collection of parameters for the HTTP Get.
|
|
172
|
-
result - string
|
|
173
|
-
The result of the request. Whatever was returned from
|
|
174
|
-
the HTTP Get call.
|
|
175
|
-
skip_ssl_verify - boolean (optional)
|
|
176
|
-
Skip the SSL verification as part of the request.
|
|
127
|
+
return skip.value
|
|
128
|
+
end
|
|
177
129
|
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
130
|
+
#
|
|
131
|
+
# Set the result of the API call.
|
|
132
|
+
#
|
|
133
|
+
def update_result( data )
|
|
134
|
+
r = find_child RESULT
|
|
135
|
+
return nil unless r
|
|
136
|
+
|
|
137
|
+
r.set_value data
|
|
138
|
+
end
|
|
139
|
+
|
|
140
|
+
#
|
|
141
|
+
# Get the URL for the service including all URL params.
|
|
142
|
+
#
|
|
143
|
+
def full_url_value
|
|
144
|
+
p = ''
|
|
145
|
+
params = find_child PARAMS
|
|
146
|
+
params.children.each do |child|
|
|
147
|
+
p << ( p.empty? ? '?' : '&' )
|
|
148
|
+
|
|
149
|
+
child = Gloo::Objs::Alias.resolve_alias( child )
|
|
150
|
+
|
|
151
|
+
# TODO: Quote URL params for safety
|
|
152
|
+
p << "#{child.name}=#{child.value}"
|
|
153
|
+
end
|
|
154
|
+
return "#{uri_value}#{p}"
|
|
181
155
|
end
|
|
182
156
|
|
|
183
157
|
end
|