feature: build groups
See docs and changelog for more details on how these work.
This commit is contained in:
@@ -0,0 +1,47 @@
|
||||
require 'set'
|
||||
|
||||
module Squib
|
||||
|
||||
# An idea for later...
|
||||
# def enable_group_env group
|
||||
# ENV['SQUIB_BUILD'] ||= ''
|
||||
# ENV['SQUIB_BUILD'] += ','
|
||||
# ENV['SQUIB_BUILD'] += group
|
||||
# end
|
||||
# module_function :enable_group_env
|
||||
|
||||
class Deck
|
||||
|
||||
# See official API docs
|
||||
def group grp = :all, &block
|
||||
raise 'Please provide a block' unless block_given?
|
||||
block.yield if groups.include? grp
|
||||
end
|
||||
|
||||
# See official API docs
|
||||
def enable_group grp
|
||||
groups # make sure it's initialized
|
||||
@build_groups << grp
|
||||
end
|
||||
|
||||
# See official API docs
|
||||
def disable_group grp
|
||||
groups # make sure it's initialized
|
||||
@build_groups.delete grp
|
||||
end
|
||||
|
||||
# See official API docs
|
||||
def groups
|
||||
@build_groups ||= Set.new.add(:all)
|
||||
end
|
||||
|
||||
# See official API docs
|
||||
def enable_groups_from_env!
|
||||
return if ENV['SQUIB_BUILD'].nil?
|
||||
ENV['SQUIB_BUILD'].split(',').each do |grp|
|
||||
enable_group grp.strip.to_sym
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
@@ -69,6 +69,7 @@ module Squib
|
||||
@height = Args::UnitConversion.parse height, dpi
|
||||
cards.times{ |i| @cards << Squib::Card.new(self, @width, @height, i) }
|
||||
@layout = LayoutParser.load_layout(layout)
|
||||
enable_groups_from_env!
|
||||
if block_given?
|
||||
instance_eval(&block) # here we go. wheeeee!
|
||||
end
|
||||
@@ -102,6 +103,7 @@ module Squib
|
||||
##################
|
||||
require_relative 'api/background'
|
||||
require_relative 'api/data'
|
||||
require_relative 'api/groups'
|
||||
require_relative 'api/image'
|
||||
require_relative 'api/save'
|
||||
require_relative 'api/settings'
|
||||
|
||||
Reference in New Issue
Block a user