class Cukedep::FileAction
Attributes
delta[R]
patterns[RW]
Public Class Methods
new(thePatterns, aDelta = nil)
click to toggle source
Constructor.
- thePatterns
-
An array of file patterns.
# File lib/cukedep/file-action.rb, line 13 def initialize(thePatterns, aDelta = nil) @patterns = validate_file_patterns(thePatterns) @delta = validate_delta(aDelta) end
Public Instance Methods
==(other)
click to toggle source
Datavalue semantic: FileActions don't have identity
# File lib/cukedep/file-action.rb, line 19 def ==(other) return true if object_id == other.object_id return false if self.class != other.class attrs = %I[patterns delta] equality = true attrs.each do |accessor| equality = send(accessor) == other.send(accessor) break unless equality end return equality end
Protected Instance Methods
full_path(targetDir)
click to toggle source
Determine the complete target path complete target path = target dir + delta
# File lib/cukedep/file-action.rb, line 62 def full_path(targetDir) if delta.nil? result = Pathname.new(targetDir) else result = (Pathname.new(targetDir) + delta) end path = result.relative? ? result.expand_path : result return path.to_s end
validate_delta(aDelta)
click to toggle source
# File lib/cukedep/file-action.rb, line 48 def validate_delta(aDelta) case aDelta when NilClass then validated = nil when String validated = aDelta.empty? ? nil : aDelta else raise StandardError, "Invalid relative path #{aDelta}" end return validated end
validate_file_patterns(filePatterns)
click to toggle source
# File lib/cukedep/file-action.rb, line 36 def validate_file_patterns(filePatterns) err_msg = 'Expecting a list of file patterns' raise StandardError, err_msg unless filePatterns.is_a?(Array) filePatterns.each do |file_patt| err_msg = "Invalid value in list of file patterns: #{file_patt}" raise StandardError, err_msg unless file_patt.is_a?(String) end return filePatterns end