Browse Source

Rip out old constants from pre args classes

dev
Andy Meneely 10 years ago
parent
commit
47b5f569a4
  1. 5
      CHANGELOG.md
  2. 2
      lib/squib/api/settings.rb
  3. 3
      lib/squib/args/paragraph.rb
  4. 4
      lib/squib/conf.rb
  5. 174
      lib/squib/constants.rb
  6. 2
      lib/squib/deck.rb
  7. 2
      spec/args/paragraph_spec.rb

5
CHANGELOG.md

@ -1,6 +1,11 @@
# Squib CHANGELOG # Squib CHANGELOG
Squib follows [semantic versioning](http://semver.org). Squib follows [semantic versioning](http://semver.org).
## v0.9.0 / Unreleased
Chores:
* Ripped out a lot of old constants used from the old way we handled arguments. Yay negative churn!
## v0.8.0 / 2015-10-26 ## v0.8.0 / 2015-10-26
Features Features
* The `xlsx` and `csv` support quantity explosion! Just use the column name 'Qty' and put integers in your sheet and you'll produce copies of the entire row. See README and the csv sample for more info. (#78) * The `xlsx` and `csv` support quantity explosion! Just use the column name 'Qty' and put integers in your sheet and you'll produce copies of the entire row. See README and the csv sample for more info. (#78)

2
lib/squib/api/settings.rb

@ -28,7 +28,7 @@ module Squib
# @api public # @api public
def set(opts = {}) def set(opts = {})
raise 'DEPRECATED: As of v0.7 img_dir is no longer supported in "set". Use config.yml instead.' if opts.key? :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
@font = (opts[:font] == :default) ? Squib::SYSTEM_DEFAULTS[:default_font] : opts[:font] @font = (opts[:font] == :default) ? Squib::DEFAULT_FONT: opts[:font]
end end
end end

3
lib/squib/args/paragraph.rb

@ -1,4 +1,5 @@
require 'squib/args/arg_loader' require 'squib/args/arg_loader'
require 'squib/constants'
module Squib module Squib
# @api private # @api private
@ -41,7 +42,7 @@ module Squib
def validate_font(arg, _i) def validate_font(arg, _i)
arg = @deck_font if arg == :use_set arg = @deck_font if arg == :use_set
arg = Squib::SYSTEM_DEFAULTS[:default_font] if arg == :default arg = DEFAULT_FONT if arg == :default
arg arg
end end

4
lib/squib/conf.rb

@ -10,9 +10,9 @@ module Squib
DEFAULTS = { DEFAULTS = {
'antialias' => 'best', 'antialias' => 'best',
'backend' => 'memory', 'backend' => 'memory',
'count_format' => SYSTEM_DEFAULTS[:count_format], 'count_format' => '%02d',
'custom_colors' => {}, 'custom_colors' => {},
'dir' => SYSTEM_DEFAULTS[:dir], 'dir' => '_output',
'hint' => :none, 'hint' => :none,
'img_dir' => '.', 'img_dir' => '.',
'progress_bars' => false, 'progress_bars' => false,

174
lib/squib/constants.rb

@ -1,175 +1,9 @@
module Squib module Squib
# Squib's defaults for when arguments are not specified in the command nor layouts.
#
# @api public
SYSTEM_DEFAULTS = {
:align => :left,
:alpha => 1.0,
:angle => 0,
:angle_range => (Math::PI / -4.0)..(Math::PI / 4),
:blend => :none,
:color => :black,
:columns => 5,
:count_format => '%02d',
:cx1 => 0,
:cx2 => 0,
:cy1 => 0,
:cy2 => 0,
:data => nil,
:default_font => 'Arial 36',
:dir => '_output',
:dx => 0, # delta
:dy => 0, # delta
:ellipsize => :end,
:face => :left,
:fill_color => '#0000',
:force_id => false,
:font => :use_set,
:font_size => nil,
:format => :png,
:gap => 0,
:height => :native,
:hint => :off,
:inner_radius => 50,
:img_dir => '.',
:justify => false,
:key => '*',
:margin => 75,
:markup => false,
:mask => nil,
:n => 5,
:offset => 1.1,
:outer_radius => 100,
:prefix => 'card_',
:progress_bar => false,
:quotes => :dumb,
:reflect_offset => 15,
:reflect_percent => 0.25,
:reflect_strength => 0.2,
:range => :all,
:rotate => false,
:rows => :infinite,
:scale => 0.85,
:sheet => 0,
:spacing => 0,
:str => '',
:stroke_color => :black,
:stroke_width => 2.0,
:trim => 0,
:trim_radius => 38,
:valign => :top,
:width => :native,
:wrap => true,
:x => 0,
:x1 => 100,
:x2 => 150,
:x3 => 100,
:x_radius => 0,
:y => 0,
:y1 => 100,
:y2 => 150,
:y3 => 150,
:y_radius => 0,
}
# These are parameters that are intended to be "expanded" across
# range if they are singletons.
#
# For example: using a different font for each card, using one `text` command
#
# key: the internal name of the param (e.g. :files)
# value: the user-facing API key (e.g. file: 'abc.png')
#
# @api private
EXPANDING_PARAMS = {
:align => :align,
:alpha => :alpha,
:angle => :angle,
:blend => :blend,
:circle_radius => :radius,
:color => :color,
:cx1 => :cx1,
:cx2 => :cx2,
:cy1 => :cy1,
:cy2 => :cy2,
:dx => :dx,
:dy => :dy,
:ellipsize => :ellipsize,
:files => :file,
:fill_color => :fill_color,
:force_svgid => :force_id,
:font => :font,
:font_size => :font_size,
:height => :height,
:hint => :hint,
:inner_radius => :inner_radius,
:justify => :justify,
:layout => :layout,
:markup => :markup,
:mask => :mask,
:n => :n,
:outer_radius => :outer_radius,
:quotes => :quotes,
:rect_radius => :radius,
:spacing => :spacing,
:str => :str,
:stroke_color => :stroke_color,
:stroke_width => :stroke_width,
:svgdata => :data,
:svgid => :id,
:valign => :valign,
:width => :width,
:wrap => :wrap,
:x => :x,
:x1 => :x1,
:x2 => :x2,
:x3 => :x3,
:x_radius => :x_radius,
:y => :y,
:y1 => :y1,
:y2 => :y2,
:y3 => :y3,
:y_radius => :y_radius,
}
# These parameters are considered for unit conversion # System-wide default font
# # :nodoc:
# For example # @api public
# text str: 'Hello, World', x: '1in' DEFAULT_FONT = 'Arial 36'
#
# key: the internal name of the param (e.g. :circle_radius)
# value: the user-facing API key (e.g. radius: '1in')
UNIT_CONVERSION_PARAMS = {
:circle_radius => :radius,
:cx1 => :cx1,
:cx2 => :cx2,
:cy1 => :cy1,
:cy2 => :cy2,
:dx => :dx, # delta
:dy => :dx, # delta
:gap => :gap,
:height => :height,
:inner_radius => :inner_radius,
:margin => :margin,
:outer_radius => :outer_radius,
:paper_width => :width,
:paper_height => :height,
:rect_radius => :radius,
:spacing => :spacing,
:stroke_width => :stroke_width,
:trim => :trim,
:width => :width,
:x => :x,
:x1 => :x1,
:x2 => :x2,
:x3 => :x3,
:x_radius => :x_radius,
:y => :y,
:y1 => :y1,
:y2 => :y2,
:y3 => :y3,
:y_radius => :y_radius,
}
# Used for inch-cm conversion # Used for inch-cm conversion
# :nodoc: # :nodoc:

2
lib/squib/deck.rb

@ -60,7 +60,7 @@ module Squib
# @api public # @api public
def initialize(width: 825, height: 1125, cards: 1, dpi: 300, config: 'config.yml', layout: nil, &block) def initialize(width: 825, height: 1125, cards: 1, dpi: 300, config: 'config.yml', layout: nil, &block)
@dpi = dpi @dpi = dpi
@font = SYSTEM_DEFAULTS[:default_font] @font = DEFAULT_FONT
@cards = [] @cards = []
@conf = Conf.load(config) @conf = Conf.load(config)
@progress_bar = Progress.new(@conf.progress_bars) # FIXME this is evil. Using something different with @ and non-@ @progress_bar = Progress.new(@conf.progress_bars) # FIXME this is evil. Using something different with @ and non-@

2
spec/args/paragraph_spec.rb

@ -21,7 +21,7 @@ describe Squib::Args::Paragraph do
it 'uses system default font when deck font is :default' do it 'uses system default font when deck font is :default' do
para = Squib::Args::Paragraph.new(:default) para = Squib::Args::Paragraph.new(:default)
para.load!( {} ) para.load!( {} )
expect(para.font).to eq [Squib::SYSTEM_DEFAULTS[:default_font]] expect(para.font).to eq [Squib::DEFAULT_FONT]
end end
it 'uses specified font when given' do it 'uses specified font when given' do

Loading…
Cancel
Save