gloo 1.4.2 → 2.0.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 +4 -4
- data/.DS_Store +0 -0
- data/.gitignore +1 -0
- data/gloo.gemspec +0 -2
- data/lib/VERSION +1 -1
- data/lib/dependencies.rb +4 -4
- data/lib/gloo/app/args.rb +112 -0
- data/lib/gloo/app/engine.rb +247 -0
- data/lib/gloo/app/engine_context.rb +25 -0
- data/lib/gloo/app/info.rb +20 -3
- data/lib/gloo/app/log.rb +73 -1
- data/lib/gloo/app/mode.rb +27 -0
- data/lib/gloo/app/platform.rb +8 -1
- data/lib/gloo/app/settings.rb +202 -0
- data/lib/gloo/convert/converter.rb +42 -0
- data/lib/gloo/convert/string_to_date.rb +21 -0
- data/lib/gloo/convert/string_to_datetime.rb +21 -0
- data/lib/gloo/convert/string_to_decimal.rb +20 -0
- data/lib/gloo/convert/string_to_integer.rb +20 -0
- data/lib/gloo/convert/string_to_time.rb +21 -0
- data/lib/gloo/core/baseo.rb +31 -0
- data/lib/gloo/core/dictionary.rb +245 -0
- data/lib/gloo/core/error.rb +61 -0
- data/lib/gloo/core/event_manager.rb +45 -0
- data/lib/gloo/core/factory.rb +211 -0
- data/lib/gloo/core/gloo_system.rb +267 -0
- data/lib/gloo/core/heap.rb +53 -0
- data/lib/gloo/core/here.rb +36 -0
- data/lib/gloo/core/it.rb +36 -0
- data/lib/gloo/core/literal.rb +30 -0
- data/lib/gloo/core/obj.rb +318 -0
- data/lib/gloo/core/obj_finder.rb +30 -0
- data/lib/gloo/core/op.rb +40 -0
- data/lib/gloo/core/parser.rb +60 -0
- data/lib/gloo/core/pn.rb +212 -0
- data/lib/gloo/core/tokens.rb +165 -0
- data/lib/gloo/core/verb.rb +87 -0
- data/lib/gloo/exec/action.rb +48 -0
- data/lib/gloo/exec/dispatch.rb +40 -0
- data/lib/gloo/exec/exec_env.rb +75 -0
- data/lib/gloo/exec/runner.rb +45 -0
- data/lib/gloo/exec/script.rb +50 -0
- data/lib/gloo/exec/stack.rb +79 -0
- data/lib/gloo/expr/expression.rb +119 -0
- data/lib/gloo/expr/l_boolean.rb +36 -0
- data/lib/gloo/expr/l_decimal.rb +39 -0
- data/lib/gloo/expr/l_integer.rb +37 -0
- data/lib/gloo/expr/l_string.rb +58 -0
- data/lib/gloo/expr/op_div.rb +22 -0
- data/lib/gloo/expr/op_minus.rb +22 -0
- data/lib/gloo/expr/op_mult.rb +22 -0
- data/lib/gloo/expr/op_plus.rb +24 -0
- data/lib/gloo/objs/basic/alias.rb +78 -0
- data/lib/gloo/objs/basic/boolean.rb +120 -0
- data/lib/gloo/objs/basic/container.rb +65 -0
- data/lib/gloo/objs/basic/decimal.rb +76 -0
- data/lib/gloo/objs/basic/integer.rb +73 -0
- data/lib/gloo/objs/basic/script.rb +99 -0
- data/lib/gloo/objs/basic/string.rb +77 -0
- data/lib/gloo/objs/basic/text.rb +79 -0
- data/lib/gloo/objs/basic/untyped.rb +41 -0
- data/lib/gloo/objs/cli/banner.rb +1 -1
- data/lib/gloo/objs/cli/bar.rb +3 -3
- data/lib/gloo/objs/cli/colorize.rb +1 -1
- data/lib/gloo/objs/cli/confirm.rb +1 -1
- data/lib/gloo/objs/cli/menu.rb +6 -6
- data/lib/gloo/objs/cli/menu_item.rb +1 -1
- data/lib/gloo/objs/cli/pastel.rb +1 -1
- data/lib/gloo/objs/cli/prompt.rb +1 -1
- data/lib/gloo/objs/cli/select.rb +2 -2
- data/lib/gloo/objs/ctrl/each.rb +279 -0
- data/lib/gloo/objs/ctrl/repeat.rb +108 -0
- data/lib/gloo/objs/data/markdown.rb +79 -0
- data/lib/gloo/objs/data/mysql.rb +5 -5
- data/lib/gloo/objs/data/query.rb +4 -4
- data/lib/gloo/objs/data/sqlite.rb +1 -1
- data/lib/gloo/objs/data/table.rb +112 -0
- data/lib/gloo/objs/dev/git.rb +2 -2
- data/lib/gloo/objs/dev/stats.rb +4 -4
- data/lib/gloo/objs/dt/date.rb +65 -0
- data/lib/gloo/objs/dt/datetime.rb +120 -0
- data/lib/gloo/objs/dt/dt_tools.rb +100 -0
- data/lib/gloo/objs/dt/time.rb +65 -0
- data/lib/gloo/objs/ror/erb.rb +116 -0
- data/lib/gloo/objs/ror/eval.rb +107 -0
- data/lib/gloo/objs/snd/play.rb +1 -1
- data/lib/gloo/objs/snd/say.rb +1 -1
- data/lib/gloo/objs/system/file_handle.rb +4 -4
- data/lib/gloo/objs/system/ssh_exec.rb +1 -1
- data/lib/gloo/objs/system/system.rb +1 -1
- data/lib/gloo/objs/web/http_get.rb +159 -0
- data/lib/gloo/objs/web/http_post.rb +183 -0
- data/lib/gloo/objs/web/json.rb +135 -0
- data/lib/gloo/objs/web/slack.rb +130 -0
- data/lib/gloo/objs/web/teams.rb +117 -0
- data/lib/gloo/objs/web/uri.rb +148 -0
- data/lib/gloo/persist/disc_mech.rb +87 -0
- data/lib/gloo/persist/file_loader.rb +193 -0
- data/lib/gloo/persist/file_saver.rb +51 -0
- data/lib/gloo/persist/file_storage.rb +46 -0
- data/lib/gloo/persist/line_splitter.rb +81 -0
- data/lib/gloo/persist/persist_man.rb +153 -0
- data/lib/gloo/utils/format.rb +21 -0
- data/lib/gloo/utils/stats.rb +206 -0
- data/lib/gloo/utils/words.rb +19 -0
- data/lib/gloo/verbs/alert.rb +2 -2
- data/lib/gloo/verbs/beep.rb +1 -1
- data/lib/gloo/verbs/cls.rb +1 -1
- data/lib/gloo/verbs/context.rb +62 -0
- data/lib/gloo/verbs/create.rb +68 -0
- data/lib/gloo/verbs/execute.rb +56 -0
- data/lib/gloo/verbs/files.rb +49 -0
- data/lib/gloo/verbs/help.rb +1 -1
- data/lib/gloo/verbs/if.rb +92 -0
- data/lib/gloo/verbs/list.rb +98 -0
- data/lib/gloo/verbs/load.rb +45 -0
- data/lib/gloo/verbs/move.rb +89 -0
- data/lib/gloo/verbs/put.rb +94 -0
- data/lib/gloo/verbs/quit.rb +40 -0
- data/lib/gloo/verbs/reload.rb +43 -0
- data/lib/gloo/verbs/run.rb +75 -0
- data/lib/gloo/verbs/save.rb +39 -0
- data/lib/gloo/verbs/show.rb +63 -0
- data/lib/gloo/verbs/tell.rb +80 -0
- data/lib/gloo/verbs/unless.rb +92 -0
- data/lib/gloo/verbs/unload.rb +46 -0
- data/lib/gloo/verbs/version.rb +3 -3
- data/lib/gloo/verbs/wait.rb +42 -0
- data/lib/gloo.rb +2 -2
- data/lib/run.rb +2 -2
- metadata +97 -22
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
# Author:: Eric Crane (mailto:eric.crane@mac.com)
|
|
2
|
+
# Copyright:: Copyright (c) 2019 Eric Crane. All rights reserved.
|
|
3
|
+
#
|
|
4
|
+
# The persistance manager.
|
|
5
|
+
# Keeps a collection of object-file mappings, and then
|
|
6
|
+
# uses mappings to know how/where to save updated objects.
|
|
7
|
+
#
|
|
8
|
+
|
|
9
|
+
module Gloo
|
|
10
|
+
module Persist
|
|
11
|
+
class PersistMan
|
|
12
|
+
|
|
13
|
+
attr_reader :maps, :mech
|
|
14
|
+
|
|
15
|
+
#
|
|
16
|
+
# Contructor for the persistence manager.
|
|
17
|
+
#
|
|
18
|
+
def initialize( engine )
|
|
19
|
+
@engine = engine
|
|
20
|
+
@maps = []
|
|
21
|
+
@mech = @engine.platform.getFileMech( @engine )
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
#
|
|
25
|
+
# Save one object to the file.
|
|
26
|
+
#
|
|
27
|
+
def save( name = '' )
|
|
28
|
+
name.blank? ? save_all : save_one( name )
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
#
|
|
32
|
+
# Save one object to the file.
|
|
33
|
+
#
|
|
34
|
+
def save_all
|
|
35
|
+
@maps.each( &:save )
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
#
|
|
39
|
+
# Save one object to the file.
|
|
40
|
+
#
|
|
41
|
+
def save_one( name )
|
|
42
|
+
ref = Gloo::Core::Pn.new( @engine, name )
|
|
43
|
+
obj = ref.resolve
|
|
44
|
+
|
|
45
|
+
fs = find_file_storage( obj )
|
|
46
|
+
fs.save
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
#
|
|
50
|
+
# Load the object from the file.
|
|
51
|
+
#
|
|
52
|
+
def load( name )
|
|
53
|
+
pns = get_full_path_names name
|
|
54
|
+
return unless pns
|
|
55
|
+
|
|
56
|
+
pns.each do |pn|
|
|
57
|
+
@engine.log.debug "Load file(s) at: #{pn}"
|
|
58
|
+
fs = Gloo::Persist::FileStorage.new( @engine, pn )
|
|
59
|
+
fs.load
|
|
60
|
+
@maps << fs
|
|
61
|
+
@engine.event_manager.on_load fs.obj
|
|
62
|
+
end
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
#
|
|
66
|
+
# The given object is unloading.
|
|
67
|
+
# Do any necessary clean up here.
|
|
68
|
+
#
|
|
69
|
+
def unload( obj )
|
|
70
|
+
@maps.each_with_index do |o, i|
|
|
71
|
+
if o.obj.pn === obj.pn
|
|
72
|
+
@maps.delete_at( i )
|
|
73
|
+
return
|
|
74
|
+
end
|
|
75
|
+
end
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
#
|
|
79
|
+
# Reload all objects.
|
|
80
|
+
#
|
|
81
|
+
def reload_all
|
|
82
|
+
return unless @maps
|
|
83
|
+
|
|
84
|
+
@maps.each do |fs|
|
|
85
|
+
@engine.heap.unload fs.obj
|
|
86
|
+
fs.load
|
|
87
|
+
end
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
#
|
|
91
|
+
# Re-load the given object from file.
|
|
92
|
+
#
|
|
93
|
+
def reload( obj )
|
|
94
|
+
fs = find_file_storage( obj )
|
|
95
|
+
return unless fs
|
|
96
|
+
|
|
97
|
+
@engine.heap.unload obj
|
|
98
|
+
fs.load
|
|
99
|
+
end
|
|
100
|
+
|
|
101
|
+
#
|
|
102
|
+
# Find the objects FileStorage in the list.
|
|
103
|
+
#
|
|
104
|
+
def find_file_storage( obj )
|
|
105
|
+
@maps.each do |o|
|
|
106
|
+
return o if ( o.obj.pn === obj.pn )
|
|
107
|
+
end
|
|
108
|
+
|
|
109
|
+
# It was not found, so return nil.
|
|
110
|
+
return nil
|
|
111
|
+
end
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
#
|
|
115
|
+
# Get the full path and name of the file.
|
|
116
|
+
#
|
|
117
|
+
def get_full_path_names( name )
|
|
118
|
+
return nil if name.strip.empty?
|
|
119
|
+
|
|
120
|
+
if name.strip[ -1 ] == '*'
|
|
121
|
+
return @mech.get_all_files_in( name[ 0..-2 ] )
|
|
122
|
+
else
|
|
123
|
+
return @mech.expand( name )
|
|
124
|
+
end
|
|
125
|
+
end
|
|
126
|
+
|
|
127
|
+
#
|
|
128
|
+
# Check to see if a given path name refers to a gloo object file.
|
|
129
|
+
#
|
|
130
|
+
def gloo_file?( name )
|
|
131
|
+
return @mech.valid?( name )
|
|
132
|
+
end
|
|
133
|
+
|
|
134
|
+
#
|
|
135
|
+
# Get the default file extention.
|
|
136
|
+
#
|
|
137
|
+
def file_ext
|
|
138
|
+
return @mech.file_ext
|
|
139
|
+
end
|
|
140
|
+
|
|
141
|
+
#
|
|
142
|
+
# Print out all object - persistance mappings.
|
|
143
|
+
# This is a debugging tool.
|
|
144
|
+
#
|
|
145
|
+
def show_maps
|
|
146
|
+
@maps.each do |o|
|
|
147
|
+
puts " \t #{o.pn} \t #{o.obj.name}"
|
|
148
|
+
end
|
|
149
|
+
end
|
|
150
|
+
|
|
151
|
+
end
|
|
152
|
+
end
|
|
153
|
+
end
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# Author:: Eric Crane (mailto:eric.crane@mac.com)
|
|
2
|
+
# Copyright:: Copyright (c) 2020 Eric Crane. All rights reserved.
|
|
3
|
+
#
|
|
4
|
+
# Formatting utilities
|
|
5
|
+
#
|
|
6
|
+
|
|
7
|
+
module Gloo
|
|
8
|
+
module Utils
|
|
9
|
+
class Format
|
|
10
|
+
|
|
11
|
+
#
|
|
12
|
+
# Format number, adding comma separators.
|
|
13
|
+
# Ex: 1000 -> 1,000
|
|
14
|
+
#
|
|
15
|
+
def self.number( num )
|
|
16
|
+
return num.to_s.reverse.scan( /.{1,3}/ ).join( ',' ).reverse
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
# Author:: Eric Crane (mailto:eric.crane@mac.com)
|
|
2
|
+
# Copyright:: Copyright (c) 2020 Eric Crane. All rights reserved.
|
|
3
|
+
#
|
|
4
|
+
# Utilities related to words (strings).
|
|
5
|
+
#
|
|
6
|
+
|
|
7
|
+
module Gloo
|
|
8
|
+
module Utils
|
|
9
|
+
class Stats
|
|
10
|
+
|
|
11
|
+
DIR_NOT_FOUND_ERR = 'The folder was not found!'.freeze
|
|
12
|
+
|
|
13
|
+
# ---------------------------------------------------------------------
|
|
14
|
+
# Setup
|
|
15
|
+
# ---------------------------------------------------------------------
|
|
16
|
+
|
|
17
|
+
#
|
|
18
|
+
# Create a stats utility class for the given directory.
|
|
19
|
+
#
|
|
20
|
+
def initialize( engine, dir, types, skip = [] )
|
|
21
|
+
@engine = engine
|
|
22
|
+
@dir = dir
|
|
23
|
+
setup_loc types
|
|
24
|
+
@skip = skip
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
# ---------------------------------------------------------------------
|
|
28
|
+
# Public Functions
|
|
29
|
+
# ---------------------------------------------------------------------
|
|
30
|
+
|
|
31
|
+
#
|
|
32
|
+
# Is the stats utility valid?
|
|
33
|
+
# Does it have a valid root directory.
|
|
34
|
+
#
|
|
35
|
+
def valid?
|
|
36
|
+
return true if @dir && File.directory?( @dir )
|
|
37
|
+
|
|
38
|
+
@engine.err DIR_NOT_FOUND_ERR
|
|
39
|
+
@engine.heap.it.set_to false
|
|
40
|
+
|
|
41
|
+
return false
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
#
|
|
45
|
+
# Show all stat data for the project.
|
|
46
|
+
#
|
|
47
|
+
def show_all
|
|
48
|
+
return unless valid?
|
|
49
|
+
|
|
50
|
+
generate
|
|
51
|
+
puts "Showing All stats for #{@dir}".white
|
|
52
|
+
puts "\n ** #{@dir_cnt} Total Folders ** "
|
|
53
|
+
puts " ** #{@file_cnt} Total Files ** "
|
|
54
|
+
|
|
55
|
+
busy_folders( 7 )
|
|
56
|
+
file_types
|
|
57
|
+
loc
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
#
|
|
61
|
+
# Get a list of the busiest folders.
|
|
62
|
+
# Count is how many results we want.
|
|
63
|
+
#
|
|
64
|
+
def busy_folders( count = 17 )
|
|
65
|
+
return unless valid?
|
|
66
|
+
|
|
67
|
+
generate
|
|
68
|
+
puts "\nBusy Folders:".yellow
|
|
69
|
+
|
|
70
|
+
@folders.sort! { |a, b| a[ :cnt ] <=> b[ :cnt ] }
|
|
71
|
+
@folders.reverse!
|
|
72
|
+
@folders[ 0..count ].each do |f|
|
|
73
|
+
puts " #{f[ :cnt ]} - #{f[ :name ]}"
|
|
74
|
+
end
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
#
|
|
78
|
+
# Show file types and how many of each there are.
|
|
79
|
+
#
|
|
80
|
+
def file_types
|
|
81
|
+
return unless valid?
|
|
82
|
+
|
|
83
|
+
generate
|
|
84
|
+
puts "\nFiles by Type:".yellow
|
|
85
|
+
|
|
86
|
+
@types = @types.sort_by( &:last )
|
|
87
|
+
@types.reverse!
|
|
88
|
+
@types.each do |o|
|
|
89
|
+
puts " #{o[ 1 ]} - #{o[ 0 ]}" unless o[ 0 ].empty?
|
|
90
|
+
end
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
#
|
|
94
|
+
# Show Lines of Code
|
|
95
|
+
#
|
|
96
|
+
def loc
|
|
97
|
+
return unless valid?
|
|
98
|
+
|
|
99
|
+
generate
|
|
100
|
+
total = 0
|
|
101
|
+
|
|
102
|
+
@loc.each do |k, v|
|
|
103
|
+
puts "\n #{k} Lines of Code".yellow
|
|
104
|
+
total += v[ :lines ]
|
|
105
|
+
formatted = Gloo::Utils::Format.number( v[ :lines ] )
|
|
106
|
+
puts " ** #{formatted} in #{v[ :files ].count} #{k} files ** "
|
|
107
|
+
|
|
108
|
+
puts "\n Busy #{k} files:".yellow
|
|
109
|
+
files = v[ :files ].sort! { |a, b| a[ :lines ] <=> b[ :lines ] }
|
|
110
|
+
files.reverse!
|
|
111
|
+
files[ 0..12 ].each do |f|
|
|
112
|
+
puts " #{f[ :lines ]} - #{f[ :file ]}"
|
|
113
|
+
end
|
|
114
|
+
end
|
|
115
|
+
|
|
116
|
+
formatted = Gloo::Utils::Format.number( total )
|
|
117
|
+
puts "\n #{formatted} Total Lines of Code".white
|
|
118
|
+
end
|
|
119
|
+
|
|
120
|
+
# ---------------------------------------------------------------------
|
|
121
|
+
# Private Functions
|
|
122
|
+
# ---------------------------------------------------------------------
|
|
123
|
+
|
|
124
|
+
#
|
|
125
|
+
# Setup counters for lines of code by file type.
|
|
126
|
+
def setup_loc( types )
|
|
127
|
+
@loc = {}
|
|
128
|
+
|
|
129
|
+
types.split( ' ' ).each do |t|
|
|
130
|
+
@loc[ t ] = { lines: 0, files: [] }
|
|
131
|
+
end
|
|
132
|
+
end
|
|
133
|
+
|
|
134
|
+
#
|
|
135
|
+
# Generate stat data unless we've already done so.
|
|
136
|
+
#
|
|
137
|
+
def generate
|
|
138
|
+
return if @folders
|
|
139
|
+
|
|
140
|
+
@engine.log.debug 'Generating...'
|
|
141
|
+
@folders = []
|
|
142
|
+
@types = {}
|
|
143
|
+
@file_cnt = 0
|
|
144
|
+
@dir_cnt = 0
|
|
145
|
+
|
|
146
|
+
generate_for Pathname.new( @dir )
|
|
147
|
+
end
|
|
148
|
+
|
|
149
|
+
#
|
|
150
|
+
# Generate data for the given path.
|
|
151
|
+
# NOTE: this is a recursive function.
|
|
152
|
+
# It traverses all sub-direcctories.
|
|
153
|
+
#
|
|
154
|
+
def generate_for( path )
|
|
155
|
+
return if @skip.include?( File.basename( path ) )
|
|
156
|
+
|
|
157
|
+
cnt = 0
|
|
158
|
+
path.children.each do |f|
|
|
159
|
+
if f.directory?
|
|
160
|
+
@dir_cnt += 1
|
|
161
|
+
generate_for( f )
|
|
162
|
+
else
|
|
163
|
+
@file_cnt += 1
|
|
164
|
+
cnt += 1
|
|
165
|
+
handle_file( f )
|
|
166
|
+
inc_type( File.extname( f ) )
|
|
167
|
+
end
|
|
168
|
+
end
|
|
169
|
+
@folders << { name: path, cnt: cnt }
|
|
170
|
+
end
|
|
171
|
+
|
|
172
|
+
#
|
|
173
|
+
# Increment the file count.
|
|
174
|
+
#
|
|
175
|
+
def inc_type( type )
|
|
176
|
+
if @types[ type ]
|
|
177
|
+
@types[ type ] += 1
|
|
178
|
+
else
|
|
179
|
+
@types[ type ] = 1
|
|
180
|
+
end
|
|
181
|
+
end
|
|
182
|
+
|
|
183
|
+
#
|
|
184
|
+
# Consider code file types.
|
|
185
|
+
#
|
|
186
|
+
def handle_file( file )
|
|
187
|
+
ext = File.extname( file )
|
|
188
|
+
return unless ext
|
|
189
|
+
|
|
190
|
+
ext = ext[ 1..-1 ]
|
|
191
|
+
return unless @loc.key?( ext )
|
|
192
|
+
|
|
193
|
+
lines = count_lines( file )
|
|
194
|
+
@loc[ ext ][ :lines ] += lines
|
|
195
|
+
@loc[ ext ][ :files ] << { lines: lines, file: file }
|
|
196
|
+
end
|
|
197
|
+
|
|
198
|
+
#
|
|
199
|
+
# Count lines of code in file.
|
|
200
|
+
def count_lines( file )
|
|
201
|
+
return `wc -l #{file}`.split.first.to_i
|
|
202
|
+
end
|
|
203
|
+
|
|
204
|
+
end
|
|
205
|
+
end
|
|
206
|
+
end
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# Author:: Eric Crane (mailto:eric.crane@mac.com)
|
|
2
|
+
# Copyright:: Copyright (c) 2019 Eric Crane. All rights reserved.
|
|
3
|
+
#
|
|
4
|
+
# Utilities related to words (strings).
|
|
5
|
+
#
|
|
6
|
+
|
|
7
|
+
require 'active_support/inflector'
|
|
8
|
+
|
|
9
|
+
module Gloo
|
|
10
|
+
module Utils
|
|
11
|
+
class Words
|
|
12
|
+
|
|
13
|
+
def self.pluralize( word )
|
|
14
|
+
return word.pluralize
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
data/lib/gloo/verbs/alert.rb
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
module Gloo
|
|
8
8
|
module Verbs
|
|
9
|
-
class Alert <
|
|
9
|
+
class Alert < Gloo::Core::Verb
|
|
10
10
|
|
|
11
11
|
KEYWORD = 'alert'.freeze
|
|
12
12
|
KEYWORD_SHORT = '!'.freeze
|
|
@@ -23,7 +23,7 @@ module Gloo
|
|
|
23
23
|
return
|
|
24
24
|
end
|
|
25
25
|
|
|
26
|
-
expr =
|
|
26
|
+
expr = Gloo::Expr::Expression.new( @engine, @tokens.params )
|
|
27
27
|
result = expr.evaluate
|
|
28
28
|
|
|
29
29
|
if result
|
data/lib/gloo/verbs/beep.rb
CHANGED
data/lib/gloo/verbs/cls.rb
CHANGED
|
@@ -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
|
+
# Set the current context pointer.
|
|
5
|
+
# Alternatively if no value is provided, just show the context.
|
|
6
|
+
#
|
|
7
|
+
|
|
8
|
+
module Gloo
|
|
9
|
+
module Verbs
|
|
10
|
+
class Context < Gloo::Core::Verb
|
|
11
|
+
|
|
12
|
+
KEYWORD = 'context'.freeze
|
|
13
|
+
KEYWORD_SHORT = '@'.freeze
|
|
14
|
+
|
|
15
|
+
#
|
|
16
|
+
# Run the verb.
|
|
17
|
+
#
|
|
18
|
+
def run
|
|
19
|
+
set_context if @tokens.token_count > 1
|
|
20
|
+
show_context
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
#
|
|
24
|
+
# Show the current context.
|
|
25
|
+
#
|
|
26
|
+
def show_context
|
|
27
|
+
@engine.log.show "Context: #{@engine.heap.context}"
|
|
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
|
+
# ---------------------------------------------------------------------
|
|
45
|
+
# Private functions
|
|
46
|
+
# ---------------------------------------------------------------------
|
|
47
|
+
|
|
48
|
+
private
|
|
49
|
+
|
|
50
|
+
#
|
|
51
|
+
# Set the context to the given path.
|
|
52
|
+
#
|
|
53
|
+
def set_context
|
|
54
|
+
path = @tokens.second
|
|
55
|
+
@engine.heap.context.set_to path
|
|
56
|
+
@engine.heap.it.set_to path
|
|
57
|
+
@engine.log.debug "Context set to #{@engine.heap.context}"
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
end
|
|
61
|
+
end
|
|
62
|
+
end
|
|
@@ -0,0 +1,68 @@
|
|
|
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'.freeze
|
|
12
|
+
KEYWORD_SHORT = '`'.freeze
|
|
13
|
+
AS = 'as'.freeze
|
|
14
|
+
VAL = ':'.freeze
|
|
15
|
+
NO_NAME_ERR = 'Object name is missing!'.freeze
|
|
16
|
+
|
|
17
|
+
#
|
|
18
|
+
# Run the verb.
|
|
19
|
+
#
|
|
20
|
+
def run
|
|
21
|
+
name = @tokens.second
|
|
22
|
+
type = @tokens.after_token( AS )
|
|
23
|
+
value = @tokens.after_token( VAL )
|
|
24
|
+
|
|
25
|
+
unless name
|
|
26
|
+
@engine.err NO_NAME_ERR
|
|
27
|
+
return
|
|
28
|
+
end
|
|
29
|
+
create name, type, value
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
#
|
|
33
|
+
# Get the Verb's keyword.
|
|
34
|
+
#
|
|
35
|
+
def self.keyword
|
|
36
|
+
return KEYWORD
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
#
|
|
40
|
+
# Get the Verb's keyword shortcut.
|
|
41
|
+
#
|
|
42
|
+
def self.keyword_shortcut
|
|
43
|
+
return KEYWORD_SHORT
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
# ---------------------------------------------------------------------
|
|
47
|
+
# Private functions
|
|
48
|
+
# ---------------------------------------------------------------------
|
|
49
|
+
|
|
50
|
+
private
|
|
51
|
+
|
|
52
|
+
#
|
|
53
|
+
# Create an object with given name of given type with
|
|
54
|
+
# the given initial value.
|
|
55
|
+
#
|
|
56
|
+
def create( name, type, value )
|
|
57
|
+
if Gloo::Expr::LString.string?( value )
|
|
58
|
+
value = Gloo::Expr::LString.strip_quotes( value )
|
|
59
|
+
end
|
|
60
|
+
obj = @engine.factory.create( { name: name, type: type, value: value } )
|
|
61
|
+
|
|
62
|
+
obj.add_default_children if obj&.add_children_on_create?
|
|
63
|
+
@engine.heap.it.set_to value
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
end
|
|
67
|
+
end
|
|
68
|
+
end
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
# Author:: Eric Crane (mailto:eric.crane@mac.com)
|
|
2
|
+
# Copyright:: Copyright (c) 2020 Eric Crane. All rights reserved.
|
|
3
|
+
#
|
|
4
|
+
# Execute a shell command.
|
|
5
|
+
#
|
|
6
|
+
|
|
7
|
+
module Gloo
|
|
8
|
+
module Verbs
|
|
9
|
+
class Execute < Gloo::Core::Verb
|
|
10
|
+
|
|
11
|
+
KEYWORD = 'execute'.freeze
|
|
12
|
+
KEYWORD_SHORT = 'exec'.freeze
|
|
13
|
+
MISSING_EXPR_ERR = 'Missing Expression!'.freeze
|
|
14
|
+
|
|
15
|
+
#
|
|
16
|
+
# Run the verb.
|
|
17
|
+
#
|
|
18
|
+
def run
|
|
19
|
+
if @tokens.token_count < 2
|
|
20
|
+
@engine.err MISSING_EXPR_ERR
|
|
21
|
+
return
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
expr = Gloo::Expr::Expression.new( @engine, @tokens.params )
|
|
25
|
+
cmd = expr.evaluate
|
|
26
|
+
@engine.log.debug "starting cmd: #{cmd}"
|
|
27
|
+
|
|
28
|
+
pid = fork { exec( cmd ) }
|
|
29
|
+
Process.wait pid
|
|
30
|
+
|
|
31
|
+
# pid = spawn cmd
|
|
32
|
+
# Process.wait pid
|
|
33
|
+
@engine.log.debug "done executing cmd: #{cmd}"
|
|
34
|
+
|
|
35
|
+
# system expr.evaluate #, chdir: Dir.pwd
|
|
36
|
+
# `#{expr.evaluate}`
|
|
37
|
+
# exec expr.evaluate
|
|
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,49 @@
|
|
|
1
|
+
# Author:: Eric Crane (mailto:eric.crane@mac.com)
|
|
2
|
+
# Copyright:: Copyright (c) 2022 Eric Crane. All rights reserved.
|
|
3
|
+
#
|
|
4
|
+
# Show all the currently loaded files.
|
|
5
|
+
#
|
|
6
|
+
|
|
7
|
+
module Gloo
|
|
8
|
+
module Verbs
|
|
9
|
+
class Files < Gloo::Core::Verb
|
|
10
|
+
|
|
11
|
+
KEYWORD = 'files'.freeze
|
|
12
|
+
KEYWORD_SHORT = 'fs'.freeze
|
|
13
|
+
|
|
14
|
+
#
|
|
15
|
+
# Run the verb.
|
|
16
|
+
#
|
|
17
|
+
def run
|
|
18
|
+
return unless @engine.persist_man.maps
|
|
19
|
+
|
|
20
|
+
@engine.persist_man.maps.each do |map|
|
|
21
|
+
# puts "#{map.obj.name} - #{map.pn}"
|
|
22
|
+
@engine.log.show "#{map.obj.name} - #{map.pn}"
|
|
23
|
+
end
|
|
24
|
+
@engine.heap.it.set_to @engine.persist_man.maps.count
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
#
|
|
28
|
+
# Get the Verb's keyword.
|
|
29
|
+
#
|
|
30
|
+
def self.keyword
|
|
31
|
+
return KEYWORD
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
#
|
|
35
|
+
# Get the Verb's keyword shortcut.
|
|
36
|
+
#
|
|
37
|
+
def self.keyword_shortcut
|
|
38
|
+
return KEYWORD_SHORT
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
# ---------------------------------------------------------------------
|
|
42
|
+
# Private functions
|
|
43
|
+
# ---------------------------------------------------------------------
|
|
44
|
+
|
|
45
|
+
private
|
|
46
|
+
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
end
|