diff --git a/lib/squib/deck.rb b/lib/squib/deck.rb index e2143fb..fcef644 100644 --- a/lib/squib/deck.rb +++ b/lib/squib/deck.rb @@ -86,8 +86,8 @@ module Squib if File.exists?(file) && config = YAML.load_file(file) config = Squib::CONFIG_DEFAULTS.merge(config) @dpi = config['dpi'].to_i - @hint = config['hint'] - @progress_bar.enabled = config['progress_bar'] + @text_hint = config['text_hint'] + @progress_bar.enabled = config['progress_bars'] end end diff --git a/lib/squib/progress.rb b/lib/squib/progress.rb index 89d7bd5..c5106c4 100644 --- a/lib/squib/progress.rb +++ b/lib/squib/progress.rb @@ -1,6 +1,13 @@ require 'ruby-progressbar' module Squib + + class DoNothing + def increment + #do nothing! + end + end + # A facade that handles (or doesn't) the progress bar on the console # # :nodoc: @@ -13,12 +20,15 @@ module Squib end def start(title="", total=100, &block) - if @enabled + if @enabled && !(ENV['IN_TEST'].eql? "true") @bar = ProgressBar.create(title: title, total: total, format: '%t <%B> %p%% %a') yield(@bar) @bar.finish + else + yield(Squib::DoNothing.new) end end - end + + end \ No newline at end of file diff --git a/lib/squib/project_template/config.yml b/lib/squib/project_template/config.yml index 3f8fd58..31f1a10 100644 --- a/lib/squib/project_template/config.yml +++ b/lib/squib/project_template/config.yml @@ -1,2 +1,11 @@ # Settings in the config.yml are overriding Squib's defaults. Anything in the main script will override this. -#dpi: 72 \ No newline at end of file + +# DPI is used in making PDFs and in unit conversions +#dpi: 72 + +# Text hints are used to show the boundaries of text boxes. +# Can be enabled/disabled at the command-level, or set globally with `set` +#text_hint: '#F00' + +# Show progress bars on the command line for potentially long-running operations +#progress_bars: true diff --git a/samples/custom-config.yml b/samples/custom-config.yml index 01576ca..cb26a29 100644 --- a/samples/custom-config.yml +++ b/samples/custom-config.yml @@ -1,3 +1,3 @@ dpi: 300 -progress_bar: true -hint: '#FF0000' \ No newline at end of file +progress_bars: true +text_hint: '#FF0000' \ No newline at end of file diff --git a/samples/custom_config.rb b/samples/custom_config.rb index d691dfd..010eb52 100644 --- a/samples/custom_config.rb +++ b/samples/custom_config.rb @@ -4,7 +4,7 @@ require 'squib' Squib::Deck.new(config: 'custom-config.yml') do # Hints are turned on in the config file - text str: "The Title", x: 0, y: 78, width: 750, + text str: "The Title", x: 0, y: 78, width: 825, font: 'Arial 72', align: :center # Progress bars are shown for these commands diff --git a/spec/samples_run_spec.rb b/spec/samples_run_spec.rb index b56cb41..281e500 100644 --- a/spec/samples_run_spec.rb +++ b/spec/samples_run_spec.rb @@ -3,13 +3,17 @@ require 'squib' describe Squib do - it "should execute all examples with no errors" do - samples = File.expand_path('../samples', File.dirname(__FILE__)) - Dir["#{samples}/**/*.rb"].each do |sample| - Dir.chdir(samples) do #to save to _output - require_relative "../samples/#{File.basename(sample)}" + context "all samples" do + + it "should execute with no errors" do + samples = File.expand_path('../samples', File.dirname(__FILE__)) + Dir["#{samples}/**/*.rb"].each do |sample| + Dir.chdir(samples) do #to save to _output + require_relative "../samples/#{File.basename(sample)}" + end end end - end + + end end \ No newline at end of file diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index f983247..280ac9d 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,9 +1,10 @@ require 'simplecov' require 'coveralls' +ENV['IN_TEST']="true" + SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[ SimpleCov::Formatter::HTMLFormatter, Coveralls::SimpleCov::Formatter ] SimpleCov.start -