gloo-db 1.1 → 1.2
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/README.md +23 -0
- data/lib/query.rb +34 -0
- data/lib/table.rb +47 -0
- metadata +6 -7
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: a5f869d21a951e0e316359c444255d44fdae07b64bf9991eb1739ba9df90431c
|
|
4
|
+
data.tar.gz: 64f9bc0c6aeb28f99779a9addacbf3fbc4bcb3265c3b096d93c9db8d19b5c40e
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: e7af37a53fdc0b250306bf723ae92181cca7958aa7dedbf78c61e1f9c660bcc3ee1f46ac52082df6647a3f55ea077ac05ebf659dd309f7c5900348521d71b035
|
|
7
|
+
data.tar.gz: 25b3ec859468892ac5ed7572790b6400259e52241eca8ef18e0170f6db0cc0fa3a683bb6c27903efbd2513cd0ea4a18a2653ad0e011ccbb3a7e87c3e76641193
|
data/README.md
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# gloo-db
|
|
2
|
+
|
|
3
|
+
A core gloo library for database operations.
|
|
4
|
+
|
|
5
|
+
Use this library and one of the database-specific driver libraries (`gloo-pg`, `gloo-mysql`, `gloo-sqlite`) to interact with databases.
|
|
6
|
+
|
|
7
|
+
## Usage
|
|
8
|
+
|
|
9
|
+
Load this library, plus a driver, in a gloo script:
|
|
10
|
+
|
|
11
|
+
```gloo
|
|
12
|
+
> load lib db
|
|
13
|
+
> load lib sqlite
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
## Objects
|
|
17
|
+
|
|
18
|
+
- `query` — a SQL query (SELECT, INSERT, UPDATE, or other statement)
|
|
19
|
+
- `table` — a data table
|
|
20
|
+
|
|
21
|
+
## Full Reference
|
|
22
|
+
|
|
23
|
+
Every object's children and messages are documented in-app once the library is loaded — e.g. `help> object query`.
|
data/lib/query.rb
CHANGED
|
@@ -262,4 +262,38 @@ class Query < Gloo::Core::Obj
|
|
|
262
262
|
end
|
|
263
263
|
end
|
|
264
264
|
|
|
265
|
+
# ---------------------------------------------------------------------
|
|
266
|
+
# Object Documentation
|
|
267
|
+
# ---------------------------------------------------------------------
|
|
268
|
+
|
|
269
|
+
#
|
|
270
|
+
# Get the object's documentation data.
|
|
271
|
+
#
|
|
272
|
+
def self.doc_data
|
|
273
|
+
{
|
|
274
|
+
:name => KEYWORD,
|
|
275
|
+
:shortcut => KEYWORD_SHORT,
|
|
276
|
+
:description => 'A SQL Query — a SELECT, INSERT, UPDATE or other ' \
|
|
277
|
+
'SQL statement. The query requires a valid database connection.',
|
|
278
|
+
:children => [
|
|
279
|
+
'database (alias) — Reference to the database we\'re going to query.',
|
|
280
|
+
'sql (string) — The SQL query to execute.',
|
|
281
|
+
'result (container) — Optional. The result of the query will be a container for each row, with an object for each column. If not present, results are displayed in the console instead.',
|
|
282
|
+
'params (container) — Optional list of parameters for the query.'
|
|
283
|
+
],
|
|
284
|
+
:messages => [
|
|
285
|
+
'run — Run the query and get back the data.'
|
|
286
|
+
],
|
|
287
|
+
:examples => <<~EXAMPLES.strip
|
|
288
|
+
sqlite [can] :
|
|
289
|
+
on_load [script] : run sqlite.sql
|
|
290
|
+
db [sqlite] :
|
|
291
|
+
database : test.db
|
|
292
|
+
sql [query] :
|
|
293
|
+
database [alias] : sqlite.db
|
|
294
|
+
sql : SELECT id, key, value FROM key_values
|
|
295
|
+
EXAMPLES
|
|
296
|
+
}
|
|
297
|
+
end
|
|
298
|
+
|
|
265
299
|
end
|
data/lib/table.rb
CHANGED
|
@@ -266,4 +266,51 @@ class Table < Gloo::Core::Obj
|
|
|
266
266
|
return columns.sort_by { |hsh| hsh[ :display_index ] }
|
|
267
267
|
end
|
|
268
268
|
|
|
269
|
+
# ---------------------------------------------------------------------
|
|
270
|
+
# Object Documentation
|
|
271
|
+
# ---------------------------------------------------------------------
|
|
272
|
+
|
|
273
|
+
#
|
|
274
|
+
# Get the object's documentation data.
|
|
275
|
+
#
|
|
276
|
+
def self.doc_data
|
|
277
|
+
{
|
|
278
|
+
:name => KEYWORD,
|
|
279
|
+
:shortcut => KEYWORD_SHORT,
|
|
280
|
+
:description => 'A data table.',
|
|
281
|
+
:children => [
|
|
282
|
+
'headers (container) — A list of headers. The name of each header object must match the name of the object in the data container; the value of the header is what will be displayed.',
|
|
283
|
+
'data (container) — The table\'s data. Contains one or more containers, each representing one row of data.',
|
|
284
|
+
'cells (container) — Optional. If present, cells can be formatted with a child per column you want to format; you don\'t need to specify a child for every column.',
|
|
285
|
+
'always_rows (boolean) — Optional. By default, if a table\'s data is only 1 row, it shows that row in a vertical table. Marking this true means a horizontal table is shown even if only one row is returned.'
|
|
286
|
+
],
|
|
287
|
+
:messages => [
|
|
288
|
+
'show — Show the contents of the table in the CLI.'
|
|
289
|
+
],
|
|
290
|
+
:examples => <<~EXAMPLES.strip
|
|
291
|
+
t [tbl] :
|
|
292
|
+
on_load [script] :
|
|
293
|
+
tell t to show
|
|
294
|
+
headers [can] :
|
|
295
|
+
name : Name
|
|
296
|
+
phone : Tel
|
|
297
|
+
notes : Notes
|
|
298
|
+
data [alias] : table_data
|
|
299
|
+
table_data [can] :
|
|
300
|
+
1 [can] :
|
|
301
|
+
name : Joe
|
|
302
|
+
phone : 312-555-1212
|
|
303
|
+
notes : Play golf with Joe
|
|
304
|
+
2 [can] :
|
|
305
|
+
name : Sally
|
|
306
|
+
phone : 708-555-1212
|
|
307
|
+
notes : met Sally at the meetup last week
|
|
308
|
+
3 [can] :
|
|
309
|
+
name : Frank
|
|
310
|
+
phone : 312-555-1213
|
|
311
|
+
notes : Frank Lee Speaking
|
|
312
|
+
EXAMPLES
|
|
313
|
+
}
|
|
314
|
+
end
|
|
315
|
+
|
|
269
316
|
end
|
metadata
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: gloo-db
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: '1.
|
|
4
|
+
version: '1.2'
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Eric Crane
|
|
8
|
-
autorequire:
|
|
9
8
|
bindir: bin
|
|
10
9
|
cert_chain: []
|
|
11
|
-
date:
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
12
11
|
dependencies: []
|
|
13
12
|
description: Adds database support to Gloo.
|
|
14
13
|
email:
|
|
@@ -17,16 +16,17 @@ executables: []
|
|
|
17
16
|
extensions: []
|
|
18
17
|
extra_rdoc_files: []
|
|
19
18
|
files:
|
|
19
|
+
- README.md
|
|
20
20
|
- lib/gloo-db.rb
|
|
21
21
|
- lib/query.rb
|
|
22
22
|
- lib/query_result.rb
|
|
23
23
|
- lib/table.rb
|
|
24
|
-
homepage: https://
|
|
24
|
+
homepage: https://github.com/ecrane/gloo
|
|
25
25
|
licenses:
|
|
26
26
|
- MIT
|
|
27
27
|
metadata:
|
|
28
28
|
gloo.type: core-library
|
|
29
|
-
|
|
29
|
+
documentation_uri: https://github.com/ecrane/gloo
|
|
30
30
|
rdoc_options: []
|
|
31
31
|
require_paths:
|
|
32
32
|
- lib
|
|
@@ -41,8 +41,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
41
41
|
- !ruby/object:Gem::Version
|
|
42
42
|
version: '0'
|
|
43
43
|
requirements: []
|
|
44
|
-
rubygems_version:
|
|
45
|
-
signing_key:
|
|
44
|
+
rubygems_version: 4.0.17
|
|
46
45
|
specification_version: 4
|
|
47
46
|
summary: Gloo core library. Database support.
|
|
48
47
|
test_files: []
|