summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrick Spek <p.spek@tyil.nl>2018-06-25 20:35:03 +0200
committerPatrick Spek <p.spek@tyil.nl>2018-06-25 20:35:03 +0200
commit49675f73122b2bdc45c55cb5c26482a6a2988387 (patch)
treeb87597587a051881c01a02532abc60f8b8ab91ac
downloadText::BorderedBlock-49675f73122b2bdc45c55cb5c26482a6a2988387.tar.gz
Text::BorderedBlock-49675f73122b2bdc45c55cb5c26482a6a2988387.tar.bz2
Initial commit
-rw-r--r--.editorconfig12
-rw-r--r--.gitignore6
-rw-r--r--.gitlab-ci.yml23
-rw-r--r--.idea/codeStyles/codeStyleConfig.xml5
-rw-r--r--.idea/dictionaries/tyil.xml3
-rw-r--r--.idea/misc.xml4
-rw-r--r--.idea/modules.xml8
-rw-r--r--.idea/vcs.xml6
-rw-r--r--.idea/workspace.xml264
-rw-r--r--.travis.yml13
-rw-r--r--META6.json23
-rw-r--r--lib/Text/BorderedBlock.pm6140
-rw-r--r--perl6-Text-BorderedBlock.iml10
-rw-r--r--t/blocks.t72
-rw-r--r--t/files/footer.txt5
-rw-r--r--t/files/full.txt7
-rw-r--r--t/files/header.txt5
-rw-r--r--t/files/multi-footer.txt19
-rw-r--r--t/files/multi-full.txt28
-rw-r--r--t/files/multi-header.txt19
-rw-r--r--t/files/multi-simple.txt10
-rw-r--r--t/files/simple.txt3
22 files changed, 685 insertions, 0 deletions
diff --git a/.editorconfig b/.editorconfig
new file mode 100644
index 0000000..6bbc5b4
--- /dev/null
+++ b/.editorconfig
@@ -0,0 +1,12 @@
+[*]
+charset = utf8
+end_of_line = lf
+insert_final_newline = true
+indent_style = tab
+indent_size = 4
+
+[*.json]
+indent_style = space
+indent_size = 2
+
+# vim: ft=dosini
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..5f2320e
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,6 @@
+# Perl 6 precompiled files
+.precomp
+
+# Editor files
+*~ # emacs
+.*.sw? # vim
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
new file mode 100644
index 0000000..1370756
--- /dev/null
+++ b/.gitlab-ci.yml
@@ -0,0 +1,23 @@
+Text::BorderedBlock:
+ only:
+ - master
+ image: rakudo-star
+ before_script:
+ - zef install . --deps-only
+ script: AUTHOR_TESTING=1 prove -v -e "perl6 -Ilib" t
+ artifacts:
+ name: "perl-Text-BorderedBlock"
+ paths:
+ - META6.json
+ - bin
+ - lib
+ - resources
+ - t
+
+test:
+ except:
+ - master
+ image: rakudo-star
+ before_script:
+ - zef install . --deps-only
+ script: AUTHOR_TESTING=1 prove -v -e "perl6 -Ilib" t
diff --git a/.idea/codeStyles/codeStyleConfig.xml b/.idea/codeStyles/codeStyleConfig.xml
new file mode 100644
index 0000000..a55e7a1
--- /dev/null
+++ b/.idea/codeStyles/codeStyleConfig.xml
@@ -0,0 +1,5 @@
+<component name="ProjectCodeStyleConfiguration">
+ <state>
+ <option name="PREFERRED_PROJECT_CODE_STYLE" value="Default" />
+ </state>
+</component> \ No newline at end of file
diff --git a/.idea/dictionaries/tyil.xml b/.idea/dictionaries/tyil.xml
new file mode 100644
index 0000000..f8ac11b
--- /dev/null
+++ b/.idea/dictionaries/tyil.xml
@@ -0,0 +1,3 @@
+<component name="ProjectDictionaryState">
+ <dictionary name="tyil" />
+</component> \ No newline at end of file
diff --git a/.idea/misc.xml b/.idea/misc.xml
new file mode 100644
index 0000000..63f3197
--- /dev/null
+++ b/.idea/misc.xml
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+ <component name="ProjectRootManager" version="2" project-jdk-name="Perl 6 v2018.04.1" project-jdk-type="Perl 6 SDK" />
+</project> \ No newline at end of file
diff --git a/.idea/modules.xml b/.idea/modules.xml
new file mode 100644
index 0000000..fd1d56c
--- /dev/null
+++ b/.idea/modules.xml
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+ <component name="ProjectModuleManager">
+ <modules>
+ <module fileurl="file://$PROJECT_DIR$/perl6-Text-BorderedBlock.iml" filepath="$PROJECT_DIR$/perl6-Text-BorderedBlock.iml" />
+ </modules>
+ </component>
+</project> \ No newline at end of file
diff --git a/.idea/vcs.xml b/.idea/vcs.xml
new file mode 100644
index 0000000..94a25f7
--- /dev/null
+++ b/.idea/vcs.xml
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+ <component name="VcsDirectoryMappings">
+ <mapping directory="$PROJECT_DIR$" vcs="Git" />
+ </component>
+</project> \ No newline at end of file
diff --git a/.idea/workspace.xml b/.idea/workspace.xml
new file mode 100644
index 0000000..836a0ab
--- /dev/null
+++ b/.idea/workspace.xml
@@ -0,0 +1,264 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+ <component name="ChangeListManager">
+ <list default="true" id="d1b36346-610d-46e1-b147-b193363a489e" name="Default" comment="" />
+ <option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
+ <option name="SHOW_DIALOG" value="false" />
+ <option name="HIGHLIGHT_CONFLICTS" value="true" />
+ <option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
+ <option name="LAST_RESOLUTION" value="IGNORE" />
+ </component>
+ <component name="FileEditorManager">
+ <leaf>
+ <file pinned="false" current-in-tab="false">
+ <entry file="file://$PROJECT_DIR$/META6.json">
+ <provider selected="true" editor-type-id="text-editor" />
+ </entry>
+ </file>
+ <file pinned="false" current-in-tab="false">
+ <entry file="file://$PROJECT_DIR$/lib/Text/BorderedBlock.pm6">
+ <provider selected="true" editor-type-id="text-editor">
+ <state relative-caret-position="84">
+ <caret line="6" column="9" selection-start-line="6" selection-start-column="9" selection-end-line="6" selection-end-column="9" />
+ </state>
+ </provider>
+ </entry>
+ </file>
+ <file pinned="false" current-in-tab="true">
+ <entry file="file://$PROJECT_DIR$/t/blocks.t">
+ <provider selected="true" editor-type-id="text-editor">
+ <state relative-caret-position="106">
+ <caret line="19" column="21" selection-start-line="19" selection-start-column="21" selection-end-line="19" selection-end-column="21" />
+ </state>
+ </provider>
+ </entry>
+ </file>
+ <file pinned="false" current-in-tab="false">
+ <entry file="file://$PROJECT_DIR$/t/files/multi-full.txt">
+ <provider selected="true" editor-type-id="text-editor">
+ <state relative-caret-position="140">
+ <caret line="10" selection-start-line="10" selection-end-line="10" />
+ </state>
+ </provider>
+ </entry>
+ </file>
+ <file pinned="false" current-in-tab="false">
+ <entry file="file://$PROJECT_DIR$/t/files/multi-footer.txt">
+ <provider selected="true" editor-type-id="text-editor" />
+ </entry>
+ </file>
+ <file pinned="false" current-in-tab="false">
+ <entry file="file://$PROJECT_DIR$/t/files/simple.txt">
+ <provider selected="true" editor-type-id="text-editor">
+ <state relative-caret-position="14">
+ <caret line="1" column="30" selection-start-line="1" selection-start-column="30" selection-end-line="1" selection-end-column="30" />
+ </state>
+ </provider>
+ </entry>
+ </file>
+ <file pinned="false" current-in-tab="false">
+ <entry file="file://$PROJECT_DIR$/t/files/footer.txt">
+ <provider selected="true" editor-type-id="text-editor">
+ <state relative-caret-position="14">
+ <caret line="1" selection-start-line="1" selection-end-line="1" />
+ </state>
+ </provider>
+ </entry>
+ </file>
+ <file pinned="false" current-in-tab="false">
+ <entry file="file://$PROJECT_DIR$/t/files/full.txt">
+ <provider selected="true" editor-type-id="text-editor">
+ <state relative-caret-position="14">
+ <caret line="1" selection-start-line="1" selection-end-line="1" />
+ </state>
+ </provider>
+ </entry>
+ </file>
+ <file pinned="false" current-in-tab="false">
+ <entry file="file://$PROJECT_DIR$/t/files/header.txt">
+ <provider selected="true" editor-type-id="text-editor">
+ <state relative-caret-position="14">
+ <caret line="1" column="65" selection-start-line="1" selection-start-column="65" selection-end-line="1" selection-end-column="65" />
+ </state>
+ </provider>
+ </entry>
+ </file>
+ <file pinned="false" current-in-tab="false">
+ <entry file="file://$PROJECT_DIR$/.gitlab-ci.yml">
+ <provider selected="true" editor-type-id="text-editor">
+ <state relative-caret-position="112">
+ <caret line="8" column="31" selection-start-line="8" selection-start-column="31" selection-end-line="8" selection-end-column="31" />
+ </state>
+ </provider>
+ </entry>
+ </file>
+ </leaf>
+ </component>
+ <component name="Git.Settings">
+ <option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
+ </component>
+ <component name="IdeDocumentHistory">
+ <option name="CHANGED_PATHS">
+ <list>
+ <option value="$PROJECT_DIR$/.gitlab-ci.yml" />
+ <option value="$PROJECT_DIR$/lib/Text/BorderedBlock.pm6" />
+ <option value="$PROJECT_DIR$/t/files/header.txt" />
+ <option value="$PROJECT_DIR$/t/files/simple.txt" />
+ <option value="$PROJECT_DIR$/t/files/footer.txt" />
+ <option value="$PROJECT_DIR$/t/files/full.txt" />
+ <option value="$PROJECT_DIR$/t/blocks.t" />
+ <option value="$PROJECT_DIR$/t/files/multi-full.txt" />
+ </list>
+ </option>
+ </component>
+ <component name="ProjectFrameBounds">
+ <option name="x" value="12" />
+ <option name="y" value="33" />
+ <option name="width" value="1301" />
+ <option name="height" value="1031" />
+ </component>
+ <component name="ProjectLevelVcsManager" settingsEditedManually="true" />
+ <component name="ProjectView">
+ <navigator currentView="Scope" currentSubView="Scope 'Project Files'; set:Project Files; class com.intellij.psi.search.scope.ProjectFilesScope" proportions="" version="1">
+ <foldersAlwaysOnTop value="true" />
+ </navigator>
+ <panes>
+ <pane id="Scope">
+ <subPane subId="Scope 'Project Files'; set:Project Files; class com.intellij.psi.search.scope.ProjectFilesScope">
+ <expand>
+ <path>
+ <item name="perl6-Text-BorderedBlock" type="3d21c010:ScopeViewTreeModel$ProjectNode" />
+ <item name="" type="442cc68d:ScopeViewTreeModel$RootNode" />
+ </path>
+ <path>
+ <item name="perl6-Text-BorderedBlock" type="3d21c010:ScopeViewTreeModel$ProjectNode" />
+ <item name="" type="442cc68d:ScopeViewTreeModel$RootNode" />
+ <item name="t" type="9f88c78c:ScopeViewTreeModel$FileNode" />
+ </path>
+ <path>
+ <item name="perl6-Text-BorderedBlock" type="3d21c010:ScopeViewTreeModel$ProjectNode" />
+ <item name="" type="442cc68d:ScopeViewTreeModel$RootNode" />
+ <item name="t" type="9f88c78c:ScopeViewTreeModel$FileNode" />
+ <item name="files" type="9f88c78c:ScopeViewTreeModel$FileNode" />
+ </path>
+ </expand>
+ <select />
+ </subPane>
+ </pane>
+ </panes>
+ </component>
+ <component name="PropertiesComponent">
+ <property name="editorconfig.notification" value="utf8" />
+ <property name="settings.editor.selected.configurable" value="preferences.lookFeel" />
+ </component>
+ <component name="RunDashboard">
+ <option name="ruleStates">
+ <list>
+ <RuleState>
+ <option name="name" value="ConfigurationTypeDashboardGroupingRule" />
+ </RuleState>
+ <RuleState>
+ <option name="name" value="StatusDashboardGroupingRule" />
+ </RuleState>
+ </list>
+ </option>
+ </component>
+ <component name="SvnConfiguration">
+ <configuration />
+ </component>
+ <component name="ToolWindowManager">
+ <frame x="12" y="33" width="1301" height="1031" extended-state="1" />
+ <editor active="true" />
+ <layout>
+ <window_info active="true" content_ui="combo" id="Project" order="0" visible="true" weight="0.24960877" />
+ <window_info id="Structure" order="1" side_tool="true" weight="0.25" />
+ <window_info id="Favorites" order="2" side_tool="true" />
+ <window_info anchor="bottom" id="Message" order="0" />
+ <window_info anchor="bottom" id="Find" order="1" />
+ <window_info anchor="bottom" id="Run" order="2" />
+ <window_info anchor="bottom" id="Debug" order="3" weight="0.4" />
+ <window_info anchor="bottom" id="Cvs" order="4" weight="0.25" />
+ <window_info anchor="bottom" id="Inspection" order="5" weight="0.4" />
+ <window_info anchor="bottom" id="TODO" order="6" />
+ <window_info anchor="bottom" id="Version Control" order="7" />
+ <window_info anchor="bottom" id="Terminal" order="8" />
+ <window_info anchor="bottom" id="Event Log" order="9" side_tool="true" />
+ <window_info anchor="right" id="Commander" internal_type="SLIDING" order="0" type="SLIDING" weight="0.4" />
+ <window_info anchor="right" id="Ant Build" order="1" weight="0.25" />
+ <window_info anchor="right" content_ui="combo" id="Hierarchy" order="2" weight="0.25" />
+ </layout>
+ </component>
+ <component name="VcsContentAnnotationSettings">
+ <option name="myLimit" value="2678400000" />
+ </component>
+ <component name="editorHistoryManager">
+ <entry file="file://$PROJECT_DIR$/.idea/workspace.xml">
+ <provider selected="true" editor-type-id="text-editor" />
+ </entry>
+ <entry file="file://$PROJECT_DIR$/.idea/modules.xml">
+ <provider selected="true" editor-type-id="text-editor" />
+ </entry>
+ <entry file="file://$PROJECT_DIR$/.gitlab-ci.yml">
+ <provider selected="true" editor-type-id="text-editor">
+ <state relative-caret-position="112">
+ <caret line="8" column="31" selection-start-line="8" selection-start-column="31" selection-end-line="8" selection-end-column="31" />
+ </state>
+ </provider>
+ </entry>
+ <entry file="file://$PROJECT_DIR$/t/files/header.txt">
+ <provider selected="true" editor-type-id="text-editor">
+ <state relative-caret-position="14">
+ <caret line="1" column="65" selection-start-line="1" selection-start-column="65" selection-end-line="1" selection-end-column="65" />
+ </state>
+ </provider>
+ </entry>
+ <entry file="file://$PROJECT_DIR$/t/files/simple.txt">
+ <provider selected="true" editor-type-id="text-editor">
+ <state relative-caret-position="14">
+ <caret line="1" column="30" selection-start-line="1" selection-start-column="30" selection-end-line="1" selection-end-column="30" />
+ </state>
+ </provider>
+ </entry>
+ <entry file="file://$PROJECT_DIR$/t/files/footer.txt">
+ <provider selected="true" editor-type-id="text-editor">
+ <state relative-caret-position="14">
+ <caret line="1" selection-start-line="1" selection-end-line="1" />
+ </state>
+ </provider>
+ </entry>
+ <entry file="file://$PROJECT_DIR$/t/files/full.txt">
+ <provider selected="true" editor-type-id="text-editor">
+ <state relative-caret-position="14">
+ <caret line="1" selection-start-line="1" selection-end-line="1" />
+ </state>
+ </provider>
+ </entry>
+ <entry file="file://$PROJECT_DIR$/lib/Text/BorderedBlock.pm6">
+ <provider selected="true" editor-type-id="text-editor">
+ <state relative-caret-position="84">
+ <caret line="6" column="9" selection-start-line="6" selection-start-column="9" selection-end-line="6" selection-end-column="9" />
+ </state>
+ </provider>
+ </entry>
+ <entry file="file://$PROJECT_DIR$/META6.json">
+ <provider selected="true" editor-type-id="text-editor" />
+ </entry>
+ <entry file="file://$PROJECT_DIR$/t/files/multi-footer.txt">
+ <provider selected="true" editor-type-id="text-editor" />
+ </entry>
+ <entry file="file://$PROJECT_DIR$/t/files/multi-full.txt">
+ <provider selected="true" editor-type-id="text-editor">
+ <state relative-caret-position="140">
+ <caret line="10" selection-start-line="10" selection-end-line="10" />
+ </state>
+ </provider>
+ </entry>
+ <entry file="file://$PROJECT_DIR$/t/blocks.t">
+ <provider selected="true" editor-type-id="text-editor">
+ <state relative-caret-position="106">
+ <caret line="19" column="21" selection-start-line="19" selection-start-column="21" selection-end-line="19" selection-end-column="21" />
+ </state>
+ </provider>
+ </entry>
+ </component>
+</project> \ No newline at end of file
diff --git a/.travis.yml b/.travis.yml
new file mode 100644
index 0000000..077ddb0
--- /dev/null
+++ b/.travis.yml
@@ -0,0 +1,13 @@
+language: perl6
+
+perl6:
+ - latest
+
+os:
+ - linux
+
+install:
+ - rakudobrew build zef
+ - zef install --deps-only .
+
+script: AUTHOR_TESTING=1 prove -v -e "perl6 -Ilib" t/
diff --git a/META6.json b/META6.json
new file mode 100644
index 0000000..3bf57ca
--- /dev/null
+++ b/META6.json
@@ -0,0 +1,23 @@
+{
+ "authors": [
+ "Patrick Spek <p.spek@tyil.work>"
+ ],
+ "depends": [
+ "Terminal::ANSIColor"
+ ],
+ "description": "Put a border around a block of text",
+ "license": "AGPL-3.0",
+ "meta-version": 0,
+ "name": "Text::BorderedBlock",
+ "perl": "6.c",
+ "provides": {
+ "Text::BorderedBlock": "lib/Text/BorderedBlock.pm6"
+ },
+ "resources": [
+
+ ],
+ "tags": [
+
+ ],
+ "version": "0.0.0"
+} \ No newline at end of file
diff --git a/lib/Text/BorderedBlock.pm6 b/lib/Text/BorderedBlock.pm6
new file mode 100644
index 0000000..9f91215
--- /dev/null
+++ b/lib/Text/BorderedBlock.pm6
@@ -0,0 +1,140 @@
+#! /usr/bin/env false
+
+use v6.c;
+
+use Terminal::ANSIColor;
+
+class Text::BorderedBlock
+{
+ has Str %.box-characters =
+ outer-top-left => "┏",
+ outer-top-right => "┓",
+ outer-bottom-left => "┗",
+ outer-bottom-right => "┛",
+ outer-horizontal => "━",
+ outer-vertical => "┃",
+ seperator-left => "┠",
+ seperator-right => "┨",
+ seperator => "─",
+ ;
+
+ has Str $.content = "";
+ has Str $.header = "";
+ has Str $.footer = "";
+ has Int $.minimum-width = 66;
+
+ multi method render (
+ --> Str
+ ) {
+ self.render(
+ $!content,
+ header => $!header,
+ footer => $!footer,
+ minimum-width => $!minimum-width,
+ );
+ }
+
+ multi method render (
+ Str:D $content is copy,
+ :$header = $!header,
+ :$footer = $!header,
+ :$minimum-width = $!minimum-width,
+ --> Str
+ ) {
+ # Trim content
+ $content .= trim;
+
+ # Calculate the maximum width of the content
+ my Int $longest-string = 0;
+
+ for $content.lines { $longest-string = colorstrip($_).chars if $longest-string < colorstrip($_).chars; }
+ for $header.lines { $longest-string = colorstrip($_).chars if $longest-string < colorstrip($_).chars; }
+ for $footer.lines { $longest-string = colorstrip($_).chars if $longest-string < colorstrip($_).chars; }
+
+ $longest-string = $minimum-width if $longest-string < $minimum-width;
+
+ # Create the top bar
+ my Str $block = %!box-characters<outer-top-left>;
+ $block ~= %!box-characters<outer-horizontal> x $longest-string;
+ $block ~= %!box-characters<outer-top-right>;
+ $block ~= "\n";
+
+ # Add a header, if needed
+ if ($header ne "") {
+ for $header.lines {
+ $block ~= self!wrap-line($_, $longest-string);
+ }
+
+ $block ~= %!box-characters<seperator-left>;
+ $block ~= %!box-characters<seperator> x $longest-string;
+ $block ~= %!box-characters<seperator-right>;
+ $block ~= "\n";
+ }
+
+ # Add the main content
+ for $content.lines {
+ $block ~= self!wrap-line($_, $longest-string);
+ }
+
+ # Add a footer, if needed
+ if ($footer ne "") {
+ $block ~= %!box-characters<seperator-left>;
+ $block ~= %!box-characters<seperator> x $longest-string;
+ $block ~= %!box-characters<seperator-right>;
+ $block ~= "\n";
+
+ for $footer.lines {
+ $block ~= self!wrap-line($_, $longest-string);
+ }
+ }
+
+ # Create the bottom bar
+ $block ~= %!box-characters<outer-bottom-left>;
+ $block ~= %!box-characters<outer-horizontal> x $longest-string;
+ $block ~= %!box-characters<outer-bottom-right>;
+ }
+
+ method !wrap-line (
+ Str:D $line,
+ Int:D $length,
+ --> Str
+ ) {
+ %!box-characters<outer-vertical>
+ ~ $line ~ " " x ($length - colorstrip($line).chars)
+ ~ %!box-characters<outer-vertical> ~ "\n";
+ }
+}
+
+=begin pod
+
+=NAME Text::BorderedBlock
+=AUTHOR Patrick Spek
+=VERSION 0.2.0
+=LICENSE GNU Aferro General Public License, version 3
+
+=head1 Description
+
+This module is supporting for C<p6man>, to create the blocks of text surrounded
+by a border. It is intended to be seperated into it's own module later on.
+
+=head1 Examples
+
+=head2 Default usage
+
+=begin code
+use Text::BorderedBlock;
+
+my Text::BorderedBlock $block .= new;
+
+say $block.render("Some content to put a border around")
+=end code
+
+=begin output
+┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
+┃Some content to put a border around ┃
+┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
+=end output
+
+=end pod
+
+# vim: ft=perl6 noet
diff --git a/perl6-Text-BorderedBlock.iml b/perl6-Text-BorderedBlock.iml
new file mode 100644
index 0000000..bdd8f41
--- /dev/null
+++ b/perl6-Text-BorderedBlock.iml
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<module type="PERL6_MODULE_TYPE" version="4">
+ <component name="NewModuleRootManager">
+ <content url="file://$MODULE_DIR$">
+ <sourceFolder url="file://$MODULE_DIR$/lib" isTestSource="false" />
+ <sourceFolder url="file://$MODULE_DIR$/t" isTestSource="false" />
+ </content>
+ <orderEntry type="sourceFolder" forTests="false" />
+ </component>
+</module> \ No newline at end of file
diff --git a/t/blocks.t b/t/blocks.t
new file mode 100644
index 0000000..de73b98
--- /dev/null
+++ b/t/blocks.t
@@ -0,0 +1,72 @@
+#! /usr/bin/env perl6
+
+use v6.c;
+
+use Text::BorderedBlock;
+use Test;
+
+plan 2;
+
+my Text::BorderedBlock $block .= new;
+
+subtest "Single lines" => {
+ plan 4;
+
+ my Str $text = "Lorem ipsum dolor sit amet...";
+
+ is
+ $block.render($text),
+ slurp("t/files/simple.txt").trim,
+ "Simple block";
+
+ is
+ $block.render($text, header => $text),
+ slurp("t/files/header.txt").trim,
+ "Block with header";
+
+ is $block.render($text, footer => $text),
+ slurp("t/files/footer.txt").trim,
+ "Block with footer";
+
+ is $block.render($text, header => $text, footer => $text),
+ slurp("t/files/full.txt").trim,
+ "Block with header and footer";
+}
+
+subtest "Multiple lines" => {
+ plan 4;
+
+ my Str $text = q:to/END/;
+ Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praesent
+ scelerisque, mi in rutrum molestie, lacus sem pellentesque justo, faucibus
+ hendrerit purus eros quis tellus. Proin id pretium leo, quis venenatis
+ ligula. Aliquam vel scelerisque dolor. Nam tristique sodales posuere. Sed
+ rhoncus erat leo, vel volutpat odio tincidunt non. Praesent pharetra felis
+ et semper condimentum. Curabitur a lorem eget purus facilisis mollis. Sed
+ eu auctor metus. Vivamus id scelerisque libero, feugiat interdum neque.
+ Aliquam vitae sem sit amet mi porta interdum.
+ END
+
+
+ is
+ $block.render($text),
+ slurp("t/files/multi-simple.txt").trim,
+ "Simple block.";
+
+ is
+ $block.render($text, header => $text),
+ slurp("t/files/multi-header.txt").trim,
+ "Block with header";
+
+ is $block.render($text, footer => $text),
+ slurp("t/files/multi-footer.txt").trim,
+ "Block with footer";
+
+ is $block.render($text, header => $text, footer => $text),
+ slurp("t/files/multi-full.txt").trim,
+ "Block with header and footer";
+
+
+}
+
+# vim: ft=perl6 noet
diff --git a/t/files/footer.txt b/t/files/footer.txt
new file mode 100644
index 0000000..30d33bd
--- /dev/null
+++ b/t/files/footer.txt
@@ -0,0 +1,5 @@
+┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
+┃Lorem ipsum dolor sit amet... ┃
+┠──────────────────────────────────────────────────────────────────┨
+┃Lorem ipsum dolor sit amet... ┃
+┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
diff --git a/t/files/full.txt b/t/files/full.txt
new file mode 100644
index 0000000..62d259a
--- /dev/null
+++ b/t/files/full.txt
@@ -0,0 +1,7 @@
+┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
+┃Lorem ipsum dolor sit amet... ┃
+┠──────────────────────────────────────────────────────────────────┨
+┃Lorem ipsum dolor sit amet... ┃
+┠──────────────────────────────────────────────────────────────────┨
+┃Lorem ipsum dolor sit amet... ┃
+┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
diff --git a/t/files/header.txt b/t/files/header.txt
new file mode 100644
index 0000000..30d33bd
--- /dev/null
+++ b/t/files/header.txt
@@ -0,0 +1,5 @@
+┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
+┃Lorem ipsum dolor sit amet... ┃
+┠──────────────────────────────────────────────────────────────────┨
+┃Lorem ipsum dolor sit amet... ┃
+┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
diff --git a/t/files/multi-footer.txt b/t/files/multi-footer.txt
new file mode 100644
index 0000000..599e404
--- /dev/null
+++ b/t/files/multi-footer.txt
@@ -0,0 +1,19 @@
+┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
+┃Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praesent ┃
+┃scelerisque, mi in rutrum molestie, lacus sem pellentesque justo, faucibus┃
+┃hendrerit purus eros quis tellus. Proin id pretium leo, quis venenatis ┃
+┃ligula. Aliquam vel scelerisque dolor. Nam tristique sodales posuere. Sed ┃
+┃rhoncus erat leo, vel volutpat odio tincidunt non. Praesent pharetra felis┃
+┃et semper condimentum. Curabitur a lorem eget purus facilisis mollis. Sed ┃
+┃eu auctor metus. Vivamus id scelerisque libero, feugiat interdum neque. ┃
+┃Aliquam vitae sem sit amet mi porta interdum. ┃
+┠──────────────────────────────────────────────────────────────────────────┨
+┃Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praesent ┃
+┃scelerisque, mi in rutrum molestie, lacus sem pellentesque justo, faucibus┃
+┃hendrerit purus eros quis tellus. Proin id pretium leo, quis venenatis ┃
+┃ligula. Aliquam vel scelerisque dolor. Nam tristique sodales posuere. Sed ┃
+┃rhoncus erat leo, vel volutpat odio tincidunt non. Praesent pharetra felis┃
+┃et semper condimentum. Curabitur a lorem eget purus facilisis mollis. Sed ┃
+┃eu auctor metus. Vivamus id scelerisque libero, feugiat interdum neque. ┃
+┃Aliquam vitae sem sit amet mi porta interdum. ┃
+┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
diff --git a/t/files/multi-full.txt b/t/files/multi-full.txt
new file mode 100644
index 0000000..7a8d4c8
--- /dev/null
+++ b/t/files/multi-full.txt
@@ -0,0 +1,28 @@
+┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
+┃Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praesent ┃
+┃scelerisque, mi in rutrum molestie, lacus sem pellentesque justo, faucibus┃
+┃hendrerit purus eros quis tellus. Proin id pretium leo, quis venenatis ┃
+┃ligula. Aliquam vel scelerisque dolor. Nam tristique sodales posuere. Sed ┃
+┃rhoncus erat leo, vel volutpat odio tincidunt non. Praesent pharetra felis┃
+┃et semper condimentum. Curabitur a lorem eget purus facilisis mollis. Sed ┃
+┃eu auctor metus. Vivamus id scelerisque libero, feugiat interdum neque. ┃
+┃Aliquam vitae sem sit amet mi porta interdum. ┃
+┠──────────────────────────────────────────────────────────────────────────┨
+┃Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praesent ┃
+┃scelerisque, mi in rutrum molestie, lacus sem pellentesque justo, faucibus┃
+┃hendrerit purus eros quis tellus. Proin id pretium leo, quis venenatis ┃
+┃ligula. Aliquam vel scelerisque dolor. Nam tristique sodales posuere. Sed ┃
+┃rhoncus erat leo, vel volutpat odio tincidunt non. Praesent pharetra felis┃
+┃et semper condimentum. Curabitur a lorem eget purus facilisis mollis. Sed ┃
+┃eu auctor metus. Vivamus id scelerisque libero, feugiat interdum neque. ┃
+┃Aliquam vitae sem sit amet mi porta interdum. ┃
+┠──────────────────────────────────────────────────────────────────────────┨
+┃Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praesent ┃
+┃scelerisque, mi in rutrum molestie, lacus sem pellentesque justo, faucibus┃
+┃hendrerit purus eros quis tellus. Proin id pretium leo, quis venenatis ┃
+┃ligula. Aliquam vel scelerisque dolor. Nam tristique sodales posuere. Sed ┃
+┃rhoncus erat leo, vel volutpat odio tincidunt non. Praesent pharetra felis┃
+┃et semper condimentum. Curabitur a lorem eget purus facilisis mollis. Sed ┃
+┃eu auctor metus. Vivamus id scelerisque libero, feugiat interdum neque. ┃
+┃Aliquam vitae sem sit amet mi porta interdum. ┃
+┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
diff --git a/t/files/multi-header.txt b/t/files/multi-header.txt
new file mode 100644
index 0000000..599e404
--- /dev/null
+++ b/t/files/multi-header.txt
@@ -0,0 +1,19 @@
+┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
+┃Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praesent ┃
+┃scelerisque, mi in rutrum molestie, lacus sem pellentesque justo, faucibus┃
+┃hendrerit purus eros quis tellus. Proin id pretium leo, quis venenatis ┃
+┃ligula. Aliquam vel scelerisque dolor. Nam tristique sodales posuere. Sed ┃
+┃rhoncus erat leo, vel volutpat odio tincidunt non. Praesent pharetra felis┃
+┃et semper condimentum. Curabitur a lorem eget purus facilisis mollis. Sed ┃
+┃eu auctor metus. Vivamus id scelerisque libero, feugiat interdum neque. ┃
+┃Aliquam vitae sem sit amet mi porta interdum. ┃
+┠──────────────────────────────────────────────────────────────────────────┨
+┃Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praesent ┃
+┃scelerisque, mi in rutrum molestie, lacus sem pellentesque justo, faucibus┃
+┃hendrerit purus eros quis tellus. Proin id pretium leo, quis venenatis ┃
+┃ligula. Aliquam vel scelerisque dolor. Nam tristique sodales posuere. Sed ┃
+┃rhoncus erat leo, vel volutpat odio tincidunt non. Praesent pharetra felis┃
+┃et semper condimentum. Curabitur a lorem eget purus facilisis mollis. Sed ┃
+┃eu auctor metus. Vivamus id scelerisque libero, feugiat interdum neque. ┃
+┃Aliquam vitae sem sit amet mi porta interdum. ┃
+┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
diff --git a/t/files/multi-simple.txt b/t/files/multi-simple.txt
new file mode 100644
index 0000000..ec48e6e
--- /dev/null
+++ b/t/files/multi-simple.txt
@@ -0,0 +1,10 @@
+┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
+┃Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praesent ┃
+┃scelerisque, mi in rutrum molestie, lacus sem pellentesque justo, faucibus┃
+┃hendrerit purus eros quis tellus. Proin id pretium leo, quis venenatis ┃
+┃ligula. Aliquam vel scelerisque dolor. Nam tristique sodales posuere. Sed ┃
+┃rhoncus erat leo, vel volutpat odio tincidunt non. Praesent pharetra felis┃
+┃et semper condimentum. Curabitur a lorem eget purus facilisis mollis. Sed ┃
+┃eu auctor metus. Vivamus id scelerisque libero, feugiat interdum neque. ┃
+┃Aliquam vitae sem sit amet mi porta interdum. ┃
+┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
diff --git a/t/files/simple.txt b/t/files/simple.txt
new file mode 100644
index 0000000..cb9424a
--- /dev/null
+++ b/t/files/simple.txt
@@ -0,0 +1,3 @@
+┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
+┃Lorem ipsum dolor sit amet... ┃
+┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛