gloo 0.3.0
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 +7 -0
- data/.gitignore +10 -0
- data/.travis.yml +5 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +6 -0
- data/Gemfile.lock +139 -0
- data/LICENSE.txt +21 -0
- data/README.md +43 -0
- data/Rakefile +12 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/exe/gloo +4 -0
- data/exe/o +4 -0
- data/gloo.gemspec +38 -0
- data/lib/gloo.rb +19 -0
- data/lib/gloo/app/args.rb +71 -0
- data/lib/gloo/app/engine.rb +158 -0
- data/lib/gloo/app/help.rb +29 -0
- data/lib/gloo/app/info.rb +21 -0
- data/lib/gloo/app/log.rb +58 -0
- data/lib/gloo/app/mode.rb +25 -0
- data/lib/gloo/app/settings.rb +125 -0
- data/lib/gloo/core/baseo.rb +28 -0
- data/lib/gloo/core/dictionary.rb +101 -0
- data/lib/gloo/core/event_manager.rb +46 -0
- data/lib/gloo/core/factory.rb +67 -0
- data/lib/gloo/core/gloo_system.rb +190 -0
- data/lib/gloo/core/heap.rb +42 -0
- data/lib/gloo/core/it.rb +30 -0
- data/lib/gloo/core/literal.rb +25 -0
- data/lib/gloo/core/obj.rb +222 -0
- data/lib/gloo/core/obj_finder.rb +35 -0
- data/lib/gloo/core/op.rb +33 -0
- data/lib/gloo/core/parser.rb +52 -0
- data/lib/gloo/core/pn.rb +134 -0
- data/lib/gloo/core/script.rb +37 -0
- data/lib/gloo/core/tokens.rb +123 -0
- data/lib/gloo/core/verb.rb +63 -0
- data/lib/gloo/expr/expression.rb +103 -0
- data/lib/gloo/expr/l_boolean.rb +29 -0
- data/lib/gloo/expr/l_integer.rb +29 -0
- data/lib/gloo/expr/l_string.rb +53 -0
- data/lib/gloo/expr/op_div.rb +20 -0
- data/lib/gloo/expr/op_minus.rb +20 -0
- data/lib/gloo/expr/op_mult.rb +20 -0
- data/lib/gloo/expr/op_plus.rb +22 -0
- data/lib/gloo/objs/basic/boolean.rb +113 -0
- data/lib/gloo/objs/basic/container.rb +50 -0
- data/lib/gloo/objs/basic/integer.rb +65 -0
- data/lib/gloo/objs/basic/script.rb +101 -0
- data/lib/gloo/objs/basic/string.rb +65 -0
- data/lib/gloo/objs/basic/text.rb +64 -0
- data/lib/gloo/objs/basic/untyped.rb +42 -0
- data/lib/gloo/objs/cli/colorize.rb +73 -0
- data/lib/gloo/objs/cli/confirm.rb +92 -0
- data/lib/gloo/objs/cli/prompt.rb +92 -0
- data/lib/gloo/objs/ctrl/each.rb +212 -0
- data/lib/gloo/objs/dev/git.rb +112 -0
- data/lib/gloo/objs/ror/erb.rb +109 -0
- data/lib/gloo/objs/ror/eval.rb +92 -0
- data/lib/gloo/objs/system/file_handle.rb +86 -0
- data/lib/gloo/objs/system/system.rb +120 -0
- data/lib/gloo/objs/web/http_get.rb +128 -0
- data/lib/gloo/objs/web/http_post.rb +127 -0
- data/lib/gloo/objs/web/slack.rb +126 -0
- data/lib/gloo/objs/web/teams.rb +117 -0
- data/lib/gloo/persist/file_loader.rb +171 -0
- data/lib/gloo/persist/file_saver.rb +43 -0
- data/lib/gloo/persist/file_storage.rb +43 -0
- data/lib/gloo/persist/persist_man.rb +90 -0
- data/lib/gloo/utils/words.rb +19 -0
- data/lib/gloo/verbs/alert.rb +42 -0
- data/lib/gloo/verbs/context.rb +52 -0
- data/lib/gloo/verbs/create.rb +52 -0
- data/lib/gloo/verbs/help.rb +69 -0
- data/lib/gloo/verbs/if.rb +56 -0
- data/lib/gloo/verbs/list.rb +85 -0
- data/lib/gloo/verbs/load.rb +39 -0
- data/lib/gloo/verbs/put.rb +62 -0
- data/lib/gloo/verbs/quit.rb +40 -0
- data/lib/gloo/verbs/run.rb +46 -0
- data/lib/gloo/verbs/save.rb +37 -0
- data/lib/gloo/verbs/show.rb +55 -0
- data/lib/gloo/verbs/tell.rb +47 -0
- data/lib/gloo/verbs/unless.rb +56 -0
- data/lib/gloo/verbs/version.rb +37 -0
- data/lib/run.rb +13 -0
- metadata +254 -0
@@ -0,0 +1,52 @@
|
|
1
|
+
# Author:: Eric Crane (mailto:eric.crane@mac.com)
|
2
|
+
# Copyright:: Copyright (c) 2019 Eric Crane. All rights reserved.
|
3
|
+
#
|
4
|
+
# Create an object, optionally of a type.
|
5
|
+
#
|
6
|
+
|
7
|
+
module Gloo
|
8
|
+
module Verbs
|
9
|
+
class Create < Gloo::Core::Verb
|
10
|
+
|
11
|
+
KEYWORD = 'create'
|
12
|
+
KEYWORD_SHORT = '`'
|
13
|
+
AS = 'as'
|
14
|
+
VAL = ':'
|
15
|
+
|
16
|
+
#
|
17
|
+
# Run the verb.
|
18
|
+
#
|
19
|
+
def run
|
20
|
+
name = @tokens.second
|
21
|
+
type = @tokens.after_token( AS )
|
22
|
+
value = @tokens.after_token( VAL )
|
23
|
+
|
24
|
+
if Gloo::Expr::LString.is_string?( value )
|
25
|
+
value = Gloo::Expr::LString.strip_quotes( value )
|
26
|
+
end
|
27
|
+
obj = $engine.factory.create( name, type, value )
|
28
|
+
|
29
|
+
if obj && obj.add_children_on_create?
|
30
|
+
obj.add_default_children
|
31
|
+
end
|
32
|
+
|
33
|
+
$engine.heap.it.set_to value
|
34
|
+
end
|
35
|
+
|
36
|
+
#
|
37
|
+
# Get the Verb's keyword.
|
38
|
+
#
|
39
|
+
def self.keyword
|
40
|
+
return KEYWORD
|
41
|
+
end
|
42
|
+
|
43
|
+
#
|
44
|
+
# Get the Verb's keyword shortcut.
|
45
|
+
#
|
46
|
+
def self.keyword_shortcut
|
47
|
+
return KEYWORD_SHORT
|
48
|
+
end
|
49
|
+
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
@@ -0,0 +1,69 @@
|
|
1
|
+
# Author:: Eric Crane (mailto:eric.crane@mac.com)
|
2
|
+
# Copyright:: Copyright (c) 2019 Eric Crane. All rights reserved.
|
3
|
+
#
|
4
|
+
# Show the help information.
|
5
|
+
#
|
6
|
+
|
7
|
+
module Gloo
|
8
|
+
module Verbs
|
9
|
+
class Help < Gloo::Core::Verb
|
10
|
+
|
11
|
+
KEYWORD = 'help'
|
12
|
+
KEYWORD_SHORT = '?'
|
13
|
+
|
14
|
+
#
|
15
|
+
# Run the verb.
|
16
|
+
#
|
17
|
+
def run
|
18
|
+
opts = @tokens.second if @tokens
|
19
|
+
|
20
|
+
if opts && opts.strip.downcase == 'verbs'
|
21
|
+
show_verbs
|
22
|
+
elsif opts && opts.strip.downcase == 'objects'
|
23
|
+
show_objs
|
24
|
+
else
|
25
|
+
$engine.run_help( true )
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
#
|
30
|
+
# List the verbs
|
31
|
+
#
|
32
|
+
def show_verbs
|
33
|
+
return if $engine.args.quiet?
|
34
|
+
|
35
|
+
puts "Verbs:"
|
36
|
+
$engine.dictionary.get_verbs.each do |v|
|
37
|
+
puts " \t #{v.keyword_shortcut} \t #{v.keyword}"
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
#
|
42
|
+
# List the object types
|
43
|
+
#
|
44
|
+
def show_objs
|
45
|
+
return if $engine.args.quiet?
|
46
|
+
|
47
|
+
puts "Object Types:"
|
48
|
+
$engine.dictionary.get_obj_types.each do |v|
|
49
|
+
puts " \t #{v.short_typename} \t #{v.typename}"
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
#
|
54
|
+
# Get the Verb's keyword.
|
55
|
+
#
|
56
|
+
def self.keyword
|
57
|
+
return KEYWORD
|
58
|
+
end
|
59
|
+
|
60
|
+
#
|
61
|
+
# Get the Verb's keyword shortcut.
|
62
|
+
#
|
63
|
+
def self.keyword_shortcut
|
64
|
+
return KEYWORD_SHORT
|
65
|
+
end
|
66
|
+
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
# Author:: Eric Crane (mailto:eric.crane@mac.com)
|
2
|
+
# Copyright:: Copyright (c) 2019 Eric Crane. All rights reserved.
|
3
|
+
#
|
4
|
+
# If something is true, do something.
|
5
|
+
#
|
6
|
+
|
7
|
+
module Gloo
|
8
|
+
module Verbs
|
9
|
+
class If < Gloo::Core::Verb
|
10
|
+
|
11
|
+
KEYWORD = 'if'
|
12
|
+
KEYWORD_SHORT = 'if'
|
13
|
+
THEN = 'then'
|
14
|
+
|
15
|
+
#
|
16
|
+
# Run the verb.
|
17
|
+
#
|
18
|
+
def run
|
19
|
+
value = @tokens.before_token( THEN )
|
20
|
+
if value.count > 1
|
21
|
+
# The first token is the verb, so we drop it.
|
22
|
+
value = value[1..-1]
|
23
|
+
end
|
24
|
+
|
25
|
+
evals_true = false
|
26
|
+
if value.count > 0
|
27
|
+
expr = Gloo::Expr::Expression.new( value )
|
28
|
+
result = expr.evaluate
|
29
|
+
evals_true = true if result == true
|
30
|
+
end
|
31
|
+
|
32
|
+
if evals_true
|
33
|
+
cmd = @tokens.expr_after( THEN )
|
34
|
+
i = $engine.parser.parse_immediate cmd
|
35
|
+
return unless i
|
36
|
+
i.run
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
#
|
41
|
+
# Get the Verb's keyword.
|
42
|
+
#
|
43
|
+
def self.keyword
|
44
|
+
return KEYWORD
|
45
|
+
end
|
46
|
+
|
47
|
+
#
|
48
|
+
# Get the Verb's keyword shortcut.
|
49
|
+
#
|
50
|
+
def self.keyword_shortcut
|
51
|
+
return KEYWORD_SHORT
|
52
|
+
end
|
53
|
+
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
@@ -0,0 +1,85 @@
|
|
1
|
+
# Author:: Eric Crane (mailto:eric.crane@mac.com)
|
2
|
+
# Copyright:: Copyright (c) 2019 Eric Crane. All rights reserved.
|
3
|
+
#
|
4
|
+
# List out an object and it's children.
|
5
|
+
#
|
6
|
+
|
7
|
+
module Gloo
|
8
|
+
module Verbs
|
9
|
+
class List < Gloo::Core::Verb
|
10
|
+
|
11
|
+
KEYWORD = 'list'
|
12
|
+
KEYWORD_SHORT = '.'
|
13
|
+
|
14
|
+
#
|
15
|
+
# Run the verb.
|
16
|
+
#
|
17
|
+
def run
|
18
|
+
levels = determine_levels
|
19
|
+
target = self.determine_target
|
20
|
+
obj = target.resolve
|
21
|
+
if obj
|
22
|
+
self.show_target( obj, levels )
|
23
|
+
else
|
24
|
+
$log.warn "Object #{target} does not exist"
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
# Determine how many levels to show.
|
29
|
+
def determine_levels
|
30
|
+
# Check settings for the default value.
|
31
|
+
levels = $settings.list_indent
|
32
|
+
return levels if levels
|
33
|
+
|
34
|
+
# Last chance: use the default
|
35
|
+
return 1
|
36
|
+
end
|
37
|
+
|
38
|
+
# Determine the target object for the show command.
|
39
|
+
def determine_target
|
40
|
+
if @tokens.token_count == 1
|
41
|
+
return $engine.heap.context
|
42
|
+
else
|
43
|
+
return Gloo::Core::Pn.new( @tokens.second )
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
# Show the target object.
|
48
|
+
def show_target( obj, levels, indent="" )
|
49
|
+
show_obj( obj, indent )
|
50
|
+
|
51
|
+
return if levels == 0
|
52
|
+
obj.children.each do |o|
|
53
|
+
show_target( o, levels - 1, "#{indent} " )
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
# Show object in standard format.
|
58
|
+
def show_obj obj, indent=" "
|
59
|
+
if obj.has_multiline_value? && obj.value_is_array?
|
60
|
+
$log.show "#{indent}#{obj.name} [#{obj.type_display}] :"
|
61
|
+
obj.value.each do |line|
|
62
|
+
$log.show "#{indent} #{line}"
|
63
|
+
end
|
64
|
+
else
|
65
|
+
$log.show "#{indent}#{obj.name} [#{obj.type_display}] : #{obj.value}"
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
#
|
70
|
+
# Get the Verb's keyword.
|
71
|
+
#
|
72
|
+
def self.keyword
|
73
|
+
return KEYWORD
|
74
|
+
end
|
75
|
+
|
76
|
+
#
|
77
|
+
# Get the Verb's keyword shortcut.
|
78
|
+
#
|
79
|
+
def self.keyword_shortcut
|
80
|
+
return KEYWORD_SHORT
|
81
|
+
end
|
82
|
+
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
# Author:: Eric Crane (mailto:eric.crane@mac.com)
|
2
|
+
# Copyright:: Copyright (c) 2019 Eric Crane. All rights reserved.
|
3
|
+
#
|
4
|
+
# Save an object to a file or other persistance mechcanism.
|
5
|
+
#
|
6
|
+
|
7
|
+
module Gloo
|
8
|
+
module Verbs
|
9
|
+
class Load < Gloo::Core::Verb
|
10
|
+
|
11
|
+
KEYWORD = 'load'
|
12
|
+
KEYWORD_SHORT = '<'
|
13
|
+
|
14
|
+
#
|
15
|
+
# Run the verb.
|
16
|
+
#
|
17
|
+
def run
|
18
|
+
fn = @tokens.second
|
19
|
+
$log.debug "Getting ready to load file: #{fn}"
|
20
|
+
$engine.persist_man.load fn
|
21
|
+
end
|
22
|
+
|
23
|
+
#
|
24
|
+
# Get the Verb's keyword.
|
25
|
+
#
|
26
|
+
def self.keyword
|
27
|
+
return KEYWORD
|
28
|
+
end
|
29
|
+
|
30
|
+
#
|
31
|
+
# Get the Verb's keyword shortcut.
|
32
|
+
#
|
33
|
+
def self.keyword_shortcut
|
34
|
+
return KEYWORD_SHORT
|
35
|
+
end
|
36
|
+
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,62 @@
|
|
1
|
+
# Author:: Eric Crane (mailto:eric.crane@mac.com)
|
2
|
+
# Copyright:: Copyright (c) 2019 Eric Crane. All rights reserved.
|
3
|
+
#
|
4
|
+
# Create an object, optionally of a type.
|
5
|
+
#
|
6
|
+
|
7
|
+
module Gloo
|
8
|
+
module Verbs
|
9
|
+
class Put < Gloo::Core::Verb
|
10
|
+
|
11
|
+
KEYWORD = 'put'
|
12
|
+
KEYWORD_SHORT = 'p'
|
13
|
+
INTO = 'into'
|
14
|
+
|
15
|
+
#
|
16
|
+
# Run the verb.
|
17
|
+
#
|
18
|
+
def run
|
19
|
+
value = @tokens.before_token( INTO )
|
20
|
+
if value.nil?
|
21
|
+
$log.error "'put' must include 'into'"
|
22
|
+
end
|
23
|
+
if value.count > 1
|
24
|
+
# The first token is the verb, so we drop it.
|
25
|
+
value = value[1..-1]
|
26
|
+
end
|
27
|
+
|
28
|
+
target = @tokens.after_token( INTO )
|
29
|
+
if target.nil?
|
30
|
+
$log.error "'put' must include 'into' target"
|
31
|
+
end
|
32
|
+
pn = Gloo::Core::Pn.new target
|
33
|
+
o = pn.resolve
|
34
|
+
if o.nil?
|
35
|
+
$log.error "could not find target of put: #{target}"
|
36
|
+
else
|
37
|
+
if value.count > 0
|
38
|
+
expr = Gloo::Expr::Expression.new( value )
|
39
|
+
result = expr.evaluate
|
40
|
+
o.set_value result
|
41
|
+
$engine.heap.it.set_to result
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
#
|
47
|
+
# Get the Verb's keyword.
|
48
|
+
#
|
49
|
+
def self.keyword
|
50
|
+
return KEYWORD
|
51
|
+
end
|
52
|
+
|
53
|
+
#
|
54
|
+
# Get the Verb's keyword shortcut.
|
55
|
+
#
|
56
|
+
def self.keyword_shortcut
|
57
|
+
return KEYWORD_SHORT
|
58
|
+
end
|
59
|
+
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
# Author:: Eric Crane (mailto:eric.crane@mac.com)
|
2
|
+
# Copyright:: Copyright (c) 2019 Eric Crane. All rights reserved.
|
3
|
+
#
|
4
|
+
# Quit the running gloo engine.
|
5
|
+
#
|
6
|
+
|
7
|
+
module Gloo
|
8
|
+
module Verbs
|
9
|
+
class Quit < Gloo::Core::Verb
|
10
|
+
|
11
|
+
KEYWORD = 'quit'
|
12
|
+
KEYWORD_SHORT = 'q'
|
13
|
+
|
14
|
+
#
|
15
|
+
# Run the verb.
|
16
|
+
#
|
17
|
+
# We'll mark the application as not running and let the
|
18
|
+
# engine stop gracefully next time through the loop.
|
19
|
+
#
|
20
|
+
def run
|
21
|
+
$engine.stop_running
|
22
|
+
end
|
23
|
+
|
24
|
+
#
|
25
|
+
# Get the Verb's keyword.
|
26
|
+
#
|
27
|
+
def self.keyword
|
28
|
+
return KEYWORD
|
29
|
+
end
|
30
|
+
|
31
|
+
#
|
32
|
+
# Get the Verb's keyword shortcut.
|
33
|
+
#
|
34
|
+
def self.keyword_shortcut
|
35
|
+
return KEYWORD_SHORT
|
36
|
+
end
|
37
|
+
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
# Author:: Eric Crane (mailto:eric.crane@mac.com)
|
2
|
+
# Copyright:: Copyright (c) 2019 Eric Crane. All rights reserved.
|
3
|
+
#
|
4
|
+
# Run a script.
|
5
|
+
# Shortcut for telling a script to run.
|
6
|
+
#
|
7
|
+
|
8
|
+
module Gloo
|
9
|
+
module Verbs
|
10
|
+
class Run < Gloo::Core::Verb
|
11
|
+
|
12
|
+
KEYWORD = 'run'
|
13
|
+
KEYWORD_SHORT = 'r'
|
14
|
+
|
15
|
+
#
|
16
|
+
# Run the verb.
|
17
|
+
#
|
18
|
+
def run
|
19
|
+
name = @tokens.second
|
20
|
+
pn = Gloo::Core::Pn.new name
|
21
|
+
o = pn.resolve
|
22
|
+
|
23
|
+
if o
|
24
|
+
o.send_message 'run'
|
25
|
+
else
|
26
|
+
$log.error "Could not send message to object. Bad path: #{name}"
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
#
|
31
|
+
# Get the Verb's keyword.
|
32
|
+
#
|
33
|
+
def self.keyword
|
34
|
+
return KEYWORD
|
35
|
+
end
|
36
|
+
|
37
|
+
#
|
38
|
+
# Get the Verb's keyword shortcut.
|
39
|
+
#
|
40
|
+
def self.keyword_shortcut
|
41
|
+
return KEYWORD_SHORT
|
42
|
+
end
|
43
|
+
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|