typestrict 0.0.9 → 0.0.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. data/lib/supertypes.rb +10 -5
  2. data/lib/typestrict.rb +1 -1
  3. metadata +4 -4
data/lib/supertypes.rb CHANGED
@@ -51,6 +51,12 @@ module Strict
51
51
  enforce_primitive!(Proc, data, context)
52
52
  end
53
53
 
54
+ @@handlers[:hex_color] = proc do |data, context|
55
+ enforce!(:string, data, context)
56
+ catch_error "#{header(context, data)} must be six characters long" unless (data.size == 6)
57
+ data.upcase.each_byte {|c| catch_error "#{header(context, data)} must contain only hexadecimal characters" unless ((48 <= c and c <= 57) or (65 <= c and c <= 70))}
58
+ end
59
+
54
60
  @@handlers[:string_array] = proc do |data, context|
55
61
  enforce_primitive!(Array, data, context)
56
62
  data.each {|item| enforce_primitive!(String, item, context)}
@@ -66,15 +72,14 @@ module Strict
66
72
  data.each {|item| enforce_primitive!(Float, item, context)}
67
73
  end
68
74
 
69
- @@handlers[ :integer_array] = proc do |data, context|
75
+ @@handlers[:integer_array] = proc do |data, context|
70
76
  enforce_primitive!(Array, data, context)
71
77
  data.each {|item| enforce_primitive!(Fixnum, item, context)}
72
78
  end
73
79
 
74
- @@handlers[:hex_color] = proc do |data, context|
75
- enforce!(:string, data, context)
76
- catch_error "#{header(context, data)} must be six characters long" unless (data.size == 6)
77
- data.upcase.each_byte {|c| catch_error "#{header(context, data)} must contain only hexadecimal characters" unless ((48 <= c and c <= 57) or (65 <= c and c <= 70))}
80
+ @@handlers[:hex_color_array] = proc do |data, context|
81
+ enforce_primitive!(Array, data)
82
+ data.each {|item| enforce!(:hex_color, item)}
78
83
  end
79
84
 
80
85
  @@handlers.each do |supertype, handler|
data/lib/typestrict.rb CHANGED
@@ -2,7 +2,7 @@ require File.join(File.dirname(__FILE__), 'base')
2
2
  require File.join(File.dirname(__FILE__), 'supertypes')
3
3
 
4
4
  module Strict
5
- VERSION = '0.0.9'
5
+ VERSION = '0.0.10'
6
6
  include Strict::Base
7
7
  include Strict::SuperTypes
8
8
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: typestrict
3
3
  version: !ruby/object:Gem::Version
4
- hash: 13
4
+ hash: 11
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 9
10
- version: 0.0.9
9
+ - 10
10
+ version: 0.0.10
11
11
  platform: ruby
12
12
  authors:
13
13
  - Raeez Lorgat
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-08-09 00:00:00 -04:00
18
+ date: 2010-08-12 00:00:00 -04:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency