gloo 0.5.4 → 0.7.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/Gemfile.lock +1 -1
- data/lib/gloo/app/args.rb +48 -6
- data/lib/gloo/app/engine.rb +60 -38
- data/lib/gloo/app/help.rb +137 -16
- data/lib/gloo/app/info.rb +3 -1
- data/lib/gloo/app/log.rb +23 -0
- data/lib/gloo/app/mode.rb +2 -0
- data/lib/gloo/app/settings.rb +98 -47
- data/lib/gloo/convert/converter.rb +35 -0
- data/lib/gloo/convert/string_to_datetime.rb +1 -1
- data/lib/gloo/convert/string_to_decimal.rb +1 -1
- data/lib/gloo/convert/string_to_integer.rb +1 -1
- data/lib/gloo/core/dictionary.rb +99 -22
- data/lib/gloo/core/error.rb +19 -8
- data/lib/gloo/core/event_manager.rb +4 -0
- data/lib/gloo/core/factory.rb +11 -0
- data/lib/gloo/core/gloo_system.rb +1 -1
- data/lib/gloo/core/heap.rb +11 -3
- data/lib/gloo/core/here.rb +36 -0
- data/lib/gloo/core/it.rb +6 -0
- data/lib/gloo/core/literal.rb +5 -0
- data/lib/gloo/core/obj.rb +22 -0
- data/lib/gloo/core/op.rb +7 -0
- data/lib/gloo/core/parser.rb +6 -0
- data/lib/gloo/core/pn.rb +38 -0
- data/lib/gloo/core/tokens.rb +66 -22
- data/lib/gloo/core/verb.rb +12 -0
- data/lib/gloo/exec/action.rb +48 -0
- data/lib/gloo/exec/dispatch.rb +15 -5
- data/lib/gloo/exec/exec_env.rb +74 -0
- data/lib/gloo/exec/runner.rb +4 -2
- data/lib/gloo/{core → exec}/script.rb +21 -9
- data/lib/gloo/exec/stack.rb +78 -0
- data/lib/gloo/expr/expression.rb +26 -4
- data/lib/gloo/expr/l_boolean.rb +6 -0
- data/lib/gloo/expr/l_decimal.rb +5 -0
- data/lib/gloo/expr/l_integer.rb +7 -0
- data/lib/gloo/expr/l_string.rb +7 -0
- data/lib/gloo/expr/op_div.rb +2 -0
- data/lib/gloo/expr/op_minus.rb +2 -0
- data/lib/gloo/expr/op_mult.rb +2 -0
- data/lib/gloo/expr/op_plus.rb +2 -0
- data/lib/gloo/help/app/application.txt +22 -0
- data/lib/gloo/help/app/configuration.txt +7 -0
- data/lib/gloo/help/app/default_help.txt +14 -0
- data/lib/gloo/help/app/logging.txt +16 -0
- data/lib/gloo/help/core/color.txt +31 -0
- data/lib/gloo/help/core/error.txt +33 -0
- data/lib/gloo/help/core/events.txt +21 -0
- data/lib/gloo/help/core/gloo_system.txt +54 -0
- data/lib/gloo/help/core/here.txt +30 -0
- data/lib/gloo/help/core/it.txt +23 -0
- data/lib/gloo/help/core/ops.txt +16 -0
- data/lib/gloo/help/core/pathname.txt +29 -0
- data/lib/gloo/help/objs/basic/alias.txt +36 -0
- data/lib/gloo/help/objs/basic/boolean.txt +28 -0
- data/lib/gloo/help/objs/basic/container.txt +33 -0
- data/lib/gloo/help/objs/basic/decimal.txt +28 -0
- data/lib/gloo/help/objs/basic/integer.txt +27 -0
- data/lib/gloo/help/objs/basic/script.txt +29 -0
- data/lib/gloo/help/objs/basic/string.txt +28 -0
- data/lib/gloo/help/objs/basic/text.txt +27 -0
- data/lib/gloo/help/objs/basic/untyped.txt +22 -0
- data/lib/gloo/help/objs/cli/banner.txt +49 -0
- data/lib/gloo/help/objs/cli/bar.txt +34 -0
- data/lib/gloo/help/objs/cli/colorize.txt +33 -0
- data/lib/gloo/help/objs/cli/confirm.txt +26 -0
- data/lib/gloo/help/objs/cli/menu.txt +44 -0
- data/lib/gloo/help/objs/cli/menu_item.txt +26 -0
- data/lib/gloo/help/objs/cli/pastel.txt +43 -0
- data/lib/gloo/help/objs/cli/prompt.txt +27 -0
- data/lib/gloo/help/objs/cli/select.txt +34 -0
- data/lib/gloo/help/objs/ctrl/each.txt +48 -0
- data/lib/gloo/help/objs/ctrl/repeat.txt +38 -0
- data/lib/gloo/help/objs/data/markdown.txt +25 -0
- data/lib/gloo/help/objs/data/table.txt +46 -0
- data/lib/gloo/help/objs/dev/git_repo.txt +35 -0
- data/lib/gloo/help/objs/dt/date.txt +23 -0
- data/lib/gloo/help/objs/dt/datetime.txt +24 -0
- data/lib/gloo/help/objs/dt/time.txt +23 -0
- data/lib/gloo/help/objs/ror/erb.txt +37 -0
- data/lib/gloo/help/objs/ror/eval.txt +24 -0
- data/lib/gloo/help/objs/snd/play.txt +23 -0
- data/lib/gloo/help/objs/snd/say.txt +28 -0
- data/lib/gloo/help/objs/system/file.txt +41 -0
- data/lib/gloo/help/objs/system/system.txt +32 -0
- data/lib/gloo/help/objs/web/http_get.txt +35 -0
- data/lib/gloo/help/objs/web/http_post.txt +32 -0
- data/lib/gloo/help/objs/web/json.txt +34 -0
- data/lib/gloo/help/objs/web/slack.txt +33 -0
- data/lib/gloo/help/objs/web/teams.txt +30 -0
- data/lib/gloo/help/objs/web/uri.txt +37 -0
- data/lib/gloo/help/verbs/alert.txt +33 -0
- data/lib/gloo/help/verbs/beep.txt +25 -0
- data/lib/gloo/help/verbs/cls.txt +24 -0
- data/lib/gloo/help/verbs/context.txt +43 -0
- data/lib/gloo/help/verbs/create.txt +33 -0
- data/lib/gloo/help/verbs/execute.txt +27 -0
- data/lib/gloo/help/verbs/help.txt +34 -0
- data/lib/gloo/help/verbs/if.txt +37 -0
- data/lib/gloo/help/verbs/list.txt +34 -0
- data/lib/gloo/help/verbs/load.txt +38 -0
- data/lib/gloo/help/verbs/move.txt +42 -0
- data/lib/gloo/help/verbs/put.txt +38 -0
- data/lib/gloo/help/verbs/quit.txt +25 -0
- data/lib/gloo/help/verbs/run.txt +41 -0
- data/lib/gloo/help/verbs/save.txt +26 -0
- data/lib/gloo/help/verbs/show.txt +30 -0
- data/lib/gloo/help/verbs/tell.txt +34 -0
- data/lib/gloo/help/verbs/unless.txt +38 -0
- data/lib/gloo/help/verbs/version.txt +32 -0
- data/lib/gloo/help/verbs/wait.txt +29 -0
- data/lib/gloo/objs/basic/alias.rb +0 -33
- data/lib/gloo/objs/basic/boolean.rb +6 -27
- data/lib/gloo/objs/basic/container.rb +0 -33
- data/lib/gloo/objs/basic/decimal.rb +8 -28
- data/lib/gloo/objs/basic/integer.rb +5 -26
- data/lib/gloo/objs/basic/script.rb +1 -27
- data/lib/gloo/objs/basic/string.rb +6 -26
- data/lib/gloo/objs/basic/text.rb +0 -25
- data/lib/gloo/objs/basic/untyped.rb +0 -26
- data/lib/gloo/objs/cli/banner.rb +0 -29
- data/lib/gloo/objs/cli/bar.rb +0 -29
- data/lib/gloo/objs/cli/colorize.rb +4 -34
- data/lib/gloo/objs/cli/confirm.rb +6 -36
- data/lib/gloo/objs/cli/menu.rb +6 -36
- data/lib/gloo/objs/cli/menu_item.rb +0 -33
- data/lib/gloo/objs/cli/pastel.rb +4 -27
- data/lib/gloo/objs/cli/prompt.rb +4 -28
- data/lib/gloo/objs/cli/select.rb +4 -31
- data/lib/gloo/objs/ctrl/each.rb +33 -33
- data/lib/gloo/objs/ctrl/repeat.rb +8 -29
- data/lib/gloo/objs/data/markdown.rb +0 -25
- data/lib/gloo/objs/data/table.rb +4 -32
- data/lib/gloo/objs/dev/git.rb +12 -30
- data/lib/gloo/objs/dt/date.rb +3 -25
- data/lib/gloo/objs/dt/datetime.rb +4 -26
- data/lib/gloo/objs/dt/time.rb +3 -25
- data/lib/gloo/objs/ror/erb.rb +11 -45
- data/lib/gloo/objs/ror/eval.rb +11 -38
- data/lib/gloo/objs/snd/play.rb +2 -25
- data/lib/gloo/objs/snd/say.rb +9 -31
- data/lib/gloo/objs/system/file_handle.rb +0 -38
- data/lib/gloo/objs/system/system.rb +16 -46
- data/lib/gloo/objs/web/http_get.rb +57 -83
- data/lib/gloo/objs/web/http_post.rb +8 -31
- data/lib/gloo/objs/web/json.rb +11 -31
- data/lib/gloo/objs/web/slack.rb +7 -34
- data/lib/gloo/objs/web/teams.rb +13 -48
- data/lib/gloo/objs/web/uri.rb +0 -29
- data/lib/gloo/persist/file_loader.rb +8 -0
- data/lib/gloo/persist/file_saver.rb +6 -0
- data/lib/gloo/persist/file_storage.rb +2 -0
- data/lib/gloo/persist/line_splitter.rb +2 -0
- data/lib/gloo/persist/persist_man.rb +6 -0
- data/lib/gloo/verbs/alert.rb +30 -44
- data/lib/gloo/verbs/beep.rb +0 -30
- data/lib/gloo/verbs/cls.rb +0 -30
- data/lib/gloo/verbs/context.rb +9 -39
- data/lib/gloo/verbs/create.rb +17 -32
- data/lib/gloo/verbs/execute.rb +52 -0
- data/lib/gloo/verbs/help.rb +151 -115
- data/lib/gloo/verbs/if.rb +46 -44
- data/lib/gloo/verbs/list.rb +36 -54
- data/lib/gloo/verbs/load.rb +8 -37
- data/lib/gloo/verbs/move.rb +12 -51
- data/lib/gloo/verbs/put.rb +28 -52
- data/lib/gloo/verbs/quit.rb +0 -31
- data/lib/gloo/verbs/run.rb +23 -39
- data/lib/gloo/verbs/save.rb +0 -33
- data/lib/gloo/verbs/show.rb +6 -31
- data/lib/gloo/verbs/tell.rb +31 -31
- data/lib/gloo/verbs/unless.rb +47 -46
- data/lib/gloo/verbs/version.rb +0 -30
- data/lib/gloo/verbs/wait.rb +0 -31
- metadata +79 -3
@@ -72,16 +72,20 @@ module Gloo
|
|
72
72
|
# Children
|
73
73
|
# ---------------------------------------------------------------------
|
74
74
|
|
75
|
+
#
|
75
76
|
# Does this object have children to add when an object
|
76
77
|
# is created in interactive mode?
|
77
78
|
# This does not apply during obj load, etc.
|
79
|
+
#
|
78
80
|
def add_children_on_create?
|
79
81
|
return true
|
80
82
|
end
|
81
83
|
|
84
|
+
#
|
82
85
|
# Add children to this object.
|
83
86
|
# This is used by containers to add children needed
|
84
87
|
# for default configurations.
|
88
|
+
#
|
85
89
|
def add_default_children
|
86
90
|
fac = $engine.factory
|
87
91
|
fac.create_string URL, 'https://web.site/', self
|
@@ -99,7 +103,9 @@ module Gloo
|
|
99
103
|
return super + [ 'run' ]
|
100
104
|
end
|
101
105
|
|
106
|
+
#
|
102
107
|
# Post the content to the endpoint.
|
108
|
+
#
|
103
109
|
def msg_run
|
104
110
|
uri = uri_value
|
105
111
|
return unless uri
|
@@ -116,7 +122,9 @@ module Gloo
|
|
116
122
|
# Static functions
|
117
123
|
# ---------------------------------------------------------------------
|
118
124
|
|
125
|
+
#
|
119
126
|
# Post the content to the endpoint.
|
127
|
+
#
|
120
128
|
def self.post_json( url, body, use_ssl = true )
|
121
129
|
# Structure the request
|
122
130
|
uri = URI.parse( url )
|
@@ -133,37 +141,6 @@ module Gloo
|
|
133
141
|
return result.body
|
134
142
|
end
|
135
143
|
|
136
|
-
# ---------------------------------------------------------------------
|
137
|
-
# Help
|
138
|
-
# ---------------------------------------------------------------------
|
139
|
-
|
140
|
-
#
|
141
|
-
# Get help for this object type.
|
142
|
-
#
|
143
|
-
def self.help
|
144
|
-
return <<~TEXT
|
145
|
-
HTTP_POST OBJECT TYPE
|
146
|
-
NAME: http_post
|
147
|
-
SHORTCUT: post
|
148
|
-
|
149
|
-
DESCRIPTION
|
150
|
-
Perform an HTTP Post.
|
151
|
-
|
152
|
-
CHILDREN
|
153
|
-
uri - string - 'https://web.site/'
|
154
|
-
The URI for the HTTP Post.
|
155
|
-
body - container
|
156
|
-
Collection of parameters for the HTTP Post.
|
157
|
-
result - string - Optional parameter
|
158
|
-
The result of the request. Whatever was returned in the body
|
159
|
-
of the HTTP POST.
|
160
|
-
|
161
|
-
MESSAGES
|
162
|
-
run - Run the HTTP Post sending the body data to the
|
163
|
-
endpoint specified in the URI.
|
164
|
-
TEXT
|
165
|
-
end
|
166
|
-
|
167
144
|
end
|
168
145
|
end
|
169
146
|
end
|
data/lib/gloo/objs/web/json.rb
CHANGED
@@ -38,7 +38,7 @@ module Gloo
|
|
38
38
|
# Initially only true for scripts.
|
39
39
|
#
|
40
40
|
def multiline_value?
|
41
|
-
return
|
41
|
+
return true
|
42
42
|
end
|
43
43
|
|
44
44
|
#
|
@@ -56,7 +56,16 @@ module Gloo
|
|
56
56
|
# Get a list of message names that this object receives.
|
57
57
|
#
|
58
58
|
def self.messages
|
59
|
-
return super + %w[get parse]
|
59
|
+
return super + %w[get parse pretty]
|
60
|
+
end
|
61
|
+
|
62
|
+
#
|
63
|
+
# Make the JSON pretty.
|
64
|
+
#
|
65
|
+
def msg_pretty
|
66
|
+
pretty = JSON.pretty_generate( self.value )
|
67
|
+
puts pretty
|
68
|
+
set_value pretty
|
60
69
|
end
|
61
70
|
|
62
71
|
#
|
@@ -121,35 +130,6 @@ module Gloo
|
|
121
130
|
end
|
122
131
|
end
|
123
132
|
|
124
|
-
# ---------------------------------------------------------------------
|
125
|
-
# Help
|
126
|
-
# ---------------------------------------------------------------------
|
127
|
-
|
128
|
-
#
|
129
|
-
# Get help for this object type.
|
130
|
-
#
|
131
|
-
def self.help
|
132
|
-
return <<~TEXT
|
133
|
-
JSON OBJECT TYPE
|
134
|
-
NAME: json
|
135
|
-
SHORTCUT: json
|
136
|
-
|
137
|
-
DESCRIPTION
|
138
|
-
JSON data in a text string.
|
139
|
-
|
140
|
-
CHILDREN
|
141
|
-
None
|
142
|
-
|
143
|
-
MESSAGES
|
144
|
-
get - get a value from the JSON data
|
145
|
-
Example: tell myjson to get ("title")
|
146
|
-
The additional parameter is the path to the value.
|
147
|
-
parse - parse the JSON data and put values in the
|
148
|
-
object specified by the additional parameter
|
149
|
-
Example: tell myjson to parse ("path.to.objects")
|
150
|
-
TEXT
|
151
|
-
end
|
152
|
-
|
153
133
|
end
|
154
134
|
end
|
155
135
|
end
|
data/lib/gloo/objs/web/slack.rb
CHANGED
@@ -81,16 +81,20 @@ module Gloo
|
|
81
81
|
# Children
|
82
82
|
# ---------------------------------------------------------------------
|
83
83
|
|
84
|
+
#
|
84
85
|
# Does this object have children to add when an object
|
85
86
|
# is created in interactive mode?
|
86
87
|
# This does not apply during obj load, etc.
|
88
|
+
#
|
87
89
|
def add_children_on_create?
|
88
90
|
return true
|
89
91
|
end
|
90
92
|
|
93
|
+
#
|
91
94
|
# Add children to this object.
|
92
95
|
# This is used by containers to add children needed
|
93
96
|
# for default configurations.
|
97
|
+
#
|
94
98
|
def add_default_children
|
95
99
|
fac = $engine.factory
|
96
100
|
fac.create_string URL, 'https://hooks.slack.com/services/...', self
|
@@ -111,7 +115,9 @@ module Gloo
|
|
111
115
|
return super + [ 'run' ]
|
112
116
|
end
|
113
117
|
|
114
|
-
#
|
118
|
+
#
|
119
|
+
# Post the content to the Slack channel.
|
120
|
+
#
|
115
121
|
def msg_run
|
116
122
|
uri = uri_value
|
117
123
|
return unless uri
|
@@ -119,39 +125,6 @@ module Gloo
|
|
119
125
|
Gloo::Objs::HttpPost.post_json uri, body_as_json, true
|
120
126
|
end
|
121
127
|
|
122
|
-
# ---------------------------------------------------------------------
|
123
|
-
# Help
|
124
|
-
# ---------------------------------------------------------------------
|
125
|
-
|
126
|
-
#
|
127
|
-
# Get help for this object type.
|
128
|
-
#
|
129
|
-
def self.help
|
130
|
-
return <<~TEXT
|
131
|
-
SLACK OBJECT TYPE
|
132
|
-
NAME: slack
|
133
|
-
SHORTCUT: slack
|
134
|
-
|
135
|
-
DESCRIPTION
|
136
|
-
Send message to channel in Slack.
|
137
|
-
|
138
|
-
CHILDREN
|
139
|
-
uri - string - 'https://hooks.slack.com/services/...'
|
140
|
-
The URI with access to the Slack channel.
|
141
|
-
message - string - 'textual message'
|
142
|
-
Message to send to Slack.
|
143
|
-
username - string - 'Slack Bot'
|
144
|
-
Attribute the message to this user.
|
145
|
-
channel - string - 'general'
|
146
|
-
The name of the channel for the post.
|
147
|
-
icon_emoji - string - ':ghost:'
|
148
|
-
The emoji to use for the attribution.
|
149
|
-
|
150
|
-
MESSAGES
|
151
|
-
run - Post the message to Slack.
|
152
|
-
TEXT
|
153
|
-
end
|
154
|
-
|
155
128
|
end
|
156
129
|
end
|
157
130
|
end
|
data/lib/gloo/objs/web/teams.rb
CHANGED
@@ -14,9 +14,11 @@ module Gloo
|
|
14
14
|
KEYWORD = 'teams'.freeze
|
15
15
|
KEYWORD_SHORT = 'team'.freeze
|
16
16
|
URL = 'uri'.freeze
|
17
|
+
DEFAULT_URL = 'https://outlook.office.com/webhook/...'.freeze
|
17
18
|
MSG = 'message'.freeze
|
18
19
|
TITLE = 'title'.freeze
|
19
20
|
COLOR = 'color'.freeze
|
21
|
+
DEFAULT_COLOR = '008000'.freeze
|
20
22
|
|
21
23
|
#
|
22
24
|
# The name of the object type.
|
@@ -67,34 +69,26 @@ module Gloo
|
|
67
69
|
# Children
|
68
70
|
# ---------------------------------------------------------------------
|
69
71
|
|
72
|
+
#
|
70
73
|
# Does this object have children to add when an object
|
71
74
|
# is created in interactive mode?
|
72
75
|
# This does not apply during obj load, etc.
|
76
|
+
#
|
73
77
|
def add_children_on_create?
|
74
78
|
return true
|
75
79
|
end
|
76
80
|
|
81
|
+
#
|
77
82
|
# Add children to this object.
|
78
83
|
# This is used by containers to add children needed
|
79
84
|
# for default configurations.
|
85
|
+
#
|
80
86
|
def add_default_children
|
81
87
|
fac = $engine.factory
|
82
|
-
fac.
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
fac.create( { :name => TITLE,
|
87
|
-
:type => 'string',
|
88
|
-
:value => '',
|
89
|
-
:parent => self } )
|
90
|
-
fac.create( { :name => COLOR,
|
91
|
-
:type => 'color',
|
92
|
-
:value => '008000',
|
93
|
-
:parent => self } )
|
94
|
-
fac.create( { :name => MSG,
|
95
|
-
:type => 'string',
|
96
|
-
:value => '',
|
97
|
-
:parent => self } )
|
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
|
98
92
|
end
|
99
93
|
|
100
94
|
# ---------------------------------------------------------------------
|
@@ -108,7 +102,9 @@ module Gloo
|
|
108
102
|
return super + [ 'run' ]
|
109
103
|
end
|
110
104
|
|
111
|
-
#
|
105
|
+
#
|
106
|
+
# Post the content to Microsoft Teams.
|
107
|
+
#
|
112
108
|
def msg_run
|
113
109
|
uri = uri_value
|
114
110
|
return unless uri
|
@@ -116,37 +112,6 @@ module Gloo
|
|
116
112
|
Gloo::Objs::HttpPost.post_json uri, body_as_json, true
|
117
113
|
end
|
118
114
|
|
119
|
-
# ---------------------------------------------------------------------
|
120
|
-
# Help
|
121
|
-
# ---------------------------------------------------------------------
|
122
|
-
|
123
|
-
#
|
124
|
-
# Get help for this object type.
|
125
|
-
#
|
126
|
-
def self.help
|
127
|
-
return <<~TEXT
|
128
|
-
TEAMS OBJECT TYPE
|
129
|
-
NAME: teams
|
130
|
-
SHORTCUT: team
|
131
|
-
|
132
|
-
DESCRIPTION
|
133
|
-
Send message to channel in Teams.
|
134
|
-
|
135
|
-
CHILDREN
|
136
|
-
uri - string - 'https://outlook.office.com/webhook/...'
|
137
|
-
The URI with access to the Teams channel.
|
138
|
-
title - string
|
139
|
-
Message title; header.
|
140
|
-
color - string - '008000'
|
141
|
-
Color theme for the message.
|
142
|
-
message - string
|
143
|
-
The message to post in Teams.
|
144
|
-
|
145
|
-
MESSAGES
|
146
|
-
run - Post the message to Teams.
|
147
|
-
TEXT
|
148
|
-
end
|
149
|
-
|
150
115
|
end
|
151
116
|
end
|
152
117
|
end
|
data/lib/gloo/objs/web/uri.rb
CHANGED
@@ -126,35 +126,6 @@ module Gloo
|
|
126
126
|
`#{cmd_with_param}`
|
127
127
|
end
|
128
128
|
|
129
|
-
# ---------------------------------------------------------------------
|
130
|
-
# Help
|
131
|
-
# ---------------------------------------------------------------------
|
132
|
-
|
133
|
-
#
|
134
|
-
# Get help for this object type.
|
135
|
-
#
|
136
|
-
def self.help
|
137
|
-
return <<~TEXT
|
138
|
-
URI OBJECT TYPE
|
139
|
-
NAME: uri
|
140
|
-
SHORTCUT: url
|
141
|
-
|
142
|
-
DESCRIPTION
|
143
|
-
A URI or URL.
|
144
|
-
|
145
|
-
CHILDREN
|
146
|
-
None
|
147
|
-
|
148
|
-
MESSAGES
|
149
|
-
open - open the URL in the default browser
|
150
|
-
get_scheme - get the URI scheme; example: http
|
151
|
-
get_host - get the URI host; example: google.com
|
152
|
-
get_path - get the URI resource path; example: /post
|
153
|
-
get_query - get the URI query parameterse; example: id=121
|
154
|
-
get_fragment - get the URI fragment
|
155
|
-
TEXT
|
156
|
-
end
|
157
|
-
|
158
129
|
end
|
159
130
|
end
|
160
131
|
end
|
@@ -14,7 +14,9 @@ module Gloo
|
|
14
14
|
|
15
15
|
attr_reader :obj
|
16
16
|
|
17
|
+
#
|
17
18
|
# Set up a file storage for an object.
|
19
|
+
#
|
18
20
|
def initialize( pn )
|
19
21
|
@pn = pn
|
20
22
|
@tabs = 0
|
@@ -67,8 +69,10 @@ module Gloo
|
|
67
69
|
end
|
68
70
|
end
|
69
71
|
|
72
|
+
#
|
70
73
|
# Is this line a comment or a blank line?
|
71
74
|
# If so we'll skip it.
|
75
|
+
#
|
72
76
|
def skip_line?( line )
|
73
77
|
line = line.strip
|
74
78
|
return true if line.empty?
|
@@ -77,7 +81,9 @@ module Gloo
|
|
77
81
|
return false
|
78
82
|
end
|
79
83
|
|
84
|
+
#
|
80
85
|
# Determine the relative indent level for the line.
|
86
|
+
#
|
81
87
|
def determine_indent( line )
|
82
88
|
tabs = tab_count( line )
|
83
89
|
@indent = 0 # same level as prior line
|
@@ -93,7 +99,9 @@ module Gloo
|
|
93
99
|
puts "tabs: #{@tabs}, indent: #{@indent}, line: #{line}" if @debug
|
94
100
|
end
|
95
101
|
|
102
|
+
#
|
96
103
|
# Process one line and add objects.
|
104
|
+
#
|
97
105
|
def process_line( line )
|
98
106
|
# reset multiline unless we're actually indented
|
99
107
|
if @in_multiline && @multi_indent > @indent
|
@@ -8,7 +8,9 @@ module Gloo
|
|
8
8
|
module Persist
|
9
9
|
class FileSaver
|
10
10
|
|
11
|
+
#
|
11
12
|
# Set up a file storage for an object.
|
13
|
+
#
|
12
14
|
def initialize( pn, obj )
|
13
15
|
@pn = pn
|
14
16
|
@obj = obj
|
@@ -22,13 +24,17 @@ module Gloo
|
|
22
24
|
File.write( @pn, data )
|
23
25
|
end
|
24
26
|
|
27
|
+
#
|
25
28
|
# Get string of tabs for indentation.
|
29
|
+
#
|
26
30
|
def tabs( indent = 0 )
|
27
31
|
return "\t" * indent
|
28
32
|
end
|
29
33
|
|
34
|
+
#
|
30
35
|
# Convert an object to textual representation.
|
31
36
|
# This is a recursive function.
|
37
|
+
#
|
32
38
|
def get_obj( obj, indent = 0 )
|
33
39
|
t = tabs( indent )
|
34
40
|
str = "#{t}#{obj.name} [#{obj.type_display}] : #{obj.value_display}\n"
|
@@ -12,7 +12,9 @@ module Gloo
|
|
12
12
|
|
13
13
|
attr_reader :maps
|
14
14
|
|
15
|
+
#
|
15
16
|
# Contructor for the persistence manager.
|
17
|
+
#
|
16
18
|
def initialize
|
17
19
|
@maps = []
|
18
20
|
end
|
@@ -96,13 +98,17 @@ module Gloo
|
|
96
98
|
return true
|
97
99
|
end
|
98
100
|
|
101
|
+
#
|
99
102
|
# Get the default file extention.
|
103
|
+
#
|
100
104
|
def file_ext
|
101
105
|
return '.gloo'
|
102
106
|
end
|
103
107
|
|
108
|
+
#
|
104
109
|
# Print out all object - persistance mappings.
|
105
110
|
# This is a debugging tool.
|
111
|
+
#
|
106
112
|
def show_maps
|
107
113
|
@maps.each do |o|
|
108
114
|
puts " \t #{o.pn} \t #{o.obj.name}"
|