ddollar-albino 1.0.3 → 1.0.4
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/lib/albino.rb +18 -1
- metadata +1 -1
data/lib/albino.rb
CHANGED
@@ -40,7 +40,7 @@ require 'open4'
|
|
40
40
|
#
|
41
41
|
# To see all lexers and formatters available, run `pygmentize -L`.
|
42
42
|
#
|
43
|
-
# Chris Wanstrath // chris@ozmm.org
|
43
|
+
# Chris Wanstrath // chris@ozmm.org
|
44
44
|
#
|
45
45
|
# GitHub // http://github.com
|
46
46
|
#
|
@@ -56,6 +56,10 @@ class Albino
|
|
56
56
|
new(*args).colorize
|
57
57
|
end
|
58
58
|
|
59
|
+
def self.lexer_from_filename(filename)
|
60
|
+
new('').lexer_from_filename(filename)
|
61
|
+
end
|
62
|
+
|
59
63
|
def initialize(target, lexer = nil, format = :html)
|
60
64
|
@target = File.exists?(target) ? File.read(target) : target rescue target
|
61
65
|
@options = {}
|
@@ -81,6 +85,10 @@ class Albino
|
|
81
85
|
string += " -#{flag} #{value}"
|
82
86
|
end
|
83
87
|
end
|
88
|
+
|
89
|
+
def lexer_from_filename(filename)
|
90
|
+
execute @@bin + " -N #{filename}"
|
91
|
+
end
|
84
92
|
end
|
85
93
|
|
86
94
|
if $0 == __FILE__
|
@@ -118,5 +126,14 @@ if $0 == __FILE__
|
|
118
126
|
specify "class method colorize" do
|
119
127
|
assert_equal @syntaxer.colorize, Albino.colorize(__FILE__, :ruby)
|
120
128
|
end
|
129
|
+
|
130
|
+
specify "can get lexer from filename" do
|
131
|
+
assert_equal "rb", @syntaxer.lexer_from_filename('test.gemspec')
|
132
|
+
end
|
133
|
+
|
134
|
+
specify "class method lexer_from_filename" do
|
135
|
+
assert_equal @syntaxer.lexer_from_filename('test.gemspec'),
|
136
|
+
Albino.lexer_from_filename('test.gemspec')
|
137
|
+
end
|
121
138
|
end
|
122
139
|
end
|