Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* First step to issue #359, no change to the HTML output - add sqlite-db plugin - plugin accesses the dataset created for the Routines page in the website - the data is formatted into the rows of an sqlite table - the completed sqlite database is output into a filename specified in the `configs/03-plugin-options.raku` config file, so changing the value of the `db-filename` field of the `sqlite-db` sub-hash changes the output file name. - the sqlite file is moved by Collection to a directory defined by 'database-dir' relative to the directory in which Collection runs. As set up here, the directory sqlite_dir will be at the same level as the existing renedered_html * Separate out schema from data - data is now in filename specified in plugin config
- Loading branch information
1 parent
3f27363
commit c782dd4
Showing
8 changed files
with
88 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
=begin rakudoc | ||
=TITLE sqlite-db is a plugin for Collection | ||
|
||
The plugin is for the render, compilation, & transfer milestones | ||
|
||
Relies on 'secondaries' plugin creating routines data for the 'tablemanager' plugin. So the plugin must | ||
follow the 'secondaries' plugin. | ||
|
||
Outputs a file for the sqlite executable. Transfers it to the directory named in the `database-dir` field. | ||
|
||
Transfer cleans up the plugin directory. | ||
|
||
=head1 Custom blocks | ||
None | ||
|
||
=head1 Templates | ||
None | ||
|
||
=end rakudoc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#!/usr/bin/env raku | ||
use v6.d; | ||
sub ($pr, %processed, %options --> Array) { | ||
$pr.get-data('sqlite-db')<db-filename>.IO.unlink; | ||
[] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
use v6.d; | ||
sub ( $pr, %processed, %options) { | ||
my $sql; | ||
my %config = $pr.get-data('sqlite-db'); | ||
if $pr.plugin-datakeys (cont) 'tablemanager' { | ||
my @rows = $pr.get-data('tablemanager').<dataset><routines>.list; | ||
$sql = q:to/SQL/; | ||
INSERT INTO routines ( Category, Name, Type, URL ) | ||
VALUES | ||
SQL | ||
$sql ~= [~] @rows[0 ^..* ].map({ | ||
'("' ~ .[0] ~ '" , "' ~ .[1] ~ '" , "'~ .[2] ~ '" , "' | ||
~ .[3] ~ '#' ~ .[4] | ||
~ '")' | ||
}) | ||
.join(",\n") ~ ";\n"; | ||
} | ||
else { | ||
# change the line below to create a string that will cause a better sqlite result | ||
$sql = 'There is no tablemanager data' | ||
} | ||
%config<db-filename>.IO.spurt: $sql; | ||
[ | ||
[ %config<database-dir> ~ '/schema.sql' , 'myself', 'schema.sql' ], | ||
[ %config<database-dir> ~ '/' ~ %config<db-filename> , 'myself', %config<db-filename> ] | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
%( | ||
:auth<collection>, | ||
:authors( | ||
"finanalyst", | ||
), | ||
:compilation<compilation-callable.raku>, | ||
:custom-raku(), | ||
:license<Artistic-2.0>, | ||
:name<sqlite-db>, | ||
:render, | ||
:transfer<cleanup.raku>, | ||
:template-raku(), | ||
:version<0.1.0>, | ||
:database-dir<../sqlite-db>, | ||
:db-filename<sqlite-db.sql>, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
CREATE TABLE IF NOT EXISTS routines ( | ||
Category TEXT, | ||
Name TEXT, | ||
Type TEXT, | ||
URL TEXT | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
use v6.d; | ||
use Test; | ||
use Test::CollectionPlugin; | ||
test-plugin(); | ||
done-testing |