From b4e2ed0e5c89d7fd0234b429a8ba811a91335553 Mon Sep 17 00:00:00 2001 From: Charlie Sharpsteen Date: Sat, 24 May 2014 12:54:22 -0700 Subject: [PATCH] Re-work require statements Use `require_relative` for all components under Puppetx. This makes it possible to load `pupetx/yardoc/yard/plugin` outside of Puppet as a YARD plugin. Also fix the `yardoc` face so that Puppetx bits are loaded _after_ feature checks. --- lib/puppet/face/yardoc.rb | 7 +++---- lib/puppetx/yardoc/pops/yard_statement.rb | 4 ++-- lib/puppetx/yardoc/pops/yard_transformer.rb | 3 +-- lib/puppetx/yardoc/yard/handlers/base.rb | 3 ++- lib/puppetx/yardoc/yard/parser.rb | 6 +++--- 5 files changed, 11 insertions(+), 12 deletions(-) diff --git a/lib/puppet/face/yardoc.rb b/lib/puppet/face/yardoc.rb index b48a4ef..329e152 100644 --- a/lib/puppet/face/yardoc.rb +++ b/lib/puppet/face/yardoc.rb @@ -1,5 +1,4 @@ require 'puppet/face' -require 'puppetx/yardoc/yard/parser' Puppet::Face.define(:yardoc, '0.0.1') do @@ -12,12 +11,12 @@ Puppet::Face.define(:yardoc, '0.0.1') do raise RuntimeError, "The 'yard' gem must be installed in order to use this face." end - if Puppet.features.rgen? - require 'puppet/pops' - else + unless Puppet.features.rgen? raise RuntimeError, "The 'rgen' gem must be installed in order to use this face." end + require 'puppetx/yardoc/yard/plugin' + parser = Puppetx::Yardoc::YARD::PuppetParser.new(File.read(manifest), manifest) parser.parse diff --git a/lib/puppetx/yardoc/pops/yard_statement.rb b/lib/puppetx/yardoc/pops/yard_statement.rb index b7d90bf..0df1773 100644 --- a/lib/puppetx/yardoc/pops/yard_statement.rb +++ b/lib/puppetx/yardoc/pops/yard_statement.rb @@ -1,7 +1,7 @@ -require 'puppetx/yardoc' - require 'puppet/pops' +require_relative '../../yardoc' + module Puppetx::Yardoc::Pops # An adapter class that conforms a Pops model instance + adapters to the # interface expected by YARD handlers. diff --git a/lib/puppetx/yardoc/pops/yard_transformer.rb b/lib/puppetx/yardoc/pops/yard_transformer.rb index af32e39..ebf4446 100644 --- a/lib/puppetx/yardoc/pops/yard_transformer.rb +++ b/lib/puppetx/yardoc/pops/yard_transformer.rb @@ -1,7 +1,6 @@ -require 'puppetx/yardoc' - require 'puppet/pops' +require_relative '../../yardoc' require_relative 'yard_statement' module Puppetx::Yardoc::Pops diff --git a/lib/puppetx/yardoc/yard/handlers/base.rb b/lib/puppetx/yardoc/yard/handlers/base.rb index b23e58b..552532f 100644 --- a/lib/puppetx/yardoc/yard/handlers/base.rb +++ b/lib/puppetx/yardoc/yard/handlers/base.rb @@ -1,7 +1,8 @@ -require 'puppetx/yardoc' require 'yard' require 'puppet/pops' +require_relative '../../../yardoc' + module Puppetx::Yardoc::YARD::Handlers class Base < YARD::Handlers::Base include Puppet::Pops::Model # This allows handlers to match based on model classes. diff --git a/lib/puppetx/yardoc/yard/parser.rb b/lib/puppetx/yardoc/yard/parser.rb index 7b7d367..aa64fb0 100644 --- a/lib/puppetx/yardoc/yard/parser.rb +++ b/lib/puppetx/yardoc/yard/parser.rb @@ -1,8 +1,8 @@ -require 'puppetx/yardoc' - require 'yard' require 'puppet/pops' -require 'puppetx/yardoc/pops/yard_transformer' + +require_relative '../../yardoc' +require_relative '../pops/yard_transformer' module Puppetx::Yardoc::YARD class PuppetParser < YARD::Parser::Base