artii 1.0.2 → 1.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/.rspec +1 -0
- data/.rvmrc +1 -0
- data/Gemfile +8 -0
- data/Gemfile.lock +28 -0
- data/History.txt +9 -1
- data/Rakefile +29 -26
- data/VERSION +1 -1
- data/artii.gemspec +25 -19
- data/bin/artii +1 -1
- data/lib/artii.rb +3 -15
- data/lib/artii/base.rb +4 -1
- data/lib/artii/figlet.rb +2 -2
- data/lib/figlet/font.rb +98 -100
- data/lib/figlet/smusher.rb +50 -51
- data/lib/figlet/typesetter.rb +48 -49
- data/spec/spec_helper.rb +3 -6
- metadata +73 -58
data/.rspec
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--color
|
data/.rvmrc
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
rvm --create ruby-1.9.2@artii
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
GEM
|
2
|
+
remote: http://rubygems.org/
|
3
|
+
specs:
|
4
|
+
diff-lcs (1.1.3)
|
5
|
+
git (1.2.5)
|
6
|
+
jeweler (1.6.4)
|
7
|
+
bundler (~> 1.0)
|
8
|
+
git (>= 1.2.5)
|
9
|
+
rake
|
10
|
+
rake (0.9.2.2)
|
11
|
+
rcov (0.9.11)
|
12
|
+
rspec (2.3.0)
|
13
|
+
rspec-core (~> 2.3.0)
|
14
|
+
rspec-expectations (~> 2.3.0)
|
15
|
+
rspec-mocks (~> 2.3.0)
|
16
|
+
rspec-core (2.3.1)
|
17
|
+
rspec-expectations (2.3.0)
|
18
|
+
diff-lcs (~> 1.1.2)
|
19
|
+
rspec-mocks (2.3.0)
|
20
|
+
|
21
|
+
PLATFORMS
|
22
|
+
ruby
|
23
|
+
|
24
|
+
DEPENDENCIES
|
25
|
+
bundler (~> 1.0.0)
|
26
|
+
jeweler (~> 1.6.4)
|
27
|
+
rcov
|
28
|
+
rspec (~> 2.3.0)
|
data/History.txt
CHANGED
data/Rakefile
CHANGED
@@ -1,40 +1,43 @@
|
|
1
1
|
# -*- ruby -*-
|
2
|
+
# encoding: utf-8
|
2
3
|
|
3
4
|
require 'rubygems'
|
4
|
-
require '
|
5
|
-
require './lib/artii.rb'
|
5
|
+
require 'bundler'
|
6
6
|
|
7
7
|
begin
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
gem.description = "A Figlet-based ASCII art generator, useful for command-line based ASCII Art Generation."
|
14
|
-
gem.email = "mike@panpainter.com"
|
15
|
-
gem.homepage = "http://github.com/miketierney/artii"
|
16
|
-
gem.authors = ["Mike Tierney"]
|
17
|
-
gem.add_development_dependency "rspec", ">= 1.2.9"
|
18
|
-
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
|
19
|
-
end
|
20
|
-
Jeweler::GemcutterTasks.new
|
21
|
-
rescue LoadError
|
22
|
-
puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
|
8
|
+
Bundler.setup(:default, :development)
|
9
|
+
rescue Bundler::BundlerError => e
|
10
|
+
$stderr.puts e.message
|
11
|
+
$stderr.puts "Run `bundle install` to install missing gems"
|
12
|
+
exit e.status_code
|
23
13
|
end
|
14
|
+
require 'rake'
|
24
15
|
|
25
|
-
require '
|
26
|
-
|
27
|
-
|
28
|
-
|
16
|
+
require 'jeweler'
|
17
|
+
Jeweler::Tasks.new do |gem|
|
18
|
+
# gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
|
19
|
+
gem.name = "artii"
|
20
|
+
gem.executables = ["artii"]
|
21
|
+
gem.summary = "A little Figlet-based ASCII art generator."
|
22
|
+
gem.description = "A Figlet-based ASCII art generator, useful for comand-line based ASCII Art Generation."
|
23
|
+
gem.email = "mike@panpainter.com"
|
24
|
+
gem.homepage = "http://github.com/miketierney/artii"
|
25
|
+
gem.authors = ["Mike Tierney"]
|
26
|
+
gem.license = "MIT"
|
27
|
+
# dependencies defined in Gemfile
|
29
28
|
end
|
29
|
+
Jeweler::RubygemsDotOrgTasks.new
|
30
30
|
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
spec.
|
31
|
+
require 'rspec/core'
|
32
|
+
require 'rspec/core/rake_task'
|
33
|
+
RSpec::Core::RakeTask.new(:spec) do |spec|
|
34
|
+
spec.pattern = FileList["spec/**/*_spec.rb"]
|
35
35
|
end
|
36
36
|
|
37
|
-
|
37
|
+
RSpec::Core::RakeTask.new(:rcov) do |spec|
|
38
|
+
spec.pattern = "spec/**/*_spec.rb"
|
39
|
+
spec.rcov = true
|
40
|
+
end
|
38
41
|
|
39
42
|
task :default => :spec
|
40
43
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.0.
|
1
|
+
1.0.3
|
data/artii.gemspec
CHANGED
@@ -4,20 +4,23 @@
|
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
|
-
s.name =
|
8
|
-
s.version = "1.0.
|
7
|
+
s.name = "artii"
|
8
|
+
s.version = "1.0.3"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Mike Tierney"]
|
12
|
-
s.date =
|
13
|
-
s.
|
14
|
-
s.
|
15
|
-
s.email = %q{mike@panpainter.com}
|
12
|
+
s.date = "2012-01-05"
|
13
|
+
s.description = "A Figlet-based ASCII art generator, useful for comand-line based ASCII Art Generation."
|
14
|
+
s.email = "mike@panpainter.com"
|
16
15
|
s.executables = ["artii"]
|
17
16
|
s.extra_rdoc_files = [
|
18
17
|
"README.rdoc"
|
19
18
|
]
|
20
19
|
s.files = [
|
20
|
+
".rspec",
|
21
|
+
".rvmrc",
|
22
|
+
"Gemfile",
|
23
|
+
"Gemfile.lock",
|
21
24
|
"History.txt",
|
22
25
|
"README.rdoc",
|
23
26
|
"Rakefile",
|
@@ -703,28 +706,31 @@ Gem::Specification.new do |s|
|
|
703
706
|
"spec/spec.opts",
|
704
707
|
"spec/spec_helper.rb"
|
705
708
|
]
|
706
|
-
s.homepage =
|
709
|
+
s.homepage = "http://github.com/miketierney/artii"
|
710
|
+
s.licenses = ["MIT"]
|
707
711
|
s.require_paths = ["lib"]
|
708
|
-
s.rubygems_version =
|
709
|
-
s.summary =
|
710
|
-
s.test_files = [
|
711
|
-
"spec/artii/base_spec.rb",
|
712
|
-
"spec/artii_spec.rb",
|
713
|
-
"spec/figlet_spec.rb",
|
714
|
-
"spec/spec_helper.rb"
|
715
|
-
]
|
712
|
+
s.rubygems_version = "1.8.10"
|
713
|
+
s.summary = "A little Figlet-based ASCII art generator."
|
716
714
|
|
717
715
|
if s.respond_to? :specification_version then
|
718
|
-
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
719
716
|
s.specification_version = 3
|
720
717
|
|
721
718
|
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
722
|
-
s.add_development_dependency(%q<rspec>, ["
|
719
|
+
s.add_development_dependency(%q<rspec>, ["~> 2.3.0"])
|
720
|
+
s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
|
721
|
+
s.add_development_dependency(%q<jeweler>, ["~> 1.6.4"])
|
722
|
+
s.add_development_dependency(%q<rcov>, [">= 0"])
|
723
723
|
else
|
724
|
-
s.add_dependency(%q<rspec>, ["
|
724
|
+
s.add_dependency(%q<rspec>, ["~> 2.3.0"])
|
725
|
+
s.add_dependency(%q<bundler>, ["~> 1.0.0"])
|
726
|
+
s.add_dependency(%q<jeweler>, ["~> 1.6.4"])
|
727
|
+
s.add_dependency(%q<rcov>, [">= 0"])
|
725
728
|
end
|
726
729
|
else
|
727
|
-
s.add_dependency(%q<rspec>, ["
|
730
|
+
s.add_dependency(%q<rspec>, ["~> 2.3.0"])
|
731
|
+
s.add_dependency(%q<bundler>, ["~> 1.0.0"])
|
732
|
+
s.add_dependency(%q<jeweler>, ["~> 1.6.4"])
|
733
|
+
s.add_dependency(%q<rcov>, [">= 0"])
|
728
734
|
end
|
729
735
|
end
|
730
736
|
|
data/bin/artii
CHANGED
data/lib/artii.rb
CHANGED
@@ -12,11 +12,8 @@
|
|
12
12
|
# Copyright:: Copyright (c) 2010 Michael Tierney
|
13
13
|
# License:: Distributed under the MIT License
|
14
14
|
|
15
|
-
require 'rubygems'
|
16
|
-
|
17
|
-
$: << File.dirname(__FILE__)
|
18
|
-
|
19
15
|
require 'artii/base'
|
16
|
+
require 'artii/figlet'
|
20
17
|
|
21
18
|
module Artii
|
22
19
|
FONTPATH = File.expand_path(File.dirname(__FILE__) + '/../lib/figlet/fonts')
|
@@ -27,19 +24,10 @@ module Artii
|
|
27
24
|
|
28
25
|
def self.encoding_of(string)
|
29
26
|
if is_19?
|
30
|
-
string.encoding.to_s
|
31
|
-
else
|
27
|
+
string.encoding.to_s
|
28
|
+
else
|
32
29
|
$KCODE
|
33
30
|
end
|
34
31
|
end
|
35
32
|
|
36
|
-
def self.raise_19_incompat
|
37
|
-
if is_19?
|
38
|
-
raise "Artii::Figlet is not compatible with Ruby 1.9 at this time"
|
39
|
-
end
|
40
|
-
end
|
41
33
|
end
|
42
|
-
|
43
|
-
if !Artii.is_19?
|
44
|
-
require 'artii/figlet'
|
45
|
-
end
|
data/lib/artii/base.rb
CHANGED
data/lib/artii/figlet.rb
CHANGED
data/lib/figlet/font.rb
CHANGED
@@ -1,119 +1,117 @@
|
|
1
1
|
module Artii
|
2
|
-
module Figlet
|
3
|
-
|
4
|
-
class UnknownFontFormat < StandardError
|
5
|
-
end
|
6
|
-
|
7
|
-
class Font
|
8
|
-
def initialize(filename, load_german = true)
|
9
|
-
Artii.raise_19_incompat
|
10
|
-
|
11
|
-
file = File.open(filename, 'rb')
|
12
|
-
|
13
|
-
header = file.gets.strip.split(/ /)
|
14
|
-
|
15
|
-
raise UnknownFontFormat if 'flf2a' != header[0][0, 5]
|
16
|
-
|
17
|
-
@hard_blank = header.shift[-1, 1]
|
18
|
-
@height = header.shift.to_i
|
19
|
-
@baseline = header.shift
|
20
|
-
@max_length = header.shift
|
21
|
-
@old_layout = header.shift.to_i
|
22
|
-
@comment_count = header.shift.to_i
|
23
|
-
@right_to_left = header.shift
|
24
|
-
@right_to_left = !@right_to_left.nil? && @right_to_left.to_i == 1
|
25
|
-
|
26
|
-
@load_german, @characters = load_german, {}
|
27
|
-
|
28
|
-
load_comments file
|
29
|
-
load_ascii_characters file
|
30
|
-
load_german_characters file
|
31
|
-
load_extended_characters file
|
32
|
-
|
33
|
-
file.close
|
34
|
-
end
|
2
|
+
module Figlet
|
35
3
|
|
36
|
-
|
37
|
-
@characters[char]
|
38
|
-
end
|
39
|
-
|
40
|
-
def has_char?(char)
|
41
|
-
@characters.has_key? char
|
4
|
+
class UnknownFontFormat < StandardError
|
42
5
|
end
|
43
6
|
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
@right_to_left
|
48
|
-
end
|
7
|
+
class Font
|
8
|
+
def initialize(filename, load_german = true)
|
9
|
+
file = File.open(filename, 'rb')
|
49
10
|
|
11
|
+
header = file.gets.strip.split(/ /)
|
50
12
|
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
13
|
+
raise UnknownFontFormat if 'flf2a' != header[0][0, 5]
|
14
|
+
|
15
|
+
@hard_blank = header.shift[-1, 1]
|
16
|
+
@height = header.shift.to_i
|
17
|
+
@baseline = header.shift
|
18
|
+
@max_length = header.shift
|
19
|
+
@old_layout = header.shift.to_i
|
20
|
+
@comment_count = header.shift.to_i
|
21
|
+
@right_to_left = header.shift
|
22
|
+
@right_to_left = !@right_to_left.nil? && @right_to_left.to_i == 1
|
23
|
+
|
24
|
+
@load_german, @characters = load_german, {}
|
25
|
+
|
26
|
+
load_comments file
|
27
|
+
load_ascii_characters file
|
28
|
+
load_german_characters file
|
29
|
+
load_extended_characters file
|
30
|
+
|
31
|
+
file.close
|
32
|
+
end
|
33
|
+
|
34
|
+
def [](char)
|
35
|
+
@characters[char]
|
36
|
+
end
|
37
|
+
|
38
|
+
def has_char?(char)
|
39
|
+
@characters.has_key? char
|
40
|
+
end
|
41
|
+
|
42
|
+
attr_reader :height, :hard_blank, :old_layout
|
43
|
+
|
44
|
+
def right_to_left?
|
45
|
+
@right_to_left
|
46
|
+
end
|
60
47
|
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
48
|
+
|
49
|
+
private
|
50
|
+
|
51
|
+
def load_comments(file)
|
52
|
+
@comment_count.times { file.gets.strip }
|
53
|
+
end
|
54
|
+
|
55
|
+
def load_ascii_characters(file)
|
56
|
+
(32..126).each { |i| @characters[i] = load_char(file) }
|
57
|
+
end
|
58
|
+
|
59
|
+
def load_german_characters(file)
|
60
|
+
[91, 92, 93, 123, 124, 125, 126].each do |i|
|
61
|
+
if @load_german
|
62
|
+
unless char = load_char(file)
|
63
|
+
return
|
64
|
+
end
|
65
|
+
@characters[i] = char
|
66
|
+
else
|
67
|
+
skip_char file
|
66
68
|
end
|
67
|
-
@characters[i] = char
|
68
|
-
else
|
69
|
-
skip_char file
|
70
69
|
end
|
71
70
|
end
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
i
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
71
|
+
|
72
|
+
def load_extended_characters(file)
|
73
|
+
until file.eof?
|
74
|
+
i = file.gets.strip.split(/ /).first
|
75
|
+
if i.empty?
|
76
|
+
next
|
77
|
+
elsif /^\-0x/i =~ i # comment
|
78
|
+
skip_char file
|
79
|
+
else
|
80
|
+
if /^0x/i =~ i
|
81
|
+
i = i[2, 1].hex
|
82
|
+
elsif '0' == i[0] && '0' != i || '-0' == i[0, 2]
|
83
|
+
i = i.oct
|
84
|
+
end
|
85
|
+
unless char = load_char(file)
|
86
|
+
return
|
87
|
+
end
|
88
|
+
@characters[i] = char
|
89
89
|
end
|
90
|
-
@characters[i] = char
|
91
90
|
end
|
92
91
|
end
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
92
|
+
|
93
|
+
def load_char(file)
|
94
|
+
char = []
|
95
|
+
@height.times do
|
96
|
+
return false if file.eof?
|
97
|
+
line = file.gets.rstrip
|
98
|
+
if match = /(.){1,2}$/.match(line)
|
99
|
+
line.gsub! match[1], ''
|
100
|
+
end
|
101
|
+
line << "\x00"
|
102
|
+
char << line
|
102
103
|
end
|
103
|
-
|
104
|
-
char << line
|
104
|
+
return char
|
105
105
|
end
|
106
|
-
return char
|
107
|
-
end
|
108
106
|
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
107
|
+
def skip_char(file)
|
108
|
+
@height.times do
|
109
|
+
return if file.eof?
|
110
|
+
return if file.gets.strip.nil?
|
111
|
+
end
|
113
112
|
end
|
114
|
-
end
|
115
113
|
|
116
|
-
|
114
|
+
end
|
117
115
|
|
118
|
-
end # module Figlet
|
119
|
-
end # module Artii
|
116
|
+
end # module Figlet
|
117
|
+
end # module Artii
|
data/lib/figlet/smusher.rb
CHANGED
@@ -1,65 +1,64 @@
|
|
1
1
|
module Artii
|
2
|
-
module Figlet
|
2
|
+
module Figlet
|
3
3
|
|
4
|
-
|
4
|
+
class Smusher
|
5
5
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
end
|
6
|
+
def initialize(font)
|
7
|
+
@font = font
|
8
|
+
end
|
10
9
|
|
11
|
-
|
12
|
-
|
10
|
+
def [](result)
|
11
|
+
todo = false
|
13
12
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
13
|
+
@font.height.times do |j|
|
14
|
+
result[j] = result[j].sub(pattern) { todo, x = callback(todo, $1, $2); x }
|
15
|
+
end
|
16
|
+
@font.height.times do |j|
|
17
|
+
result[j] = if todo
|
18
|
+
result[j].sub(/\s\x00(?!$)|\x00\s/, '').sub(/\x00(?!$)/, '')
|
19
|
+
else
|
20
|
+
result[j].sub(/\x00(?!$)/, '')
|
21
|
+
end
|
22
22
|
end
|
23
23
|
end
|
24
|
-
end
|
25
24
|
|
26
|
-
|
27
|
-
|
28
|
-
|
25
|
+
def pattern
|
26
|
+
@pattern ||= /([^#{@font.hard_blank}\x00\s])\x00([^#{@font.hard_blank}\x00\s])/
|
27
|
+
end
|
29
28
|
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
29
|
+
def symbols
|
30
|
+
@@symbols ||= {
|
31
|
+
24 => '|/\\[]{}()<>',
|
32
|
+
8 => {'[' => ']', ']' => '[', '{' => '}', '}' => '{', '(' => ')', ')' => '('},
|
33
|
+
16 => {"/\\" => '|', "\\/" => 'Y', '><' => 'X'}
|
34
|
+
}
|
35
|
+
end
|
37
36
|
|
38
|
-
|
39
|
-
|
40
|
-
|
37
|
+
def old_layout?(n)
|
38
|
+
@font.old_layout & n > 0
|
39
|
+
end
|
40
|
+
|
41
|
+
def callback(s, a, b)
|
42
|
+
combined = a + b
|
41
43
|
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
else
|
58
|
-
return s, "#{a}\00#{b}"
|
44
|
+
if old_layout?(1) && a == b
|
45
|
+
return true, a
|
46
|
+
elsif old_layout?(2) && ('_' == a && symbols[24].include?(b) || '_' == b && symbols[24].include?(a))
|
47
|
+
return true, a
|
48
|
+
elsif old_layout?(4) && ((left = symbols[24].index(a)) && (right = symbols[24].index(b)))
|
49
|
+
return true, (right > left ? b : a)
|
50
|
+
elsif old_layout?(8) && (symbols[8].has_key?(b) && symbols[8][b] == a)
|
51
|
+
return true, '|'
|
52
|
+
elsif old_layout?(16) && symbols[16].has_key?(combined)
|
53
|
+
return true, symbols[16][combined]
|
54
|
+
elsif old_layout?(32) && (a == b && @font.hard_blank == a)
|
55
|
+
return true, @font.hard_blank
|
56
|
+
else
|
57
|
+
return s, "#{a}\00#{b}"
|
58
|
+
end
|
59
59
|
end
|
60
|
-
end
|
61
60
|
|
62
|
-
|
61
|
+
end
|
63
62
|
|
64
|
-
end # module Figlet
|
65
|
-
end # module Artii
|
63
|
+
end # module Figlet
|
64
|
+
end # module Artii
|
data/lib/figlet/typesetter.rb
CHANGED
@@ -1,69 +1,68 @@
|
|
1
1
|
module Artii
|
2
|
-
module Figlet
|
2
|
+
module Figlet
|
3
3
|
|
4
|
-
|
4
|
+
class Typesetter
|
5
5
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
end
|
6
|
+
def initialize(font, options = nil)
|
7
|
+
@font = font
|
8
|
+
@options = options || {}
|
9
|
+
@smush = @options.has_key?(:smush) ? @options[:smush] : true
|
10
|
+
end
|
12
11
|
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
end
|
24
|
-
@font.height.times do |j|
|
25
|
-
line = @font[char][j]
|
26
|
-
if result[j].nil?
|
27
|
-
result[j] = line
|
28
|
-
else
|
29
|
-
result[j] = @font.right_to_left?? (line + result[j]) : (result[j] + line)
|
12
|
+
def [](str)
|
13
|
+
result = []
|
14
|
+
str.length.times do |i|
|
15
|
+
char = str[i]
|
16
|
+
unless @font.has_char?(char.ord)
|
17
|
+
if @font.has_char?(0)
|
18
|
+
char = 0
|
19
|
+
else
|
20
|
+
next
|
21
|
+
end
|
30
22
|
end
|
31
|
-
end
|
32
|
-
if @font.old_layout > -1 && i > 0
|
33
|
-
diff = -1
|
34
23
|
@font.height.times do |j|
|
35
|
-
|
36
|
-
|
37
|
-
|
24
|
+
line = @font[char.ord][j]
|
25
|
+
if result[j].nil?
|
26
|
+
result[j] = line
|
27
|
+
else
|
28
|
+
result[j] = @font.right_to_left?? (line + result[j]) : (result[j] + line)
|
38
29
|
end
|
39
30
|
end
|
40
|
-
|
41
|
-
|
31
|
+
if @font.old_layout > -1 && i > 0
|
32
|
+
diff = -1
|
42
33
|
@font.height.times do |j|
|
43
|
-
if match = /\
|
44
|
-
|
45
|
-
|
34
|
+
if match = /\S(\s*\x00\s*)\S/.match(result[j])
|
35
|
+
len = match[1].length
|
36
|
+
diff = (diff == -1 ? len : min(diff, len))
|
37
|
+
end
|
38
|
+
end
|
39
|
+
diff -= 1
|
40
|
+
if diff > 0
|
41
|
+
@font.height.times do |j|
|
42
|
+
if match = /\x00(\s{0,#{diff}})/.match(result[j])
|
43
|
+
b = diff - match[1].length
|
44
|
+
result[j] = result[j].sub(/\s{0,#{b}}\x00\s{#{match[1].length}}/, "\0")
|
45
|
+
end
|
46
46
|
end
|
47
47
|
end
|
48
|
+
smush[result] if @smush
|
48
49
|
end
|
49
|
-
smush[result] if @smush
|
50
50
|
end
|
51
|
+
return result.join("\n").gsub(/\0/, '').gsub(@font.hard_blank, ' ')
|
51
52
|
end
|
52
|
-
return result.join("\n").gsub(/\0/, '').gsub(@font.hard_blank, ' ')
|
53
|
-
end
|
54
53
|
|
55
54
|
|
56
|
-
|
55
|
+
private
|
57
56
|
|
58
|
-
|
59
|
-
|
60
|
-
|
57
|
+
def min(a, b)
|
58
|
+
a > b ? b : a
|
59
|
+
end
|
61
60
|
|
62
|
-
|
63
|
-
|
64
|
-
|
61
|
+
def smush
|
62
|
+
@smusher ||= Smusher.new(@font)
|
63
|
+
end
|
65
64
|
|
66
|
-
|
65
|
+
end
|
67
66
|
|
68
|
-
end # module Figlet
|
69
|
-
end # module Artii
|
67
|
+
end # module Figlet
|
68
|
+
end # module Artii
|
data/spec/spec_helper.rb
CHANGED
@@ -1,14 +1,11 @@
|
|
1
|
-
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
2
|
-
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
3
1
|
require 'artii'
|
4
|
-
require '
|
5
|
-
require 'spec/autorun'
|
2
|
+
require 'rspec'
|
6
3
|
|
7
|
-
|
4
|
+
RSpec.configure do |config|
|
8
5
|
end
|
9
6
|
|
10
7
|
class File
|
11
8
|
def self.rel(*path)
|
12
9
|
join(dirname(__FILE__), *path)
|
13
10
|
end
|
14
|
-
end
|
11
|
+
end
|
metadata
CHANGED
@@ -1,48 +1,73 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: artii
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
prerelease:
|
6
|
-
segments:
|
7
|
-
- 1
|
8
|
-
- 0
|
9
|
-
- 2
|
10
|
-
version: 1.0.2
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.3
|
5
|
+
prerelease:
|
11
6
|
platform: ruby
|
12
|
-
authors:
|
7
|
+
authors:
|
13
8
|
- Mike Tierney
|
14
9
|
autorequire:
|
15
10
|
bindir: bin
|
16
11
|
cert_chain: []
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
dependencies:
|
21
|
-
- !ruby/object:Gem::Dependency
|
12
|
+
date: 2012-01-05 00:00:00.000000000Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
22
15
|
name: rspec
|
16
|
+
requirement: &70246026050280 !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ~>
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: 2.3.0
|
22
|
+
type: :development
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: *70246026050280
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: bundler
|
27
|
+
requirement: &70246026049800 !ruby/object:Gem::Requirement
|
28
|
+
none: false
|
29
|
+
requirements:
|
30
|
+
- - ~>
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: 1.0.0
|
33
|
+
type: :development
|
23
34
|
prerelease: false
|
24
|
-
|
35
|
+
version_requirements: *70246026049800
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
name: jeweler
|
38
|
+
requirement: &70246026049320 !ruby/object:Gem::Requirement
|
25
39
|
none: false
|
26
|
-
requirements:
|
27
|
-
- -
|
28
|
-
- !ruby/object:Gem::Version
|
29
|
-
|
30
|
-
segments:
|
31
|
-
- 1
|
32
|
-
- 2
|
33
|
-
- 9
|
34
|
-
version: 1.2.9
|
40
|
+
requirements:
|
41
|
+
- - ~>
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: 1.6.4
|
35
44
|
type: :development
|
36
|
-
|
37
|
-
|
45
|
+
prerelease: false
|
46
|
+
version_requirements: *70246026049320
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: rcov
|
49
|
+
requirement: &70246026048800 !ruby/object:Gem::Requirement
|
50
|
+
none: false
|
51
|
+
requirements:
|
52
|
+
- - ! '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
type: :development
|
56
|
+
prerelease: false
|
57
|
+
version_requirements: *70246026048800
|
58
|
+
description: A Figlet-based ASCII art generator, useful for comand-line based ASCII
|
59
|
+
Art Generation.
|
38
60
|
email: mike@panpainter.com
|
39
|
-
executables:
|
61
|
+
executables:
|
40
62
|
- artii
|
41
63
|
extensions: []
|
42
|
-
|
43
|
-
extra_rdoc_files:
|
64
|
+
extra_rdoc_files:
|
44
65
|
- README.rdoc
|
45
|
-
files:
|
66
|
+
files:
|
67
|
+
- .rspec
|
68
|
+
- .rvmrc
|
69
|
+
- Gemfile
|
70
|
+
- Gemfile.lock
|
46
71
|
- History.txt
|
47
72
|
- README.rdoc
|
48
73
|
- Rakefile
|
@@ -727,42 +752,32 @@ files:
|
|
727
752
|
- spec/figlet_spec.rb
|
728
753
|
- spec/spec.opts
|
729
754
|
- spec/spec_helper.rb
|
730
|
-
has_rdoc: true
|
731
755
|
homepage: http://github.com/miketierney/artii
|
732
|
-
licenses:
|
733
|
-
|
756
|
+
licenses:
|
757
|
+
- MIT
|
734
758
|
post_install_message:
|
735
759
|
rdoc_options: []
|
736
|
-
|
737
|
-
require_paths:
|
760
|
+
require_paths:
|
738
761
|
- lib
|
739
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
762
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
740
763
|
none: false
|
741
|
-
requirements:
|
742
|
-
- -
|
743
|
-
- !ruby/object:Gem::Version
|
744
|
-
|
745
|
-
segments:
|
764
|
+
requirements:
|
765
|
+
- - ! '>='
|
766
|
+
- !ruby/object:Gem::Version
|
767
|
+
version: '0'
|
768
|
+
segments:
|
746
769
|
- 0
|
747
|
-
|
748
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
770
|
+
hash: -2121241110675444317
|
771
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
749
772
|
none: false
|
750
|
-
requirements:
|
751
|
-
- -
|
752
|
-
- !ruby/object:Gem::Version
|
753
|
-
|
754
|
-
segments:
|
755
|
-
- 0
|
756
|
-
version: "0"
|
773
|
+
requirements:
|
774
|
+
- - ! '>='
|
775
|
+
- !ruby/object:Gem::Version
|
776
|
+
version: '0'
|
757
777
|
requirements: []
|
758
|
-
|
759
778
|
rubyforge_project:
|
760
|
-
rubygems_version: 1.
|
779
|
+
rubygems_version: 1.8.10
|
761
780
|
signing_key:
|
762
781
|
specification_version: 3
|
763
782
|
summary: A little Figlet-based ASCII art generator.
|
764
|
-
test_files:
|
765
|
-
- spec/artii/base_spec.rb
|
766
|
-
- spec/artii_spec.rb
|
767
|
-
- spec/figlet_spec.rb
|
768
|
-
- spec/spec_helper.rb
|
783
|
+
test_files: []
|