Sha256: a7c2b0a060aa56ad13733d03144d856dea4d73637d2793d1e6b9b24d11b50957
Contents?: true
Size: 1.39 KB
Versions: 3
Compression:
Stored size: 1.39 KB
Contents
class Checked class Demand class Strings < Sinatra::Base include Checked::Arch map '/string!' get def check! case return! when String return! when StringIO target.rewind return! target.readlines target.rewind return! else demand false, "...must be a String or StringIO." end end get def include! demand return![matcher], "...must contain: #{matcher.inspect}" end get def exclude! matcher demand !(return![matcher]), "...can't contain #{matcher.inspect}" end get def matches_only! invalid = return!.gsub(matcher, '') demand invalid.empty?, "...has invalid characters: #{str.inspect}" end get def not_empty! demand !(return!.strip.empty?), "...can't be empty." end get def file_read! return!.gsub("\r\n", "\n") end get def new_content! not_empty! file_read! end get def file_content! new_content! end get def hostname! invalid = return![ %r!([^\dA-Za-z_-]+)! ] demand !invalid, "...has invalid characters: #{$1.inspect}" end end # === class String end # === class Demand end # === class Checked
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
Checked-2.0.2 | lib/Checked/Demand/Strings.rb |
Checked-2.0.1 | lib/Checked/Demand/Strings.rb |
Checked-2.0.0 | lib/Checked/Demand/Strings.rb |