Sha256: fde6b75d8fad931c5575cd57abec9b4327d319c5bf14a50143f5db8b6c72b89d

Contents?: true

Size: 932 Bytes

Versions: 1

Compression:

Stored size: 932 Bytes

Contents

module Checked
class Demand
module Mods
module File_Addresses

  def self.apply? d
    d.target.is_a?(String)
  end

  def hostname!
    string!
    not_empty!
    matches_only! %r![\dA-Za-z_-]!
  end

  def not_dir!
    string!
    not_empty!
    if File.directory?(target)
      fail! "...can't be a directory."
    end
  end

  def not_file!
    string!
    not_empty!
    if File.file?(target)
      fail! "...can't be a file."
    end
  end

  def dir_address!
    file_address!
  end

  def file_address!
    self.target= target.strip
    string!
    not_empty!
    if target[%r!([^a-zA-Z0-9\.\_\-\/~,]+)!]
      fail! "...has invalid characters: #{$1.inspect}"
    end
  end

  def file_read!
    self.target= target.gsub("\r\n", "\n")
  end

  def file_content! 
    string!
    not_empty!   
    file_read!
  end
      
end # === module File_Addresses
end # === module Mods
end # === class Demand
end # === module Checked

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
Checked-0.1.4 lib/Checked/Demand/Mods/File_Addresses.rb