rasskey 0.0.5 → 0.0.6
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.
- data/VERSION +1 -1
- data/lib/rasskey.rb +1 -0
- data/lib/rasskey/line.rb +60 -0
- data/rasskey.gemspec +5 -2
- data/spec/rasskey_line_spec.rb +34 -0
- metadata +22 -26
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.6
|
data/lib/rasskey.rb
CHANGED
data/lib/rasskey/line.rb
ADDED
@@ -0,0 +1,60 @@
|
|
1
|
+
module RassKey
|
2
|
+
class Line
|
3
|
+
class << self
|
4
|
+
attr_accessor :default_length
|
5
|
+
attr_accessor :default_padding
|
6
|
+
attr_accessor :default_glyph
|
7
|
+
attr_accessor :default_orientation
|
8
|
+
end
|
9
|
+
|
10
|
+
@default_length = 20
|
11
|
+
@default_padding = 1
|
12
|
+
@default_glyph = '-'
|
13
|
+
@default_orientation = "horizontal"
|
14
|
+
|
15
|
+
attr_accessor :line_length
|
16
|
+
attr_accessor :padding
|
17
|
+
attr_accessor :glyph
|
18
|
+
attr_accessor :orientation
|
19
|
+
|
20
|
+
def initialize(options = {})
|
21
|
+
options = {
|
22
|
+
:line_length => RassKey::Line.default_length,
|
23
|
+
:padding => RassKey::Line.default_padding,
|
24
|
+
:glyph => RassKey::Line.default_glyph,
|
25
|
+
:orientation => RassKey::Line.default_orientation
|
26
|
+
}.merge(options)
|
27
|
+
|
28
|
+
self.line_length = options[:line_length]
|
29
|
+
self.padding = options[:padding]
|
30
|
+
self.glyph = options[:glyph]
|
31
|
+
self.orientation = options[:orientation]
|
32
|
+
|
33
|
+
super()
|
34
|
+
end
|
35
|
+
|
36
|
+
def draw(data)
|
37
|
+
@glyph.length == 1 ? (@glyph = @glyph) : (@glyph = @glyph[0,1])
|
38
|
+
spacing = " " * @padding || " "
|
39
|
+
line_text = "#{spacing}#{data}#{spacing}"
|
40
|
+
begin
|
41
|
+
content_line = "#{@glyph * ((@line_length - line_text.length)/2)}#{line_text}#{@glyph * ((@line_length - line_text.length)/2)}"
|
42
|
+
rescue
|
43
|
+
puts "line length must be larger to accomodate text"
|
44
|
+
end
|
45
|
+
case @orientation
|
46
|
+
when "horizontal"
|
47
|
+
content_line
|
48
|
+
when "vertical"
|
49
|
+
self.vertical(content_line)
|
50
|
+
else
|
51
|
+
puts "unknown orientation. Should be vertical or horizontal"
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
def vertical(data)
|
56
|
+
data.split(//).join("\n")
|
57
|
+
end
|
58
|
+
|
59
|
+
end
|
60
|
+
end
|
data/rasskey.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{rasskey}
|
8
|
-
s.version = "0.0.
|
8
|
+
s.version = "0.0.6"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["lusis"]
|
12
|
-
s.date = %q{2010-11-
|
12
|
+
s.date = %q{2010-11-30}
|
13
13
|
s.description = %q{Small Ruby library for ASCII drawing}
|
14
14
|
s.email = %q{lusis.org+rubygems.org@gmail.com}
|
15
15
|
s.extra_rdoc_files = [
|
@@ -31,9 +31,11 @@ Gem::Specification.new do |s|
|
|
31
31
|
"lib/rasskey.rb",
|
32
32
|
"lib/rasskey/box.rb",
|
33
33
|
"lib/rasskey/extensions/string.rb",
|
34
|
+
"lib/rasskey/line.rb",
|
34
35
|
"lib/rasskey/version.rb",
|
35
36
|
"rasskey.gemspec",
|
36
37
|
"spec/rasskey_box_spec.rb",
|
38
|
+
"spec/rasskey_line_spec.rb",
|
37
39
|
"spec/rasskey_string_spec.rb",
|
38
40
|
"spec/spec_helper.rb"
|
39
41
|
]
|
@@ -44,6 +46,7 @@ Gem::Specification.new do |s|
|
|
44
46
|
s.summary = %q{Small Ruby library for ASCII drawing}
|
45
47
|
s.test_files = [
|
46
48
|
"spec/rasskey_box_spec.rb",
|
49
|
+
"spec/rasskey_line_spec.rb",
|
47
50
|
"spec/rasskey_string_spec.rb",
|
48
51
|
"spec/spec_helper.rb"
|
49
52
|
]
|
@@ -0,0 +1,34 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
2
|
+
|
3
|
+
describe "Rasskey::Line" do
|
4
|
+
it "should return a RassKey::Line object" do
|
5
|
+
line = RassKey::Line.new
|
6
|
+
line.padding.should == 1
|
7
|
+
line.glyph.should == "-"
|
8
|
+
line.line_length.should == 20
|
9
|
+
line.instance_of?(RassKey::Line).should be_true
|
10
|
+
end
|
11
|
+
|
12
|
+
it "should draw the default line with text 'test'" do
|
13
|
+
line = RassKey::Line.new
|
14
|
+
line.draw("test").should == "------- test -------"
|
15
|
+
end
|
16
|
+
|
17
|
+
it "should accept an option hash " do
|
18
|
+
line = RassKey::Line.new :padding => 2, :glyph => "=", :line_length => 50
|
19
|
+
line.draw("test").should == "===================== test ====================="
|
20
|
+
end
|
21
|
+
|
22
|
+
it "should accept attr_accessors" do
|
23
|
+
line = RassKey::Line.new
|
24
|
+
line.padding = 2
|
25
|
+
line.glyph = "="
|
26
|
+
line.line_length = 50
|
27
|
+
line.draw("test").should == "===================== test ====================="
|
28
|
+
end
|
29
|
+
|
30
|
+
it "should draw a vertical line" do
|
31
|
+
line = RassKey::Line.new :orientation => 'vertical', :glyph => '|'
|
32
|
+
line.draw('vertical').should == "|\n|\n|\n|\n|\n \nv\ne\nr\nt\ni\nc\na\nl\n \n|\n|\n|\n|\n|"
|
33
|
+
end
|
34
|
+
end
|
metadata
CHANGED
@@ -1,13 +1,12 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rasskey
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash: 21
|
5
4
|
prerelease: false
|
6
5
|
segments:
|
7
6
|
- 0
|
8
7
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
8
|
+
- 6
|
9
|
+
version: 0.0.6
|
11
10
|
platform: ruby
|
12
11
|
authors:
|
13
12
|
- lusis
|
@@ -15,85 +14,80 @@ autorequire:
|
|
15
14
|
bindir: bin
|
16
15
|
cert_chain: []
|
17
16
|
|
18
|
-
date: 2010-11-
|
17
|
+
date: 2010-11-30 00:00:00 -05:00
|
19
18
|
default_executable:
|
20
19
|
dependencies:
|
21
20
|
- !ruby/object:Gem::Dependency
|
22
|
-
prerelease: false
|
23
21
|
name: rspec
|
24
|
-
|
22
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
25
23
|
none: false
|
26
24
|
requirements:
|
27
25
|
- - ~>
|
28
26
|
- !ruby/object:Gem::Version
|
29
|
-
hash: 11
|
30
27
|
segments:
|
31
28
|
- 2
|
32
29
|
- 1
|
33
30
|
- 0
|
34
31
|
version: 2.1.0
|
35
|
-
requirement: *id001
|
36
32
|
type: :development
|
37
|
-
- !ruby/object:Gem::Dependency
|
38
33
|
prerelease: false
|
34
|
+
version_requirements: *id001
|
35
|
+
- !ruby/object:Gem::Dependency
|
39
36
|
name: cucumber
|
40
|
-
|
37
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
41
38
|
none: false
|
42
39
|
requirements:
|
43
40
|
- - ">="
|
44
41
|
- !ruby/object:Gem::Version
|
45
|
-
hash: 3
|
46
42
|
segments:
|
47
43
|
- 0
|
48
44
|
version: "0"
|
49
|
-
requirement: *id002
|
50
45
|
type: :development
|
51
|
-
- !ruby/object:Gem::Dependency
|
52
46
|
prerelease: false
|
47
|
+
version_requirements: *id002
|
48
|
+
- !ruby/object:Gem::Dependency
|
53
49
|
name: bundler
|
54
|
-
|
50
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
55
51
|
none: false
|
56
52
|
requirements:
|
57
53
|
- - ~>
|
58
54
|
- !ruby/object:Gem::Version
|
59
|
-
hash: 23
|
60
55
|
segments:
|
61
56
|
- 1
|
62
57
|
- 0
|
63
58
|
- 0
|
64
59
|
version: 1.0.0
|
65
|
-
requirement: *id003
|
66
60
|
type: :development
|
67
|
-
- !ruby/object:Gem::Dependency
|
68
61
|
prerelease: false
|
62
|
+
version_requirements: *id003
|
63
|
+
- !ruby/object:Gem::Dependency
|
69
64
|
name: jeweler
|
70
|
-
|
65
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
71
66
|
none: false
|
72
67
|
requirements:
|
73
68
|
- - ~>
|
74
69
|
- !ruby/object:Gem::Version
|
75
|
-
hash: 1
|
76
70
|
segments:
|
77
71
|
- 1
|
78
72
|
- 5
|
79
73
|
- 1
|
80
74
|
version: 1.5.1
|
81
|
-
requirement: *id004
|
82
75
|
type: :development
|
83
|
-
- !ruby/object:Gem::Dependency
|
84
76
|
prerelease: false
|
77
|
+
version_requirements: *id004
|
78
|
+
- !ruby/object:Gem::Dependency
|
85
79
|
name: rcov
|
86
|
-
|
80
|
+
requirement: &id005 !ruby/object:Gem::Requirement
|
87
81
|
none: false
|
88
82
|
requirements:
|
89
83
|
- - ">="
|
90
84
|
- !ruby/object:Gem::Version
|
91
|
-
hash: 3
|
92
85
|
segments:
|
93
86
|
- 0
|
94
87
|
version: "0"
|
95
|
-
requirement: *id005
|
96
88
|
type: :development
|
89
|
+
prerelease: false
|
90
|
+
version_requirements: *id005
|
97
91
|
description: Small Ruby library for ASCII drawing
|
98
92
|
email: lusis.org+rubygems.org@gmail.com
|
99
93
|
executables: []
|
@@ -118,9 +112,11 @@ files:
|
|
118
112
|
- lib/rasskey.rb
|
119
113
|
- lib/rasskey/box.rb
|
120
114
|
- lib/rasskey/extensions/string.rb
|
115
|
+
- lib/rasskey/line.rb
|
121
116
|
- lib/rasskey/version.rb
|
122
117
|
- rasskey.gemspec
|
123
118
|
- spec/rasskey_box_spec.rb
|
119
|
+
- spec/rasskey_line_spec.rb
|
124
120
|
- spec/rasskey_string_spec.rb
|
125
121
|
- spec/spec_helper.rb
|
126
122
|
has_rdoc: true
|
@@ -137,7 +133,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
137
133
|
requirements:
|
138
134
|
- - ">="
|
139
135
|
- !ruby/object:Gem::Version
|
140
|
-
hash:
|
136
|
+
hash: -2176102894295194534
|
141
137
|
segments:
|
142
138
|
- 0
|
143
139
|
version: "0"
|
@@ -146,7 +142,6 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
146
142
|
requirements:
|
147
143
|
- - ">="
|
148
144
|
- !ruby/object:Gem::Version
|
149
|
-
hash: 3
|
150
145
|
segments:
|
151
146
|
- 0
|
152
147
|
version: "0"
|
@@ -159,5 +154,6 @@ specification_version: 3
|
|
159
154
|
summary: Small Ruby library for ASCII drawing
|
160
155
|
test_files:
|
161
156
|
- spec/rasskey_box_spec.rb
|
157
|
+
- spec/rasskey_line_spec.rb
|
162
158
|
- spec/rasskey_string_spec.rb
|
163
159
|
- spec/spec_helper.rb
|