From c66c6bc4f0fd788aff294b17a5fbcd4679314262 Mon Sep 17 00:00:00 2001 From: Andy Meneely Date: Fri, 10 Jul 2015 12:43:56 -0400 Subject: [PATCH] Removed img_dir from set method, added specs --- CHANGELOG.md | 5 +++-- lib/squib/api/settings.rb | 5 ++--- spec/api/api_settings_spec.rb | 20 ++++++++++++++++++++ 3 files changed, 25 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ec69d4c..a7d1ecd 100644 --- a/CHANGELOG.md +++ b/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 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. -* 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. +* 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 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: * Fixed a `Cairo::WriteError` on `save_sheet` (#56, PR #96 thank you @meltheadorable!) diff --git a/lib/squib/api/settings.rb b/lib/squib/api/settings.rb index f02f8e1..9811414 100644 --- a/lib/squib/api/settings.rb +++ b/lib/squib/api/settings.rb @@ -24,13 +24,12 @@ module Squib # 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 img_dir: the default directory to READ images from. Default is `.`. Useful for switching from bw to color images. # @return [nil] Returns nothing # @api public 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 - @img_dir = opts[:img_dir] end end diff --git a/spec/api/api_settings_spec.rb b/spec/api/api_settings_spec.rb index ae14725..af0b2e6 100644 --- a/spec/api/api_settings_spec.rb +++ b/spec/api/api_settings_spec.rb @@ -15,4 +15,24 @@ describe Squib::Deck do 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 \ No newline at end of file