ddollar-albino 1.0.1 → 1.0.2
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 +8 -5
- metadata +1 -1
data/lib/albino.rb
CHANGED
@@ -56,7 +56,7 @@ class Albino
|
|
56
56
|
new(*args).colorize
|
57
57
|
end
|
58
58
|
|
59
|
-
def initialize(target, lexer =
|
59
|
+
def initialize(target, lexer = nil, format = :html)
|
60
60
|
@target = File.exists?(target) ? File.read(target) : target rescue target
|
61
61
|
@options = { :l => lexer, :f => format }
|
62
62
|
end
|
@@ -74,8 +74,10 @@ class Albino
|
|
74
74
|
alias_method :to_s, :colorize
|
75
75
|
|
76
76
|
def convert_options(options = {})
|
77
|
-
@options.merge(options).inject('') do |string,
|
78
|
-
|
77
|
+
@options.merge(options).keys.sort_by { |k| k.to_s }.inject('') do |string, flag|
|
78
|
+
value = @options[flag]
|
79
|
+
break(string) unless value
|
80
|
+
string += " -#{flag} #{value}"
|
79
81
|
end
|
80
82
|
end
|
81
83
|
end
|
@@ -91,13 +93,14 @@ if $0 == __FILE__
|
|
91
93
|
@syntaxer = Albino.new(__FILE__, :ruby)
|
92
94
|
end
|
93
95
|
|
94
|
-
specify "defaults to text" do
|
96
|
+
specify "defaults to text with no and no syntax" do
|
95
97
|
syntaxer = Albino.new(__FILE__)
|
96
|
-
syntaxer.expects(:execute).with('pygmentize -f html
|
98
|
+
syntaxer.expects(:execute).with('pygmentize -f html').returns(true)
|
97
99
|
syntaxer.colorize
|
98
100
|
end
|
99
101
|
|
100
102
|
specify "accepts options" do
|
103
|
+
syntaxer = Albino.new(__FILE__, :ruby, :html)
|
101
104
|
@syntaxer.expects(:execute).with('pygmentize -f html -l ruby').returns(true)
|
102
105
|
@syntaxer.colorize
|
103
106
|
end
|