forked from voxpupuli/hiera-eyaml
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added plugin finder for purpose of plugin cmdline options
- Loading branch information
Geoff Meakin
committed
Aug 8, 2013
1 parent
a49b677
commit c6b3fe8
Showing
5 changed files
with
79 additions
and
2 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
Empty file.
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 'rubygems' | ||
|
||
class Hiera | ||
module Backend | ||
module Eyaml | ||
class Plugins | ||
|
||
@@plugins = [] | ||
@@options = [] | ||
|
||
def self.register_options options_array | ||
@@options += options_array | ||
end | ||
|
||
def self.options | ||
@@options | ||
end | ||
|
||
def self.find | ||
|
||
this_version = Gem::Version.create(Hiera::Backend::Eyaml::VERSION) | ||
index = Gem::VERSION >= "1.8.0" ? Gem::Specification : Gem.source_index | ||
|
||
[index].flatten.each do |source| | ||
|
||
specs.each do |spec| | ||
next if @@plugins.include? spec | ||
|
||
# If this gem depends on Vagrant, verify this is a valid release of | ||
# Vagrant for this gem to load into. | ||
dependency = spec.dependencies.find { |d| d.name == "hiera-eyaml" } | ||
next if dependency && !dependency.requirement.satisfied_by? this_version | ||
|
||
file = nil | ||
if Gem::VERSION >= "1.8.0" | ||
file = spec.matches_for_glob("**/eyaml_init.rb").first | ||
else | ||
file = Gem.searcher.matching_files(spec, "eyaml_init.rb").first | ||
end | ||
|
||
next unless file | ||
|
||
@@plugins << spec | ||
load file | ||
end | ||
|
||
end | ||
|
||
@@plugins | ||
|
||
end | ||
|
||
def self.plugins | ||
@@plugins | ||
end | ||
|
||
end | ||
end | ||
end | ||
end |