Browse Source

Removed img_dir from set method, added specs

dev
Andy Meneely 11 years ago
parent
commit
c66c6bc4f0
  1. 5
      CHANGELOG.md
  2. 5
      lib/squib/api/settings.rb
  3. 20
      spec/api/api_settings_spec.rb

5
CHANGELOG.md

@ -11,8 +11,9 @@ Features
* The `text` method and several other methods will throw errors on invalid input. This means your scripts will be more likely to break if you provide bad input * The `text` method and several other methods will throw errors on invalid input. This means your scripts will be more likely to break if you provide bad input
Compatibility: Compatibility:
* All drawn shapes (e.g. circle, triangle, star) will now draw their stroke on top of the fill. This was not consistent before, and now it is (because Squib is more DRY about it!). This might mean that your `stroke_width` will render wider than before. * All drawn shapes (e.g. circle, triangle, star) will now draw their stroke on top of the fill. This was not consistent before, and now it is (because Squib is more DRY about it!). This means that your `stroke_width` might render wider than before, but now it's accurate.
* The `width` and `height` options for `text` have changed their defaults away from `:native` to `:auto`. This is to differentiate them from `:native` widths that default elsewhere. * The `width` and `height` options for `text` have changed their defaults away from `:native` to `:auto`. This is to differentiate them from `:native` widths that default elsewhere. The behavior is the same, just new names.
* Removed `img_dir` from the `set` method. You can still set `img_dir` in the configuration file (e.g. `config.yml`). Added a deprecation error.
Bugs: Bugs:
* Fixed a `Cairo::WriteError` on `save_sheet` (#56, PR #96 thank you @meltheadorable!) * Fixed a `Cairo::WriteError` on `save_sheet` (#56, PR #96 thank you @meltheadorable!)

5
lib/squib/api/settings.rb

@ -24,13 +24,12 @@ module Squib
# set font: :default # Back to Squib-wide default # set font: :default # Back to Squib-wide default
# #
# @option opts font: the font string to set as default. Can also be set to `:default` to use the Squib-wide default. # @option opts font: the font string to set as default. Can also be set to `:default` to use the Squib-wide default.
# @option opts img_dir: the default directory to READ images from. Default is `.`. Useful for switching from bw to color images.
# @return [nil] Returns nothing # @return [nil] Returns nothing
# @api public # @api public
def set(opts = {}) def set(opts = {})
opts = needs(opts, [:font, :img_dir]) raise 'DEPRECATED: As of v0.7 img_dir is no longer supported in "set". Use config.yml instead.' if opts.key? :img_dir
opts = needs(opts, [:font])
@font = opts[:font][0] #was expanded - just need the first @font = opts[:font][0] #was expanded - just need the first
@img_dir = opts[:img_dir]
end end
end end

20
spec/api/api_settings_spec.rb

@ -15,4 +15,24 @@ describe Squib::Deck do
end end
context '#set' do
it 'puts font in @font' do
deck = Squib::Deck.new do
set font: 'foo'
end
expect(deck.font).to eq ('foo')
end
it 'raises deprecation errors on img_dir' do
set_img_dir = Proc.new do
Squib::Deck.new do
set img_dir: 'foo'
end
end
expect { set_img_dir.call }.to raise_error('DEPRECATED: As of v0.7 img_dir is no longer supported in "set". Use config.yml instead.')
end
end
end end
Loading…
Cancel
Save