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.
Files changed (2) hide show
  1. data/lib/albino.rb +8 -5
  2. 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 = :text, format = :html)
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, (flag, value)|
78
- string + " -#{flag} #{value}"
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 -l text').returns(true)
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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ddollar-albino
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Dollar