Sha256: 0cc3babd217201be7370d1fd765fd01570696aecf46fce3f27f7642b3c81cabf

Contents?: true

Size: 1.15 KB

Versions: 1

Compression:

Stored size: 1.15 KB

Contents

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

    # DSL method. See http://squib.readthedocs.io
    def build grp = :all, &block
      raise 'Please provide a block' unless block_given?
      block.yield if build_groups.include? grp
    end

    # DSL method. See http://squib.readthedocs.io
    def enable_build grp
      build_groups # make sure it's initialized
      @build_groups << grp
    end

    # DSL method. See http://squib.readthedocs.io
    def disable_build grp
      build_groups # make sure it's initialized
      @build_groups.delete grp
    end

    # DSL method. See http://squib.readthedocs.io
    def build_groups
      @build_groups ||= Set.new.add(:all)
    end

    # Not a DSL method, but initialized from Deck.new
    def enable_groups_from_env!
      return if ENV['SQUIB_BUILD'].nil?
      ENV['SQUIB_BUILD'].split(',').each do |grp|
        enable_build grp.strip.to_sym
      end
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
squib-0.11.0 lib/squib/api/groups.rb