summaryrefslogtreecommitdiffstats
path: root/lib/puppet/util
diff options
context:
space:
mode:
authorMatt Robinson <matt@puppetlabs.com>2011-03-06 20:42:39 -0800
committerMatt Robinson <matt@puppetlabs.com>2011-03-07 14:02:17 -0800
commit28095d7435bcab15b76ddfa4435d61653f2f890d (patch)
tree74ae5f037aaee78ed31de178c6e6f4203e9d7959 /lib/puppet/util
parent6869385300dc694c4f087e134949dff9e1e43df9 (diff)
parente8145f91debc863b341a270e1d8cff6c43d93ef5 (diff)
downloadpuppet-28095d7435bcab15b76ddfa4435d61653f2f890d.tar.gz
puppet-28095d7435bcab15b76ddfa4435d61653f2f890d.tar.xz
puppet-28095d7435bcab15b76ddfa4435d61653f2f890d.zip
Merge branch '2.6.next' into next
This was a particularly nasty merge, so rather than hold up merges into next any longer, I'm going to push this merge with a few outstanding problems. The tests that were failing in the following areas have been marked pending, and will be addressed separately, immediately following this push. TODO: Verify that brice's rdoc change is still valid: tests to show that line numbers from class, define and node get into the ast Fix mount parsed_spec spec/unit/provider/mount/parsed_spec.rb * 2.6.next: (85 commits) (#5148) Fix failing spec due to timezone (#5148) Add support for PSON to facts (#6338) Remove inventory indirection, and move to facts indirection (#6445) Fix inline docs: puppet agent does not accept --mkusers Update CHANGELOG and version for 2.6.6rc1 (#6541) Fix content with checksum truncation bug (#6418) Recursive files shouldn't be audited (#6541) maint: whitespace cleanup on the file integration spec (#6541) Fix content with checksum truncation bug (#5466) Write specs for output of puppet resource (#5466) Monkey patch Symbol so that you can sort them (#5466) Fixed puppet resource bug with trailing , Update CHANGELOG for 2.6.5 (#4922) Don't truncate remotely-sourced files on 404 (#6338) Remove unused version control tags Maint: Align tabs in a code block in the Augeas type. (#6509) Inline docs: Fix erroneous code block in directoryservice provider for computer type Maint: Rewrite comments about symlinks to reflect best practice. (#6509) Inline docs: Fix broken lists in Launchd provider. (#6509) Inline docs: Fix broken code blocks in zpool type ... Manually Resolved Conflicts: lib/puppet/application/inspect.rb lib/puppet/defaults.rb lib/puppet/file_bucket/dipper.rb lib/puppet/network/http/handler.rb lib/puppet/node/facts.rb lib/puppet/parser/parser.rb lib/puppet/parser/parser_support.rb lib/puppet/util/command_line/puppet lib/puppet/util/command_line/puppetd lib/puppet/util/command_line/puppetmasterd lib/puppet/util/monkey_patches.rb lib/puppet/util/rdoc/parser.rb spec/unit/application/agent_spec.rb spec/unit/file_bucket/file_spec.rb spec/unit/indirector/file_bucket_file/file_spec.rb spec/unit/network/http/handler_spec.rb spec/unit/parser/parser_spec.rb spec/unit/provider/mount/parsed_spec.rb
Diffstat (limited to 'lib/puppet/util')
-rw-r--r--lib/puppet/util/command_line.rb10
-rw-r--r--lib/puppet/util/monkey_patches.rb21
-rw-r--r--lib/puppet/util/rdoc/code_objects.rb39
-rw-r--r--lib/puppet/util/rdoc/generators/puppet_generator.rb18
-rw-r--r--lib/puppet/util/rdoc/parser.rb6
5 files changed, 87 insertions, 7 deletions
diff --git a/lib/puppet/util/command_line.rb b/lib/puppet/util/command_line.rb
index 3562a3dc0..7f74d266a 100644
--- a/lib/puppet/util/command_line.rb
+++ b/lib/puppet/util/command_line.rb
@@ -33,8 +33,12 @@ module Puppet
end
def available_subcommands
- absolute_appdir = $LOAD_PATH.collect { |x| File.join(x,'puppet','application') }.detect{ |x| File.directory?(x) }
- Dir[File.join(absolute_appdir, '*.rb')].map{|fn| File.basename(fn, '.rb')}
+ absolute_appdirs = $LOAD_PATH.collect do |x|
+ File.join(x,'puppet','application')
+ end.select{ |x| File.directory?(x) }
+ absolute_appdirs.inject([]) do |commands, dir|
+ commands + Dir[File.join(dir, '*.rb')].map{|fn| File.basename(fn, '.rb')}
+ end.uniq
end
def usage_message
@@ -81,7 +85,7 @@ module Puppet
if zero == 'puppet'
case argv.first
when nil; [ stdin.tty? ? nil : "apply", argv] # ttys get usage info
- when "--help"; [nil, argv] # help should give you usage, not the help for `puppet apply`
+ when "--help", "-h"; [nil, argv] # help should give you usage, not the help for `puppet apply`
when /^-|\.pp$|\.rb$/; ["apply", argv]
else [ argv.first, argv[1..-1] ]
end
diff --git a/lib/puppet/util/monkey_patches.rb b/lib/puppet/util/monkey_patches.rb
index 1c35ae523..a93c66b07 100644
--- a/lib/puppet/util/monkey_patches.rb
+++ b/lib/puppet/util/monkey_patches.rb
@@ -21,6 +21,9 @@ class Symbol
z.emit("!ruby/sym ")
to_s.to_zaml(z)
end
+ def <=> (other)
+ self.to_s <=> other.to_s
+ end
end
[Object, Exception, Integer, Struct, Date, Time, Range, Regexp, Hash, Array, Float, String, FalseClass, TrueClass, Symbol, NilClass, Class].each { |cls|
@@ -48,7 +51,6 @@ if RUBY_VERSION == '1.8.7'
end
end
-
class Object
# ActiveSupport 2.3.x mixes in a dangerous method
# that can cause rspec to fork bomb
@@ -56,6 +58,23 @@ class Object
def daemonize
raise NotImplementedError, "Kernel.daemonize is too dangerous, please don't try to use it."
end
+
+ # The following code allows callers to make assertions that are only
+ # checked when the environment variable PUPPET_ENABLE_ASSERTIONS is
+ # set to a non-empty string. For example:
+ #
+ # assert_that { condition }
+ # assert_that(message) { condition }
+ if ENV["PUPPET_ENABLE_ASSERTIONS"].to_s != ''
+ def assert_that(message = nil)
+ unless yield
+ raise Exception.new("Assertion failure: #{message}")
+ end
+ end
+ else
+ def assert_that(message = nil)
+ end
+ end
end
# Workaround for yaml_initialize, which isn't supported before Ruby
diff --git a/lib/puppet/util/rdoc/code_objects.rb b/lib/puppet/util/rdoc/code_objects.rb
index 3854fbc01..3c789a0c5 100644
--- a/lib/puppet/util/rdoc/code_objects.rb
+++ b/lib/puppet/util/rdoc/code_objects.rb
@@ -124,6 +124,45 @@ module RDoc
def add_child(child)
@childs << child
end
+
+ # Look up the given symbol. RDoc only looks for class1::class2.method
+ # or class1::class2#method. Since our definitions are mapped to RDoc methods
+ # but are written class1::class2::define we need to perform the lookup by
+ # ourselves.
+ def find_symbol(symbol, method=nil)
+ result = super
+ if not result and symbol =~ /::/
+ modules = symbol.split(/::/)
+ unless modules.empty?
+ module_name = modules.shift
+ result = find_module_named(module_name)
+ if result
+ last_name = ""
+ previous = nil
+ modules.each do |module_name|
+ previous = result
+ last_name = module_name
+ result = result.find_module_named(module_name)
+ break unless result
+ end
+ unless result
+ result = previous
+ method = last_name
+ end
+ end
+ end
+ if result && method
+ if !result.respond_to?(:find_local_symbol)
+ p result.name
+ p method
+ fail
+ end
+ result = result.find_local_symbol(method)
+ end
+ end
+ result
+ end
+
end
# PuppetNode holds a puppet node
diff --git a/lib/puppet/util/rdoc/generators/puppet_generator.rb b/lib/puppet/util/rdoc/generators/puppet_generator.rb
index e6bbb2e1e..249c9a8ba 100644
--- a/lib/puppet/util/rdoc/generators/puppet_generator.rb
+++ b/lib/puppet/util/rdoc/generators/puppet_generator.rb
@@ -31,6 +31,24 @@ module Generators
NODE_DIR = "nodes"
PLUGIN_DIR = "plugins"
+ # We're monkey patching RDoc markup to allow
+ # lowercase class1::class2::class3 crossref hyperlinking
+ module MarkUp
+ alias :old_markup :markup
+
+ def new_markup(str, remove_para=false)
+ first = @markup.nil?
+ res = old_markup(str, remove_para)
+ if first and not @markup.nil?
+ @markup.add_special(/\b([a-z]\w+(::\w+)*)/,:CROSSREF)
+ # we need to call it again, since we added a rule
+ res = old_markup(str, remove_para)
+ end
+ res
+ end
+ alias :markup :new_markup
+ end
+
# This is a specialized HTMLGenerator tailored to Puppet manifests
class PuppetGenerator < HTMLGenerator
diff --git a/lib/puppet/util/rdoc/parser.rb b/lib/puppet/util/rdoc/parser.rb
index ce34442ab..2b89baace 100644
--- a/lib/puppet/util/rdoc/parser.rb
+++ b/lib/puppet/util/rdoc/parser.rb
@@ -43,9 +43,9 @@ class Parser
@parser.parse.instantiate('').each do |type|
@known_resource_types.add type
end
- scan_top_level(@top_level)
end
end
+ scan_top_level(@top_level)
@top_level
end
@@ -160,8 +160,8 @@ class Parser
if stmt.is_a?(Puppet::Parser::AST::Function) and ['include','require'].include?(stmt.name)
stmt.arguments.each do |included|
- Puppet.debug "found #{stmt.name}: #{included.value}"
- container.send("add_#{stmt.name}",Include.new(included.value, stmt.doc))
+ Puppet.debug "found #{stmt.name}: #{included}"
+ container.send("add_#{stmt.name}",Include.new(included.to_s, stmt.doc))
end
end
end