Class: Rubu::Flow

Inherits:
Action show all
Includes:
FlowRun
Defined in:
lib/rubu.rb

Overview

Action Flow with name. Action Flow is a collection of build steps.

Direct Known Subclasses

Fork, Walk

Constant Summary

@@flows =

Flow hash.

{}

Instance Attribute Summary (collapse)

Attributes inherited from Action

#errmsg, #output, #status, #subs

Class Method Summary (collapse)

Instance Method Summary (collapse)

Methods included from FlowRun

#parallel_run, #serial_run

Methods inherited from Action

#display, #error, #host, #host_in, #host_out, #pick, #use

Constructor Details

- (Flow) initialize(name = nil, &blk)

Returns a new instance of Flow



650
651
652
653
654
655
656
657
658
659
# File 'lib/rubu.rb', line 650

def initialize( name = nil, &blk )
    super()
    @name = name
    host_in
    instance_eval &blk
    host_out
    if @name
        @@flows[ @name ] = self
    end
end

Instance Attribute Details

- (Object) name (readonly)

Returns the value of attribute name



648
649
650
# File 'lib/rubu.rb', line 648

def name
  @name
end

Class Method Details

+ (Object) [](name)

Reference Flow by name.



643
644
645
# File 'lib/rubu.rb', line 643

def self.[]( name )
    @@flows[ name ]
end

+ (Object) form(name = nil, &blk)

Replacement for new method.



637
638
639
# File 'lib/rubu.rb', line 637

def self.form( name = nil, &blk )
    self.new( name, &blk )
end

+ (Object) load_setup(setup)



666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
# File 'lib/rubu.rb', line 666

def Flow.load_setup( setup )

    if File.exist? setup

        conf = YAML.load_file( setup )

        conf.each do |k,v|

            scope = nil

            case k
            when :var; scope = Var
            when :order; scope = Order
            when :info; scope = Info
            end

            v.each do |k2,v2|
                scope[ k2 ] = v2
            end
        end
    end
end

+ (Object) run(flows)

Run selected flow(s).



717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
# File 'lib/rubu.rb', line 717

def Flow.run( flows )

    flows.each do |name|

        begin

            ret = Flow[ name ].run
            if ret.status == :error
                STDERR.puts "Rubu FAILURE..."
                exit false
            end

        rescue

            STDERR.puts "Broken flow: \"#{name}\"..."
            exit false

        end

    end

    State.save

    exit true
end

+ (Object) setup(spec)

Apply configuration options if any.



690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
# File 'lib/rubu.rb', line 690

def Flow.setup( spec )

    load_setup( "#{ENV['HOME']}/.rubu.yml" )
    load_setup( ENV['RUBU_CONF'] ) if ENV['RUBU_CONF']
    load_setup( ".rubu.yml" )

    State.load

    # Apply options from Como.
    if spec[ :como ]
        como = spec[ :como ]
        if Opt[ como ].given
            Opt[ como ].value.each do |conf|
                name, value = conf.split( '=' )
                value = case value
                        when 'true'; true
                        when 'false'; false
                        else value
                        end
                Var[ name.to_sym ] = value
            end
        end
    end

end

Instance Method Details

- (Object) run

Default run style for Flow.



662
663
664
# File 'lib/rubu.rb', line 662

def run
    serial_run
end