duck-hunt 0.0.3

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 (63) hide show
  1. data/LICENSE +20 -0
  2. data/README.md +526 -0
  3. data/Rakefile +15 -0
  4. data/lib/duck-hunt.rb +17 -0
  5. data/lib/duck-hunt/hash_helpers.rb +28 -0
  6. data/lib/duck-hunt/properties.rb +13 -0
  7. data/lib/duck-hunt/properties/array.rb +81 -0
  8. data/lib/duck-hunt/properties/boolean.rb +10 -0
  9. data/lib/duck-hunt/properties/float.rb +10 -0
  10. data/lib/duck-hunt/properties/integer.rb +9 -0
  11. data/lib/duck-hunt/properties/nested_hash.rb +61 -0
  12. data/lib/duck-hunt/properties/nil.rb +15 -0
  13. data/lib/duck-hunt/properties/property.rb +85 -0
  14. data/lib/duck-hunt/properties/string.rb +10 -0
  15. data/lib/duck-hunt/properties/validator_lookup.rb +27 -0
  16. data/lib/duck-hunt/schemas.rb +8 -0
  17. data/lib/duck-hunt/schemas/array_schema.rb +254 -0
  18. data/lib/duck-hunt/schemas/hash_schema.rb +135 -0
  19. data/lib/duck-hunt/schemas/property_lookup.rb +32 -0
  20. data/lib/duck-hunt/schemas/schema_definition.rb +25 -0
  21. data/lib/duck-hunt/string_helpers.rb +25 -0
  22. data/lib/duck-hunt/validators.rb +16 -0
  23. data/lib/duck-hunt/validators/accepted_values.rb +19 -0
  24. data/lib/duck-hunt/validators/divisible_by.rb +19 -0
  25. data/lib/duck-hunt/validators/equal_to.rb +19 -0
  26. data/lib/duck-hunt/validators/greater_than.rb +19 -0
  27. data/lib/duck-hunt/validators/greater_than_or_equal_to.rb +19 -0
  28. data/lib/duck-hunt/validators/less_than.rb +19 -0
  29. data/lib/duck-hunt/validators/less_than_or_equal_to.rb +19 -0
  30. data/lib/duck-hunt/validators/matches.rb +18 -0
  31. data/lib/duck-hunt/validators/not_divisible_by.rb +19 -0
  32. data/lib/duck-hunt/validators/not_equal_to.rb +19 -0
  33. data/lib/duck-hunt/validators/rejected_values.rb +19 -0
  34. data/lib/duck-hunt/validators/validator.rb +16 -0
  35. data/lib/duck-hunt/version.rb +3 -0
  36. data/test/properties/array_test.rb +837 -0
  37. data/test/properties/boolean_test.rb +37 -0
  38. data/test/properties/float_test.rb +49 -0
  39. data/test/properties/integer_test.rb +48 -0
  40. data/test/properties/nested_hash_test.rb +465 -0
  41. data/test/properties/nil_test.rb +30 -0
  42. data/test/properties/property_test.rb +193 -0
  43. data/test/properties/string_test.rb +24 -0
  44. data/test/properties/validator_lookup_test.rb +25 -0
  45. data/test/schemas/array_schema_test.rb +797 -0
  46. data/test/schemas/hash_schema_test.rb +264 -0
  47. data/test/schemas/property_lookup_test.rb +41 -0
  48. data/test/schemas/schema_definition_test.rb +51 -0
  49. data/test/test_helper.rb +29 -0
  50. data/test/test_helper/test_classes.rb +74 -0
  51. data/test/validators/accepted_values_test.rb +46 -0
  52. data/test/validators/divisible_by_test.rb +38 -0
  53. data/test/validators/equal_to_test.rb +38 -0
  54. data/test/validators/greater_than_or_equal_to_test.rb +39 -0
  55. data/test/validators/greater_than_test.rb +39 -0
  56. data/test/validators/less_than_or_equal_to_test.rb +40 -0
  57. data/test/validators/less_than_test.rb +39 -0
  58. data/test/validators/matches_test.rb +43 -0
  59. data/test/validators/not_divisible_by_test.rb +38 -0
  60. data/test/validators/not_equal_to_test.rb +38 -0
  61. data/test/validators/rejected_values_test.rb +46 -0
  62. data/test/validators/validator_test.rb +23 -0
  63. metadata +196 -0
@@ -0,0 +1,23 @@
1
+ require File.expand_path('../../test_helper', __FILE__)
2
+
3
+ describe DuckHunt::Validators::Validator, "initialization" do
4
+ it "should allow an instance to be created with any number of arguments" do
5
+ DuckHunt::Validators::Validator.new("hello", "world")
6
+ end
7
+ end
8
+
9
+ describe DuckHunt::Validators::Validator, "methods to be defined in subclasses" do
10
+ it "raise NotImplementedError if valid? has not been defined" do
11
+ validator = DuckHunt::Validators::Validator.new
12
+ lambda{
13
+ validator.valid?("test")
14
+ }.must_raise(NotImplementedError)
15
+ end
16
+
17
+ it "raise NotImplementedError if valid? has not been defined" do
18
+ validator = DuckHunt::Validators::Validator.new
19
+ lambda{
20
+ validator.error_message
21
+ }.must_raise(NotImplementedError)
22
+ end
23
+ end
metadata ADDED
@@ -0,0 +1,196 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: duck-hunt
3
+ version: !ruby/object:Gem::Version
4
+ hash: 25
5
+ prerelease:
6
+ segments:
7
+ - 0
8
+ - 0
9
+ - 3
10
+ version: 0.0.3
11
+ platform: ruby
12
+ authors:
13
+ - Thomas Cannon
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2014-07-12 00:00:00 -04:00
19
+ default_executable:
20
+ dependencies:
21
+ - !ruby/object:Gem::Dependency
22
+ name: minitest
23
+ prerelease: false
24
+ requirement: &id001 !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ hash: 3
30
+ segments:
31
+ - 0
32
+ version: "0"
33
+ type: :development
34
+ version_requirements: *id001
35
+ - !ruby/object:Gem::Dependency
36
+ name: mocha
37
+ prerelease: false
38
+ requirement: &id002 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ">="
42
+ - !ruby/object:Gem::Version
43
+ hash: 3
44
+ segments:
45
+ - 0
46
+ version: "0"
47
+ type: :development
48
+ version_requirements: *id002
49
+ - !ruby/object:Gem::Dependency
50
+ name: rake
51
+ prerelease: false
52
+ requirement: &id003 !ruby/object:Gem::Requirement
53
+ none: false
54
+ requirements:
55
+ - - ">="
56
+ - !ruby/object:Gem::Version
57
+ hash: 3
58
+ segments:
59
+ - 0
60
+ version: "0"
61
+ type: :development
62
+ version_requirements: *id003
63
+ description: Dependency-free object validation library for Ruby 1.8.7+
64
+ email:
65
+ - hello@thomascannon.me
66
+ executables: []
67
+
68
+ extensions: []
69
+
70
+ extra_rdoc_files: []
71
+
72
+ files:
73
+ - lib/duck-hunt/hash_helpers.rb
74
+ - lib/duck-hunt/properties/array.rb
75
+ - lib/duck-hunt/properties/boolean.rb
76
+ - lib/duck-hunt/properties/float.rb
77
+ - lib/duck-hunt/properties/integer.rb
78
+ - lib/duck-hunt/properties/nested_hash.rb
79
+ - lib/duck-hunt/properties/nil.rb
80
+ - lib/duck-hunt/properties/property.rb
81
+ - lib/duck-hunt/properties/string.rb
82
+ - lib/duck-hunt/properties/validator_lookup.rb
83
+ - lib/duck-hunt/properties.rb
84
+ - lib/duck-hunt/schemas/array_schema.rb
85
+ - lib/duck-hunt/schemas/hash_schema.rb
86
+ - lib/duck-hunt/schemas/property_lookup.rb
87
+ - lib/duck-hunt/schemas/schema_definition.rb
88
+ - lib/duck-hunt/schemas.rb
89
+ - lib/duck-hunt/string_helpers.rb
90
+ - lib/duck-hunt/validators/accepted_values.rb
91
+ - lib/duck-hunt/validators/divisible_by.rb
92
+ - lib/duck-hunt/validators/equal_to.rb
93
+ - lib/duck-hunt/validators/greater_than.rb
94
+ - lib/duck-hunt/validators/greater_than_or_equal_to.rb
95
+ - lib/duck-hunt/validators/less_than.rb
96
+ - lib/duck-hunt/validators/less_than_or_equal_to.rb
97
+ - lib/duck-hunt/validators/matches.rb
98
+ - lib/duck-hunt/validators/not_divisible_by.rb
99
+ - lib/duck-hunt/validators/not_equal_to.rb
100
+ - lib/duck-hunt/validators/rejected_values.rb
101
+ - lib/duck-hunt/validators/validator.rb
102
+ - lib/duck-hunt/validators.rb
103
+ - lib/duck-hunt/version.rb
104
+ - lib/duck-hunt.rb
105
+ - LICENSE
106
+ - Rakefile
107
+ - README.md
108
+ - test/properties/array_test.rb
109
+ - test/properties/boolean_test.rb
110
+ - test/properties/float_test.rb
111
+ - test/properties/integer_test.rb
112
+ - test/properties/nested_hash_test.rb
113
+ - test/properties/nil_test.rb
114
+ - test/properties/property_test.rb
115
+ - test/properties/string_test.rb
116
+ - test/properties/validator_lookup_test.rb
117
+ - test/schemas/array_schema_test.rb
118
+ - test/schemas/hash_schema_test.rb
119
+ - test/schemas/property_lookup_test.rb
120
+ - test/schemas/schema_definition_test.rb
121
+ - test/test_helper/test_classes.rb
122
+ - test/test_helper.rb
123
+ - test/validators/accepted_values_test.rb
124
+ - test/validators/divisible_by_test.rb
125
+ - test/validators/equal_to_test.rb
126
+ - test/validators/greater_than_or_equal_to_test.rb
127
+ - test/validators/greater_than_test.rb
128
+ - test/validators/less_than_or_equal_to_test.rb
129
+ - test/validators/less_than_test.rb
130
+ - test/validators/matches_test.rb
131
+ - test/validators/not_divisible_by_test.rb
132
+ - test/validators/not_equal_to_test.rb
133
+ - test/validators/rejected_values_test.rb
134
+ - test/validators/validator_test.rb
135
+ has_rdoc: true
136
+ homepage: https://github.com/LockeCole117/duck-hunt
137
+ licenses: []
138
+
139
+ post_install_message:
140
+ rdoc_options: []
141
+
142
+ require_paths:
143
+ - lib
144
+ required_ruby_version: !ruby/object:Gem::Requirement
145
+ none: false
146
+ requirements:
147
+ - - ">="
148
+ - !ruby/object:Gem::Version
149
+ hash: 3
150
+ segments:
151
+ - 0
152
+ version: "0"
153
+ required_rubygems_version: !ruby/object:Gem::Requirement
154
+ none: false
155
+ requirements:
156
+ - - ">="
157
+ - !ruby/object:Gem::Version
158
+ hash: 3
159
+ segments:
160
+ - 0
161
+ version: "0"
162
+ requirements: []
163
+
164
+ rubyforge_project:
165
+ rubygems_version: 1.6.2
166
+ signing_key:
167
+ specification_version: 3
168
+ summary: Dependency-free object validation library for Ruby 1.8.7+
169
+ test_files:
170
+ - test/properties/array_test.rb
171
+ - test/properties/boolean_test.rb
172
+ - test/properties/float_test.rb
173
+ - test/properties/integer_test.rb
174
+ - test/properties/nested_hash_test.rb
175
+ - test/properties/nil_test.rb
176
+ - test/properties/property_test.rb
177
+ - test/properties/string_test.rb
178
+ - test/properties/validator_lookup_test.rb
179
+ - test/schemas/array_schema_test.rb
180
+ - test/schemas/hash_schema_test.rb
181
+ - test/schemas/property_lookup_test.rb
182
+ - test/schemas/schema_definition_test.rb
183
+ - test/test_helper/test_classes.rb
184
+ - test/test_helper.rb
185
+ - test/validators/accepted_values_test.rb
186
+ - test/validators/divisible_by_test.rb
187
+ - test/validators/equal_to_test.rb
188
+ - test/validators/greater_than_or_equal_to_test.rb
189
+ - test/validators/greater_than_test.rb
190
+ - test/validators/less_than_or_equal_to_test.rb
191
+ - test/validators/less_than_test.rb
192
+ - test/validators/matches_test.rb
193
+ - test/validators/not_divisible_by_test.rb
194
+ - test/validators/not_equal_to_test.rb
195
+ - test/validators/rejected_values_test.rb
196
+ - test/validators/validator_test.rb