Class: Rubu::Trail
Overview
Trail with name. Trail is a collection of Steps and/or Trails.
Constant Summary collapse
- @@trails =
Trail hash.
{}
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Attributes inherited from Move
#errmsg, #output, #status, #subs
Class Method Summary collapse
-
.[](name) ⇒ Object
Reference Trail by name.
-
.form(name = nil, &blk) ⇒ Object
Replacement (alias) for new method.
-
.list ⇒ Object
Return list of trails.
-
.load_setup(setup_file) ⇒ Object
Load a setup file.
-
.run(trails = 'default') ⇒ Object
Run selected trail(s).
-
.setup(spec) ⇒ Object
Apply configuration options and command parameters, if any, to Rubu.
Instance Method Summary collapse
-
#initialize(name = nil, &blk) ⇒ Trail
constructor
Create Trail object.
-
#pick(trail) ⇒ Object
Take trail into use.
-
#run ⇒ Object
Default run style for Trail.
Methods included from MoveStyles
Methods inherited from Move
#display, #error, #host, #host_in, #host_out, #use, #warn
Constructor Details
#initialize(name = nil, &blk) ⇒ Trail
Create Trail object. Named Trails are registered and can be referenced later.
743 744 745 746 747 748 749 750 751 752 |
# File 'lib/rubu.rb', line 743 def initialize( name = nil, &blk ) super() @name = name host_in instance_eval &blk host_out if @name @@trails[ @name ] = self end end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name
739 740 741 |
# File 'lib/rubu.rb', line 739 def name @name end |
Class Method Details
.[](name) ⇒ Object
Reference Trail by name.
729 730 731 |
# File 'lib/rubu.rb', line 729 def self.[]( name ) @@trails[ name ] end |
.form(name = nil, &blk) ⇒ Object
Replacement (alias) for new method.
723 724 725 |
# File 'lib/rubu.rb', line 723 def self.form( name = nil, &blk ) self.new( name, &blk ) end |
.list ⇒ Object
Return list of trails.
734 735 736 |
# File 'lib/rubu.rb', line 734 def self.list @@trails.keys end |
.load_setup(setup_file) ⇒ Object
Load a setup file.
767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 |
# File 'lib/rubu.rb', line 767 def Trail.load_setup( setup_file ) if File.exist? setup_file conf = YAML.load_file( setup_file ) 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 |
.run(trails = 'default') ⇒ Object
Run selected trail(s).
824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 |
# File 'lib/rubu.rb', line 824 def Trail.run( trails = 'default' ) unless trails.kind_of? Array trails = [ trails ] end trails.each do |name| begin ret = Trail[ name ].run if ret.status == :error STDERR.puts "Rubu FAILURE..." exit false end rescue STDERR.puts "Broken trail: \"#{name}\"..." exit false end end State.save exit true end |
.setup(spec) ⇒ Object
Apply configuration options and command parameters, if any, to Rubu.
795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 |
# File 'lib/rubu.rb', line 795 def Trail.setup( spec ) Trail.load_setup( "#{ENV['HOME']}/.rubu.yml" ) Trail.load_setup( ENV['RUBU_CONF'] ) if ENV['RUBU_CONF'] Trail.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
#pick(trail) ⇒ Object
Take trail into use.
756 757 758 |
# File 'lib/rubu.rb', line 756 def pick( trail ) Trail[ trail ].use end |
#run ⇒ Object
Default run style for Trail.
762 763 764 |
# File 'lib/rubu.rb', line 762 def run serial_run end |