forked from voxpupuli/hiera-eyaml
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplugins.rb
More file actions
66 lines (53 loc) · 1.78 KB
/
Copy pathplugins.rb
File metadata and controls
66 lines (53 loc) · 1.78 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
require 'rubygems'
class Hiera
module Backend
module Eyaml
class Plugins
@@plugins = []
@@commands = []
@@options = []
def self.register_options(args)
options = args[:options]
plugin = args[:plugin]
options.each do |name, option_hash|
new_option = { name: "#{plugin}_#{name}" }
new_option.merge! option_hash
@@options << new_option
end
end
def self.options
@@options
end
def self.find
gem_version = Gem::Version.new(Gem::VERSION)
this_version = Gem::Version.create(Hiera::Backend::Eyaml::VERSION)
index = (gem_version >= Gem::Version.new('1.8.0')) ? Gem::Specification : Gem.source_index
[index].flatten.each do |source|
specs = (gem_version >= Gem::Version.new('1.6.0')) ? source.latest_specs(true) : source.latest_specs
specs.each do |spec|
spec = spec.to_spec if spec.respond_to?(:to_spec)
next if @@plugins.include? spec
dependency = spec.dependencies.find { |d| d.name == 'hiera-eyaml' }
next if dependency && !dependency.requirement.satisfied_by?(this_version)
file = if gem_version >= Gem::Version.new('1.8.0')
spec.matches_for_glob('**/eyaml_init.rb').first
else
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
def self.commands
@@commands
end
end
end
end
end