Browse Source

Better logging and docs thereof

dev
Andy Meneely 11 years ago
parent
commit
cad197553b
  1. 1
      CHANGELOG.md
  2. 10
      README.md
  3. 8
      lib/squib/deck.rb

1
CHANGELOG.md

@ -2,6 +2,7 @@
# Custom layouts now support loading & merging multiple files, see README and updated sample # Custom layouts now support loading & merging multiple files, see README and updated sample
# Samples now show that you can use text instead of symbols # Samples now show that you can use text instead of symbols
# Improved logging, and documentation on increasing logger verboseness
# Better regression testing technique that tracks when a sample has changed. # Better regression testing technique that tracks when a sample has changed.
## v0.0.5 ## v0.0.5

10
README.md

@ -251,6 +251,16 @@ See the `custom_config` sample found [here](https://github.com/andymeneely/squib
{include:file:samples/custom_config.rb} {include:file:samples/custom_config.rb}
## Making Squib Verbose
By default, Squib's logger is set to WARN, but more fine-grained logging is embedded in the code. To set the logger, just put this at the top of your script:
```ruby
Squib::logger.level = Logger::INFO
```
If you REALLY want to see tons of output, you can also set DEBUG, but that's not intended for general consumption.
## Staying DRY ## Staying DRY
Squib tries to keep you DRY (Don't Repeat Yourself) with the following features: Squib tries to keep you DRY (Don't Repeat Yourself) with the following features:

8
lib/squib/deck.rb

@ -63,6 +63,7 @@ module Squib
@progress_bar = Squib::Progress.new(false) @progress_bar = Squib::Progress.new(false)
@text_hint = :off @text_hint = :off
cards.times{ @cards << Squib::Card.new(self, width, height) } cards.times{ @cards << Squib::Card.new(self, width, height) }
show_info(config, layout)
load_config(config) load_config(config)
load_layout(layout) load_layout(layout)
if block_given? if block_given?
@ -95,6 +96,7 @@ module Squib
# @api private # @api private
def load_config(file) def load_config(file)
if File.exists?(file) && config = YAML.load_file(file) if File.exists?(file) && config = YAML.load_file(file)
Squib::logger.info { " using config: #{file}" }
config = Squib::CONFIG_DEFAULTS.merge(config) config = Squib::CONFIG_DEFAULTS.merge(config)
@dpi = config['dpi'].to_i @dpi = config['dpi'].to_i
@text_hint = config['text_hint'] @text_hint = config['text_hint']
@ -108,6 +110,7 @@ module Squib
# @api private # @api private
def load_layout(files) def load_layout(files)
@layout = {} @layout = {}
Squib::logger.info { " using layout(s): #{files}" }
Array(files).each do |file| Array(files).each do |file|
yml = @layout.merge(YAML.load_file(file)) yml = @layout.merge(YAML.load_file(file))
yml.each do |key, value| yml.each do |key, value|
@ -159,6 +162,11 @@ module Squib
end end
end end
def show_info(config, layout)
Squib::logger.info "Squib v#{Squib::VERSION}"
Squib::logger.info " building #{@cards.size} #{@width}x#{@height} cards"
end
################## ##################
### PUBLIC API ### ### PUBLIC API ###
################## ##################

Loading…
Cancel
Save