summaryrefslogtreecommitdiffstats
path: root/lib/puppet/feature
diff options
context:
space:
mode:
authorluke <luke@980ebf18-57e1-0310-9a29-db15c13687c0>2006-12-12 20:11:35 +0000
committerluke <luke@980ebf18-57e1-0310-9a29-db15c13687c0>2006-12-12 20:11:35 +0000
commit4abbdc13f4a1762eb5d848763dde1780f6408de8 (patch)
tree32c95243992a42465a02ae3194dd98cfd4baea89 /lib/puppet/feature
parent8fee5383eb214b7e4aa38b0438f23d2a326fb103 (diff)
downloadpuppet-4abbdc13f4a1762eb5d848763dde1780f6408de8.tar.gz
puppet-4abbdc13f4a1762eb5d848763dde1780f6408de8.tar.xz
puppet-4abbdc13f4a1762eb5d848763dde1780f6408de8.zip
Working some on the export/collect problem. It actually works now, but there are not yet sufficient tests for it, so I will leave the bug open until we have got the new work in place. I also added a "rails" feature, so I do not have to keep testing whether ActiveRecord is defined.
git-svn-id: https://reductivelabs.com/svn/puppet/trunk@1911 980ebf18-57e1-0310-9a29-db15c13687c0
Diffstat (limited to 'lib/puppet/feature')
-rw-r--r--lib/puppet/feature/rails.rb44
1 files changed, 44 insertions, 0 deletions
diff --git a/lib/puppet/feature/rails.rb b/lib/puppet/feature/rails.rb
new file mode 100644
index 000000000..288f02f82
--- /dev/null
+++ b/lib/puppet/feature/rails.rb
@@ -0,0 +1,44 @@
+# Created by Luke Kanies on 2006-11-07.
+# Copyright (c) 2006. All rights reserved.
+
+require 'puppet/feature'
+
+Puppet.features.add(:rails) do
+ begin
+ require 'active_record'
+ rescue LoadError => detail
+ if Facter["operatingsystem"].value == "Debian" and
+ FileTest.exists?("/usr/share/rails")
+ count = 0
+ Dir.entries("/usr/share/rails").each do |dir|
+ libdir = File.join("/usr/share/rails", dir, "lib")
+ if FileTest.exists?(libdir) and ! $:.include?(libdir)
+ count += 1
+ $: << libdir
+ end
+ end
+
+ if count > 0
+ retry
+ end
+ end
+ end
+
+ # If we couldn't find it the normal way, try using a Gem.
+ unless defined? ActiveRecord
+ begin
+ require 'rubygems'
+ require_gem 'rails'
+ rescue LoadError
+ # Nothing
+ end
+ end
+
+ if defined? ActiveRecord
+ true
+ else
+ false
+ end
+end
+
+# $Id$