gloo 0.3.0 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +73 -0
- data/Gemfile +2 -2
- data/Gemfile.lock +3 -3
- data/Rakefile +6 -6
- data/bin/console +4 -4
- data/gloo.gemspec +19 -18
- data/lib/gloo.rb +6 -6
- data/lib/gloo/app/args.rb +30 -31
- data/lib/gloo/app/engine.rb +33 -28
- 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 +43 -40
- 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 -19
- data/lib/gloo/core/factory.rb +92 -39
- data/lib/gloo/core/gloo_system.rb +49 -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 +89 -79
- data/lib/gloo/core/obj_finder.rb +9 -14
- data/lib/gloo/core/op.rb +8 -8
- data/lib/gloo/core/parser.rb +25 -26
- data/lib/gloo/core/pn.rb +65 -50
- data/lib/gloo/core/runner.rb +26 -0
- 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/expr/expression.rb +35 -43
- data/lib/gloo/expr/l_boolean.rb +7 -6
- 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 +3 -5
- data/lib/gloo/expr/op_minus.rb +3 -5
- data/lib/gloo/expr/op_mult.rb +3 -5
- data/lib/gloo/expr/op_plus.rb +5 -7
- data/lib/gloo/objs/basic/boolean.rb +63 -38
- data/lib/gloo/objs/basic/container.rb +40 -12
- data/lib/gloo/objs/basic/integer.rb +40 -16
- data/lib/gloo/objs/basic/script.rb +62 -38
- data/lib/gloo/objs/basic/string.rb +39 -15
- data/lib/gloo/objs/basic/text.rb +43 -20
- data/lib/gloo/objs/basic/untyped.rb +35 -10
- data/lib/gloo/objs/cli/colorize.rb +53 -23
- data/lib/gloo/objs/cli/confirm.rb +63 -29
- data/lib/gloo/objs/cli/prompt.rb +63 -29
- data/lib/gloo/objs/ctrl/each.rb +98 -60
- data/lib/gloo/objs/dev/git.rb +98 -64
- data/lib/gloo/objs/ror/erb.rb +81 -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 +80 -48
- data/lib/gloo/objs/system/system.rb +84 -38
- data/lib/gloo/objs/web/http_get.rb +83 -46
- data/lib/gloo/objs/web/http_post.rb +69 -43
- data/lib/gloo/objs/web/slack.rb +89 -58
- data/lib/gloo/objs/web/teams.rb +88 -53
- data/lib/gloo/persist/file_loader.rb +81 -82
- 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 +74 -0
- data/lib/gloo/persist/persist_man.rb +29 -29
- 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/context.rb +61 -21
- data/lib/gloo/verbs/create.rb +52 -21
- data/lib/gloo/verbs/help.rb +177 -27
- data/lib/gloo/verbs/if.rb +54 -21
- data/lib/gloo/verbs/list.rb +55 -24
- data/lib/gloo/verbs/load.rb +46 -12
- data/lib/gloo/verbs/put.rb +90 -34
- data/lib/gloo/verbs/quit.rb +43 -12
- data/lib/gloo/verbs/run.rb +42 -11
- data/lib/gloo/verbs/save.rb +45 -10
- data/lib/gloo/verbs/show.rb +56 -22
- data/lib/gloo/verbs/tell.rb +44 -12
- data/lib/gloo/verbs/unless.rb +55 -21
- data/lib/gloo/verbs/version.rb +42 -12
- data/lib/run.rb +5 -5
- metadata +19 -12
data/lib/gloo/objs/ror/erb.rb
CHANGED
@@ -8,61 +8,61 @@ require 'erb'
|
|
8
8
|
module Gloo
|
9
9
|
module Objs
|
10
10
|
class Erb < Gloo::Core::Obj
|
11
|
-
|
12
|
-
KEYWORD = 'erb'
|
13
|
-
KEYWORD_SHORT = 'erb'
|
14
|
-
TEMPLATE = 'template'
|
15
|
-
PARAMS = 'params'
|
16
|
-
RESULT = 'result'
|
17
|
-
|
18
|
-
#
|
11
|
+
|
12
|
+
KEYWORD = 'erb'.freeze
|
13
|
+
KEYWORD_SHORT = 'erb'.freeze
|
14
|
+
TEMPLATE = 'template'.freeze
|
15
|
+
PARAMS = 'params'.freeze
|
16
|
+
RESULT = 'result'.freeze
|
17
|
+
|
18
|
+
#
|
19
19
|
# The name of the object type.
|
20
|
-
#
|
20
|
+
#
|
21
21
|
def self.typename
|
22
22
|
return KEYWORD
|
23
23
|
end
|
24
24
|
|
25
|
-
#
|
25
|
+
#
|
26
26
|
# The short name of the object type.
|
27
|
-
#
|
27
|
+
#
|
28
28
|
def self.short_typename
|
29
29
|
return KEYWORD_SHORT
|
30
30
|
end
|
31
|
-
|
32
|
-
#
|
31
|
+
|
32
|
+
#
|
33
33
|
# Get the ERB template.
|
34
|
-
#
|
35
|
-
def
|
34
|
+
#
|
35
|
+
def template_value
|
36
36
|
tmpl = find_child TEMPLATE
|
37
37
|
return nil unless tmpl
|
38
|
+
|
38
39
|
return tmpl.value
|
39
40
|
end
|
40
|
-
|
41
|
-
#
|
41
|
+
|
42
|
+
#
|
42
43
|
# Set the result of the system call.
|
43
|
-
#
|
44
|
-
def set_result data
|
44
|
+
#
|
45
|
+
def set_result( data )
|
45
46
|
r = find_child RESULT
|
46
47
|
return nil unless r
|
48
|
+
|
47
49
|
r.set_value data
|
48
50
|
end
|
49
|
-
|
50
|
-
#
|
51
|
+
|
52
|
+
#
|
51
53
|
# Get a hash with parameters for the ERB render.
|
52
|
-
#
|
53
|
-
def
|
54
|
+
#
|
55
|
+
def param_hash
|
54
56
|
h = {}
|
55
|
-
|
57
|
+
|
56
58
|
body = find_child PARAMS
|
57
59
|
body.children.each do |child|
|
58
60
|
h[ child.name ] = child.value
|
59
61
|
end
|
60
|
-
|
62
|
+
|
61
63
|
return h
|
62
64
|
end
|
63
65
|
|
64
|
-
|
65
|
-
|
66
66
|
# ---------------------------------------------------------------------
|
67
67
|
# Children
|
68
68
|
# ---------------------------------------------------------------------
|
@@ -73,37 +73,77 @@ module Gloo
|
|
73
73
|
def add_children_on_create?
|
74
74
|
return true
|
75
75
|
end
|
76
|
-
|
76
|
+
|
77
77
|
# Add children to this object.
|
78
|
-
# This is used by containers to add children needed
|
78
|
+
# This is used by containers to add children needed
|
79
79
|
# for default configurations.
|
80
80
|
def add_default_children
|
81
81
|
fac = $engine.factory
|
82
|
-
fac.create
|
83
|
-
|
84
|
-
|
82
|
+
fac.create( { :name => 'template',
|
83
|
+
:type => 'text',
|
84
|
+
:value => '',
|
85
|
+
:parent => self } )
|
86
|
+
fac.create( { :name => 'params',
|
87
|
+
:type => 'container',
|
88
|
+
:value => nil,
|
89
|
+
:parent => self } )
|
90
|
+
fac.create( { :name => 'result',
|
91
|
+
:type => 'text',
|
92
|
+
:value => nil,
|
93
|
+
:parent => self } )
|
85
94
|
end
|
86
95
|
|
87
|
-
|
88
96
|
# ---------------------------------------------------------------------
|
89
97
|
# Messages
|
90
98
|
# ---------------------------------------------------------------------
|
91
99
|
|
92
|
-
#
|
100
|
+
#
|
93
101
|
# Get a list of message names that this object receives.
|
94
|
-
#
|
102
|
+
#
|
95
103
|
def self.messages
|
96
|
-
return super + [
|
104
|
+
return super + [ 'run' ]
|
97
105
|
end
|
98
|
-
|
106
|
+
|
99
107
|
# Run the system command.
|
100
108
|
def msg_run
|
101
|
-
tmpl =
|
109
|
+
tmpl = template_value
|
102
110
|
return unless tmpl
|
103
|
-
|
104
|
-
|
111
|
+
|
112
|
+
render = ERB.new( tmpl )
|
113
|
+
set_result render.result_with_hash( param_hash )
|
105
114
|
end
|
106
|
-
|
115
|
+
|
116
|
+
# ---------------------------------------------------------------------
|
117
|
+
# Help
|
118
|
+
# ---------------------------------------------------------------------
|
119
|
+
|
120
|
+
#
|
121
|
+
# Get help for this object type.
|
122
|
+
#
|
123
|
+
def self.help
|
124
|
+
return <<~TEXT
|
125
|
+
ERB OBJECT TYPE
|
126
|
+
NAME: erb
|
127
|
+
SHORTCUT: erb
|
128
|
+
|
129
|
+
DESCRIPTION
|
130
|
+
Use the ERB templating system to generate content.
|
131
|
+
|
132
|
+
CHILDREN
|
133
|
+
template - text
|
134
|
+
The template that will be used the the ERB object is run.
|
135
|
+
params - container
|
136
|
+
The collection of children values that will be used
|
137
|
+
when the template object is rendered.
|
138
|
+
result - text
|
139
|
+
The result of the template rendering.
|
140
|
+
|
141
|
+
MESSAGES
|
142
|
+
run - Render the result based on the template and the
|
143
|
+
parameter values.
|
144
|
+
TEXT
|
145
|
+
end
|
146
|
+
|
107
147
|
end
|
108
148
|
end
|
109
149
|
end
|
data/lib/gloo/objs/ror/eval.rb
CHANGED
@@ -7,45 +7,46 @@
|
|
7
7
|
module Gloo
|
8
8
|
module Objs
|
9
9
|
class Eval < Gloo::Core::Obj
|
10
|
-
|
11
|
-
KEYWORD = 'eval'
|
12
|
-
KEYWORD_SHORT = 'ruby'
|
13
|
-
CMD = 'command'
|
14
|
-
RESULT = 'result'
|
15
10
|
|
16
|
-
|
11
|
+
KEYWORD = 'eval'.freeze
|
12
|
+
KEYWORD_SHORT = 'ruby'.freeze
|
13
|
+
CMD = 'command'.freeze
|
14
|
+
RESULT = 'result'.freeze
|
15
|
+
|
16
|
+
#
|
17
17
|
# The name of the object type.
|
18
|
-
#
|
18
|
+
#
|
19
19
|
def self.typename
|
20
20
|
return KEYWORD
|
21
21
|
end
|
22
22
|
|
23
|
-
#
|
23
|
+
#
|
24
24
|
# The short name of the object type.
|
25
|
-
#
|
25
|
+
#
|
26
26
|
def self.short_typename
|
27
27
|
return KEYWORD_SHORT
|
28
28
|
end
|
29
|
-
|
30
|
-
#
|
29
|
+
|
30
|
+
#
|
31
31
|
# Get the URI from the child object.
|
32
32
|
# Returns nil if there is none.
|
33
|
-
#
|
34
|
-
def
|
33
|
+
#
|
34
|
+
def cmd_value
|
35
35
|
cmd = find_child CMD
|
36
36
|
return nil unless cmd
|
37
|
+
|
37
38
|
return cmd.value
|
38
39
|
end
|
39
|
-
|
40
|
-
#
|
40
|
+
|
41
|
+
#
|
41
42
|
# Set the result of the system call.
|
42
|
-
#
|
43
|
-
def set_result data
|
43
|
+
#
|
44
|
+
def set_result( data )
|
44
45
|
r = find_child RESULT
|
45
46
|
return nil unless r
|
47
|
+
|
46
48
|
r.set_value data
|
47
49
|
end
|
48
|
-
|
49
50
|
|
50
51
|
# ---------------------------------------------------------------------
|
51
52
|
# Children
|
@@ -57,36 +58,77 @@ module Gloo
|
|
57
58
|
def add_children_on_create?
|
58
59
|
return true
|
59
60
|
end
|
60
|
-
|
61
|
+
|
61
62
|
# Add children to this object.
|
62
|
-
# This is used by containers to add children needed
|
63
|
+
# This is used by containers to add children needed
|
63
64
|
# for default configurations.
|
64
65
|
def add_default_children
|
65
66
|
fac = $engine.factory
|
66
|
-
fac.create
|
67
|
-
|
67
|
+
fac.create( { :name => 'command',
|
68
|
+
:type => 'string',
|
69
|
+
:value => '1+2',
|
70
|
+
:parent => self } )
|
71
|
+
fac.create( { :name => 'result',
|
72
|
+
:type => 'string',
|
73
|
+
:value => nil,
|
74
|
+
:parent => self } )
|
68
75
|
end
|
69
76
|
|
70
|
-
|
71
77
|
# ---------------------------------------------------------------------
|
72
78
|
# Messages
|
73
79
|
# ---------------------------------------------------------------------
|
74
80
|
|
75
|
-
#
|
81
|
+
#
|
76
82
|
# Get a list of message names that this object receives.
|
77
|
-
#
|
83
|
+
#
|
78
84
|
def self.messages
|
79
|
-
return super + [
|
85
|
+
return super + [ 'run' ]
|
80
86
|
end
|
81
|
-
|
87
|
+
|
82
88
|
# Run the system command.
|
83
89
|
def msg_run
|
84
|
-
cmd =
|
90
|
+
cmd = cmd_value
|
85
91
|
return unless cmd
|
86
|
-
|
87
|
-
|
92
|
+
|
93
|
+
begin
|
94
|
+
# rubocop:disable Security/Eval
|
95
|
+
result = eval cmd
|
96
|
+
# rubocop:enable Security/Eval
|
97
|
+
set_result result
|
98
|
+
$engine.heap.it.set_to result
|
99
|
+
rescue => e
|
100
|
+
$log.error e.message
|
101
|
+
$engine.heap.error.set_to e.message
|
102
|
+
end
|
88
103
|
end
|
89
|
-
|
104
|
+
|
105
|
+
# ---------------------------------------------------------------------
|
106
|
+
# Help
|
107
|
+
# ---------------------------------------------------------------------
|
108
|
+
|
109
|
+
#
|
110
|
+
# Get help for this object type.
|
111
|
+
#
|
112
|
+
def self.help
|
113
|
+
return <<~TEXT
|
114
|
+
EVAL OBJECT TYPE
|
115
|
+
NAME: eval
|
116
|
+
SHORTCUT: ruby
|
117
|
+
|
118
|
+
DESCRIPTION
|
119
|
+
Execute a ruby expression.
|
120
|
+
|
121
|
+
CHILDREN
|
122
|
+
command - string
|
123
|
+
The ruby expression or command that will be run.
|
124
|
+
result - string
|
125
|
+
The result of the command or expression after it is run.
|
126
|
+
|
127
|
+
MESSAGES
|
128
|
+
run - Execute the ruby command and update the result.
|
129
|
+
TEXT
|
130
|
+
end
|
131
|
+
|
90
132
|
end
|
91
133
|
end
|
92
134
|
end
|
@@ -0,0 +1,71 @@
|
|
1
|
+
# Author:: Eric Crane (mailto:eric.crane@mac.com)
|
2
|
+
# Copyright:: Copyright (c) 2020 Eric Crane. All rights reserved.
|
3
|
+
#
|
4
|
+
# Play an audio file (MP3).
|
5
|
+
#
|
6
|
+
|
7
|
+
module Gloo
|
8
|
+
module Objs
|
9
|
+
class Play < Gloo::Core::Obj
|
10
|
+
|
11
|
+
KEYWORD = 'play'.freeze
|
12
|
+
KEYWORD_SHORT = 'play'.freeze
|
13
|
+
|
14
|
+
#
|
15
|
+
# The name of the object type.
|
16
|
+
#
|
17
|
+
def self.typename
|
18
|
+
return KEYWORD
|
19
|
+
end
|
20
|
+
|
21
|
+
#
|
22
|
+
# The short name of the object type.
|
23
|
+
#
|
24
|
+
def self.short_typename
|
25
|
+
return KEYWORD_SHORT
|
26
|
+
end
|
27
|
+
|
28
|
+
# ---------------------------------------------------------------------
|
29
|
+
# Messages
|
30
|
+
# ---------------------------------------------------------------------
|
31
|
+
|
32
|
+
#
|
33
|
+
# Get a list of message names that this object receives.
|
34
|
+
#
|
35
|
+
def self.messages
|
36
|
+
return super + [ 'run' ]
|
37
|
+
end
|
38
|
+
|
39
|
+
# Play the audio file.
|
40
|
+
def msg_run
|
41
|
+
system "afplay #{value}"
|
42
|
+
end
|
43
|
+
|
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
|
+
end
|
70
|
+
end
|
71
|
+
end
|
@@ -0,0 +1,120 @@
|
|
1
|
+
# Author:: Eric Crane (mailto:eric.crane@mac.com)
|
2
|
+
# Copyright:: Copyright (c) 2020 Eric Crane. All rights reserved.
|
3
|
+
#
|
4
|
+
# Wrapper for the 'say something' function on the Mac.
|
5
|
+
#
|
6
|
+
require 'erb'
|
7
|
+
|
8
|
+
module Gloo
|
9
|
+
module Objs
|
10
|
+
class Say < Gloo::Core::Obj
|
11
|
+
|
12
|
+
KEYWORD = 'say'.freeze
|
13
|
+
KEYWORD_SHORT = 'say'.freeze
|
14
|
+
VOICE = 'voice'.freeze
|
15
|
+
MSG = 'message'.freeze
|
16
|
+
|
17
|
+
#
|
18
|
+
# The name of the object type.
|
19
|
+
#
|
20
|
+
def self.typename
|
21
|
+
return KEYWORD
|
22
|
+
end
|
23
|
+
|
24
|
+
#
|
25
|
+
# The short name of the object type.
|
26
|
+
#
|
27
|
+
def self.short_typename
|
28
|
+
return KEYWORD_SHORT
|
29
|
+
end
|
30
|
+
|
31
|
+
#
|
32
|
+
# Get the voice to use.
|
33
|
+
#
|
34
|
+
def voice_value
|
35
|
+
v = find_child VOICE
|
36
|
+
return nil unless v
|
37
|
+
|
38
|
+
return v.value
|
39
|
+
end
|
40
|
+
|
41
|
+
#
|
42
|
+
# Get the message to speak.
|
43
|
+
#
|
44
|
+
def msg_value
|
45
|
+
o = find_child MSG
|
46
|
+
return nil unless o
|
47
|
+
|
48
|
+
return o.value
|
49
|
+
end
|
50
|
+
|
51
|
+
# ---------------------------------------------------------------------
|
52
|
+
# Children
|
53
|
+
# ---------------------------------------------------------------------
|
54
|
+
|
55
|
+
# Does this object have children to add when an object
|
56
|
+
# is created in interactive mode?
|
57
|
+
# This does not apply during obj load, etc.
|
58
|
+
def add_children_on_create?
|
59
|
+
return true
|
60
|
+
end
|
61
|
+
|
62
|
+
# Add children to this object.
|
63
|
+
# This is used by containers to add children needed
|
64
|
+
# for default configurations.
|
65
|
+
def add_default_children
|
66
|
+
fac = $engine.factory
|
67
|
+
fac.create_string VOICE, '', self
|
68
|
+
fac.create_string MSG, 'talk to me', self
|
69
|
+
end
|
70
|
+
|
71
|
+
# ---------------------------------------------------------------------
|
72
|
+
# Messages
|
73
|
+
# ---------------------------------------------------------------------
|
74
|
+
|
75
|
+
#
|
76
|
+
# Get a list of message names that this object receives.
|
77
|
+
#
|
78
|
+
def self.messages
|
79
|
+
return super + [ 'run' ]
|
80
|
+
end
|
81
|
+
|
82
|
+
# Run the system command.
|
83
|
+
def msg_run
|
84
|
+
v = voice_value.empty? ? '' : "-v '#{voice_value}'"
|
85
|
+
cmd = "say #{v} '#{msg_value}'"
|
86
|
+
system cmd
|
87
|
+
end
|
88
|
+
|
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
|
+
end
|
119
|
+
end
|
120
|
+
end
|