gloo 0.3.0 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (87) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +73 -0
  3. data/Gemfile +2 -2
  4. data/Gemfile.lock +3 -3
  5. data/Rakefile +6 -6
  6. data/bin/console +4 -4
  7. data/gloo.gemspec +19 -18
  8. data/lib/gloo.rb +6 -6
  9. data/lib/gloo/app/args.rb +30 -31
  10. data/lib/gloo/app/engine.rb +33 -28
  11. data/lib/gloo/app/help.rb +17 -11
  12. data/lib/gloo/app/info.rb +3 -3
  13. data/lib/gloo/app/log.rb +17 -17
  14. data/lib/gloo/app/mode.rb +4 -4
  15. data/lib/gloo/app/settings.rb +43 -40
  16. data/lib/gloo/core/baseo.rb +7 -7
  17. data/lib/gloo/core/dictionary.rb +30 -27
  18. data/lib/gloo/core/error.rb +50 -0
  19. data/lib/gloo/core/event_manager.rb +17 -19
  20. data/lib/gloo/core/factory.rb +92 -39
  21. data/lib/gloo/core/gloo_system.rb +49 -54
  22. data/lib/gloo/core/heap.rb +15 -13
  23. data/lib/gloo/core/it.rb +5 -5
  24. data/lib/gloo/core/literal.rb +7 -7
  25. data/lib/gloo/core/obj.rb +89 -79
  26. data/lib/gloo/core/obj_finder.rb +9 -14
  27. data/lib/gloo/core/op.rb +8 -8
  28. data/lib/gloo/core/parser.rb +25 -26
  29. data/lib/gloo/core/pn.rb +65 -50
  30. data/lib/gloo/core/runner.rb +26 -0
  31. data/lib/gloo/core/script.rb +7 -7
  32. data/lib/gloo/core/tokens.rb +39 -41
  33. data/lib/gloo/core/verb.rb +30 -19
  34. data/lib/gloo/expr/expression.rb +35 -43
  35. data/lib/gloo/expr/l_boolean.rb +7 -6
  36. data/lib/gloo/expr/l_integer.rb +5 -4
  37. data/lib/gloo/expr/l_string.rb +13 -15
  38. data/lib/gloo/expr/op_div.rb +3 -5
  39. data/lib/gloo/expr/op_minus.rb +3 -5
  40. data/lib/gloo/expr/op_mult.rb +3 -5
  41. data/lib/gloo/expr/op_plus.rb +5 -7
  42. data/lib/gloo/objs/basic/boolean.rb +63 -38
  43. data/lib/gloo/objs/basic/container.rb +40 -12
  44. data/lib/gloo/objs/basic/integer.rb +40 -16
  45. data/lib/gloo/objs/basic/script.rb +62 -38
  46. data/lib/gloo/objs/basic/string.rb +39 -15
  47. data/lib/gloo/objs/basic/text.rb +43 -20
  48. data/lib/gloo/objs/basic/untyped.rb +35 -10
  49. data/lib/gloo/objs/cli/colorize.rb +53 -23
  50. data/lib/gloo/objs/cli/confirm.rb +63 -29
  51. data/lib/gloo/objs/cli/prompt.rb +63 -29
  52. data/lib/gloo/objs/ctrl/each.rb +98 -60
  53. data/lib/gloo/objs/dev/git.rb +98 -64
  54. data/lib/gloo/objs/ror/erb.rb +81 -41
  55. data/lib/gloo/objs/ror/eval.rb +73 -31
  56. data/lib/gloo/objs/snd/play.rb +71 -0
  57. data/lib/gloo/objs/snd/say.rb +120 -0
  58. data/lib/gloo/objs/system/file_handle.rb +80 -48
  59. data/lib/gloo/objs/system/system.rb +84 -38
  60. data/lib/gloo/objs/web/http_get.rb +83 -46
  61. data/lib/gloo/objs/web/http_post.rb +69 -43
  62. data/lib/gloo/objs/web/slack.rb +89 -58
  63. data/lib/gloo/objs/web/teams.rb +88 -53
  64. data/lib/gloo/persist/file_loader.rb +81 -82
  65. data/lib/gloo/persist/file_saver.rb +12 -12
  66. data/lib/gloo/persist/file_storage.rb +15 -15
  67. data/lib/gloo/persist/line_splitter.rb +74 -0
  68. data/lib/gloo/persist/persist_man.rb +29 -29
  69. data/lib/gloo/utils/words.rb +2 -2
  70. data/lib/gloo/verbs/alert.rb +67 -16
  71. data/lib/gloo/verbs/beep.rb +70 -0
  72. data/lib/gloo/verbs/context.rb +61 -21
  73. data/lib/gloo/verbs/create.rb +52 -21
  74. data/lib/gloo/verbs/help.rb +177 -27
  75. data/lib/gloo/verbs/if.rb +54 -21
  76. data/lib/gloo/verbs/list.rb +55 -24
  77. data/lib/gloo/verbs/load.rb +46 -12
  78. data/lib/gloo/verbs/put.rb +90 -34
  79. data/lib/gloo/verbs/quit.rb +43 -12
  80. data/lib/gloo/verbs/run.rb +42 -11
  81. data/lib/gloo/verbs/save.rb +45 -10
  82. data/lib/gloo/verbs/show.rb +56 -22
  83. data/lib/gloo/verbs/tell.rb +44 -12
  84. data/lib/gloo/verbs/unless.rb +55 -21
  85. data/lib/gloo/verbs/version.rb +42 -12
  86. data/lib/run.rb +5 -5
  87. metadata +19 -12
@@ -7,36 +7,35 @@
7
7
  module Gloo
8
8
  module Objs
9
9
  class Container < Gloo::Core::Obj
10
-
11
- KEYWORD = 'container'
12
- KEYWORD_SHORT = 'can'
13
10
 
14
- #
11
+ KEYWORD = 'container'.freeze
12
+ KEYWORD_SHORT = 'can'.freeze
13
+
14
+ #
15
15
  # The name of the object type.
16
- #
16
+ #
17
17
  def self.typename
18
18
  return KEYWORD
19
19
  end
20
20
 
21
- #
21
+ #
22
22
  # The short name of the object type.
23
- #
23
+ #
24
24
  def self.short_typename
25
25
  return KEYWORD_SHORT
26
26
  end
27
27
 
28
-
29
28
  # ---------------------------------------------------------------------
30
29
  # Messages
31
30
  # ---------------------------------------------------------------------
32
31
 
33
- #
32
+ #
34
33
  # Get a list of message names that this object receives.
35
- #
34
+ #
36
35
  def self.messages
37
- return super + [ "count" ]
36
+ return super + [ 'count' ]
38
37
  end
39
-
38
+
40
39
  # Count the number of children in the container.
41
40
  def msg_count
42
41
  i = child_count
@@ -44,6 +43,35 @@ module Gloo
44
43
  return i
45
44
  end
46
45
 
46
+ # ---------------------------------------------------------------------
47
+ # Help
48
+ # ---------------------------------------------------------------------
49
+
50
+ #
51
+ # Get help for this object type.
52
+ #
53
+ def self.help
54
+ return <<~TEXT
55
+ CONTAINER OBJECT TYPE
56
+ NAME: container
57
+ SHORTCUT: can
58
+
59
+ DESCRIPTION
60
+ A container of other objects.
61
+ A container is similar to a folder in a file system.
62
+ It can contain any number of objects including other containers.
63
+ The container structure provides direct access to any object
64
+ within it through the object.object.object path-name structure.
65
+
66
+ CHILDREN
67
+ None by default. But any container can have any number of
68
+ objects added to it.
69
+
70
+ MESSAGES
71
+ count - Count the number of children objects in the container.
72
+ The result is put in <it>.
73
+ TEXT
74
+ end
47
75
 
48
76
  end
49
77
  end
@@ -7,43 +7,42 @@
7
7
  module Gloo
8
8
  module Objs
9
9
  class Integer < Gloo::Core::Obj
10
-
11
- KEYWORD = 'integer'
12
- KEYWORD_SHORT = 'int'
13
10
 
14
- #
11
+ KEYWORD = 'integer'.freeze
12
+ KEYWORD_SHORT = 'int'.freeze
13
+
14
+ #
15
15
  # The name of the object type.
16
- #
16
+ #
17
17
  def self.typename
18
18
  return KEYWORD
19
19
  end
20
20
 
21
- #
21
+ #
22
22
  # The short name of the object type.
23
- #
23
+ #
24
24
  def self.short_typename
25
25
  return KEYWORD_SHORT
26
26
  end
27
27
 
28
- #
28
+ #
29
29
  # Set the value with any necessary type conversions.
30
- #
31
- def set_value new_value
30
+ #
31
+ def set_value( new_value )
32
32
  self.value = new_value.to_i
33
33
  end
34
-
35
-
34
+
36
35
  # ---------------------------------------------------------------------
37
36
  # Messages
38
37
  # ---------------------------------------------------------------------
39
38
 
40
- #
39
+ #
41
40
  # Get a list of message names that this object receives.
42
- #
41
+ #
43
42
  def self.messages
44
- return super + [ "inc", "dec" ]
43
+ return super + %w[inc dec]
45
44
  end
46
-
45
+
47
46
  # Increment the integer
48
47
  def msg_inc
49
48
  i = value + 1
@@ -60,6 +59,31 @@ module Gloo
60
59
  return i
61
60
  end
62
61
 
62
+ # ---------------------------------------------------------------------
63
+ # Help
64
+ # ---------------------------------------------------------------------
65
+
66
+ #
67
+ # Get help for this object type.
68
+ #
69
+ def self.help
70
+ return <<~TEXT
71
+ INTEGER OBJECT TYPE
72
+ NAME: integer
73
+ SHORTCUT: int
74
+
75
+ DESCRIPTION
76
+ An integer (numeric) value.
77
+
78
+ CHILDREN
79
+ None
80
+
81
+ MESSAGES
82
+ inc - Increment the integer value by 1.
83
+ dec - Decrement the integer value by 1.
84
+ TEXT
85
+ end
86
+
63
87
  end
64
88
  end
65
89
  end
@@ -8,43 +8,43 @@
8
8
  module Gloo
9
9
  module Objs
10
10
  class Script < Gloo::Core::Obj
11
-
12
- KEYWORD = 'script'
13
- KEYWORD_SHORT = 'cmd'
14
11
 
15
- #
12
+ KEYWORD = 'script'.freeze
13
+ KEYWORD_SHORT = 'cmd'.freeze
14
+
15
+ #
16
16
  # The name of the object type.
17
- #
17
+ #
18
18
  def self.typename
19
19
  return KEYWORD
20
20
  end
21
21
 
22
- #
22
+ #
23
23
  # The short name of the object type.
24
- #
24
+ #
25
25
  def self.short_typename
26
26
  return KEYWORD_SHORT
27
27
  end
28
28
 
29
- #
29
+ #
30
30
  # Set the value with any necessary type conversions.
31
- #
32
- def set_value new_value
31
+ #
32
+ def set_value( new_value )
33
33
  self.value = new_value.to_s
34
34
  end
35
-
36
- #
35
+
36
+ #
37
37
  # Set the value as an array.
38
- #
39
- def set_array_value arr
38
+ #
39
+ def set_array_value( arr )
40
40
  self.value = arr
41
41
  end
42
-
43
- #
42
+
43
+ #
44
44
  # Add a line (cmd) to the script.
45
- #
46
- def add_line line
47
- if self.value_is_string?
45
+ #
46
+ def add_line( line )
47
+ if self.value_string?
48
48
  first = self.value
49
49
  self.set_array_value []
50
50
  self.value << first unless first.empty?
@@ -54,48 +54,72 @@ module Gloo
54
54
  self.value << line.strip
55
55
  end
56
56
 
57
- #
57
+ #
58
58
  # Does this object support multi-line values?
59
59
  # Initially only true for scripts.
60
- #
61
- def has_multiline_value?
60
+ #
61
+ def multiline_value?
62
62
  return true
63
63
  end
64
-
65
- #
64
+
65
+ #
66
66
  # Get the number of lines in this script.
67
- #
67
+ #
68
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
69
+ return self.value.count if self.value_is_array?
70
+
71
+ if self.value_string?
72
+ return self.value.strip.empty? ? 0 : 1
76
73
  end
74
+
75
+ return 0
77
76
  end
78
77
 
79
-
80
78
  # ---------------------------------------------------------------------
81
79
  # Messages
82
80
  # ---------------------------------------------------------------------
83
81
 
84
- #
82
+ #
85
83
  # Get a list of message names that this object receives.
86
- #
84
+ #
87
85
  def self.messages
88
- return super + [ "run" ]
86
+ return super + [ 'run' ]
89
87
  end
90
88
 
91
- #
89
+ #
92
90
  # Send the object the unload message.
93
- #
91
+ #
94
92
  def msg_run
95
93
  s = Gloo::Core::Script.new self
96
94
  s.run
97
95
  end
98
96
 
97
+ # ---------------------------------------------------------------------
98
+ # Help
99
+ # ---------------------------------------------------------------------
100
+
101
+ #
102
+ # Get help for this object type.
103
+ #
104
+ def self.help
105
+ return <<~TEXT
106
+ SCRIPT OBJECT TYPE
107
+ NAME: script
108
+ SHORTCUT: cmd
109
+
110
+ DESCRIPTION
111
+ An exectutable script.
112
+
113
+ CHILDREN
114
+ None
115
+
116
+ MESSAGES
117
+ run - Run the script.
118
+ The script can be run by telling the object or run.
119
+ It can all be executed with the run verb.
120
+ TEXT
121
+ end
122
+
99
123
  end
100
124
  end
101
125
  end
@@ -7,43 +7,42 @@
7
7
  module Gloo
8
8
  module Objs
9
9
  class String < Gloo::Core::Obj
10
-
11
- KEYWORD = 'string'
12
- KEYWORD_SHORT = 'str'
13
10
 
14
- #
11
+ KEYWORD = 'string'.freeze
12
+ KEYWORD_SHORT = 'str'.freeze
13
+
14
+ #
15
15
  # The name of the object type.
16
- #
16
+ #
17
17
  def self.typename
18
18
  return KEYWORD
19
19
  end
20
20
 
21
- #
21
+ #
22
22
  # The short name of the object type.
23
- #
23
+ #
24
24
  def self.short_typename
25
25
  return KEYWORD_SHORT
26
26
  end
27
27
 
28
- #
28
+ #
29
29
  # Set the value with any necessary type conversions.
30
- #
31
- def set_value new_value
30
+ #
31
+ def set_value( new_value )
32
32
  self.value = new_value.to_s
33
33
  end
34
34
 
35
-
36
35
  # ---------------------------------------------------------------------
37
36
  # Messages
38
37
  # ---------------------------------------------------------------------
39
38
 
40
- #
39
+ #
41
40
  # Get a list of message names that this object receives.
42
- #
41
+ #
43
42
  def self.messages
44
- return super + [ "up", "down" ]
43
+ return super + %w[up down]
45
44
  end
46
-
45
+
47
46
  # Convert string to upper case
48
47
  def msg_up
49
48
  s = value.upcase
@@ -60,6 +59,31 @@ module Gloo
60
59
  return s
61
60
  end
62
61
 
62
+ # ---------------------------------------------------------------------
63
+ # Help
64
+ # ---------------------------------------------------------------------
65
+
66
+ #
67
+ # Get help for this object type.
68
+ #
69
+ def self.help
70
+ return <<~TEXT
71
+ STRING OBJECT TYPE
72
+ NAME: string
73
+ SHORTCUT: str
74
+
75
+ DESCRIPTION
76
+ A string value.
77
+
78
+ CHILDREN
79
+ None
80
+
81
+ MESSAGES
82
+ up - Convert the string to uppercase.
83
+ down - Convert the string to lowercase.
84
+ TEXT
85
+ end
86
+
63
87
  end
64
88
  end
65
89
  end
@@ -7,58 +7,81 @@
7
7
  module Gloo
8
8
  module Objs
9
9
  class Text < Gloo::Core::Obj
10
-
11
- KEYWORD = 'text'
12
- KEYWORD_SHORT = 'txt'
13
10
 
14
- #
11
+ KEYWORD = 'text'.freeze
12
+ KEYWORD_SHORT = 'txt'.freeze
13
+
14
+ #
15
15
  # The name of the object type.
16
- #
16
+ #
17
17
  def self.typename
18
18
  return KEYWORD
19
19
  end
20
20
 
21
- #
21
+ #
22
22
  # The short name of the object type.
23
- #
23
+ #
24
24
  def self.short_typename
25
25
  return KEYWORD_SHORT
26
26
  end
27
27
 
28
- #
28
+ #
29
29
  # Set the value with any necessary type conversions.
30
- #
31
- def set_value new_value
30
+ #
31
+ def set_value( new_value )
32
32
  self.value = new_value.to_s
33
33
  end
34
34
 
35
- #
35
+ #
36
36
  # Does this object support multi-line values?
37
37
  # Initially only true for scripts.
38
- #
39
- def has_multiline_value?
38
+ #
39
+ def multiline_value?
40
40
  return false
41
41
  end
42
-
43
- #
42
+
43
+ #
44
44
  # Get the number of lines of text.
45
- #
45
+ #
46
46
  def line_count
47
47
  return value.split( "\n" ).count
48
48
  end
49
-
50
-
49
+
51
50
  # ---------------------------------------------------------------------
52
51
  # Messages
53
52
  # ---------------------------------------------------------------------
54
53
 
55
- #
54
+ #
56
55
  # Get a list of message names that this object receives.
57
- #
56
+ #
58
57
  def self.messages
59
58
  return super
60
59
  end
61
60
 
61
+ # ---------------------------------------------------------------------
62
+ # Help
63
+ # ---------------------------------------------------------------------
64
+
65
+ #
66
+ # Get help for this object type.
67
+ #
68
+ def self.help
69
+ return <<~TEXT
70
+ TEXT OBJECT TYPE
71
+ NAME: text
72
+ SHORTCUT: txt
73
+
74
+ DESCRIPTION
75
+ A longer, multi-line text string.
76
+
77
+ CHILDREN
78
+ None
79
+
80
+ MESSAGES
81
+ None
82
+ TEXT
83
+ end
84
+
62
85
  end
63
86
  end
64
87
  end