This repository has been archived by the owner on Jun 23, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Relax polisher deps, gracefully fail if missing (rev 4)
Now polisher gem contains minimal runtime deps w/ mechanism to catch runtime load errors. Components missing reqs will not be accessible / calling methods on them will indicate to install optional dependencies Rebased against latest master
- Loading branch information
Showing
13 changed files
with
1,435 additions
and
1,410 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# Polisher Components & Component Helpers | ||
# | ||
# Licensed under the MIT license | ||
# Copyright (C) 2014 Red Hat, Inc. | ||
|
||
require 'active_support/core_ext' | ||
|
||
module Polisher | ||
module Component | ||
class Missing | ||
def initialize(*args) | ||
raise "polisher is missing a dependency - cannot instantiate" | ||
end | ||
|
||
def method_missing(method_id, *args, &bl) | ||
raise "polisher is missing a dependency - cannot invoke #{method_id} on #{self}" | ||
end | ||
end # class MissingComponent | ||
|
||
def self.verify(polisher_klass, *dependencies) | ||
dependencies.each { |dep| require dep } | ||
rescue LoadError | ||
klass = polisher_klass.demodulize | ||
polisher_module = "Polisher::#{polisher_klass.deconstantize}" | ||
polisher_module.constantize.const_set(klass, Missing) | ||
else | ||
yield | ||
end | ||
end # module Component | ||
end # module Polisher |
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.