Suppressing progress bar output and getting hints to work
parent
8bfdf4b777
commit
202b4c4235
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
@ -1,2 +1,11 @@
|
|||
# Settings in the config.yml are overriding Squib's defaults. Anything in the main script will override this.
|
||||
#dpi: 72
|
||||
|
||||
# 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
|
||||
|
|
|
|||
|
|
@ -1,3 +1,3 @@
|
|||
dpi: 300
|
||||
progress_bar: true
|
||||
hint: '#FF0000'
|
||||
progress_bars: true
|
||||
text_hint: '#FF0000'
|
||||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue