summaryrefslogtreecommitdiffstats
path: root/lib/puppet/feature/rails.rb
blob: 561863c9f8f3c2b41e0ef2f48f2f0e07a9b204ac (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
34
35
36
37
38
#  Created by Luke Kanies on 2006-11-07.
#  Copyright (c) 2006. All rights reserved.

require 'puppet/util/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
        else
            #If ActiveRecord was installed only via rubygems this is required
            require 'rubygems'
            require 'active_record'
        end
    end

    unless defined?(::ActiveRecord) and ::ActiveRecord::VERSION::MAJOR == 2 and ::ActiveRecord::VERSION::MINOR == 3
        Puppet.err "ActiveRecord 2.3 required for StoreConfigs"
        raise "ActiveRecord 2.3 required for StoreConfigs"
    end

    true
end