summaryrefslogtreecommitdiffstats
path: root/lib/puppet/feature/rails.rb
blob: 74ed09aa64d370bebe01b0e6703cbd8c83e0e486 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#  Created by Luke Kanies on 2006-11-07.
#  Copyright (c) 2006. All rights reserved.

require 'puppet/util/feature'

Puppet.features.rubygems?

Puppet.features.add(:rails) do
  begin
    require 'active_record'
    require 'active_record/version'
  rescue LoadError => detail
    if 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 ! $LOAD_PATH.include?(libdir)
          count += 1
          $LOAD_PATH << libdir
        end
      end

      retry if count > 0
    end
  end

  unless (Puppet::Util.activerecord_version >= 2.1)
    Puppet.info "ActiveRecord 2.1 or later required for StoreConfigs"
    false
  else
    true
  end
end