gloo 0.8.0 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (125) hide show
  1. checksums.yaml +4 -4
  2. data/.DS_Store +0 -0
  3. data/Gemfile.lock +32 -28
  4. data/LICENSE.txt +1 -1
  5. data/gloo.gemspec +11 -6
  6. data/lib/VERSION +1 -1
  7. data/lib/dependencies.rb +4 -4
  8. data/lib/gloo/app/info.rb +3 -1
  9. data/lib/gloo/app/log.rb +1 -29
  10. data/lib/gloo/app/platform.rb +142 -0
  11. data/lib/gloo/objs/cli/banner.rb +2 -2
  12. data/lib/gloo/objs/cli/bar.rb +4 -4
  13. data/lib/gloo/objs/cli/colorize.rb +3 -3
  14. data/lib/gloo/objs/cli/confirm.rb +3 -3
  15. data/lib/gloo/objs/cli/menu.rb +9 -9
  16. data/lib/gloo/objs/cli/menu_item.rb +2 -2
  17. data/lib/gloo/objs/cli/pastel.rb +2 -2
  18. data/lib/gloo/objs/cli/prompt.rb +4 -4
  19. data/lib/gloo/objs/cli/select.rb +4 -4
  20. data/lib/gloo/objs/dev/git.rb +7 -7
  21. data/lib/gloo/objs/dev/stats.rb +8 -5
  22. data/lib/gloo/objs/snd/play.rb +1 -1
  23. data/lib/gloo/objs/snd/say.rb +2 -2
  24. data/lib/gloo/objs/system/file_handle.rb +9 -9
  25. data/lib/gloo/objs/system/ssh_exec.rb +3 -3
  26. data/lib/gloo/objs/system/system.rb +2 -2
  27. data/lib/gloo/verbs/alert.rb +7 -7
  28. data/lib/gloo/verbs/beep.rb +1 -1
  29. data/lib/gloo/verbs/cls.rb +2 -2
  30. data/lib/gloo.rb +5 -1
  31. data/lib/run.rb +5 -1
  32. metadata +39 -145
  33. data/lib/gloo/app/args.rb +0 -112
  34. data/lib/gloo/app/engine.rb +0 -230
  35. data/lib/gloo/app/help.rb +0 -156
  36. data/lib/gloo/app/mode.rb +0 -27
  37. data/lib/gloo/app/settings.rb +0 -186
  38. data/lib/gloo/convert/converter.rb +0 -35
  39. data/lib/gloo/convert/string_to_datetime.rb +0 -21
  40. data/lib/gloo/convert/string_to_decimal.rb +0 -20
  41. data/lib/gloo/convert/string_to_integer.rb +0 -20
  42. data/lib/gloo/core/baseo.rb +0 -30
  43. data/lib/gloo/core/dictionary.rb +0 -181
  44. data/lib/gloo/core/error.rb +0 -61
  45. data/lib/gloo/core/event_manager.rb +0 -44
  46. data/lib/gloo/core/factory.rb +0 -210
  47. data/lib/gloo/core/gloo_system.rb +0 -266
  48. data/lib/gloo/core/heap.rb +0 -52
  49. data/lib/gloo/core/here.rb +0 -36
  50. data/lib/gloo/core/it.rb +0 -36
  51. data/lib/gloo/core/literal.rb +0 -30
  52. data/lib/gloo/core/obj.rb +0 -303
  53. data/lib/gloo/core/obj_finder.rb +0 -30
  54. data/lib/gloo/core/op.rb +0 -40
  55. data/lib/gloo/core/parser.rb +0 -59
  56. data/lib/gloo/core/pn.rb +0 -188
  57. data/lib/gloo/core/tokens.rb +0 -165
  58. data/lib/gloo/core/verb.rb +0 -86
  59. data/lib/gloo/exec/action.rb +0 -48
  60. data/lib/gloo/exec/dispatch.rb +0 -40
  61. data/lib/gloo/exec/exec_env.rb +0 -74
  62. data/lib/gloo/exec/runner.rb +0 -45
  63. data/lib/gloo/exec/script.rb +0 -49
  64. data/lib/gloo/exec/stack.rb +0 -78
  65. data/lib/gloo/expr/expression.rb +0 -118
  66. data/lib/gloo/expr/l_boolean.rb +0 -36
  67. data/lib/gloo/expr/l_decimal.rb +0 -39
  68. data/lib/gloo/expr/l_integer.rb +0 -37
  69. data/lib/gloo/expr/l_string.rb +0 -58
  70. data/lib/gloo/expr/op_div.rb +0 -22
  71. data/lib/gloo/expr/op_minus.rb +0 -22
  72. data/lib/gloo/expr/op_mult.rb +0 -22
  73. data/lib/gloo/expr/op_plus.rb +0 -24
  74. data/lib/gloo/objs/basic/alias.rb +0 -78
  75. data/lib/gloo/objs/basic/boolean.rb +0 -120
  76. data/lib/gloo/objs/basic/container.rb +0 -76
  77. data/lib/gloo/objs/basic/decimal.rb +0 -76
  78. data/lib/gloo/objs/basic/integer.rb +0 -73
  79. data/lib/gloo/objs/basic/script.rb +0 -99
  80. data/lib/gloo/objs/basic/string.rb +0 -77
  81. data/lib/gloo/objs/basic/text.rb +0 -87
  82. data/lib/gloo/objs/basic/untyped.rb +0 -41
  83. data/lib/gloo/objs/ctrl/each.rb +0 -279
  84. data/lib/gloo/objs/ctrl/repeat.rb +0 -108
  85. data/lib/gloo/objs/data/markdown.rb +0 -84
  86. data/lib/gloo/objs/data/mysql.rb +0 -192
  87. data/lib/gloo/objs/data/query.rb +0 -176
  88. data/lib/gloo/objs/data/sqlite.rb +0 -159
  89. data/lib/gloo/objs/data/table.rb +0 -140
  90. data/lib/gloo/objs/dt/date.rb +0 -50
  91. data/lib/gloo/objs/dt/datetime.rb +0 -62
  92. data/lib/gloo/objs/dt/time.rb +0 -50
  93. data/lib/gloo/objs/ror/erb.rb +0 -116
  94. data/lib/gloo/objs/ror/eval.rb +0 -107
  95. data/lib/gloo/objs/web/http_get.rb +0 -159
  96. data/lib/gloo/objs/web/http_post.rb +0 -183
  97. data/lib/gloo/objs/web/json.rb +0 -135
  98. data/lib/gloo/objs/web/slack.rb +0 -130
  99. data/lib/gloo/objs/web/teams.rb +0 -117
  100. data/lib/gloo/objs/web/uri.rb +0 -148
  101. data/lib/gloo/persist/file_loader.rb +0 -191
  102. data/lib/gloo/persist/file_saver.rb +0 -49
  103. data/lib/gloo/persist/file_storage.rb +0 -45
  104. data/lib/gloo/persist/line_splitter.rb +0 -81
  105. data/lib/gloo/persist/persist_man.rb +0 -120
  106. data/lib/gloo/utils/format.rb +0 -21
  107. data/lib/gloo/utils/stats.rb +0 -205
  108. data/lib/gloo/utils/words.rb +0 -19
  109. data/lib/gloo/verbs/context.rb +0 -62
  110. data/lib/gloo/verbs/create.rb +0 -68
  111. data/lib/gloo/verbs/execute.rb +0 -56
  112. data/lib/gloo/verbs/help.rb +0 -264
  113. data/lib/gloo/verbs/if.rb +0 -92
  114. data/lib/gloo/verbs/list.rb +0 -98
  115. data/lib/gloo/verbs/load.rb +0 -45
  116. data/lib/gloo/verbs/move.rb +0 -89
  117. data/lib/gloo/verbs/put.rb +0 -94
  118. data/lib/gloo/verbs/quit.rb +0 -40
  119. data/lib/gloo/verbs/run.rb +0 -75
  120. data/lib/gloo/verbs/save.rb +0 -39
  121. data/lib/gloo/verbs/show.rb +0 -64
  122. data/lib/gloo/verbs/tell.rb +0 -79
  123. data/lib/gloo/verbs/unless.rb +0 -92
  124. data/lib/gloo/verbs/version.rb +0 -37
  125. data/lib/gloo/verbs/wait.rb +0 -42
@@ -1,130 +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 that can send a message to a slack channel.
5
- #
6
- require 'net/http'
7
- require 'uri'
8
- require 'json'
9
-
10
- module Gloo
11
- module Objs
12
- class Slack < Gloo::Core::Obj
13
-
14
- KEYWORD = 'slack'.freeze
15
- KEYWORD_SHORT = 'slack'.freeze
16
- URL = 'uri'.freeze
17
- MSG = 'message'.freeze
18
- USER = 'username'.freeze
19
- CHANNEL = 'channel'.freeze
20
- ICON = 'icon_emoji'.freeze
21
-
22
- ATTACHMENT = 'attachment'.freeze
23
- TITLE = 'title'.freeze
24
- TEXT = 'text'.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 uri_value
45
- uri = find_child URL
46
- return nil unless uri
47
-
48
- return uri.value
49
- end
50
-
51
- #
52
- # Get the URI from the child object.
53
- # Returns nil if there is none.
54
- #
55
- def attachment_value
56
- o = find_child ATTACHMENT
57
- return nil unless o
58
-
59
- title = o.find_child TITLE
60
- text = o.find_child TEXT
61
- return [ { 'title' => title.value,
62
- 'text' => text.value } ]
63
- end
64
-
65
- #
66
- # Get all the children of the body container and
67
- # convert to JSON that will be sent in the HTTP body.
68
- #
69
- def body_as_json
70
- h = { 'text' => find_child( MSG ).value,
71
- 'username' => find_child( USER ).value,
72
- 'channel' => find_child( CHANNEL ).value,
73
- 'icon_emoji' => find_child( ICON ).value }
74
-
75
- o = attachment_value
76
- h[ 'attachments' ] = o if o
77
- return h.to_json
78
- end
79
-
80
- # ---------------------------------------------------------------------
81
- # Children
82
- # ---------------------------------------------------------------------
83
-
84
- #
85
- # Does this object have children to add when an object
86
- # is created in interactive mode?
87
- # This does not apply during obj load, etc.
88
- #
89
- def add_children_on_create?
90
- return true
91
- end
92
-
93
- #
94
- # Add children to this object.
95
- # This is used by containers to add children needed
96
- # for default configurations.
97
- #
98
- def add_default_children
99
- fac = $engine.factory
100
- fac.create_string URL, 'https://hooks.slack.com/services/...', self
101
- fac.create_string MSG, 'textual message', self
102
- fac.create_string USER, 'Slack Bot', self
103
- fac.create_string CHANNEL, 'general', self
104
- fac.create_string ICON, ':ghost:', self
105
- end
106
-
107
- # ---------------------------------------------------------------------
108
- # Messages
109
- # ---------------------------------------------------------------------
110
-
111
- #
112
- # Get a list of message names that this object receives.
113
- #
114
- def self.messages
115
- return super + [ 'run' ]
116
- end
117
-
118
- #
119
- # Post the content to the Slack channel.
120
- #
121
- def msg_run
122
- uri = uri_value
123
- return unless uri
124
-
125
- Gloo::Objs::HttpPost.post_json uri, body_as_json
126
- end
127
-
128
- end
129
- end
130
- end
@@ -1,117 +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 that can send a message to a Teams webhook.
5
- #
6
- require 'net/http'
7
- require 'uri'
8
- require 'json'
9
-
10
- module Gloo
11
- module Objs
12
- class Teams < Gloo::Core::Obj
13
-
14
- KEYWORD = 'teams'.freeze
15
- KEYWORD_SHORT = 'team'.freeze
16
- URL = 'uri'.freeze
17
- DEFAULT_URL = 'https://outlook.office.com/webhook/...'.freeze
18
- MSG = 'message'.freeze
19
- TITLE = 'title'.freeze
20
- COLOR = 'color'.freeze
21
- DEFAULT_COLOR = '008000'.freeze
22
-
23
- #
24
- # The name of the object type.
25
- #
26
- def self.typename
27
- return KEYWORD
28
- end
29
-
30
- #
31
- # The short name of the object type.
32
- #
33
- def self.short_typename
34
- return KEYWORD_SHORT
35
- end
36
-
37
- #
38
- # Get the URI from the child object.
39
- # Returns nil if there is none.
40
- #
41
- def uri_value
42
- uri = find_child URL
43
- return nil unless uri
44
-
45
- return uri.value
46
- end
47
-
48
- # Get the color value.
49
- def color_value
50
- c = find_child COLOR
51
- return nil unless c
52
-
53
- return c.value
54
- end
55
-
56
- #
57
- # Get all the children of the body container and
58
- # convert to JSON that will be sent in the HTTP body.
59
- #
60
- def body_as_json
61
- h = { 'title' => find_child( TITLE ).value,
62
- 'text' => find_child( MSG ).value }
63
- color = color_value
64
- h[ 'themeColor' ] = color if color
65
- return h.to_json
66
- end
67
-
68
- # ---------------------------------------------------------------------
69
- # Children
70
- # ---------------------------------------------------------------------
71
-
72
- #
73
- # Does this object have children to add when an object
74
- # is created in interactive mode?
75
- # This does not apply during obj load, etc.
76
- #
77
- def add_children_on_create?
78
- return true
79
- end
80
-
81
- #
82
- # Add children to this object.
83
- # This is used by containers to add children needed
84
- # for default configurations.
85
- #
86
- def add_default_children
87
- fac = $engine.factory
88
- fac.create_string URL, DEFAULT_URL, self
89
- fac.create_string TITLE, '', self
90
- fac.create_string COLOR, DEFAULT_COLOR, self
91
- fac.create_string MSG, '', self
92
- end
93
-
94
- # ---------------------------------------------------------------------
95
- # Messages
96
- # ---------------------------------------------------------------------
97
-
98
- #
99
- # Get a list of message names that this object receives.
100
- #
101
- def self.messages
102
- return super + [ 'run' ]
103
- end
104
-
105
- #
106
- # Post the content to Microsoft Teams.
107
- #
108
- def msg_run
109
- uri = uri_value
110
- return unless uri
111
-
112
- Gloo::Objs::HttpPost.post_json uri, body_as_json
113
- end
114
-
115
- end
116
- end
117
- end
@@ -1,148 +0,0 @@
1
- # Author:: Eric Crane (mailto:eric.crane@mac.com)
2
- # Copyright:: Copyright (c) 2020 Eric Crane. All rights reserved.
3
- #
4
- # A URI (URL).
5
- #
6
- require 'uri'
7
- require 'net/http'
8
- require 'openssl'
9
-
10
- module Gloo
11
- module Objs
12
- class Uri < Gloo::Core::Obj
13
-
14
- KEYWORD = 'uri'.freeze
15
- KEYWORD_SHORT = 'url'.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
- # Messages
48
- # ---------------------------------------------------------------------
49
-
50
- #
51
- # Get a list of message names that this object receives.
52
- #
53
- def self.messages
54
- basic = %w[open]
55
- gets = %w[get_scheme get_host get_path]
56
- more = %w[get_query get_fragment get_cert_expires]
57
- return super + basic + gets + more
58
- end
59
-
60
- #
61
- # Get the expiration date for the certificate.
62
- #
63
- def msg_get_cert_expires
64
- return unless value
65
- o = value
66
- uri = URI( value )
67
- response = Net::HTTP.start( uri.host, uri.port, :use_ssl => true )
68
- cert = response.peer_cert
69
- o = cert.not_after
70
-
71
- $engine.heap.it.set_to o
72
- return o
73
- end
74
-
75
- #
76
- # Get the URI fragment that comes after the '#'
77
- # in the URL. Might be used to scroll down in the page.
78
- #
79
- def msg_get_fragment
80
- return unless value
81
-
82
- o = URI( value ).fragment
83
- $engine.heap.it.set_to o
84
- return o
85
- end
86
-
87
- #
88
- # Get the URI query parameters.
89
- # Example: id=121
90
- #
91
- def msg_get_query
92
- return unless value
93
-
94
- o = URI( value ).query
95
- $engine.heap.it.set_to o
96
- return o
97
- end
98
-
99
- #
100
- # Get the URI path.
101
- # Example: /posts
102
- #
103
- def msg_get_path
104
- return unless value
105
-
106
- o = URI( value ).path
107
- $engine.heap.it.set_to o
108
- return o
109
- end
110
-
111
- #
112
- # Get the URI host.
113
- # Example: google.com
114
- #
115
- def msg_get_host
116
- return unless value
117
-
118
- o = URI( value ).host
119
- $engine.heap.it.set_to o
120
- return o
121
- end
122
-
123
- #
124
- # Get the URI Scheme.
125
- # Example: http
126
- #
127
- def msg_get_scheme
128
- return unless value
129
-
130
- o = URI( value ).scheme
131
- $engine.heap.it.set_to o
132
- return o
133
- end
134
-
135
- #
136
- # Open the URI in the default browser.
137
- #
138
- def msg_open
139
- return unless value
140
-
141
- cmd = Gloo::Core::GlooSystem.open_for_platform
142
- cmd_with_param = "#{cmd} \"#{value}\""
143
- `#{cmd_with_param}`
144
- end
145
-
146
- end
147
- end
148
- end
@@ -1,191 +0,0 @@
1
- # Author:: Eric Crane (mailto:eric.crane@mac.com)
2
- # Copyright:: Copyright (c) 2019 Eric Crane. All rights reserved.
3
- #
4
- # Helper class used to load a file and create objects in the heap.
5
- #
6
-
7
- module Gloo
8
- module Persist
9
- class FileLoader
10
-
11
- BEGIN_BLOCK = 'BEGIN'.freeze
12
- END_BLOCK = 'END'.freeze
13
- SPACE_CNT = 2
14
-
15
- attr_reader :obj
16
-
17
- #
18
- # Set up a file storage for an object.
19
- #
20
- def initialize( pn )
21
- @pn = pn
22
- @tabs = 0
23
- @obj = nil
24
- @in_multiline = false
25
- @exiting_multiline = false
26
- @in_block = false
27
- @block_value = ''
28
- @debug = false
29
- end
30
-
31
- #
32
- # Load the objects from the file.
33
- #
34
- def load
35
- unless File.exist?( @pn )
36
- $log.error "File '#{@pn}' does not exist."
37
- return
38
- end
39
-
40
- $log.debug "Loading file '#{@pn}'"
41
- @tabs = 0
42
- @parent_stack = []
43
- @parent = $engine.heap.root
44
- @parent_stack.push @parent
45
- f = File.open( @pn, 'r' )
46
- f.each_line do |line|
47
- next if skip_line? line
48
-
49
- handle_one_line line
50
- end
51
- end
52
-
53
- #
54
- # Process one one of the file we're loading.
55
- #
56
- def handle_one_line( line )
57
- if line.strip.end_with? BEGIN_BLOCK
58
- @in_block = true
59
- @save_line = line
60
- elsif @in_block
61
- if line.strip == END_BLOCK
62
- @in_block = false
63
- determine_indent @save_line
64
- process_line @save_line
65
- else
66
- @block_value << line
67
- end
68
- else
69
- determine_indent line
70
- process_line line
71
- end
72
- end
73
-
74
- #
75
- # Is this line a comment or a blank line?
76
- # If so we'll skip it.
77
- #
78
- def skip_line?( line )
79
- line = line.strip
80
- return true if line.empty?
81
- return true if line[ 0 ] == '#'
82
-
83
- return false
84
- end
85
-
86
- #
87
- # Determine the relative indent level for the line.
88
- #
89
- def determine_indent( line )
90
- tabs = tab_count( line )
91
- @indent = 0 # same level as prior line
92
- if tabs > @tabs # indent
93
- # TODO: What if indent is more than one more level?
94
- @tabs = tabs
95
- @indent = 1
96
- elsif tabs < @tabs # outdent
97
- diff = @tabs - tabs
98
- @tabs -= diff
99
- @indent -= diff
100
- end
101
- puts "tabs: #{@tabs}, indent: #{@indent}, line: #{line}" if @debug
102
- end
103
-
104
- #
105
- # Process one line and add objects.
106
- #
107
- def process_line( line )
108
- # reset multiline unless we're actually indented
109
- if @in_multiline && @multi_indent > @indent
110
- puts "Done multiline mi: #{@multi_indent}, i: #{@indent}" if @debug
111
- @in_multiline = false
112
- @exiting_multiline = true
113
- end
114
-
115
- if @in_multiline
116
- @last.add_line line
117
- else
118
- setup_process_obj_line
119
- process_obj_line line
120
- end
121
- end
122
-
123
- #
124
- # Setup and get ready to process an object line.
125
- #
126
- def setup_process_obj_line
127
- if @exiting_multiline
128
- @exiting_multiline = false
129
- @indent += 1
130
- end
131
-
132
- if @indent.positive?
133
- @parent = @last
134
- @parent_stack.push @parent
135
- elsif @indent.negative?
136
- @indent.abs.times do
137
- @parent_stack.pop
138
- @parent = @parent_stack.last
139
- end
140
- end
141
- end
142
-
143
- #
144
- # Process one line and add objects.
145
- #
146
- def process_obj_line( line )
147
- name, type, value = split_line( line )
148
- unless @block_value == ''
149
- value = @block_value
150
- @block_value = ''
151
- end
152
- params = { name: name, type: type, value: value, parent: @parent }
153
- @last = $engine.factory.create( params )
154
-
155
- if value.empty? && @last&.multiline_value?
156
- @multi_indent = 0
157
- @in_multiline = true
158
- puts "*** Start multiline. multi_indent: #{@multi_indent}" if @debug
159
- end
160
-
161
- @obj = @last if @obj.nil?
162
- end
163
-
164
- #
165
- # Get the number of leading tabs.
166
- #
167
- def tab_count( line )
168
- i = 0
169
-
170
- if line[ i ] == ' '
171
- i += 1 while line[ i ] == ' '
172
- tab_equiv = ( i / SPACE_CNT ).to_i
173
- puts "Found #{i} spaces => #{tab_equiv}" if @debug
174
- return tab_equiv
175
- end
176
-
177
- i += 1 while line[ i ] == "\t"
178
- return i
179
- end
180
-
181
- #
182
- # Split the line into 3 parts.
183
- #
184
- def split_line( line )
185
- o = LineSplitter.new( line, @tabs )
186
- return o.split
187
- end
188
-
189
- end
190
- end
191
- end
@@ -1,49 +0,0 @@
1
- # Author:: Eric Crane (mailto:eric.crane@mac.com)
2
- # Copyright:: Copyright (c) 2019 Eric Crane. All rights reserved.
3
- #
4
- # Helper class used to save an object to a file..
5
- #
6
-
7
- module Gloo
8
- module Persist
9
- class FileSaver
10
-
11
- #
12
- # Set up a file storage for an object.
13
- #
14
- def initialize( pn, obj )
15
- @pn = pn
16
- @obj = obj
17
- end
18
-
19
- #
20
- # Save the object to the file.
21
- #
22
- def save
23
- data = get_obj( @obj )
24
- File.write( @pn, data )
25
- end
26
-
27
- #
28
- # Get string of tabs for indentation.
29
- #
30
- def tabs( indent = 0 )
31
- return "\t" * indent
32
- end
33
-
34
- #
35
- # Convert an object to textual representation.
36
- # This is a recursive function.
37
- #
38
- def get_obj( obj, indent = 0 )
39
- t = tabs( indent )
40
- str = "#{t}#{obj.name} [#{obj.type_display}] : #{obj.value_display}\n"
41
- obj.children.each do |child|
42
- str << get_obj( child, indent + 1 )
43
- end
44
- return str
45
- end
46
-
47
- end
48
- end
49
- end
@@ -1,45 +0,0 @@
1
- # Author:: Eric Crane (mailto:eric.crane@mac.com)
2
- # Copyright:: Copyright (c) 2019 Eric Crane. All rights reserved.
3
- #
4
- # Helper class takes an object and writes it to a file.
5
- #
6
-
7
- module Gloo
8
- module Persist
9
- class FileStorage
10
-
11
- attr_reader :obj, :pn
12
-
13
- #
14
- # Set up a file storage for an object.
15
- #
16
- def initialize( pn, obj = nil )
17
- @obj = obj
18
- @pn = pn
19
- end
20
-
21
- #
22
- # Save the object to the file.
23
- #
24
- def save
25
- fs = FileSaver.new @pn, @obj
26
- fs.save
27
- end
28
-
29
- #
30
- # Load the object from the file.
31
- #
32
- def load
33
- fl = FileLoader.new @pn
34
- fl.load
35
- @obj = fl.obj
36
- if @obj
37
- $log.debug "Loaded object: #{@obj.name}"
38
- else
39
- $log.error "Error loading file at #{@pn}"
40
- end
41
- end
42
-
43
- end
44
- end
45
- end