Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
20 changed files
with
223 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
require 'singleton' | ||
|
||
module Nanoc::Int | ||
# @api private | ||
module ContractsSupport | ||
class Ignorer | ||
include Singleton | ||
|
||
def method_missing(*_args) | ||
self | ||
end | ||
end | ||
|
||
module DisabledContracts | ||
Any = Ignorer.instance | ||
Bool = Ignorer.instance | ||
Num = Ignorer.instance | ||
KeywordArgs = Ignorer.instance | ||
Optional = Ignorer.instance | ||
Maybe = Ignorer.instance | ||
None = Ignorer.instance | ||
ArrayOf = Ignorer.instance | ||
Or = Ignorer.instance | ||
Func = Ignorer.instance | ||
RespondTo = Ignorer.instance | ||
|
||
def contract(*args) | ||
end | ||
end | ||
|
||
module EnabledContracts | ||
def contract(*args) | ||
Contract(*args) | ||
end | ||
end | ||
|
||
def self.included(base) | ||
contracts_loadable = | ||
begin | ||
require 'contracts' | ||
true | ||
rescue LoadError | ||
false | ||
end | ||
|
||
should_enable = contracts_loadable && !ENV.key?('DISABLE_CONTRACTS') | ||
|
||
if should_enable | ||
unless base.include?(::Contracts::Core) | ||
base.include(::Contracts::Core) | ||
base.extend(EnabledContracts) | ||
base.const_set('C', ::Contracts) | ||
end | ||
else | ||
base.extend(DisabledContracts) | ||
base.const_set('C', DisabledContracts) | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,17 @@ | ||
require_relative 'entities/identifier' | ||
require_relative 'entities/content' | ||
require_relative 'entities/rule_memory_action' | ||
require_relative 'entities/rule_memory_actions' | ||
|
||
require_relative 'entities/code_snippet' | ||
require_relative 'entities/configuration' | ||
require_relative 'entities/lazy_value' | ||
require_relative 'entities/content' | ||
require_relative 'entities/document' | ||
require_relative 'entities/identifier' | ||
require_relative 'entities/identifiable_collection' | ||
require_relative 'entities/item' | ||
require_relative 'entities/item_rep' | ||
require_relative 'entities/layout' | ||
require_relative 'entities/pattern' | ||
require_relative 'entities/rule_memory' | ||
require_relative 'entities/rule_memory_action' | ||
require_relative 'entities/rule_memory_actions' | ||
require_relative 'entities/site' | ||
require_relative 'entities/snapshot_def' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.