jschematic 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (61) hide show
  1. data/.rspec +1 -0
  2. data/.rvmrc +1 -0
  3. data/Gemfile +2 -0
  4. data/Gemfile.lock +40 -0
  5. data/LICENSE +20 -0
  6. data/README.md +48 -0
  7. data/Rakefile +10 -0
  8. data/cucumber.yml +1 -0
  9. data/features/default.feature +72 -0
  10. data/features/dependencies.feature +73 -0
  11. data/features/enum.feature +26 -0
  12. data/features/format.feature +40 -0
  13. data/features/id.feature +75 -0
  14. data/features/items.feature +90 -0
  15. data/features/min_length_max_length.feature +20 -0
  16. data/features/minimum_maximum.feature +29 -0
  17. data/features/pattern.feature +6 -0
  18. data/features/pattern_properties.feature +18 -0
  19. data/features/properties.feature +124 -0
  20. data/features/required.feature +42 -0
  21. data/features/step_definitions/jschematic_steps.rb +62 -0
  22. data/features/support/env.rb +6 -0
  23. data/features/type.feature +76 -0
  24. data/jschematic.gemspec +22 -0
  25. data/lib/jschematic/attributes/additional_items.rb +35 -0
  26. data/lib/jschematic/attributes/additional_properties.rb +28 -0
  27. data/lib/jschematic/attributes/dependencies.rb +26 -0
  28. data/lib/jschematic/attributes/enum.rb +18 -0
  29. data/lib/jschematic/attributes/exclusive_maximum.rb +21 -0
  30. data/lib/jschematic/attributes/exclusive_minimum.rb +21 -0
  31. data/lib/jschematic/attributes/format.rb +56 -0
  32. data/lib/jschematic/attributes/items.rb +24 -0
  33. data/lib/jschematic/attributes/max_items.rb +18 -0
  34. data/lib/jschematic/attributes/max_length.rb +18 -0
  35. data/lib/jschematic/attributes/maximum.rb +22 -0
  36. data/lib/jschematic/attributes/min_items.rb +18 -0
  37. data/lib/jschematic/attributes/min_length.rb +18 -0
  38. data/lib/jschematic/attributes/minimum.rb +22 -0
  39. data/lib/jschematic/attributes/pattern.rb +18 -0
  40. data/lib/jschematic/attributes/pattern_properties.rb +23 -0
  41. data/lib/jschematic/attributes/properties.rb +38 -0
  42. data/lib/jschematic/attributes/required.rb +28 -0
  43. data/lib/jschematic/attributes/type.rb +61 -0
  44. data/lib/jschematic/attributes/unique_items.rb +18 -0
  45. data/lib/jschematic/attributes.rb +28 -0
  46. data/lib/jschematic/element.rb +25 -0
  47. data/lib/jschematic/errors.rb +34 -0
  48. data/lib/jschematic/schema.rb +77 -0
  49. data/lib/jschematic/validation_error.rb +13 -0
  50. data/lib/jschematic.rb +13 -0
  51. data/spec/jschematic/attributes/enum_spec.rb +14 -0
  52. data/spec/jschematic/attributes/max_items_spec.rb +15 -0
  53. data/spec/jschematic/attributes/min_items_spec.rb +15 -0
  54. data/spec/jschematic/attributes/minimum_maximum_spec.rb +33 -0
  55. data/spec/jschematic/attributes/required_spec.rb +29 -0
  56. data/spec/jschematic/attributes/type_spec.rb +63 -0
  57. data/spec/jschematic/attributes_spec.rb +12 -0
  58. data/spec/jschematic/errors_spec.rb +43 -0
  59. data/spec/jschematic/schema_spec.rb +58 -0
  60. data/spec/spec_helper.rb +16 -0
  61. metadata +199 -0
@@ -0,0 +1,58 @@
1
+ require 'spec_helper'
2
+
3
+ module Jschematic
4
+ describe Schema do
5
+ describe "#required?" do
6
+ it "answers whether when one of its contained elements is required" do
7
+ Schema.new({ "required" => true }).should be_required
8
+ Schema.new({ "required" => false }).should_not be_required
9
+ end
10
+ end
11
+
12
+ describe "#title" do
13
+ it "is taken from the raw schema" do
14
+ title = Schema.new({ "title" => "An hero" }).title
15
+ title.should == "An hero"
16
+ end
17
+
18
+ it "defaults to an empty string" do
19
+ title = Schema.new({}).title
20
+ title.should == ""
21
+ end
22
+ end
23
+
24
+ describe "#description" do
25
+ it "is taken from the raw schema" do
26
+ description = Schema.new({ "description" => "A lengthy diatribe on corn futures" }).description
27
+ description.should == "A lengthy diatribe on corn futures"
28
+ end
29
+
30
+ it "defaults to an empty string" do
31
+ description = Schema.new({}).description
32
+ description.should == ""
33
+ end
34
+ end
35
+ end
36
+
37
+ class Parent
38
+ attr_reader :id
39
+ def initialize(opts)
40
+ @id = opts["id"]
41
+ @children = []
42
+ end
43
+
44
+ def add_child(child)
45
+ child.parent = self
46
+ @children << child
47
+ end
48
+ end
49
+
50
+ describe Schema, "as a child element" do
51
+ it "builds its id from its parent" do
52
+ parent = Parent.new("id" => "http://www.example.com/parent/")
53
+ schema = Schema.new("id" => "child")
54
+ parent.add_child(schema)
55
+ schema.id.should == "http://www.example.com/parent/child"
56
+ end
57
+ end
58
+ end
@@ -0,0 +1,16 @@
1
+ require 'bundler'
2
+ Bundler.setup
3
+
4
+ require 'rspec'
5
+ require 'jschematic'
6
+
7
+ RSpec::Matchers.define :accept do |instance_value|
8
+ match do |validator|
9
+ begin
10
+ validator.accepts?(instance_value)
11
+ rescue Jschematic::ValidationError
12
+ false
13
+ end
14
+ end
15
+ end
16
+
metadata ADDED
@@ -0,0 +1,199 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: jschematic
3
+ version: !ruby/object:Gem::Version
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 0
8
+ - 1
9
+ version: 0.0.1
10
+ platform: ruby
11
+ authors:
12
+ - Mike Sassak
13
+ autorequire:
14
+ bindir: bin
15
+ cert_chain: []
16
+
17
+ date: 2011-02-21 00:00:00 -06:00
18
+ default_executable:
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
21
+ name: addressable
22
+ prerelease: false
23
+ requirement: &id001 !ruby/object:Gem::Requirement
24
+ none: false
25
+ requirements:
26
+ - - ">="
27
+ - !ruby/object:Gem::Version
28
+ segments:
29
+ - 0
30
+ version: "0"
31
+ type: :runtime
32
+ version_requirements: *id001
33
+ - !ruby/object:Gem::Dependency
34
+ name: cucumber
35
+ prerelease: false
36
+ requirement: &id002 !ruby/object:Gem::Requirement
37
+ none: false
38
+ requirements:
39
+ - - ">="
40
+ - !ruby/object:Gem::Version
41
+ segments:
42
+ - 0
43
+ version: "0"
44
+ type: :development
45
+ version_requirements: *id002
46
+ - !ruby/object:Gem::Dependency
47
+ name: rspec
48
+ prerelease: false
49
+ requirement: &id003 !ruby/object:Gem::Requirement
50
+ none: false
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ segments:
55
+ - 0
56
+ version: "0"
57
+ type: :development
58
+ version_requirements: *id003
59
+ - !ruby/object:Gem::Dependency
60
+ name: yajl-ruby
61
+ prerelease: false
62
+ requirement: &id004 !ruby/object:Gem::Requirement
63
+ none: false
64
+ requirements:
65
+ - - ">="
66
+ - !ruby/object:Gem::Version
67
+ segments:
68
+ - 0
69
+ version: "0"
70
+ type: :development
71
+ version_requirements: *id004
72
+ description: JSON Schema v3 Validator
73
+ email: msassak@gmail.com
74
+ executables: []
75
+
76
+ extensions: []
77
+
78
+ extra_rdoc_files:
79
+ - LICENSE
80
+ - README.md
81
+ files:
82
+ - .rspec
83
+ - .rvmrc
84
+ - Gemfile
85
+ - Gemfile.lock
86
+ - LICENSE
87
+ - README.md
88
+ - Rakefile
89
+ - cucumber.yml
90
+ - features/default.feature
91
+ - features/dependencies.feature
92
+ - features/enum.feature
93
+ - features/format.feature
94
+ - features/id.feature
95
+ - features/items.feature
96
+ - features/min_length_max_length.feature
97
+ - features/minimum_maximum.feature
98
+ - features/pattern.feature
99
+ - features/pattern_properties.feature
100
+ - features/properties.feature
101
+ - features/required.feature
102
+ - features/step_definitions/jschematic_steps.rb
103
+ - features/support/env.rb
104
+ - features/type.feature
105
+ - jschematic.gemspec
106
+ - lib/jschematic.rb
107
+ - lib/jschematic/attributes.rb
108
+ - lib/jschematic/attributes/additional_items.rb
109
+ - lib/jschematic/attributes/additional_properties.rb
110
+ - lib/jschematic/attributes/dependencies.rb
111
+ - lib/jschematic/attributes/enum.rb
112
+ - lib/jschematic/attributes/exclusive_maximum.rb
113
+ - lib/jschematic/attributes/exclusive_minimum.rb
114
+ - lib/jschematic/attributes/format.rb
115
+ - lib/jschematic/attributes/items.rb
116
+ - lib/jschematic/attributes/max_items.rb
117
+ - lib/jschematic/attributes/max_length.rb
118
+ - lib/jschematic/attributes/maximum.rb
119
+ - lib/jschematic/attributes/min_items.rb
120
+ - lib/jschematic/attributes/min_length.rb
121
+ - lib/jschematic/attributes/minimum.rb
122
+ - lib/jschematic/attributes/pattern.rb
123
+ - lib/jschematic/attributes/pattern_properties.rb
124
+ - lib/jschematic/attributes/properties.rb
125
+ - lib/jschematic/attributes/required.rb
126
+ - lib/jschematic/attributes/type.rb
127
+ - lib/jschematic/attributes/unique_items.rb
128
+ - lib/jschematic/element.rb
129
+ - lib/jschematic/errors.rb
130
+ - lib/jschematic/schema.rb
131
+ - lib/jschematic/validation_error.rb
132
+ - spec/jschematic/attributes/enum_spec.rb
133
+ - spec/jschematic/attributes/max_items_spec.rb
134
+ - spec/jschematic/attributes/min_items_spec.rb
135
+ - spec/jschematic/attributes/minimum_maximum_spec.rb
136
+ - spec/jschematic/attributes/required_spec.rb
137
+ - spec/jschematic/attributes/type_spec.rb
138
+ - spec/jschematic/attributes_spec.rb
139
+ - spec/jschematic/errors_spec.rb
140
+ - spec/jschematic/schema_spec.rb
141
+ - spec/spec_helper.rb
142
+ has_rdoc: true
143
+ homepage: https://github.com/msassak/jschematic
144
+ licenses: []
145
+
146
+ post_install_message:
147
+ rdoc_options:
148
+ - --charset=UTF-8
149
+ require_paths:
150
+ - lib
151
+ required_ruby_version: !ruby/object:Gem::Requirement
152
+ none: false
153
+ requirements:
154
+ - - ">="
155
+ - !ruby/object:Gem::Version
156
+ segments:
157
+ - 0
158
+ version: "0"
159
+ required_rubygems_version: !ruby/object:Gem::Requirement
160
+ none: false
161
+ requirements:
162
+ - - ">="
163
+ - !ruby/object:Gem::Version
164
+ segments:
165
+ - 0
166
+ version: "0"
167
+ requirements: []
168
+
169
+ rubyforge_project:
170
+ rubygems_version: 1.3.7
171
+ signing_key:
172
+ specification_version: 3
173
+ summary: jschematic 0.0.1
174
+ test_files:
175
+ - features/default.feature
176
+ - features/dependencies.feature
177
+ - features/enum.feature
178
+ - features/format.feature
179
+ - features/id.feature
180
+ - features/items.feature
181
+ - features/min_length_max_length.feature
182
+ - features/minimum_maximum.feature
183
+ - features/pattern.feature
184
+ - features/pattern_properties.feature
185
+ - features/properties.feature
186
+ - features/required.feature
187
+ - features/step_definitions/jschematic_steps.rb
188
+ - features/support/env.rb
189
+ - features/type.feature
190
+ - spec/jschematic/attributes/enum_spec.rb
191
+ - spec/jschematic/attributes/max_items_spec.rb
192
+ - spec/jschematic/attributes/min_items_spec.rb
193
+ - spec/jschematic/attributes/minimum_maximum_spec.rb
194
+ - spec/jschematic/attributes/required_spec.rb
195
+ - spec/jschematic/attributes/type_spec.rb
196
+ - spec/jschematic/attributes_spec.rb
197
+ - spec/jschematic/errors_spec.rb
198
+ - spec/jschematic/schema_spec.rb
199
+ - spec/spec_helper.rb