class Cukedep::ActionTriplet

An (file) action triplet combines three FileActions that are executed in sequence.

Attributes

copy_action[R]
delete_action[R]
save_action[R]

Public Class Methods

builtin(anEvent) click to toggle source

Retrieve the 'built-in' action triplet associated with the given event. Return nil if no triplet was found for the event.

# File lib/cukedep/file-action.rb, line 180
def self.builtin(anEvent)
  @@builtin_actions ||= {
    before_each: ActionTriplet.new(
      save_patterns: [],
      save_subdir: '',
      delete_patterns: ['*.feature'],
      delete_subdir: './features',
      copy_patterns: [],
      copy_subdir: './features'
    ),
    after_each: ActionTriplet.new(
      save_patterns: [],
      save_subdir: '',
      delete_patterns: ['*.feature'], # Remove feature files after the run
      delete_subdir: './features',
      copy_patterns: [],
      copy_subdir: ''
    )
  }

  return @@builtin_actions.fetch(anEvent, nil)
end
new(theActionSettings) click to toggle source
theActionSettings

An object that responds to the [] operator.

The argument of the operator must be: :save_patterns, :save_subdir, :delete_patterns, :delete_subdir, :copy_patterns, :copy_subdir

# File lib/cukedep/file-action.rb, line 154
def initialize(theActionSettings)
  @save_action = CopyAction.new(theActionSettings[:save_patterns],
                                theActionSettings[:save_subdir])
  @delete_action = DeleteAction.new(theActionSettings[:delete_patterns],
                                    theActionSettings[:delete_subdir])
  @copy_action = CopyAction.new(theActionSettings[:copy_patterns],
                                theActionSettings[:copy_subdir])
end

Public Instance Methods

==(other) click to toggle source
# File lib/cukedep/file-action.rb, line 163
def ==(other)
  return true if object_id == other.object_id

  return (save_action == other.save_action) &&
         (delete_action == other.delete_action) &&
         (copy_action == other.copy_action)
end
run!(currentDir, projectDir) click to toggle source

Launch the file actions in sequence.

# File lib/cukedep/file-action.rb, line 172
def run!(currentDir, projectDir)
  save_action.run!(projectDir, currentDir)
  delete_action.run!(projectDir)
  copy_action.run!(currentDir, projectDir)
end