Class: ASRake::BaseExecutable
- Inherits:
-
Object
- Object
- ASRake::BaseExecutable
- Includes:
- Rake::DSL
- Defined in:
- lib/asrake/base_executable.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#output ⇒ Object
readonly
output file or directory.
-
#output_dir ⇒ Object
readonly
Returns the value of attribute output_dir.
-
#output_file ⇒ Object
readonly
Returns the value of attribute output_file.
Instance Method Summary collapse
- #execute ⇒ Object
-
#initialize(file) ⇒ BaseExecutable
constructor
A new instance of BaseExecutable.
- #merge_in(args) ⇒ Object
- #output_is_dir? ⇒ Boolean
-
#pathmap(*args) ⇒ Object
used so we can add this task to a FileList.
- #to_s ⇒ Object
- #to_str ⇒ Object
Constructor Details
#initialize(file) ⇒ BaseExecutable
Returns a new instance of BaseExecutable.
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/asrake/base_executable.rb', line 17 def initialize(file) raise "An output file must be provided" if file == nil @output = file.to_s # if the output path ends in a path separator, it is a directory if @output =~ /[\/\\]$/ @output_dir = @output else # forward-slashes required for File methods @output = Path::forward @output @output_dir = File.dirname(@output) @output_file = File.basename(@output) end # create file task for output @task = ASRake::ExeTask.define_task self.output do self.execute end @task.pre_invoke = method(:task_pre_invoke) @task.post_invoke = method(:task_post_invoke) # create directory task for output if !self.output_is_dir? directory self.output_dir @task.enhance([self.output_dir]) end end |
Instance Attribute Details
#output ⇒ Object (readonly)
output file or directory
13 14 15 |
# File 'lib/asrake/base_executable.rb', line 13 def output @output end |
#output_dir ⇒ Object (readonly)
Returns the value of attribute output_dir.
15 16 17 |
# File 'lib/asrake/base_executable.rb', line 15 def output_dir @output_dir end |
#output_file ⇒ Object (readonly)
Returns the value of attribute output_file.
14 15 16 |
# File 'lib/asrake/base_executable.rb', line 14 def output_file @output_file end |
Instance Method Details
#execute ⇒ Object
71 72 73 |
# File 'lib/asrake/base_executable.rb', line 71 def execute raise "Must define execute in subclass" end |
#merge_in(args) ⇒ Object
51 52 53 54 55 56 |
# File 'lib/asrake/base_executable.rb', line 51 def merge_in(args) @@args.each do |arg| # TODO: This needs to concat arrays not overwite them self.send("#{arg}=", args.send(arg)) end end |
#output_is_dir? ⇒ Boolean
47 48 49 |
# File 'lib/asrake/base_executable.rb', line 47 def output_is_dir? output_file == nil end |
#pathmap(*args) ⇒ Object
used so we can add this task to a FileList. This is probably a terrible idea.
67 68 69 |
# File 'lib/asrake/base_executable.rb', line 67 def pathmap *args to_s.pathmap *args end |
#to_s ⇒ Object
58 59 60 |
# File 'lib/asrake/base_executable.rb', line 58 def to_s @output end |
#to_str ⇒ Object
62 63 64 |
# File 'lib/asrake/base_executable.rb', line 62 def to_str @output end |