From 3ad750d103e6904a14941d6c8d6c230df55d70d5 Mon Sep 17 00:00:00 2001 From: Charlie Sharpsteen Date: Mon, 19 May 2014 22:24:03 -0700 Subject: [PATCH] Add feature guards for necessary requirements Add `Puppet.feature` guards for the `yard` and `rgen` libraries. --- lib/puppet/face/yardoc.rb | 12 +++++++++++- lib/puppet/feature/rgen.rb | 3 +++ lib/puppet/feature/yard.rb | 3 +++ 3 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 lib/puppet/feature/rgen.rb create mode 100644 lib/puppet/feature/yard.rb diff --git a/lib/puppet/face/yardoc.rb b/lib/puppet/face/yardoc.rb index b29faa5..bbb53e6 100644 --- a/lib/puppet/face/yardoc.rb +++ b/lib/puppet/face/yardoc.rb @@ -1,5 +1,4 @@ require 'puppet/face' -require 'puppet/pops' Puppet::Face.define(:yardoc, '0.0.1') do @@ -7,6 +6,17 @@ Puppet::Face.define(:yardoc, '0.0.1') do default 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() parse_result = parser.parse_file(args[0]) diff --git a/lib/puppet/feature/rgen.rb b/lib/puppet/feature/rgen.rb new file mode 100644 index 0000000..0ab9263 --- /dev/null +++ b/lib/puppet/feature/rgen.rb @@ -0,0 +1,3 @@ +require 'puppet/util/feature' + +Puppet.features.add(:rgen, :libs => ['rgen/metamodel_builder', 'rgen/ecore/ecore']) diff --git a/lib/puppet/feature/yard.rb b/lib/puppet/feature/yard.rb new file mode 100644 index 0000000..aab7f6c --- /dev/null +++ b/lib/puppet/feature/yard.rb @@ -0,0 +1,3 @@ +require 'puppet/util/feature' + +Puppet.features.add(:yard, :libs => ['yard'])