Add feature guards for necessary requirements

Add `Puppet.feature` guards for the `yard` and `rgen` libraries.
This commit is contained in:
Charlie Sharpsteen 2014-05-19 22:24:03 -07:00
parent 3d71143614
commit 3ad750d103
3 changed files with 17 additions and 1 deletions

View File

@ -1,5 +1,4 @@
require 'puppet/face' require 'puppet/face'
require 'puppet/pops'
Puppet::Face.define(:yardoc, '0.0.1') do Puppet::Face.define(:yardoc, '0.0.1') do
@ -7,6 +6,17 @@ Puppet::Face.define(:yardoc, '0.0.1') do
default default
when_invoked do |*args| when_invoked do |*args|
unless Puppet.features.yard?
raise RuntimeError, "The 'yard' gem must be installed in order to use this face."
end
if Puppet.features.rgen?
require 'puppet/pops'
else
raise RuntimeError, "The 'rgen' gem must be installed in order to use this face."
end
parser = Puppet::Pops::Parser::Parser.new() parser = Puppet::Pops::Parser::Parser.new()
parse_result = parser.parse_file(args[0]) parse_result = parser.parse_file(args[0])

View File

@ -0,0 +1,3 @@
require 'puppet/util/feature'
Puppet.features.add(:rgen, :libs => ['rgen/metamodel_builder', 'rgen/ecore/ecore'])

View File

@ -0,0 +1,3 @@
require 'puppet/util/feature'
Puppet.features.add(:yard, :libs => ['yard'])