artii 0.0.3 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +7 -1
- data/README.rdoc +5 -4
- data/VERSION +1 -1
- data/artii.gemspec +4 -4
- data/lib/artii.rb +14 -0
- data/lib/artii/base.rb +40 -5
- data/spec/artii/base_spec.rb +28 -21
- metadata +11 -4
data/History.txt
CHANGED
@@ -23,4 +23,10 @@
|
|
23
23
|
|
24
24
|
=== 0.0.3 / 2010-08-27
|
25
25
|
|
26
|
-
* No functional changes.
|
26
|
+
* No functional changes.
|
27
|
+
|
28
|
+
=== 1.0.0 / 2010-08-28
|
29
|
+
|
30
|
+
* Available Fonts are generated from the included font files
|
31
|
+
* Available Fonts are stored as a hash, and now fully listed when called with -l or --list
|
32
|
+
* A few other minor tweaks
|
data/README.rdoc
CHANGED
@@ -40,16 +40,17 @@ None (yet)
|
|
40
40
|
|
41
41
|
== TODO
|
42
42
|
|
43
|
-
- Ability to load non *.flf files (fonts are available,
|
43
|
+
- Ability to load non *.flf files (fonts are available, .flc file-types seem to be an issue right now)
|
44
44
|
- Ability to set custom configurations, so you don't have to constantly set the options (like font) unless you want to
|
45
45
|
- Some nice built-in utilities (to make for easier demoing)
|
46
|
-
- Font list should be stored as a hash, and not a string
|
47
46
|
- Font list should show samples of the faces in addition to the names
|
48
47
|
- Font list should be able to show a given range (fonts starting with specific letters, or a range of letters)
|
49
48
|
- Font list should be searchable (a la grep)
|
50
|
-
- Font list needs to be generated from a) included fonts and b) a user-specified location (see To Do about custom configurations)
|
49
|
+
- Font list needs to be generated from <strike>a) included fonts</strike> and b) a user-specified location (see To Do about custom configurations)
|
51
50
|
|
52
|
-
=
|
51
|
+
= Prior Art
|
52
|
+
|
53
|
+
== Figlet
|
53
54
|
|
54
55
|
Figlet (http://www.figlet.org) implementation written by Tim Fletcher
|
55
56
|
(twoggle@gmail.com). Found originally in the text gem
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0
|
1
|
+
1.0.0
|
data/artii.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{artii}
|
8
|
-
s.version = "0.0
|
8
|
+
s.version = "1.0.0"
|
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 = %q{2010-08-
|
12
|
+
s.date = %q{2010-08-28}
|
13
13
|
s.default_executable = %q{artii}
|
14
14
|
s.description = %q{A Figlet-based ASCII art generator, useful for command-line based ASCII Art Generation.}
|
15
15
|
s.email = %q{mike@panpainter.com}
|
@@ -707,7 +707,7 @@ Gem::Specification.new do |s|
|
|
707
707
|
s.homepage = %q{http://github.com/panpainter/artii}
|
708
708
|
s.rdoc_options = ["--charset=UTF-8"]
|
709
709
|
s.require_paths = ["lib"]
|
710
|
-
s.rubygems_version = %q{1.3.
|
710
|
+
s.rubygems_version = %q{1.3.7}
|
711
711
|
s.summary = %q{A little Figlet-based ASCII art generator.}
|
712
712
|
s.test_files = [
|
713
713
|
"spec/artii/base_spec.rb",
|
@@ -720,7 +720,7 @@ Gem::Specification.new do |s|
|
|
720
720
|
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
721
721
|
s.specification_version = 3
|
722
722
|
|
723
|
-
if Gem::Version.new(Gem::
|
723
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
724
724
|
s.add_development_dependency(%q<rspec>, [">= 1.2.9"])
|
725
725
|
else
|
726
726
|
s.add_dependency(%q<rspec>, [">= 1.2.9"])
|
data/lib/artii.rb
CHANGED
@@ -1,3 +1,17 @@
|
|
1
|
+
# This gem takes a string and outputs ASCII art, generated by the
|
2
|
+
# FIGLET library. While it defaults to the 'big' font, an optional
|
3
|
+
# flag can be passed (-f or --font) with a string following it
|
4
|
+
# (e.g., slant) that will change the font that is used.
|
5
|
+
#
|
6
|
+
# The ruby Figlet implementation was written by Tim Fletcher
|
7
|
+
# (twoggle@gmail.com), and will only be curosrily maintained
|
8
|
+
# by the author of this rubygem (Michael Tierney,
|
9
|
+
# dev@panpainter.com).
|
10
|
+
#
|
11
|
+
# Author:: Michael Tierney (mailto:dev@panpainter.com)
|
12
|
+
# Copyright:: Copyright (c) 2010 Michael Tierney
|
13
|
+
# License:: Distributed under the MIT License
|
14
|
+
|
1
15
|
require 'rubygems'
|
2
16
|
|
3
17
|
$: << File.dirname(__FILE__)
|
data/lib/artii/base.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
require 'find'
|
1
2
|
require 'optparse'
|
2
3
|
|
3
4
|
module Artii
|
@@ -8,16 +9,17 @@ module Artii
|
|
8
9
|
def initialize(*args)
|
9
10
|
@options = {}
|
10
11
|
@output = ''
|
12
|
+
@faces = all_fonts
|
11
13
|
|
12
14
|
OptionParser.new do |opts|
|
13
15
|
opts.banner = "Usage: artii 'your string here' [-f FONT_NAME or --font FONT_NAME] [-l or --list]"
|
14
16
|
|
15
17
|
opts.on('-f', '--font FONT_NAME', 'Specify the font to be used (defaults to "big")') do |font|
|
16
|
-
@
|
18
|
+
@font_name = @faces[font]
|
17
19
|
end
|
18
20
|
|
19
21
|
opts.on('-l', '--list', 'Prints the list of available fonts') do |list|
|
20
|
-
@options[:list] =
|
22
|
+
@options[:list] = list_all_fonts
|
21
23
|
end
|
22
24
|
|
23
25
|
opts.on_tail("-h", "--help", "Show this message") do
|
@@ -32,12 +34,12 @@ module Artii
|
|
32
34
|
end.parse!(args)
|
33
35
|
|
34
36
|
if @options[:list]
|
35
|
-
@output =
|
37
|
+
@output = list_all_fonts
|
36
38
|
end
|
37
39
|
|
38
|
-
@font_name = @
|
40
|
+
@font_name = @font_name.nil? ? @faces['big'] : @font_name
|
39
41
|
|
40
|
-
@font = Artii::Figlet::Font.new("#{FONTPATH}/#{@font_name}
|
42
|
+
@font = Artii::Figlet::Font.new("#{FONTPATH}/#{@font_name}")
|
41
43
|
|
42
44
|
asciify args.first unless args.empty?
|
43
45
|
end
|
@@ -46,5 +48,38 @@ module Artii
|
|
46
48
|
figlet = Artii::Figlet::Typesetter.new(@font)
|
47
49
|
@output = figlet[string]
|
48
50
|
end
|
51
|
+
|
52
|
+
def list_all_fonts
|
53
|
+
font_list = "\n--------------------\nAll Available Fonts:\n--------------------\n\n"
|
54
|
+
@faces.sort.each do |k,v|
|
55
|
+
font_list += "#{k}\n"
|
56
|
+
end
|
57
|
+
font_list += "\n--------------------------\nTotal Available Fonts: #{@faces.size}\n\n"
|
58
|
+
end
|
59
|
+
|
60
|
+
def all_fonts
|
61
|
+
font_faces = {}
|
62
|
+
size_of_fontpath = FONTPATH.split('/').size
|
63
|
+
font_exts = %w(flf) # FIXME: was %w(flf flc) but the .flc format seems to not be recognized. Need to investigate further.
|
64
|
+
|
65
|
+
Find.find(FONTPATH) do |file|
|
66
|
+
ext = File.extname(file).gsub('.','')
|
67
|
+
next if (File.directory?(file) or !font_exts.include?(ext))
|
68
|
+
|
69
|
+
dir = File.dirname(file).split('/')
|
70
|
+
if dir.size > size_of_fontpath
|
71
|
+
dir = "#{dir.last}/"
|
72
|
+
else
|
73
|
+
dir = ''
|
74
|
+
end
|
75
|
+
|
76
|
+
filename = File.basename(file)
|
77
|
+
filename = "#{dir}#{filename}"
|
78
|
+
|
79
|
+
font_faces[File.basename(file, ".#{ext}")] = filename
|
80
|
+
end
|
81
|
+
|
82
|
+
font_faces
|
83
|
+
end
|
49
84
|
end
|
50
85
|
end
|
data/spec/artii/base_spec.rb
CHANGED
@@ -9,37 +9,43 @@ describe Artii::Base do
|
|
9
9
|
end
|
10
10
|
end
|
11
11
|
|
12
|
-
it "should default to 'big'" do
|
12
|
+
it "font_name should default to 'big.flf'" do
|
13
13
|
a = Artii::Base.new 'test'
|
14
|
-
a.font_name.should == 'big'
|
14
|
+
a.font_name.should == 'big.flf'
|
15
15
|
end
|
16
16
|
|
17
17
|
describe "font switching" do
|
18
18
|
context 'should set font if passed -f ' do
|
19
|
-
|
20
|
-
|
19
|
+
it "should set @font_name" do
|
20
|
+
a = Artii::Base.new 'test', '-f', 'chunky'
|
21
|
+
a.instance_variable_get(:@font_name).should == 'chunky.flf'
|
21
22
|
end
|
22
23
|
|
23
|
-
|
24
|
-
|
24
|
+
xit "should accept non-flf file formats" do
|
25
|
+
a = Artii::Base.new 'test', '-f', 'frango'
|
26
|
+
a.font_name.should == 'frango.flc'
|
25
27
|
end
|
26
28
|
|
27
|
-
it "should
|
28
|
-
|
29
|
+
it "should accept fonts in nested directories" do
|
30
|
+
a = Artii::Base.new 'test', '-f', 'cour'
|
31
|
+
a.font_name.should == 'bdffonts/cour.flf'
|
29
32
|
end
|
30
33
|
end
|
31
34
|
|
32
35
|
context 'should set font if passed --font' do
|
33
|
-
|
34
|
-
|
36
|
+
it "set @font_name" do
|
37
|
+
a = Artii::Base.new 'test', '--font', 'chunky'
|
38
|
+
a.instance_variable_get(:@font_name).should == 'chunky.flf'
|
35
39
|
end
|
36
40
|
|
37
|
-
it "
|
38
|
-
|
41
|
+
it "should accept fonts in nested directories" do
|
42
|
+
a = Artii::Base.new 'test', '--f', 'cour'
|
43
|
+
a.font_name.should == 'bdffonts/cour.flf'
|
39
44
|
end
|
40
45
|
|
41
|
-
|
42
|
-
|
46
|
+
xit "should accept non-flf file formats" do
|
47
|
+
a = Artii::Base.new 'test', '--font', 'frango'
|
48
|
+
a.font_name.should == 'frango.flc'
|
43
49
|
end
|
44
50
|
end
|
45
51
|
end
|
@@ -49,18 +55,19 @@ describe Artii::Base do
|
|
49
55
|
it "should list all fonts if passed -l" do
|
50
56
|
a = Artii::Base.new '-l'
|
51
57
|
a.output.should_not be_empty
|
52
|
-
a.output.should include '
|
53
|
-
a.output.should include '
|
54
|
-
a.output.should include '
|
55
|
-
|
58
|
+
a.output.should include 'big'
|
59
|
+
a.output.should include 'chunky'
|
60
|
+
a.output.should include 'slant'
|
61
|
+
a.output.should include 'helv'
|
56
62
|
end
|
57
63
|
|
58
64
|
it "should list all fonts if passed --list" do
|
59
65
|
a = Artii::Base.new '--list'
|
60
66
|
a.output.should_not be_empty
|
61
|
-
a.output.should include '
|
62
|
-
a.output.should include '
|
63
|
-
a.output.should include '
|
67
|
+
a.output.should include 'big'
|
68
|
+
a.output.should include 'chunky'
|
69
|
+
a.output.should include 'slant'
|
70
|
+
a.output.should include 'helv'
|
64
71
|
end
|
65
72
|
end
|
66
73
|
|
metadata
CHANGED
@@ -1,12 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: artii
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
+
hash: 23
|
4
5
|
prerelease: false
|
5
6
|
segments:
|
7
|
+
- 1
|
6
8
|
- 0
|
7
9
|
- 0
|
8
|
-
|
9
|
-
version: 0.0.3
|
10
|
+
version: 1.0.0
|
10
11
|
platform: ruby
|
11
12
|
authors:
|
12
13
|
- Mike Tierney
|
@@ -14,16 +15,18 @@ autorequire:
|
|
14
15
|
bindir: bin
|
15
16
|
cert_chain: []
|
16
17
|
|
17
|
-
date: 2010-08-
|
18
|
+
date: 2010-08-28 00:00:00 -07:00
|
18
19
|
default_executable: artii
|
19
20
|
dependencies:
|
20
21
|
- !ruby/object:Gem::Dependency
|
21
22
|
name: rspec
|
22
23
|
prerelease: false
|
23
24
|
requirement: &id001 !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
24
26
|
requirements:
|
25
27
|
- - ">="
|
26
28
|
- !ruby/object:Gem::Version
|
29
|
+
hash: 13
|
27
30
|
segments:
|
28
31
|
- 1
|
29
32
|
- 2
|
@@ -735,23 +738,27 @@ rdoc_options:
|
|
735
738
|
require_paths:
|
736
739
|
- lib
|
737
740
|
required_ruby_version: !ruby/object:Gem::Requirement
|
741
|
+
none: false
|
738
742
|
requirements:
|
739
743
|
- - ">="
|
740
744
|
- !ruby/object:Gem::Version
|
745
|
+
hash: 3
|
741
746
|
segments:
|
742
747
|
- 0
|
743
748
|
version: "0"
|
744
749
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
750
|
+
none: false
|
745
751
|
requirements:
|
746
752
|
- - ">="
|
747
753
|
- !ruby/object:Gem::Version
|
754
|
+
hash: 3
|
748
755
|
segments:
|
749
756
|
- 0
|
750
757
|
version: "0"
|
751
758
|
requirements: []
|
752
759
|
|
753
760
|
rubyforge_project:
|
754
|
-
rubygems_version: 1.3.
|
761
|
+
rubygems_version: 1.3.7
|
755
762
|
signing_key:
|
756
763
|
specification_version: 3
|
757
764
|
summary: A little Figlet-based ASCII art generator.
|