~ubuntu-branches/ubuntu/lucid/puppet/lucid-security

« back to all changes in this revision

Viewing changes to lib/puppet/feature/rails.rb

  • Committer: Bazaar Package Importer
  • Author(s): Chuck Short
  • Date: 2009-12-23 00:48:10 UTC
  • mfrom: (1.1.10 upstream) (3.1.7 squeeze)
  • Revision ID: james.westby@ubuntu.com-20091223004810-3i4oryds922g5n59
Tags: 0.25.1-3ubuntu1
* Merge from debian testing.  Remaining changes:
  - debian/rules:
    + Don't start puppet when first installing puppet.
  - debian/puppet.conf, lib/puppet/defaults.rb:
    + Move templates to /etc/puppet
  - lib/puppet/defaults.rb:
    + Fix /var/lib/puppet/state ownership.
  - man/man8/puppet.conf.8: 
    + Fix broken URL in manpage.
  - debian/control:
    + Update maintainer accordint to spec.
    + Puppetmaster Recommends -> Suggests
    + Created puppet-testsuite as a seperate. Allow the users to run puppet's 
      testsuite.
  - tests/Rakefile: Fix rakefile so that the testsuite can acutally be ran.

Show diffs side-by-side

added added

removed removed

Lines of Context:
3
3
 
4
4
require 'puppet/util/feature'
5
5
 
 
6
Puppet.features.rubygems?
 
7
 
6
8
Puppet.features.add(:rails) do
7
9
    begin
8
10
        require 'active_record'
 
11
        require 'active_record/version'
9
12
    rescue LoadError => detail
10
 
        if Facter["operatingsystem"].value == "Debian" and
11
 
            FileTest.exists?("/usr/share/rails")
12
 
                count = 0
13
 
                Dir.entries("/usr/share/rails").each do |dir|
14
 
                    libdir = File.join("/usr/share/rails", dir, "lib")
15
 
                    if FileTest.exists?(libdir) and ! $:.include?(libdir)
16
 
                        count += 1
17
 
                        $: << libdir
18
 
                    end
19
 
                end
20
 
 
21
 
                if count > 0
22
 
                    retry
23
 
                end
24
 
        else
25
 
            #If ActiveRecord was installed only via rubygems this is required
26
 
            require 'rubygems'
27
 
            require 'active_record'
28
 
        end
29
 
    end
30
 
 
31
 
    # If we couldn't find it the normal way, try using a Gem.
32
 
    unless defined? ActiveRecord
33
 
        begin
34
 
            require 'rubygems'
35
 
            require 'rails'
36
 
        rescue LoadError
37
 
            # Nothing
38
 
        end
39
 
    end
40
 
 
41
 
    # We check a fairly specific class, so that we can be sure that we've
42
 
    # loaded a new enough version of AR that will support the features we
43
 
    # actually use.
44
 
    if defined? ActiveRecord::Associations::BelongsToPolymorphicAssociation
45
 
        require 'puppet/rails'
 
13
        if FileTest.exists?("/usr/share/rails")
 
14
            count = 0
 
15
            Dir.entries("/usr/share/rails").each do |dir|
 
16
                libdir = File.join("/usr/share/rails", dir, "lib")
 
17
                if FileTest.exists?(libdir) and ! $:.include?(libdir)
 
18
                    count += 1
 
19
                    $: << libdir
 
20
                end
 
21
            end
 
22
 
 
23
            if count > 0
 
24
                retry
 
25
            end
 
26
        end
 
27
    end
 
28
 
 
29
    if ! (defined?(::ActiveRecord) and defined?(::ActiveRecord::VERSION) and defined?(::ActiveRecord::VERSION::MAJOR) and defined?(::ActiveRecord::VERSION::MINOR))
 
30
        false
 
31
    elsif ! (::ActiveRecord::VERSION::MAJOR == 2 and ::ActiveRecord::VERSION::MINOR >= 1)
 
32
        Puppet.info "ActiveRecord 2.1 or later required for StoreConfigs"
 
33
        false
 
34
    else
46
35
        true
47
 
    else
48
 
        false
49
36
    end
50
37
end
51