lab42_text 0.0.1
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 +7 -0
- data/LICENSE +20 -0
- data/README.md +4 -0
- data/lib/lab42/text.rb +2 -0
- data/lib/lab42/text/simple_box.rb +81 -0
- data/lib/lab42/text/version.rb +5 -0
- metadata +90 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: c4fd6eb3874f67bc041d266d3c42d1678819c918
|
4
|
+
data.tar.gz: e4982b697d1e24ca06ea04329277407bb4bed9f8
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 314379e5ad6cee5f998ac8da856f8ec3be98b6b27aa917609d58050d2c3e1bf548288ea87fb56ef002cadcd974c537f68a102a681b1eb6a0467cd4e641d1f1cb
|
7
|
+
data.tar.gz: 319ac9670bf60762d064a8187cb2d022736e785b34900bf87a724a9b22ebe0e1c5624f5060145200bfbefeeba7977c81175c5dc66c1cc17c648d10688b252004
|
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2013 Robert Dober
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
6
|
+
this software and associated documentation files (the "Software"), to deal in
|
7
|
+
the Software without restriction, including without limitation the rights to
|
8
|
+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
9
|
+
the Software, and to permit persons to whom the Software is furnished to do so,
|
10
|
+
subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
17
|
+
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
18
|
+
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
19
|
+
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
20
|
+
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
data/lib/lab42/text.rb
ADDED
@@ -0,0 +1,81 @@
|
|
1
|
+
require 'lab42/core/kernel'
|
2
|
+
|
3
|
+
module Lab42
|
4
|
+
module Text
|
5
|
+
class SimpleBox
|
6
|
+
def render options = {}
|
7
|
+
set_options! options
|
8
|
+
[
|
9
|
+
header_line,
|
10
|
+
*bordered_lines,
|
11
|
+
footer_line
|
12
|
+
]
|
13
|
+
end
|
14
|
+
|
15
|
+
private
|
16
|
+
def bordered_lines
|
17
|
+
@__bordered_lines__ ||=
|
18
|
+
@lines.map{ | line | "#{lhs_border} #{line}#{" " * ( max_len - line.size )} #{rhs_border}" }
|
19
|
+
end
|
20
|
+
|
21
|
+
def footer_line
|
22
|
+
@__footer_line__ ||=
|
23
|
+
"#{left_upper_corner}#{upper_border * max_len.succ.succ}#{right_upper_corner}"
|
24
|
+
end
|
25
|
+
|
26
|
+
def header_line
|
27
|
+
@__header_line__ ||=
|
28
|
+
"#{left_lower_corner}#{lower_border * max_len.succ.succ}#{right_lower_corner}" end
|
29
|
+
|
30
|
+
def initialize lines
|
31
|
+
@lines = lines.dup
|
32
|
+
end
|
33
|
+
|
34
|
+
def left_lower_corner
|
35
|
+
@__left_lower_corner__ ||=
|
36
|
+
@options.values_at( :left_lower_corner, :lower_corner, :left_corner, :corner, :border ).compact.first || '+'
|
37
|
+
end
|
38
|
+
|
39
|
+
def left_upper_corner
|
40
|
+
@__left_upper_corner__ ||=
|
41
|
+
@options.values_at( :left_upper_corner, :upper_corner, :left_corner, :corner, :border ).compact.first || '+'
|
42
|
+
end
|
43
|
+
|
44
|
+
def lhs_border
|
45
|
+
@__lhs_border__ ||=
|
46
|
+
@options.values_at( :lhs_border, :lateral_border, :border ).compact.first || '|'
|
47
|
+
end
|
48
|
+
|
49
|
+
def lower_border
|
50
|
+
@__lower_border__ ||=
|
51
|
+
@options.values_at( :lower_border, :vertical_border, :border ).compact.first || '-'
|
52
|
+
end
|
53
|
+
|
54
|
+
def max_len
|
55
|
+
@__max_len__ ||= @lines.max_by(&sendmsg(:size)).size
|
56
|
+
end
|
57
|
+
|
58
|
+
def rhs_border
|
59
|
+
@__rhs_border__ ||=
|
60
|
+
@options.values_at(:rhs_border, :lateral_border, :border ).compact.first || '|'
|
61
|
+
end
|
62
|
+
|
63
|
+
def right_lower_corner
|
64
|
+
@__right_lower_corner__ ||=
|
65
|
+
@options.values_at( :right_lower_corner, :lower_corner, :right_corner, :corner, :border ).compact.first || '+'
|
66
|
+
end
|
67
|
+
|
68
|
+
def right_upper_corner
|
69
|
+
@__right_upper_corner__ ||=
|
70
|
+
@options.values_at( :right_upper_corner, :upper_corner, :right_corner, :corner, :border ).compact.first || '+'
|
71
|
+
end
|
72
|
+
|
73
|
+
def set_options! options; @options = options.dup end
|
74
|
+
|
75
|
+
def upper_border
|
76
|
+
@__upper_border__ ||=
|
77
|
+
@options.values_at( :upper_border, :vertical_border, :border ).compact.first || '-'
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end # module Text
|
81
|
+
end # module Lab42
|
metadata
ADDED
@@ -0,0 +1,90 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: lab42_text
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Robert Dober
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2013-12-08 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: lab42_core
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 0.0.6
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 0.0.6
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: pry
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 0.9.12
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 0.9.12
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '2.14'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '2.14'
|
55
|
+
description: Boxes, Translations,...
|
56
|
+
email: robert.dober@gmail.com
|
57
|
+
executables: []
|
58
|
+
extensions: []
|
59
|
+
extra_rdoc_files: []
|
60
|
+
files:
|
61
|
+
- lib/lab42/text.rb
|
62
|
+
- lib/lab42/text/version.rb
|
63
|
+
- lib/lab42/text/simple_box.rb
|
64
|
+
- LICENSE
|
65
|
+
- README.md
|
66
|
+
homepage: https://github.com/RobertDober/lab42_text
|
67
|
+
licenses:
|
68
|
+
- MIT
|
69
|
+
metadata: {}
|
70
|
+
post_install_message:
|
71
|
+
rdoc_options: []
|
72
|
+
require_paths:
|
73
|
+
- lib
|
74
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
75
|
+
requirements:
|
76
|
+
- - ">="
|
77
|
+
- !ruby/object:Gem::Version
|
78
|
+
version: 2.0.0
|
79
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
80
|
+
requirements:
|
81
|
+
- - ">="
|
82
|
+
- !ruby/object:Gem::Version
|
83
|
+
version: '0'
|
84
|
+
requirements: []
|
85
|
+
rubyforge_project:
|
86
|
+
rubygems_version: 2.1.5
|
87
|
+
signing_key:
|
88
|
+
specification_version: 4
|
89
|
+
summary: Simple Text Manipulation
|
90
|
+
test_files: []
|