gloo 3.5.0 → 3.6.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b527dd8c4837506689358a05681e7e81ba5804aeb617815db80e014a6f0f381b
4
- data.tar.gz: 9d0d089ff54f1c669ee3b1009411e8a0310ed01792b008946f3fee8feff89313
3
+ metadata.gz: 6e79ebad69bd8325e6f1b09ecd7d32520e7f82d1e4181d74c31433e4ca159cda
4
+ data.tar.gz: 50cdd391fa4d96d0cb8897bf8b8fdb02b30aea567083343e5540b492399a9e93
5
5
  SHA512:
6
- metadata.gz: f0632bc38a33051cbe970e0f29e01fac34d29ad9988df31773518c5cdc4d501a9462ff9a3c17fd54fa5db8b5c5326fa890eb8a1d395d7dedef057b5e41da16fc
7
- data.tar.gz: 6370739e3e635f6659ed5f28c62fd7d858cd8cb7b02e2115c29119434b8459e5cdb78dc9d1f3a547424425e41242d000216b9f89899734aa7d1e9206b4282662
6
+ metadata.gz: 6712527d452fb8c73799f4e9829ffe58edb518aa6ed440e30fadb9211af0b899dce31453098f518b6310b693aec330d567b7ffb50713049c9abb3c27b7395eb8
7
+ data.tar.gz: ba4b513a0e8b587d7418d10a16cfed7ecd2df4a9ce85409cdd78c59a5d936b0714008bfd02baa8a66814be1855ece161d3a07a9b7b1f6e6783d1ef9cf5091835
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- ruby-3.2.5
1
+ 3.3.5
data/lib/VERSION CHANGED
@@ -1 +1 @@
1
- 3.5.0
1
+ 3.6.0
data/lib/VERSION_NOTES CHANGED
@@ -1,3 +1,10 @@
1
+ 3.6.0 - 2024.11.26
2
+ - Adds support for route parameters
3
+ - Updates iterators
4
+ - Clear results for SQL queries
5
+ - Bug fixes
6
+
7
+
1
8
  3.5.0 - 2024.10.18
2
9
  - check obj for message alternate to tell
3
10
  - new base object messages
data/lib/gloo/app/info.rb CHANGED
@@ -4,8 +4,6 @@
4
4
  # Application information such as Version and public name.
5
5
  #
6
6
 
7
- # require 'gloo-lang'
8
-
9
7
  module Gloo
10
8
  module App
11
9
  class Info
@@ -12,6 +12,8 @@ module Gloo
12
12
  # Convert the given string value to an integer.
13
13
  #
14
14
  def convert( value )
15
+ return nil if value.blank?
16
+
15
17
  return value.to_i
16
18
  end
17
19
 
@@ -15,7 +15,7 @@ module Gloo
15
15
  # Does the pathname start with here reference?
16
16
  #
17
17
  def self.includes_here_ref?( elements )
18
- return elements.first.start_with?( HERE )
18
+ return elements.first&.start_with?( HERE )
19
19
  end
20
20
 
21
21
  #
data/lib/gloo/core/obj.rb CHANGED
@@ -137,6 +137,13 @@ module Gloo
137
137
  return self.value.to_s.strip.empty?
138
138
  end
139
139
 
140
+ #
141
+ # Value for a SQL query.
142
+ #
143
+ def sql_value
144
+ return self.value
145
+ end
146
+
140
147
  #
141
148
  # Is this an alias to another object?
142
149
  #
@@ -144,6 +151,13 @@ module Gloo
144
151
  return self.type_display == Gloo::Objs::Alias.typename
145
152
  end
146
153
 
154
+ #
155
+ # Is this a container object?
156
+ #
157
+ def is_container?
158
+ return self.type_display == Gloo::Objs::Container.typename
159
+ end
160
+
147
161
  #
148
162
  # Is this a function object?
149
163
  #
@@ -33,6 +33,8 @@ module Gloo
33
33
  # Dispatch the given message to the given object.
34
34
  #
35
35
  def self.message( engine, msg, to_obj, params = nil )
36
+ return unless to_obj
37
+
36
38
  engine.log.debug "Dispatch message #{msg} to #{to_obj.name}"
37
39
  a = Gloo::Exec::Action.new msg, to_obj, params
38
40
  Gloo::Exec::Dispatch.action( engine, a )
@@ -38,7 +38,16 @@ module Gloo
38
38
  self.value = new_value.to_i
39
39
  end
40
40
 
41
-
41
+ #
42
+ # Value for a SQL query.
43
+ #
44
+ def sql_value
45
+ return nil if self.value.blank?
46
+
47
+ return self.value
48
+ end
49
+
50
+
42
51
  # ---------------------------------------------------------------------
43
52
  # Messages
44
53
  # ---------------------------------------------------------------------
@@ -3,6 +3,7 @@
3
3
  #
4
4
  # A looping construct...do something for each whatever in something.
5
5
  # This object has several possible uses:
6
+ # - each child in a container
6
7
  # - each word in a string
7
8
  # - each line in a string
8
9
  # - each file in a directory
@@ -15,13 +16,9 @@ module Gloo
15
16
 
16
17
  KEYWORD = 'each'.freeze
17
18
  KEYWORD_SHORT = 'each'.freeze
18
- CHILD = 'child'.freeze
19
19
  WORD = 'word'.freeze
20
- LINE = 'line'.freeze
21
- FILE = 'file'.freeze
22
- REPO = 'repo'.freeze
23
- IN = 'IN'.freeze
24
20
  DO = 'do'.freeze
21
+ IN = 'IN'.freeze
25
22
 
26
23
  #
27
24
  # The name of the object type.
@@ -42,8 +39,7 @@ module Gloo
42
39
  # Returns nil if there is none.
43
40
  #
44
41
  def in_value
45
- o = find_child IN
46
- return o ? o.value : nil
42
+ return find_child_value IN
47
43
  end
48
44
 
49
45
  #
@@ -56,6 +52,7 @@ module Gloo
56
52
  Gloo::Exec::Dispatch.message( @engine, 'run', o )
57
53
  end
58
54
 
55
+
59
56
  # ---------------------------------------------------------------------
60
57
  # Children
61
58
  # ---------------------------------------------------------------------
@@ -81,6 +78,7 @@ module Gloo
81
78
  fac.create_script DO, '', self
82
79
  end
83
80
 
81
+
84
82
  # ---------------------------------------------------------------------
85
83
  # Messages
86
84
  # ---------------------------------------------------------------------
@@ -94,186 +92,21 @@ module Gloo
94
92
 
95
93
  # Run the system command.
96
94
  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
95
+ if EachChild.use_for?( self )
96
+ EachChild.new( @engine, self ).run
97
+ elsif EachWord.use_for?( self )
98
+ EachWord.new( @engine, self ).run
99
+ elsif EachLine.use_for?( self )
100
+ EachLine.new( @engine, self ).run
101
+ elsif EachFile.use_for?( self )
102
+ EachFile.new( @engine, self ).run
103
+ elsif EachRepo.use_for?( self )
104
+ EachRepo.new( @engine, self ).run
105
+ else
106
+ @engine.err "Not set up to run each for that target."
105
107
  end
106
108
  end
107
109
 
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( @engine, 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
110
  end
278
111
  end
279
112
  end
@@ -0,0 +1,68 @@
1
+ # Author:: Eric Crane (mailto:eric.crane@mac.com)
2
+ # Copyright:: Copyright (c) 2024 Eric Crane. All rights reserved.
3
+ #
4
+ # Iterate over each child in an object container.
5
+ #
6
+
7
+ module Gloo
8
+ module Objs
9
+ class EachChild
10
+
11
+ CHILD = 'child'.freeze
12
+ IN = 'IN'.freeze
13
+
14
+ # ---------------------------------------------------------------------
15
+ # Create Iterator
16
+ # ---------------------------------------------------------------------
17
+
18
+ def initialize( engine, iterator_obj )
19
+ @engine = engine
20
+ @iterator_obj = iterator_obj
21
+ end
22
+
23
+
24
+ # ---------------------------------------------------------------------
25
+ # Check if this is the right iterator
26
+ # ---------------------------------------------------------------------
27
+
28
+ #
29
+ # Use this iterator for each loop?
30
+ #
31
+ def self.use_for?( iterator_obj )
32
+ return true if iterator_obj.find_child CHILD
33
+
34
+ return false
35
+ end
36
+
37
+
38
+ # ---------------------------------------------------------------------
39
+ # Iterate
40
+ # ---------------------------------------------------------------------
41
+
42
+ #
43
+ # Run for each child.
44
+ #
45
+ def run
46
+ o = @iterator_obj.find_child IN
47
+ return unless o
48
+
49
+ o = Gloo::Objs::Alias.resolve_alias( @engine, o )
50
+ o.children.each do |child|
51
+ set_child child
52
+ @iterator_obj.run_do
53
+ end
54
+ end
55
+
56
+ #
57
+ # Set the child alias.
58
+ #
59
+ def set_child( obj )
60
+ o = @iterator_obj.find_child CHILD
61
+ return unless o
62
+
63
+ o.set_value obj.pn
64
+ end
65
+
66
+ end
67
+ end
68
+ end
@@ -0,0 +1,83 @@
1
+ # Author:: Eric Crane (mailto:eric.crane@mac.com)
2
+ # Copyright:: Copyright (c) 2024 Eric Crane. All rights reserved.
3
+ #
4
+ # Iterate over each file in a folder.
5
+ #
6
+
7
+ module Gloo
8
+ module Objs
9
+ class EachFile
10
+
11
+ FILE = 'file'.freeze
12
+ EXT = 'ext'.freeze
13
+ WILD = '*'.freeze
14
+
15
+
16
+ # ---------------------------------------------------------------------
17
+ # Create Iterator
18
+ # ---------------------------------------------------------------------
19
+
20
+ def initialize( engine, iterator_obj )
21
+ @engine = engine
22
+ @iterator_obj = iterator_obj
23
+ end
24
+
25
+
26
+ # ---------------------------------------------------------------------
27
+ # Check if this is the right iterator
28
+ # ---------------------------------------------------------------------
29
+
30
+ #
31
+ # Use this iterator for each loop?
32
+ #
33
+ def self.use_for?( iterator_obj )
34
+ return true if iterator_obj.find_child FILE
35
+
36
+ return false
37
+ end
38
+
39
+
40
+ # ---------------------------------------------------------------------
41
+ # Iterate
42
+ # ---------------------------------------------------------------------
43
+
44
+ #
45
+ # Run for each file.
46
+ #
47
+ def run
48
+ folder = @iterator_obj.in_value
49
+ return unless folder
50
+
51
+ unless Dir.exist?( folder )
52
+ @engine.err "Folder does not exist: #{folder}"
53
+ end
54
+
55
+ Dir.glob( "#{folder}#{wildcard}" ).each do |f|
56
+ set_file f
57
+ @iterator_obj.run_do
58
+ end
59
+ end
60
+
61
+ #
62
+ # Get the wildcard for the glob.
63
+ #
64
+ def wildcard
65
+ o = @iterator_obj.find_child EXT
66
+ return WILD unless o
67
+
68
+ return "#{WILD}.#{o.value}"
69
+ end
70
+
71
+ #
72
+ # Set the value of the word.
73
+ #
74
+ def set_file( f )
75
+ o = @iterator_obj.find_child FILE
76
+ return unless o
77
+
78
+ o.set_value f
79
+ end
80
+
81
+ end
82
+ end
83
+ end
@@ -0,0 +1,67 @@
1
+ # Author:: Eric Crane (mailto:eric.crane@mac.com)
2
+ # Copyright:: Copyright (c) 2024 Eric Crane. All rights reserved.
3
+ #
4
+ # Iterate over each line in a text block.
5
+ #
6
+
7
+ module Gloo
8
+ module Objs
9
+ class EachLine
10
+
11
+ LINE = 'line'.freeze
12
+
13
+
14
+ # ---------------------------------------------------------------------
15
+ # Create Iterator
16
+ # ---------------------------------------------------------------------
17
+
18
+ def initialize( engine, iterator_obj )
19
+ @engine = engine
20
+ @iterator_obj = iterator_obj
21
+ end
22
+
23
+
24
+ # ---------------------------------------------------------------------
25
+ # Check if this is the right iterator
26
+ # ---------------------------------------------------------------------
27
+
28
+ #
29
+ # Use this iterator for each loop?
30
+ #
31
+ def self.use_for?( iterator_obj )
32
+ return true if iterator_obj.find_child LINE
33
+
34
+ return false
35
+ end
36
+
37
+
38
+ # ---------------------------------------------------------------------
39
+ # Iterate
40
+ # ---------------------------------------------------------------------
41
+
42
+ #
43
+ # Run for each line.
44
+ #
45
+ def run
46
+ str = @iterator_obj.in_value
47
+ return unless str
48
+
49
+ str.each_line do |line|
50
+ set_line line
51
+ @iterator_obj.run_do
52
+ end
53
+ end
54
+
55
+ #
56
+ # Set the value of the word.
57
+ #
58
+ def set_line( line )
59
+ o = @iterator_obj.find_child LINE
60
+ return unless o
61
+
62
+ o.set_value line
63
+ end
64
+
65
+ end
66
+ end
67
+ end
@@ -0,0 +1,84 @@
1
+ # Author:: Eric Crane (mailto:eric.crane@mac.com)
2
+ # Copyright:: Copyright (c) 2024 Eric Crane. All rights reserved.
3
+ #
4
+ # Iterate over each repo in a directory.
5
+ #
6
+
7
+ module Gloo
8
+ module Objs
9
+ class EachRepo
10
+
11
+ FILE = 'file'.freeze
12
+ REPO = 'repo'.freeze
13
+
14
+
15
+ # ---------------------------------------------------------------------
16
+ # Create Iterator
17
+ # ---------------------------------------------------------------------
18
+
19
+ def initialize( engine, iterator_obj )
20
+ @engine = engine
21
+ @iterator_obj = iterator_obj
22
+ end
23
+
24
+
25
+ # ---------------------------------------------------------------------
26
+ # Check if this is the right iterator
27
+ # ---------------------------------------------------------------------
28
+
29
+ #
30
+ # Use this iterator for each loop?
31
+ #
32
+ def self.use_for?( iterator_obj )
33
+ return true if iterator_obj.find_child REPO
34
+
35
+ return false
36
+ end
37
+
38
+
39
+ # ---------------------------------------------------------------------
40
+ # Iterate
41
+ # ---------------------------------------------------------------------
42
+
43
+ #
44
+ # Find all git projects in a path.
45
+ #
46
+ def find_all_git_projects( path )
47
+ path.children.collect do |f|
48
+ if f.directory? && ( File.basename( f ) == '.git' )
49
+ File.dirname( f )
50
+ elsif f.directory?
51
+ find_all_git_projects( f )
52
+ end
53
+ end.flatten.compact
54
+ end
55
+
56
+ #
57
+ # Run for repo.
58
+ #
59
+ def run
60
+ path = @iterator_obj.in_value
61
+ return unless path
62
+
63
+ path = Pathname.new( path )
64
+ repos = find_all_git_projects( path )
65
+ repos.each do |o|
66
+ set_repo o
67
+ @iterator_obj.run_do
68
+ end
69
+ end
70
+
71
+ #
72
+ # Set the value of the repo.
73
+ # This is a path to the repo.
74
+ #
75
+ def set_repo( path )
76
+ o = @iterator_obj.find_child REPO
77
+ return unless o
78
+
79
+ o.set_value path
80
+ end
81
+
82
+ end
83
+ end
84
+ end