gloo 0.8.0 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (203) hide show
  1. checksums.yaml +4 -4
  2. data/.DS_Store +0 -0
  3. data/.gitignore +2 -1
  4. data/.ruby-gemset +1 -0
  5. data/.ruby-version +1 -0
  6. data/LICENSE.txt +1 -1
  7. data/gloo.gemspec +12 -4
  8. data/lib/VERSION +1 -1
  9. data/lib/dependencies.rb +4 -4
  10. data/lib/gloo/app/info.rb +3 -1
  11. data/lib/gloo/app/log.rb +1 -29
  12. data/lib/gloo/app/platform.rb +142 -0
  13. data/lib/gloo/objs/cli/banner.rb +2 -2
  14. data/lib/gloo/objs/cli/bar.rb +4 -4
  15. data/lib/gloo/objs/cli/colorize.rb +3 -3
  16. data/lib/gloo/objs/cli/confirm.rb +3 -3
  17. data/lib/gloo/objs/cli/menu.rb +9 -9
  18. data/lib/gloo/objs/cli/menu_item.rb +2 -2
  19. data/lib/gloo/objs/cli/pastel.rb +2 -2
  20. data/lib/gloo/objs/cli/prompt.rb +4 -4
  21. data/lib/gloo/objs/cli/select.rb +4 -4
  22. data/lib/gloo/objs/data/mysql.rb +9 -9
  23. data/lib/gloo/objs/data/sqlite.rb +10 -10
  24. data/lib/gloo/objs/dev/git.rb +7 -7
  25. data/lib/gloo/objs/dev/stats.rb +8 -5
  26. data/lib/gloo/objs/snd/play.rb +1 -1
  27. data/lib/gloo/objs/snd/say.rb +2 -2
  28. data/lib/gloo/objs/system/file_handle.rb +9 -9
  29. data/lib/gloo/objs/system/ssh_exec.rb +3 -3
  30. data/lib/gloo/objs/system/system.rb +2 -2
  31. data/lib/gloo/verbs/alert.rb +7 -7
  32. data/lib/gloo/verbs/beep.rb +1 -1
  33. data/lib/gloo/verbs/cls.rb +2 -2
  34. data/lib/gloo/verbs/help.rb +7 -189
  35. data/lib/gloo/verbs/version.rb +3 -3
  36. data/lib/gloo.rb +5 -1
  37. data/lib/run.rb +5 -1
  38. metadata +41 -177
  39. data/Gemfile.lock +0 -171
  40. data/lib/gloo/app/args.rb +0 -112
  41. data/lib/gloo/app/engine.rb +0 -230
  42. data/lib/gloo/app/help.rb +0 -156
  43. data/lib/gloo/app/mode.rb +0 -27
  44. data/lib/gloo/app/settings.rb +0 -186
  45. data/lib/gloo/convert/converter.rb +0 -35
  46. data/lib/gloo/convert/string_to_datetime.rb +0 -21
  47. data/lib/gloo/convert/string_to_decimal.rb +0 -20
  48. data/lib/gloo/convert/string_to_integer.rb +0 -20
  49. data/lib/gloo/core/baseo.rb +0 -30
  50. data/lib/gloo/core/dictionary.rb +0 -181
  51. data/lib/gloo/core/error.rb +0 -61
  52. data/lib/gloo/core/event_manager.rb +0 -44
  53. data/lib/gloo/core/factory.rb +0 -210
  54. data/lib/gloo/core/gloo_system.rb +0 -266
  55. data/lib/gloo/core/heap.rb +0 -52
  56. data/lib/gloo/core/here.rb +0 -36
  57. data/lib/gloo/core/it.rb +0 -36
  58. data/lib/gloo/core/literal.rb +0 -30
  59. data/lib/gloo/core/obj.rb +0 -303
  60. data/lib/gloo/core/obj_finder.rb +0 -30
  61. data/lib/gloo/core/op.rb +0 -40
  62. data/lib/gloo/core/parser.rb +0 -59
  63. data/lib/gloo/core/pn.rb +0 -188
  64. data/lib/gloo/core/tokens.rb +0 -165
  65. data/lib/gloo/core/verb.rb +0 -86
  66. data/lib/gloo/exec/action.rb +0 -48
  67. data/lib/gloo/exec/dispatch.rb +0 -40
  68. data/lib/gloo/exec/exec_env.rb +0 -74
  69. data/lib/gloo/exec/runner.rb +0 -45
  70. data/lib/gloo/exec/script.rb +0 -49
  71. data/lib/gloo/exec/stack.rb +0 -78
  72. data/lib/gloo/expr/expression.rb +0 -118
  73. data/lib/gloo/expr/l_boolean.rb +0 -36
  74. data/lib/gloo/expr/l_decimal.rb +0 -39
  75. data/lib/gloo/expr/l_integer.rb +0 -37
  76. data/lib/gloo/expr/l_string.rb +0 -58
  77. data/lib/gloo/expr/op_div.rb +0 -22
  78. data/lib/gloo/expr/op_minus.rb +0 -22
  79. data/lib/gloo/expr/op_mult.rb +0 -22
  80. data/lib/gloo/expr/op_plus.rb +0 -24
  81. data/lib/gloo/help/app/application.txt +0 -22
  82. data/lib/gloo/help/app/configuration.txt +0 -7
  83. data/lib/gloo/help/app/default_help.txt +0 -14
  84. data/lib/gloo/help/app/logging.txt +0 -16
  85. data/lib/gloo/help/core/color.txt +0 -31
  86. data/lib/gloo/help/core/error.txt +0 -33
  87. data/lib/gloo/help/core/events.txt +0 -21
  88. data/lib/gloo/help/core/gloo_system.txt +0 -57
  89. data/lib/gloo/help/core/here.txt +0 -30
  90. data/lib/gloo/help/core/it.txt +0 -23
  91. data/lib/gloo/help/core/ops.txt +0 -16
  92. data/lib/gloo/help/core/pathname.txt +0 -29
  93. data/lib/gloo/help/objs/basic/alias.txt +0 -36
  94. data/lib/gloo/help/objs/basic/boolean.txt +0 -28
  95. data/lib/gloo/help/objs/basic/container.txt +0 -33
  96. data/lib/gloo/help/objs/basic/decimal.txt +0 -28
  97. data/lib/gloo/help/objs/basic/integer.txt +0 -27
  98. data/lib/gloo/help/objs/basic/script.txt +0 -29
  99. data/lib/gloo/help/objs/basic/string.txt +0 -28
  100. data/lib/gloo/help/objs/basic/text.txt +0 -27
  101. data/lib/gloo/help/objs/basic/untyped.txt +0 -22
  102. data/lib/gloo/help/objs/cli/banner.txt +0 -49
  103. data/lib/gloo/help/objs/cli/bar.txt +0 -37
  104. data/lib/gloo/help/objs/cli/colorize.txt +0 -33
  105. data/lib/gloo/help/objs/cli/confirm.txt +0 -26
  106. data/lib/gloo/help/objs/cli/menu.txt +0 -44
  107. data/lib/gloo/help/objs/cli/menu_item.txt +0 -26
  108. data/lib/gloo/help/objs/cli/pastel.txt +0 -43
  109. data/lib/gloo/help/objs/cli/prompt.txt +0 -27
  110. data/lib/gloo/help/objs/cli/select.txt +0 -34
  111. data/lib/gloo/help/objs/ctrl/each.txt +0 -48
  112. data/lib/gloo/help/objs/ctrl/repeat.txt +0 -38
  113. data/lib/gloo/help/objs/data/markdown.txt +0 -25
  114. data/lib/gloo/help/objs/data/mysql.txt +0 -40
  115. data/lib/gloo/help/objs/data/query.txt +0 -37
  116. data/lib/gloo/help/objs/data/sqlite.txt +0 -26
  117. data/lib/gloo/help/objs/data/table.txt +0 -46
  118. data/lib/gloo/help/objs/dev/git_repo.txt +0 -36
  119. data/lib/gloo/help/objs/dev/stats.txt +0 -36
  120. data/lib/gloo/help/objs/dt/date.txt +0 -23
  121. data/lib/gloo/help/objs/dt/datetime.txt +0 -24
  122. data/lib/gloo/help/objs/dt/time.txt +0 -23
  123. data/lib/gloo/help/objs/ror/erb.txt +0 -37
  124. data/lib/gloo/help/objs/ror/eval.txt +0 -24
  125. data/lib/gloo/help/objs/snd/play.txt +0 -23
  126. data/lib/gloo/help/objs/snd/say.txt +0 -28
  127. data/lib/gloo/help/objs/system/file.txt +0 -48
  128. data/lib/gloo/help/objs/system/ssh_exec.txt +0 -30
  129. data/lib/gloo/help/objs/system/system.txt +0 -32
  130. data/lib/gloo/help/objs/web/http_get.txt +0 -35
  131. data/lib/gloo/help/objs/web/http_post.txt +0 -34
  132. data/lib/gloo/help/objs/web/json.txt +0 -34
  133. data/lib/gloo/help/objs/web/slack.txt +0 -33
  134. data/lib/gloo/help/objs/web/teams.txt +0 -30
  135. data/lib/gloo/help/objs/web/uri.txt +0 -38
  136. data/lib/gloo/help/verbs/alert.txt +0 -33
  137. data/lib/gloo/help/verbs/beep.txt +0 -25
  138. data/lib/gloo/help/verbs/cls.txt +0 -24
  139. data/lib/gloo/help/verbs/context.txt +0 -43
  140. data/lib/gloo/help/verbs/create.txt +0 -33
  141. data/lib/gloo/help/verbs/execute.txt +0 -27
  142. data/lib/gloo/help/verbs/help.txt +0 -34
  143. data/lib/gloo/help/verbs/if.txt +0 -37
  144. data/lib/gloo/help/verbs/list.txt +0 -34
  145. data/lib/gloo/help/verbs/load.txt +0 -38
  146. data/lib/gloo/help/verbs/move.txt +0 -42
  147. data/lib/gloo/help/verbs/put.txt +0 -38
  148. data/lib/gloo/help/verbs/quit.txt +0 -25
  149. data/lib/gloo/help/verbs/run.txt +0 -41
  150. data/lib/gloo/help/verbs/save.txt +0 -26
  151. data/lib/gloo/help/verbs/show.txt +0 -30
  152. data/lib/gloo/help/verbs/tell.txt +0 -34
  153. data/lib/gloo/help/verbs/unless.txt +0 -38
  154. data/lib/gloo/help/verbs/version.txt +0 -32
  155. data/lib/gloo/help/verbs/wait.txt +0 -29
  156. data/lib/gloo/objs/basic/alias.rb +0 -78
  157. data/lib/gloo/objs/basic/boolean.rb +0 -120
  158. data/lib/gloo/objs/basic/container.rb +0 -76
  159. data/lib/gloo/objs/basic/decimal.rb +0 -76
  160. data/lib/gloo/objs/basic/integer.rb +0 -73
  161. data/lib/gloo/objs/basic/script.rb +0 -99
  162. data/lib/gloo/objs/basic/string.rb +0 -77
  163. data/lib/gloo/objs/basic/text.rb +0 -87
  164. data/lib/gloo/objs/basic/untyped.rb +0 -41
  165. data/lib/gloo/objs/ctrl/each.rb +0 -279
  166. data/lib/gloo/objs/ctrl/repeat.rb +0 -108
  167. data/lib/gloo/objs/data/markdown.rb +0 -84
  168. data/lib/gloo/objs/data/query.rb +0 -176
  169. data/lib/gloo/objs/data/table.rb +0 -140
  170. data/lib/gloo/objs/dt/date.rb +0 -50
  171. data/lib/gloo/objs/dt/datetime.rb +0 -62
  172. data/lib/gloo/objs/dt/time.rb +0 -50
  173. data/lib/gloo/objs/ror/erb.rb +0 -116
  174. data/lib/gloo/objs/ror/eval.rb +0 -107
  175. data/lib/gloo/objs/web/http_get.rb +0 -159
  176. data/lib/gloo/objs/web/http_post.rb +0 -183
  177. data/lib/gloo/objs/web/json.rb +0 -135
  178. data/lib/gloo/objs/web/slack.rb +0 -130
  179. data/lib/gloo/objs/web/teams.rb +0 -117
  180. data/lib/gloo/objs/web/uri.rb +0 -148
  181. data/lib/gloo/persist/file_loader.rb +0 -191
  182. data/lib/gloo/persist/file_saver.rb +0 -49
  183. data/lib/gloo/persist/file_storage.rb +0 -45
  184. data/lib/gloo/persist/line_splitter.rb +0 -81
  185. data/lib/gloo/persist/persist_man.rb +0 -120
  186. data/lib/gloo/utils/format.rb +0 -21
  187. data/lib/gloo/utils/stats.rb +0 -205
  188. data/lib/gloo/utils/words.rb +0 -19
  189. data/lib/gloo/verbs/context.rb +0 -62
  190. data/lib/gloo/verbs/create.rb +0 -68
  191. data/lib/gloo/verbs/execute.rb +0 -56
  192. data/lib/gloo/verbs/if.rb +0 -92
  193. data/lib/gloo/verbs/list.rb +0 -98
  194. data/lib/gloo/verbs/load.rb +0 -45
  195. data/lib/gloo/verbs/move.rb +0 -89
  196. data/lib/gloo/verbs/put.rb +0 -94
  197. data/lib/gloo/verbs/quit.rb +0 -40
  198. data/lib/gloo/verbs/run.rb +0 -75
  199. data/lib/gloo/verbs/save.rb +0 -39
  200. data/lib/gloo/verbs/show.rb +0 -64
  201. data/lib/gloo/verbs/tell.rb +0 -79
  202. data/lib/gloo/verbs/unless.rb +0 -92
  203. data/lib/gloo/verbs/wait.rb +0 -42
@@ -1,73 +0,0 @@
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'.freeze
12
- KEYWORD_SHORT = 'int'.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
- # Set the value with any necessary type conversions.
30
- #
31
- def set_value( new_value )
32
- unless new_value.is_a? Numeric
33
- self.value = $engine.converter.convert( new_value, 'Integer', 0 )
34
- return
35
- end
36
-
37
- self.value = new_value.to_i
38
- end
39
-
40
- # ---------------------------------------------------------------------
41
- # Messages
42
- # ---------------------------------------------------------------------
43
-
44
- #
45
- # Get a list of message names that this object receives.
46
- #
47
- def self.messages
48
- return super + %w[inc dec]
49
- end
50
-
51
- #
52
- # Increment the integer
53
- #
54
- def msg_inc
55
- i = value + 1
56
- set_value i
57
- $engine.heap.it.set_to i
58
- return i
59
- end
60
-
61
- #
62
- # Decrement the integer
63
- #
64
- def msg_dec
65
- i = value - 1
66
- set_value i
67
- $engine.heap.it.set_to i
68
- return i
69
- end
70
-
71
- end
72
- end
73
- end
@@ -1,99 +0,0 @@
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'.freeze
13
- KEYWORD_SHORT = 'cmd'.freeze
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_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 multiline_value?
62
- return true
63
- end
64
-
65
- #
66
- # Get the number of lines in this script.
67
- #
68
- def line_count
69
- return self.value.count if self.value_is_array?
70
-
71
- if self.value_string?
72
- return self.value.strip.empty? ? 0 : 1
73
- end
74
-
75
- return 0
76
- end
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 + [ 'run' ]
87
- end
88
-
89
- #
90
- # Send the object the unload message.
91
- #
92
- def msg_run
93
- s = Gloo::Exec::Script.new self
94
- s.run
95
- end
96
-
97
- end
98
- end
99
- end
@@ -1,77 +0,0 @@
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'.freeze
12
- KEYWORD_SHORT = 'str'.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
- # 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
- # Messages
37
- # ---------------------------------------------------------------------
38
-
39
- #
40
- # Get a list of message names that this object receives.
41
- #
42
- def self.messages
43
- return super + %w[up down size]
44
- end
45
-
46
- #
47
- # Get the size of the string.
48
- #
49
- def msg_size
50
- s = value.size
51
- $engine.heap.it.set_to s
52
- return s
53
- end
54
-
55
- #
56
- # Convert string to upper case
57
- #
58
- def msg_up
59
- s = value.upcase
60
- set_value s
61
- $engine.heap.it.set_to s
62
- return s
63
- end
64
-
65
- #
66
- # Convert string to lower case
67
- #
68
- def msg_down
69
- s = value.downcase
70
- set_value s
71
- $engine.heap.it.set_to s
72
- return s
73
- end
74
-
75
- end
76
- end
77
- end
@@ -1,87 +0,0 @@
1
- # Author:: Eric Crane (mailto:eric.crane@mac.com)
2
- # Copyright:: Copyright (c) 2019 Eric Crane. All rights reserved.
3
- #
4
- # A [multiline] block of text.
5
- #
6
- require 'tty-editor'
7
- require 'tty-pager'
8
-
9
- module Gloo
10
- module Objs
11
- class Text < Gloo::Core::Obj
12
-
13
- KEYWORD = 'text'.freeze
14
- KEYWORD_SHORT = 'txt'.freeze
15
- DEFAULT_TMP_FILE = 'tmp.txt'.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
- # Set the value with any necessary type conversions.
33
- #
34
- def set_value( new_value )
35
- self.value = new_value.to_s
36
- end
37
-
38
- #
39
- # Does this object support multi-line values?
40
- # Initially only true for scripts.
41
- #
42
- def multiline_value?
43
- return false
44
- end
45
-
46
- #
47
- # Get the number of lines of text.
48
- #
49
- def line_count
50
- return value.split( "\n" ).count
51
- end
52
-
53
- # ---------------------------------------------------------------------
54
- # Messages
55
- # ---------------------------------------------------------------------
56
-
57
- #
58
- # Get a list of message names that this object receives.
59
- #
60
- def self.messages
61
- return super + %w[edit page]
62
- end
63
-
64
- #
65
- # Show the contents of the file, paginated.
66
- #
67
- def msg_page
68
- return unless value
69
-
70
- # pager = TTY::Pager::SystemPager.new command: 'less -R'
71
- pager = TTY::Pager.new
72
- pager.page( value )
73
- end
74
-
75
- #
76
- # Edit the text in the default editor.
77
- #
78
- def msg_edit
79
- tmp = File.join( $settings.tmp_path, DEFAULT_TMP_FILE )
80
- File.open( tmp, 'w' ) { |file| file.write( self.value ) }
81
- TTY::Editor.open( tmp )
82
- set_value File.read( tmp )
83
- end
84
-
85
- end
86
- end
87
- end
@@ -1,41 +0,0 @@
1
- # Author:: Eric Crane (mailto:eric.crane@mac.com)
2
- # Copyright:: Copyright (c) 2019 Eric Crane. All rights reserved.
3
- #
4
- # An Untyped Object.
5
- #
6
-
7
- module Gloo
8
- module Objs
9
- class Untyped < Gloo::Core::Obj
10
-
11
- KEYWORD = 'untyped'.freeze
12
- KEYWORD_SHORT = 'un'.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
- end
40
- end
41
- end
@@ -1,279 +0,0 @@
1
- # Author:: Eric Crane (mailto:eric.crane@mac.com)
2
- # Copyright:: Copyright (c) 2019 Eric Crane. All rights reserved.
3
- #
4
- # A looping construct...do something for each whatever in something.
5
- # This object has several possible uses:
6
- # - each word in a string
7
- # - each line in a string
8
- # - each file in a directory
9
- # - each git repo in a directory
10
- #
11
-
12
- module Gloo
13
- module Objs
14
- class Each < Gloo::Core::Obj
15
-
16
- KEYWORD = 'each'.freeze
17
- KEYWORD_SHORT = 'each'.freeze
18
- CHILD = 'child'.freeze
19
- WORD = 'word'.freeze
20
- LINE = 'line'.freeze
21
- FILE = 'file'.freeze
22
- REPO = 'repo'.freeze
23
- IN = 'IN'.freeze
24
- DO = 'do'.freeze
25
-
26
- #
27
- # The name of the object type.
28
- #
29
- def self.typename
30
- return KEYWORD
31
- end
32
-
33
- #
34
- # The short name of the object type.
35
- #
36
- def self.short_typename
37
- return KEYWORD_SHORT
38
- end
39
-
40
- #
41
- # Get the URI from the child object.
42
- # Returns nil if there is none.
43
- #
44
- def in_value
45
- o = find_child IN
46
- return o ? o.value : nil
47
- end
48
-
49
- #
50
- # Run the do script once.
51
- #
52
- def run_do
53
- o = find_child DO
54
- return unless o
55
-
56
- Gloo::Exec::Dispatch.message 'run', o
57
- end
58
-
59
- # ---------------------------------------------------------------------
60
- # Children
61
- # ---------------------------------------------------------------------
62
-
63
- #
64
- # Does this object have children to add when an object
65
- # is created in interactive mode?
66
- # This does not apply during obj load, etc.
67
- #
68
- def add_children_on_create?
69
- return true
70
- end
71
-
72
- #
73
- # Add children to this object.
74
- # This is used by containers to add children needed
75
- # for default configurations.
76
- #
77
- def add_default_children
78
- fac = $engine.factory
79
- fac.create_string WORD, '', self
80
- fac.create_string IN, '', self
81
- fac.create_script DO, '', self
82
- end
83
-
84
- # ---------------------------------------------------------------------
85
- # Messages
86
- # ---------------------------------------------------------------------
87
-
88
- #
89
- # Get a list of message names that this object receives.
90
- #
91
- def self.messages
92
- return super + [ 'run' ]
93
- end
94
-
95
- # Run the system command.
96
- def msg_run
97
- if each_child?
98
- run_each_child
99
- elsif each_word?
100
- run_each_word
101
- elsif each_line?
102
- run_each_line
103
- elsif each_repo?
104
- run_each_repo
105
- end
106
- end
107
-
108
- # ---------------------------------------------------------------------
109
- # Child Object
110
- # ---------------------------------------------------------------------
111
-
112
- #
113
- # Is it set up to run for each word?
114
- # If there is a child object by the name "word"
115
- # then we will loop for each word in the string.
116
- #
117
- def each_child?
118
- return true if contains_child? CHILD
119
-
120
- return false
121
- end
122
-
123
- #
124
- # Run for each word.
125
- #
126
- def run_each_child
127
- o = find_child IN
128
- return unless o
129
-
130
- o = Gloo::Objs::Alias.resolve_alias( o )
131
- o.children.each do |child|
132
- set_child child
133
- run_do
134
- end
135
- end
136
-
137
- #
138
- # Set the child alias.
139
- #
140
- def set_child( obj )
141
- o = find_child CHILD
142
- return unless o
143
-
144
- o.set_value obj.pn
145
- end
146
-
147
- # ---------------------------------------------------------------------
148
- # Word
149
- # ---------------------------------------------------------------------
150
-
151
- #
152
- # Is it set up to run for each word?
153
- # If there is a child object by the name "word"
154
- # then we will loop for each word in the string.
155
- #
156
- def each_word?
157
- return true if find_child WORD
158
-
159
- return false
160
- end
161
-
162
- #
163
- # Run for each word.
164
- #
165
- def run_each_word
166
- str = in_value
167
- return unless str
168
-
169
- str.split( ' ' ).each do |word|
170
- set_word word
171
- run_do
172
- end
173
- end
174
-
175
- #
176
- # Set the value of the word.
177
- #
178
- def set_word( word )
179
- o = find_child WORD
180
- return unless o
181
-
182
- o.set_value word
183
- end
184
-
185
- # ---------------------------------------------------------------------
186
- # Line
187
- # ---------------------------------------------------------------------
188
-
189
- #
190
- # Is it set up to run for each line?
191
- # If there is a child object by the name "line"
192
- # then we will loop for each line in the string.
193
- #
194
- def each_line?
195
- return true if find_child LINE
196
-
197
- return false
198
- end
199
-
200
- #
201
- # Run for each line.
202
- #
203
- def run_each_line
204
- str = in_value
205
- return unless str
206
-
207
- str.each_line do |line|
208
- set_line line
209
- run_do
210
- end
211
- end
212
-
213
- #
214
- # Set the value of the word.
215
- #
216
- def set_line( line )
217
- o = find_child LINE
218
- return unless o
219
-
220
- o.set_value line
221
- end
222
-
223
- # ---------------------------------------------------------------------
224
- # Git Repo
225
- # ---------------------------------------------------------------------
226
-
227
- #
228
- # Is it set up to run for each git repo?
229
- # If there is a child object by the name "repo"
230
- # then we will loop for each repo in the directory.
231
- #
232
- def each_repo?
233
- return true if find_child REPO
234
-
235
- return false
236
- end
237
-
238
- #
239
- # Find all git projects in a path.
240
- #
241
- def find_all_git_projects( path )
242
- path.children.collect do |f|
243
- if f.directory? && ( File.basename( f ) == '.git' )
244
- File.dirname( f )
245
- elsif f.directory?
246
- find_all_git_projects( f )
247
- end
248
- end.flatten.compact
249
- end
250
-
251
- #
252
- # Run for each line.
253
- #
254
- def run_each_repo
255
- path = in_value
256
- return unless path
257
-
258
- path = Pathname.new( path )
259
- repos = find_all_git_projects( path )
260
- repos.each do |o|
261
- set_repo o
262
- run_do
263
- end
264
- end
265
-
266
- #
267
- # Set the value of the repo.
268
- # This is a path to the repo.
269
- #
270
- def set_repo( path )
271
- o = find_child REPO
272
- return unless o
273
-
274
- o.set_value path
275
- end
276
-
277
- end
278
- end
279
- end