Class: Rant::SignedSourceNode

Inherits:
SourceNode show all
Defined in:
lib/rant/import/nodes/signed.rb

Instance Method Summary collapse

Methods inherited from SourceNode

#invoke, #prerequisites, #related_sources, #timestamp

Methods included from Node

#inspect

Constructor Details

#initialize(*args) ⇒ SignedSourceNode

Returns a new instance of SignedSourceNode.



27
28
29
30
# File 'lib/rant/import/nodes/signed.rb', line 27

def initialize(*args)
    super
    @signature = nil
end

Instance Method Details

#signature(opt = INVOKE_OPT) ⇒ Object

Invokes prerequisites and returns a signature of the source file and all related source files. Note: The signature will only be calculated once.



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
# File 'lib/rant/import/nodes/signed.rb', line 34

def signature(opt = INVOKE_OPT)
    return circular_dep if @run
    @run = true
    begin
        return @signature if @signature
        goto_task_home
        sig_list = []
        sig = @rac.var._get("__signature__")
        if test(?f, @name)
            @signature = sig.signature_for_file(@name)
        else
            @rac.abort_at(ch,
                "SourceNode: no such file -- #@name")
        end
        sd = project_subdir
        handled = {@name => true}
        @pre.each { |f|
            f = f.to_rant_target
            next if handled.include? f
            nodes = rac.resolve f, sd
            if nodes.empty?
                if test(?f, f)
                    sig_list << sig.signature_for_file(f)
                else
                    rac.abort_at(ch,
                        "SourceNode: no such file -- #{f}")
                end
            else
                file_sig = nil
                nodes.each { |node|
                    node.invoke(opt)
                    if node.respond_to? :signature
                        sig_list << node.signature
                        goto_task_home
                    else
                        rac.abort_at(ch,
                            "SourceNode can't depend on #{node.name}")
                    end
                }
                sig_list << file_sig if file_sig
            end
            handled[f] = true
        }
        sig_list.sort!
        @signature << sig_list.join
    ensure
        @run = false
    end
end