Class: Raketeer::RunTask
- Inherits:
-
Rake::TaskLib
- Object
- Rake::TaskLib
- Raketeer::RunTask
- Defined in:
- lib/raketeer/run_task.rb
Overview
Instance Attribute Summary collapse
- #bin_dir ⇒ Object
- #description ⇒ Object
- #executable ⇒ Object
- #name ⇒ Object
- #run_cmd ⇒ Object
- #warning ⇒ Object (also: #warning?)
Instance Method Summary collapse
- #define ⇒ Object
-
#initialize(name = :run) {|_self| ... } ⇒ RunTask
constructor
A new instance of RunTask.
Constructor Details
#initialize(name = :run) {|_self| ... } ⇒ RunTask
Returns a new instance of RunTask.
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/raketeer/run_task.rb', line 33 def initialize(name=:run) super() @bin_dir = 'bin' @description = %Q(Run this project's main file: "rake #{name} -- --version") @executable = nil @name = name @warning = true @run_cmd = ['ruby'] @run_cmd.push('-r','rubygems') @run_cmd.push('-r','bundler/setup') yield self if block_given? @executable = Util.find_main_executable(@bin_dir) if @executable.nil? @run_cmd << '-w' if @warning @run_cmd << File.join(@bin_dir,@executable) define end |
Instance Attribute Details
#bin_dir ⇒ Object
24 25 26 |
# File 'lib/raketeer/run_task.rb', line 24 def bin_dir @bin_dir end |
#description ⇒ Object
25 26 27 |
# File 'lib/raketeer/run_task.rb', line 25 def description @description end |
#executable ⇒ Object
26 27 28 |
# File 'lib/raketeer/run_task.rb', line 26 def executable @executable end |
#name ⇒ Object
27 28 29 |
# File 'lib/raketeer/run_task.rb', line 27 def name @name end |
#run_cmd ⇒ Object
28 29 30 |
# File 'lib/raketeer/run_task.rb', line 28 def run_cmd @run_cmd end |
#warning ⇒ Object Also known as: warning?
29 30 31 |
# File 'lib/raketeer/run_task.rb', line 29 def warning @warning end |
Instance Method Details
#define ⇒ Object
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 83 84 85 86 87 88 89 90 |
# File 'lib/raketeer/run_task.rb', line 56 def define desc @description task @name do |task,args| first_arg_index = -1 name_s = @name.to_s # Cut out "--silent" for "rake --silent rt:run -- --version", # else "--silent" will be sent to the executable. ARGV.each_with_index do |arg,i| # There could be a namespace and/or args, like "rt:run[true]". # Rake task names are case-sensitive. if arg.include?(name_s) first_arg_index = i + 1 break end end # In case this is called more than once in some way sh_cmd = @run_cmd.dup # Are there args for the run command? if first_arg_index >= 0 && first_arg_index < ARGV.length run_args = ARGV.slice!(first_arg_index..-1) # Cut out "--" for "rake run -- --version". # For older versions of rake, you didn't need "--", so check for it. run_args.slice!(0) if run_args[0] == '--' sh_cmd.push(*run_args) end sh(*sh_cmd) end end |