Sha256: 142bed5b79a8304b07a61af8c15d38cfb21baa8ccf501292f8dcb112fcbf6dc1

Contents?: true

Size: 1.37 KB

Versions: 2

Compression:

Stored size: 1.37 KB

Contents

module Checked
  class Demand
    class Strings

      include Uni_Arch::Base
      include Demand::Base
      namespace '/string!'
      
      route
      def check!
        case target
        when String
        when StringIO
          target.rewind
          request.response.body= target.readlines
          target.rewind
        else
          fail! "...must be a String or StringIO"
        end
      end

      route
      def include!
        included = target[matcher]
        return true if included
        fail!("...must contain: #{matcher.inspect}")
      end

      route
      def exclude! matcher
        raise_e = val[matcher]
        return true unless raise_e
        fail!("...can't contain #{matcher.inspect}")
      end

      route
      def matches_only!
        str = target.gsub(matcher, '')
        if !str.empty?
          fail!( "...has invalid characters: #{str.inspect}" ) 
        end
      end

      route
      def not_empty!
        if target.strip.empty? 
          fail!("...can't be empty.") 
        end
      end

      route
      def file_read!
        request.response.body= target.gsub("\r\n", "\n")
      end
      
      route
      def new_content!
        not_empty!   
        file_read!
      end

      route
      def file_content! 
        new_content!
      end

    end # === class String
  end # === class Demand
end # === module Checked

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
Checked-1.2.1 lib/Checked/Demand/Strings.rb
Checked-1.2.0 lib/Checked/Demand/Strings.rb