Module: Cordon

Defined in:
lib/cordon.rb,
lib/cordon/blacklist.rb,
lib/cordon/sanitaire.rb,
lib/cordon/violation.rb,
lib/cordon/watchlist.rb,
lib/cordon/whitelist.rb,
lib/cordon/method_list.rb

Defined Under Namespace

Modules: Blacklist, MethodList, Sanitaire, Watchlist, Whitelist Classes: Violation

Class Method Summary collapse

Class Method Details

.blacklist(subject, methods) ⇒ Object

Declare specific methods as off-limits so that invocations raise an exception



42
43
44
# File 'lib/cordon.rb', line 42

def self.blacklist(subject, methods)
  Blacklist.wrap_methods(subject, methods)
end

.dont_filter_violation_backtrace!Object

Reset custom filtering of backtraces. (This is mostly here for ease of testing.)



75
76
77
# File 'lib/cordon.rb', line 75

def self.dont_filter_violation_backtrace!
  Violation.clear_custom_backtrace_filters
end

.embargo(framework) ⇒ Object

Shorthand for blacklisting the undesirable methods in specific frameworks



30
31
32
# File 'lib/cordon.rb', line 30

def self.embargo(framework)
  wrap_framework(framework, :blacklist)
end

.filter_violation_backtrace(&proc) ⇒ Object

Allow custom filtering of backtraces on Cordon::Violation errors. Pass this a block that takes a backtrace and returns a backtrace. Multiple filters can be defined; all will be applied.



69
70
71
# File 'lib/cordon.rb', line 69

def self.filter_violation_backtrace(&proc)
  Violation.add_custom_backtrace_filter(&proc)
end

.incursion_reportObject

Plain-text report of watchlist incursions



62
63
64
# File 'lib/cordon.rb', line 62

def self.incursion_report
  Watchlist.incursion_report
end

.incursionsObject

Convenience accessor for reporting on watchlist incursions



57
58
59
# File 'lib/cordon.rb', line 57

def self.incursions
  Watchlist.incursions
end

.monitor(framework) ⇒ Object

Shorthand for watchlisting the undesirable methods in specific frameworks NOTE: while this will record incursions, you’ll have to call Cordon.incursion_report yourself until I figure out how to make it print out at exit.



37
38
39
# File 'lib/cordon.rb', line 37

def self.monitor(framework)
  wrap_framework(framework, :watchlist)
end

.watchlist(subject, methods) ⇒ Object

Declare specific methods as off-limits so that invocations are logged



47
48
49
# File 'lib/cordon.rb', line 47

def self.watchlist(subject, methods)
  Watchlist.wrap_methods(subject, methods)
end

.wrap_assertions_with(custom_method_name) ⇒ Object

Allow user-defined aliases of #assert_that



52
53
54
# File 'lib/cordon.rb', line 52

def self.wrap_assertions_with(custom_method_name)
  Sanitaire.wrap_assertions_with(custom_method_name)
end