classy_hash 0.1.1 → 0.1.2

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.
checksums.yaml CHANGED
@@ -1,7 +1,15 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 9462ba9bbda68a8f041537f21350db0341030dfd
4
- data.tar.gz: bc4645ff1e3da6c864c96de07930130b32723ede
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ MzM1YTFiM2EwOWQ2OTMyZThhODMxZTgyMWRkMGI5MmMyMzJiY2UyMQ==
5
+ data.tar.gz: !binary |-
6
+ NGE0MDdjNWJhNWRmZDM4OTRiZWVhYzRhNDVjNzdjMmFlZDM0NmQyYg==
5
7
  SHA512:
6
- metadata.gz: 1cd58d6a703ddbd622c412c3d826b048a188af021deff0e9c0e02e53568315103473889ffcc5d1657da207a9f1184886e47758bdf7ab24e904f3856cae59a9e8
7
- data.tar.gz: df4c9a612073aa3a437b9d9b003f8394dfd14e6a9ffbc843701ae21d5ae78c4f97cd7330b9f3391b8ac10f656778f3eeaf3f3251e8217910c33646d5a47ac0b7
8
+ metadata.gz: !binary |-
9
+ ZWRhMTYzZGJlMDVkMDA0N2NjMTk5MTlkODQ3MmM4OWNlMmNlMGFlZGIwZmUz
10
+ YTMwYzY2N2Y4Mzc1ZDQ1MmI3OGY5NDkzM2U0Y2NmZjc1MjRlMTEyYzE3M2Q5
11
+ MTJhZjkxMjdkMzM0MmZmYjU4NzQyNDg0YWJkNThlODNjYThjZGQ=
12
+ data.tar.gz: !binary |-
13
+ MGIxOTkyMTZmMDExYzYwZGI5ZGYwNmY0YTg4YmE2ZjI0OThlZTYxNTYyYzQx
14
+ OGE2NDcxYTk4ZDVjYjc0ZDg4YTFiYmZiMGY4OTU4NmNhMTRmNGNhNDc1N2Q5
15
+ MGYyNGJlOTBmMDk5MDhmMDhlNzk5MTVlMjA0MTY1OGViMWM3ZTg=
data/lib/classy_hash.rb CHANGED
@@ -68,7 +68,7 @@ module ClassyHash
68
68
  end
69
69
 
70
70
  # Generates a semi-compact String describing the given +constraints+.
71
- def self.multiconstraint_string constraints
71
+ def self.multiconstraint_string(constraints)
72
72
  constraints.map{|c|
73
73
  if c.is_a?(Hash)
74
74
  "{...schema...}"
@@ -161,3 +161,7 @@ module ClassyHash
161
161
  end
162
162
 
163
163
  require 'classy_hash/generate'
164
+
165
+ if !Kernel.const_defined?(:CH)
166
+ CH = ClassyHash
167
+ end
@@ -1,3 +1,5 @@
1
+ # Classy Hash extended validation generators
2
+ # Copyright (C)2014 Deseret Book
1
3
 
2
4
  module ClassyHash
3
5
  # This module contains helpers that generate constraints for common
@@ -11,7 +13,7 @@ module ClassyHash
11
13
  # a: ClassyHash::Generate.enum(1, 2, 3, 4)
12
14
  # }
13
15
  # ClassyHash.validate({ a: 1 }, schema)
14
- def self.enum *args
16
+ def self.enum(*args)
15
17
  lambda {|v|
16
18
  args.include?(v) || "an element of #{args.inspect}"
17
19
  }
@@ -27,7 +29,7 @@ module ClassyHash
27
29
  # }
28
30
  # ClassyHash.validate({a: '12345'}, schema)
29
31
  # ClassyHash.validate({a: [1, 2, 3, 4, 5]}, schema)
30
- def self.length length
32
+ def self.length(length)
31
33
  raise "length must be an Integer or a Range" unless length.is_a?(Integer) || length.is_a?(Range)
32
34
 
33
35
  if length.is_a?(Range) && !(length.min.is_a?(Integer) && length.max.is_a?(Integer))
@@ -55,7 +57,7 @@ module ClassyHash
55
57
  # a: ClassyHash::Generate.array_length(4..5, Integer, String)
56
58
  # }
57
59
  # ClassyHash.validate({ a: [ 1, 2, 3, 'four', 5 ] }, schema)
58
- def self.array_length length, *constraints
60
+ def self.array_length(length, *constraints)
59
61
  raise 'one or more constraints must be provided' if constraints.empty?
60
62
 
61
63
  length_lambda = self.length(length)
@@ -87,7 +89,7 @@ module ClassyHash
87
89
  # a: ClassyHash::Generate.string_length(3)
88
90
  # }
89
91
  # ClassyHash.validate({a: '123'}, schema)
90
- def self.string_length length
92
+ def self.string_length(length)
91
93
  length_lambda = self.length(length)
92
94
  msg = "a String of length #{length}"
93
95
 
@@ -100,4 +102,7 @@ module ClassyHash
100
102
  }
101
103
  end
102
104
  end
105
+
106
+ # Shortcut to ClassyHash::Generate
107
+ G = Generate
103
108
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: classy_hash
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Deseret Book
@@ -9,12 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-06-03 00:00:00.000000000 Z
12
+ date: 2014-08-09 00:00:00.000000000 Z
13
13
  dependencies: []
14
- description: |2
15
- Classy Hash is a schema validator for Ruby Hashes. You provide a simple
16
- schema Hash, and Classy Hash will make sure your data matches, providing
17
- helpful error messages if it doesn't.
14
+ description: ! " Classy Hash is a schema validator for Ruby Hashes. You provide
15
+ a simple\n schema Hash, and Classy Hash will make sure your data matches, providing\n
16
+ \ helpful error messages if it doesn't.\n"
18
17
  email: mike@mikebourgeous.com
19
18
  executables: []
20
19
  extensions: []
@@ -32,18 +31,19 @@ require_paths:
32
31
  - lib
33
32
  required_ruby_version: !ruby/object:Gem::Requirement
34
33
  requirements:
35
- - - ">="
34
+ - - ! '>='
36
35
  - !ruby/object:Gem::Version
37
- version: '0'
36
+ version: 1.9.3
38
37
  required_rubygems_version: !ruby/object:Gem::Requirement
39
38
  requirements:
40
- - - ">="
39
+ - - ! '>='
41
40
  - !ruby/object:Gem::Version
42
41
  version: '0'
43
42
  requirements: []
44
43
  rubyforge_project:
45
- rubygems_version: 2.2.2
44
+ rubygems_version: 2.2.1
46
45
  signing_key:
47
46
  specification_version: 4
48
- summary: 'Classy Hash: Keep your Hashes classy; a Hash schema validator'
47
+ summary: ! 'Classy Hash: Keep your Hashes classy; a Hash schema validator'
49
48
  test_files: []
49
+ has_rdoc: