Class: Hiera::Backend::Eyaml::Plugins
- Inherits:
-
Object
- Object
- Hiera::Backend::Eyaml::Plugins
- Defined in:
- lib/hiera/backend/eyaml/plugins.rb
Constant Summary collapse
- @@plugins =
[]
- @@commands =
[]
- @@options =
[]
Class Method Summary collapse
- .commands ⇒ Object
- .find ⇒ Object
- .options ⇒ Object
- .plugins ⇒ Object
- .register_options(args) ⇒ Object
Class Method Details
.commands ⇒ Object
61 62 63 |
# File 'lib/hiera/backend/eyaml/plugins.rb', line 61 def self.commands @@commands end |
.find ⇒ Object
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 |
# File 'lib/hiera/backend/eyaml/plugins.rb', line 25 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 = nil 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 |
.options ⇒ Object
21 22 23 |
# File 'lib/hiera/backend/eyaml/plugins.rb', line 21 def self. @@options end |
.plugins ⇒ Object
57 58 59 |
# File 'lib/hiera/backend/eyaml/plugins.rb', line 57 def self.plugins @@plugins end |
.register_options(args) ⇒ Object
11 12 13 14 15 16 17 18 19 |
# File 'lib/hiera/backend/eyaml/plugins.rb', line 11 def self.(args) = args[:options] plugin = args[:plugin] .each do |name, option_hash| new_option = { name: "#{plugin}_#{name}" } new_option.merge! option_hash @@options << new_option end end |