~ubuntu-branches/ubuntu/oneiric/puppet/oneiric-security

« back to all changes in this revision

Viewing changes to lib/puppet/parser/ast/collexpr.rb

  • Committer: Bazaar Package Importer
  • Author(s): Micah Anderson
  • Date: 2008-07-26 15:43:45 UTC
  • mto: (3.1.1 lenny) (1.3.1 upstream)
  • mto: This revision was merged to the branch mainline in revision 16.
  • Revision ID: james.westby@ubuntu.com-20080726154345-1fmgo76b4l72ulvc
ImportĀ upstreamĀ versionĀ 0.24.5

Show diffs side-by-side

added added

removed removed

Lines of Context:
9
9
    attr_accessor :test1, :test2, :oper, :form, :type, :parens
10
10
 
11
11
    # We return an object that does a late-binding evaluation.
12
 
    def evaluate(hash)
13
 
        scope = hash[:scope]
14
 
 
 
12
    def evaluate(scope)
15
13
        # Make sure our contained expressions have all the info they need.
16
14
        [@test1, @test2].each do |t|
17
15
            if t.is_a?(self.class)
21
19
        end
22
20
 
23
21
        # The code is only used for virtual lookups
24
 
        str1, code1 = @test1.safeevaluate :scope => scope
25
 
        str2, code2 = @test2.safeevaluate :scope => scope
 
22
        str1, code1 = @test1.safeevaluate scope
 
23
        str2, code2 = @test2.safeevaluate scope
26
24
 
27
25
        # First build up the virtual code.
28
26
        # If we're a conjunction operator, then we're calling code.  I did
43
41
        end
44
42
 
45
43
        case @oper
46
 
        when "and", "or": oper = @oper.upcase
 
44
        when "and", "or":
 
45
            if form == :exported
 
46
                raise Puppet::ParseError, "Puppet does not currently support collecting exported resources with more than one condition"
 
47
            end
 
48
            oper = @oper.upcase
47
49
        when "==": oper = "="
48
50
        else
49
51
            oper = @oper
54
56
            if str1 == "title"
55
57
                str = "title #{oper} '#{str2}'"
56
58
            else
57
 
                unless self.form == :virtual or str1 == "title"
58
 
                    parsefail "Collection from the database only supports " +
59
 
                        "title matching currently"
60
 
                end
61
 
                str = "rails_parameters.name = '#{str1}' and " +
62
 
                    "rails_parameters.value #{oper} '#{str2}'"
 
59
                str = "param_values.value #{oper} '#{str2}' and " +
 
60
                    "param_names.name = '#{str1}'"
63
61
            end
64
62
        else
65
 
            str = [str1, oper, str2].join(" ")
 
63
            str = "(%s) %s (%s)" % [str1, oper, str2]
66
64
        end
67
 
 
 
65
        
68
66
        return str, code
69
67
    end
70
68
 
77
75
    end
78
76
end
79
77
end
80
 
 
81
 
# $Id: collexpr.rb 1726 2006-10-04 18:24:24Z luke $