From e55c450d168fad55dca60ffa98a2e068c0019f5f Mon Sep 17 00:00:00 2001 From: Andy Meneely Date: Sun, 20 Mar 2016 22:51:11 -0400 Subject: [PATCH] build_groups: rename to build instead of group --- docs/dsl/{group.rst => build.rst} | 10 +++++++--- docs/dsl/{groups.rst => build_groups.rst} | 10 +++++----- .../dsl/{disable_group.rst => disable_build.rst} | 16 ++++++++++++++-- docs/dsl/{enable_group.rst => enable_build.rst} | 15 ++++++++++++--- lib/squib/api/groups.rb | 14 +++++++------- samples/build_groups | 2 +- 6 files changed, 46 insertions(+), 21 deletions(-) rename docs/dsl/{group.rst => build.rst} (73%) rename docs/dsl/{groups.rst => build_groups.rst} (70%) rename docs/dsl/{disable_group.rst => disable_build.rst} (60%) rename docs/dsl/{enable_group.rst => enable_build.rst} (61%) diff --git a/docs/dsl/group.rst b/docs/dsl/build.rst similarity index 73% rename from docs/dsl/group.rst rename to docs/dsl/build.rst index baa3971..2d9e294 100644 --- a/docs/dsl/group.rst +++ b/docs/dsl/build.rst @@ -1,4 +1,4 @@ -group +build ===== Establish a set of commands that can be enabled/disabled together to allow for customized builds. See :doc:`/build_groups` for ways to use this effectively. @@ -6,10 +6,14 @@ Establish a set of commands that can be enabled/disabled together to allow for c Required Arguments ------------------ +.. note:: + + This is an argument, not an option like most DSL methods. See example below. + group default: ``:all`` - The name of the group. Convention is to use a Ruby symbol. + The name of the build group. Convention is to use a Ruby symbol. &block @@ -22,7 +26,7 @@ Examples Use group to organize your Squib code into build groups:: Squib::Deck.new do - group :pnp do + build :pnp do save_pdf end end diff --git a/docs/dsl/groups.rst b/docs/dsl/build_groups.rst similarity index 70% rename from docs/dsl/groups.rst rename to docs/dsl/build_groups.rst index a84861f..7fcfb08 100644 --- a/docs/dsl/groups.rst +++ b/docs/dsl/build_groups.rst @@ -1,5 +1,5 @@ -groups -====== +build_groups +============ Returns the set of group names that have been enabled. See :doc:`/build_groups` for ways to use this effectively. @@ -15,9 +15,9 @@ Examples Use group to organize your Squib code into build groups:: Squib::Deck.new do - enable_group :pnp - group :pnp do + enable_build :pnp + build :pnp do save_pdf end - puts groups # outputs :all and :pnp + puts build_groups # outputs :all and :pnp end diff --git a/docs/dsl/disable_group.rst b/docs/dsl/disable_build.rst similarity index 60% rename from docs/dsl/disable_group.rst rename to docs/dsl/disable_build.rst index fe2897e..25994af 100644 --- a/docs/dsl/disable_group.rst +++ b/docs/dsl/disable_build.rst @@ -1,4 +1,4 @@ -disable_group +disable_build ============= Disable the given build group for the rest of the build. Thus, code within the corresponding :doc:`/dsl/group` block will not be executed. See :doc:`/build_groups` for ways to use this effectively. @@ -7,10 +7,22 @@ Disable the given build group for the rest of the build. Thus, code within the c Required Arguments ------------------ -group +build_group_name + default: ``:all`` the name of the group to disable. Convention is to use a Ruby symbol. +.. note:: + Examples -------- + +Can be used to disable a group (even if it's enabled via command line):: + + Squib::Deck.new do + disable_build :pnp + build :pnp do + save_pdf + end + end diff --git a/docs/dsl/enable_group.rst b/docs/dsl/enable_build.rst similarity index 61% rename from docs/dsl/enable_group.rst rename to docs/dsl/enable_build.rst index afef78d..bf05265 100644 --- a/docs/dsl/enable_group.rst +++ b/docs/dsl/enable_build.rst @@ -1,5 +1,5 @@ -enable_group -============= +enable_build +============ Enable the given build group for the rest of the build. Thus, code within the corresponding :doc:`/dsl/group` block will be executed. See :doc:`/build_groups` for ways to use this effectively. @@ -7,10 +7,19 @@ Enable the given build group for the rest of the build. Thus, code within the co Required Arguments ------------------ -group +build_group_name the name of the group to enable. Convention is to use a Ruby symbol. Examples -------- + +Can be used to disable a group (even if it's enabled via command line):: + + Squib::Deck.new do + disable_build :pnp + build :pnp do + save_pdf + end + end diff --git a/lib/squib/api/groups.rb b/lib/squib/api/groups.rb index a590e56..99374bb 100644 --- a/lib/squib/api/groups.rb +++ b/lib/squib/api/groups.rb @@ -13,29 +13,29 @@ module Squib class Deck # DSL method. See http://squib.readthedocs.org - def group grp = :all, &block + def build grp = :all, &block raise 'Please provide a block' unless block_given? block.yield if groups.include? grp end # DSL method. See http://squib.readthedocs.org - def enable_group grp - groups # make sure it's initialized + def enable_build grp + build_groups # make sure it's initialized @build_groups << grp end # DSL method. See http://squib.readthedocs.org - def disable_group grp - groups # make sure it's initialized + def disable_build grp + build_groups # make sure it's initialized @build_groups.delete grp end # DSL method. See http://squib.readthedocs.org - def groups + def build_groups @build_groups ||= Set.new.add(:all) end - # DSL method. See http://squib.readthedocs.org + # 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| diff --git a/samples/build_groups b/samples/build_groups index c58b225..943d387 160000 --- a/samples/build_groups +++ b/samples/build_groups @@ -1 +1 @@ -Subproject commit c58b225851a474d26ed3c4d1992a4af6bcf2922e +Subproject commit 943d3871f97e8d29f197d91ae306578b2e6c8c78