gloo 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- 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,20 @@
|
|
1
|
+
# Author:: Eric Crane (mailto:eric.crane@mac.com)
|
2
|
+
# Copyright:: Copyright (c) 2019 Eric Crane. All rights reserved.
|
3
|
+
#
|
4
|
+
# Subtraction operator.
|
5
|
+
#
|
6
|
+
|
7
|
+
module Gloo
|
8
|
+
module Expr
|
9
|
+
class OpMinus < Gloo::Core::Op
|
10
|
+
|
11
|
+
# Perform the operation and return the result.
|
12
|
+
def perform left, right
|
13
|
+
if left.is_a? Integer
|
14
|
+
return left - right.to_i
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# Author:: Eric Crane (mailto:eric.crane@mac.com)
|
2
|
+
# Copyright:: Copyright (c) 2019 Eric Crane. All rights reserved.
|
3
|
+
#
|
4
|
+
# Multiplication operator.
|
5
|
+
#
|
6
|
+
|
7
|
+
module Gloo
|
8
|
+
module Expr
|
9
|
+
class OpMult < Gloo::Core::Op
|
10
|
+
|
11
|
+
# Perform the operation and return the result.
|
12
|
+
def perform left, right
|
13
|
+
if left.is_a? Integer
|
14
|
+
return left * right.to_i
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# Author:: Eric Crane (mailto:eric.crane@mac.com)
|
2
|
+
# Copyright:: Copyright (c) 2019 Eric Crane. All rights reserved.
|
3
|
+
#
|
4
|
+
# Addition operator.
|
5
|
+
#
|
6
|
+
|
7
|
+
module Gloo
|
8
|
+
module Expr
|
9
|
+
class OpPlus < Gloo::Core::Op
|
10
|
+
|
11
|
+
# Perform the operation and return the result.
|
12
|
+
def perform left, right
|
13
|
+
if left.is_a? String
|
14
|
+
return left + right.to_s
|
15
|
+
elsif left.is_a? Integer
|
16
|
+
return left + right.to_i
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,113 @@
|
|
1
|
+
# Author:: Eric Crane (mailto:eric.crane@mac.com)
|
2
|
+
# Copyright:: Copyright (c) 2019 Eric Crane. All rights reserved.
|
3
|
+
#
|
4
|
+
# An object with an boolean value.
|
5
|
+
#
|
6
|
+
|
7
|
+
module Gloo
|
8
|
+
module Objs
|
9
|
+
class Boolean < Gloo::Core::Obj
|
10
|
+
|
11
|
+
KEYWORD = 'boolean'
|
12
|
+
KEYWORD_SHORT = 'bool'
|
13
|
+
TRUE = 'true'
|
14
|
+
FALSE = 'false'
|
15
|
+
|
16
|
+
#
|
17
|
+
# The name of the object type.
|
18
|
+
#
|
19
|
+
def self.typename
|
20
|
+
return KEYWORD
|
21
|
+
end
|
22
|
+
|
23
|
+
#
|
24
|
+
# The short name of the object type.
|
25
|
+
#
|
26
|
+
def self.short_typename
|
27
|
+
return KEYWORD_SHORT
|
28
|
+
end
|
29
|
+
|
30
|
+
#
|
31
|
+
# Set the value with any necessary type conversions.
|
32
|
+
#
|
33
|
+
def set_value new_value
|
34
|
+
self.value = Gloo::Objs::Boolean.coerse_to_bool( new_value )
|
35
|
+
end
|
36
|
+
|
37
|
+
#
|
38
|
+
# Coerse the new value to a boolean value.
|
39
|
+
#
|
40
|
+
def self.coerse_to_bool new_value
|
41
|
+
if new_value.nil?
|
42
|
+
return false
|
43
|
+
elsif new_value.class.name == "String"
|
44
|
+
return true if new_value.strip.downcase == TRUE
|
45
|
+
return false if new_value.strip.downcase == FALSE
|
46
|
+
return true if new_value.strip.downcase == 't'
|
47
|
+
return false if new_value.strip.downcase == 'f'
|
48
|
+
elsif new_value.class.name == "Integer"
|
49
|
+
return false if new_value == 0
|
50
|
+
return true
|
51
|
+
else
|
52
|
+
return new_value == true
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
#
|
57
|
+
# Is the given token a boolean?
|
58
|
+
#
|
59
|
+
def self.is_boolean? token
|
60
|
+
return true if token == true
|
61
|
+
return true if token == false
|
62
|
+
if token.class.name == "String"
|
63
|
+
return true if token.strip.downcase == TRUE
|
64
|
+
return true if token.strip.downcase == FALSE
|
65
|
+
end
|
66
|
+
return false
|
67
|
+
end
|
68
|
+
|
69
|
+
|
70
|
+
#
|
71
|
+
# Get the value for display purposes.
|
72
|
+
#
|
73
|
+
def value_display
|
74
|
+
return value ? TRUE : FALSE
|
75
|
+
end
|
76
|
+
|
77
|
+
|
78
|
+
# ---------------------------------------------------------------------
|
79
|
+
# Messages
|
80
|
+
# ---------------------------------------------------------------------
|
81
|
+
|
82
|
+
#
|
83
|
+
# Get a list of message names that this object receives.
|
84
|
+
#
|
85
|
+
def self.messages
|
86
|
+
return super + [ "not", "true", "false" ]
|
87
|
+
end
|
88
|
+
|
89
|
+
# Set the value to the opposite of what it is.
|
90
|
+
def msg_not
|
91
|
+
v = ! value
|
92
|
+
set_value v
|
93
|
+
$engine.heap.it.set_to v
|
94
|
+
return v
|
95
|
+
end
|
96
|
+
|
97
|
+
# Set the value to true.
|
98
|
+
def msg_true
|
99
|
+
set_value true
|
100
|
+
$engine.heap.it.set_to true
|
101
|
+
return true
|
102
|
+
end
|
103
|
+
|
104
|
+
# Set the value to false.
|
105
|
+
def msg_false
|
106
|
+
set_value false
|
107
|
+
$engine.heap.it.set_to false
|
108
|
+
return false
|
109
|
+
end
|
110
|
+
|
111
|
+
end
|
112
|
+
end
|
113
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
# Author:: Eric Crane (mailto:eric.crane@mac.com)
|
2
|
+
# Copyright:: Copyright (c) 2019 Eric Crane. All rights reserved.
|
3
|
+
#
|
4
|
+
# An object that contains a collection of other objects.
|
5
|
+
#
|
6
|
+
|
7
|
+
module Gloo
|
8
|
+
module Objs
|
9
|
+
class Container < Gloo::Core::Obj
|
10
|
+
|
11
|
+
KEYWORD = 'container'
|
12
|
+
KEYWORD_SHORT = 'can'
|
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
|
+
# ---------------------------------------------------------------------
|
30
|
+
# Messages
|
31
|
+
# ---------------------------------------------------------------------
|
32
|
+
|
33
|
+
#
|
34
|
+
# Get a list of message names that this object receives.
|
35
|
+
#
|
36
|
+
def self.messages
|
37
|
+
return super + [ "count" ]
|
38
|
+
end
|
39
|
+
|
40
|
+
# Count the number of children in the container.
|
41
|
+
def msg_count
|
42
|
+
i = child_count
|
43
|
+
$engine.heap.it.set_to i
|
44
|
+
return i
|
45
|
+
end
|
46
|
+
|
47
|
+
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
@@ -0,0 +1,65 @@
|
|
1
|
+
# Author:: Eric Crane (mailto:eric.crane@mac.com)
|
2
|
+
# Copyright:: Copyright (c) 2019 Eric Crane. All rights reserved.
|
3
|
+
#
|
4
|
+
# An object with an integer value.
|
5
|
+
#
|
6
|
+
|
7
|
+
module Gloo
|
8
|
+
module Objs
|
9
|
+
class Integer < Gloo::Core::Obj
|
10
|
+
|
11
|
+
KEYWORD = 'integer'
|
12
|
+
KEYWORD_SHORT = 'int'
|
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
|
+
# Set the value with any necessary type conversions.
|
30
|
+
#
|
31
|
+
def set_value new_value
|
32
|
+
self.value = new_value.to_i
|
33
|
+
end
|
34
|
+
|
35
|
+
|
36
|
+
# ---------------------------------------------------------------------
|
37
|
+
# Messages
|
38
|
+
# ---------------------------------------------------------------------
|
39
|
+
|
40
|
+
#
|
41
|
+
# Get a list of message names that this object receives.
|
42
|
+
#
|
43
|
+
def self.messages
|
44
|
+
return super + [ "inc", "dec" ]
|
45
|
+
end
|
46
|
+
|
47
|
+
# Increment the integer
|
48
|
+
def msg_inc
|
49
|
+
i = value + 1
|
50
|
+
set_value i
|
51
|
+
$engine.heap.it.set_to i
|
52
|
+
return i
|
53
|
+
end
|
54
|
+
|
55
|
+
# Decrement the integer
|
56
|
+
def msg_dec
|
57
|
+
i = value - 1
|
58
|
+
set_value i
|
59
|
+
$engine.heap.it.set_to i
|
60
|
+
return i
|
61
|
+
end
|
62
|
+
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
@@ -0,0 +1,101 @@
|
|
1
|
+
# Author:: Eric Crane (mailto:eric.crane@mac.com)
|
2
|
+
# Copyright:: Copyright (c) 2019 Eric Crane. All rights reserved.
|
3
|
+
#
|
4
|
+
# A Script.
|
5
|
+
# A set of commands to be run.
|
6
|
+
#
|
7
|
+
|
8
|
+
module Gloo
|
9
|
+
module Objs
|
10
|
+
class Script < Gloo::Core::Obj
|
11
|
+
|
12
|
+
KEYWORD = 'script'
|
13
|
+
KEYWORD_SHORT = 'cmd'
|
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
|
+
# Set the value as an array.
|
38
|
+
#
|
39
|
+
def set_array_value arr
|
40
|
+
self.value = arr
|
41
|
+
end
|
42
|
+
|
43
|
+
#
|
44
|
+
# Add a line (cmd) to the script.
|
45
|
+
#
|
46
|
+
def add_line line
|
47
|
+
if self.value_is_string?
|
48
|
+
first = self.value
|
49
|
+
self.set_array_value []
|
50
|
+
self.value << first unless first.empty?
|
51
|
+
elsif self.value_is_blank?
|
52
|
+
self.set_array_value []
|
53
|
+
end
|
54
|
+
self.value << line.strip
|
55
|
+
end
|
56
|
+
|
57
|
+
#
|
58
|
+
# Does this object support multi-line values?
|
59
|
+
# Initially only true for scripts.
|
60
|
+
#
|
61
|
+
def has_multiline_value?
|
62
|
+
return true
|
63
|
+
end
|
64
|
+
|
65
|
+
#
|
66
|
+
# Get the number of lines in this script.
|
67
|
+
#
|
68
|
+
def line_count
|
69
|
+
if self.value_is_array?
|
70
|
+
return self.value.count
|
71
|
+
elsif self.value_is_string?
|
72
|
+
return 0 if ( self.value.strip.empty? )
|
73
|
+
return 1
|
74
|
+
else
|
75
|
+
return 0
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
|
80
|
+
# ---------------------------------------------------------------------
|
81
|
+
# Messages
|
82
|
+
# ---------------------------------------------------------------------
|
83
|
+
|
84
|
+
#
|
85
|
+
# Get a list of message names that this object receives.
|
86
|
+
#
|
87
|
+
def self.messages
|
88
|
+
return super + [ "run" ]
|
89
|
+
end
|
90
|
+
|
91
|
+
#
|
92
|
+
# Send the object the unload message.
|
93
|
+
#
|
94
|
+
def msg_run
|
95
|
+
s = Gloo::Core::Script.new self
|
96
|
+
s.run
|
97
|
+
end
|
98
|
+
|
99
|
+
end
|
100
|
+
end
|
101
|
+
end
|
@@ -0,0 +1,65 @@
|
|
1
|
+
# Author:: Eric Crane (mailto:eric.crane@mac.com)
|
2
|
+
# Copyright:: Copyright (c) 2019 Eric Crane. All rights reserved.
|
3
|
+
#
|
4
|
+
# A String.
|
5
|
+
#
|
6
|
+
|
7
|
+
module Gloo
|
8
|
+
module Objs
|
9
|
+
class String < Gloo::Core::Obj
|
10
|
+
|
11
|
+
KEYWORD = 'string'
|
12
|
+
KEYWORD_SHORT = 'str'
|
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
|
+
# Set the value with any necessary type conversions.
|
30
|
+
#
|
31
|
+
def set_value new_value
|
32
|
+
self.value = new_value.to_s
|
33
|
+
end
|
34
|
+
|
35
|
+
|
36
|
+
# ---------------------------------------------------------------------
|
37
|
+
# Messages
|
38
|
+
# ---------------------------------------------------------------------
|
39
|
+
|
40
|
+
#
|
41
|
+
# Get a list of message names that this object receives.
|
42
|
+
#
|
43
|
+
def self.messages
|
44
|
+
return super + [ "up", "down" ]
|
45
|
+
end
|
46
|
+
|
47
|
+
# Convert string to upper case
|
48
|
+
def msg_up
|
49
|
+
s = value.upcase
|
50
|
+
set_value s
|
51
|
+
$engine.heap.it.set_to s
|
52
|
+
return s
|
53
|
+
end
|
54
|
+
|
55
|
+
# Convert string to lower case
|
56
|
+
def msg_down
|
57
|
+
s = value.downcase
|
58
|
+
set_value s
|
59
|
+
$engine.heap.it.set_to s
|
60
|
+
return s
|
61
|
+
end
|
62
|
+
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|