rosebud 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (73) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +20 -0
  3. data/.rspec +2 -0
  4. data/.travis.yml +8 -0
  5. data/Gemfile +33 -0
  6. data/LICENSE.txt +22 -0
  7. data/README.md +145 -0
  8. data/Rakefile +10 -0
  9. data/lib/rosebud.rb +33 -0
  10. data/lib/rosebud/locale/en.yml +14 -0
  11. data/lib/rosebud/params_scope.rb +35 -0
  12. data/lib/rosebud/validations.rb +17 -0
  13. data/lib/rosebud/validations/presence_validator.rb +11 -0
  14. data/lib/rosebud/validations/regex_validator.rb +11 -0
  15. data/lib/rosebud/validations/type_validator.rb +29 -0
  16. data/lib/rosebud/validator.rb +9 -0
  17. data/lib/rosebud/version.rb +3 -0
  18. data/rosebud.gemspec +28 -0
  19. data/spec/dummy/.gitignore +16 -0
  20. data/spec/dummy/README.rdoc +28 -0
  21. data/spec/dummy/Rakefile +6 -0
  22. data/spec/dummy/app/assets/images/.keep +0 -0
  23. data/spec/dummy/app/assets/javascripts/application.js +16 -0
  24. data/spec/dummy/app/assets/stylesheets/application.css +13 -0
  25. data/spec/dummy/app/controllers/application_controller.rb +5 -0
  26. data/spec/dummy/app/controllers/concerns/.keep +0 -0
  27. data/spec/dummy/app/helpers/application_helper.rb +2 -0
  28. data/spec/dummy/app/mailers/.keep +0 -0
  29. data/spec/dummy/app/models/.keep +0 -0
  30. data/spec/dummy/app/models/concerns/.keep +0 -0
  31. data/spec/dummy/app/views/layouts/application.html.erb +14 -0
  32. data/spec/dummy/bin/bundle +3 -0
  33. data/spec/dummy/bin/rails +4 -0
  34. data/spec/dummy/bin/rake +4 -0
  35. data/spec/dummy/config.ru +4 -0
  36. data/spec/dummy/config/application.rb +28 -0
  37. data/spec/dummy/config/boot.rb +4 -0
  38. data/spec/dummy/config/database.yml +25 -0
  39. data/spec/dummy/config/environment.rb +5 -0
  40. data/spec/dummy/config/environments/development.rb +29 -0
  41. data/spec/dummy/config/environments/production.rb +80 -0
  42. data/spec/dummy/config/environments/test.rb +36 -0
  43. data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
  44. data/spec/dummy/config/initializers/filter_parameter_logging.rb +4 -0
  45. data/spec/dummy/config/initializers/inflections.rb +16 -0
  46. data/spec/dummy/config/initializers/mime_types.rb +5 -0
  47. data/spec/dummy/config/initializers/secret_token.rb +12 -0
  48. data/spec/dummy/config/initializers/session_store.rb +3 -0
  49. data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
  50. data/spec/dummy/config/locales/en.yml +23 -0
  51. data/spec/dummy/config/routes.rb +56 -0
  52. data/spec/dummy/db/seeds.rb +7 -0
  53. data/spec/dummy/lib/assets/.keep +0 -0
  54. data/spec/dummy/lib/tasks/.keep +0 -0
  55. data/spec/dummy/log/.keep +0 -0
  56. data/spec/dummy/public/404.html +58 -0
  57. data/spec/dummy/public/422.html +58 -0
  58. data/spec/dummy/public/500.html +57 -0
  59. data/spec/dummy/public/favicon.ico +0 -0
  60. data/spec/dummy/public/robots.txt +5 -0
  61. data/spec/dummy/vendor/assets/javascripts/.keep +0 -0
  62. data/spec/dummy/vendor/assets/stylesheets/.keep +0 -0
  63. data/spec/optional_spec.rb +37 -0
  64. data/spec/presence_validator_spec.rb +19 -0
  65. data/spec/regex_validator_spec.rb +11 -0
  66. data/spec/requires_spec.rb +32 -0
  67. data/spec/spec_helper.rb +32 -0
  68. data/spec/support/dummy_validator.rb +5 -0
  69. data/spec/support/invalid_subclass_validator.rb +2 -0
  70. data/spec/support/not_implemented_validator.rb +2 -0
  71. data/spec/type_validator_spec.rb +15 -0
  72. data/spec/validations_spec.rb +18 -0
  73. metadata +253 -0
@@ -0,0 +1,15 @@
1
+ require 'spec_helper'
2
+
3
+ describe Rosebud::Validations::TypeValidator do
4
+ it 'should raise an error if value cannot be converted to provided type' do
5
+ expect { Rosebud::Validations::TypeValidator.new.validate_param(:param, 'A', Integer) }.to raise_error(Errawr::Error)
6
+ end
7
+
8
+ it 'should raise an error if a boolean value cannot be converted to provided type' do
9
+ expect { Rosebud::Validations::TypeValidator.new.validate_param(:param, 'A', Virtus::Attribute::Boolean) }.to raise_error(Errawr::Error)
10
+ end
11
+
12
+ it 'should not raise an error if coercion is successful' do
13
+ expect { Rosebud::Validations::TypeValidator.new.validate_param(:param, '1', String) }.not_to raise_error
14
+ end
15
+ end
@@ -0,0 +1,18 @@
1
+ require 'spec_helper'
2
+
3
+ describe Rosebud::Validations do
4
+ context 'register_validator!' do
5
+ it 'should register a validator' do
6
+ Rosebud::Validations.register_validator!(:dummy_validator, DummyValidator)
7
+ Rosebud::Validations.validators[:dummy_validator].should == DummyValidator
8
+ end
9
+
10
+ it 'should raise an error if validator subclass is not of type Rosebud::Validator' do
11
+ expect { Rosebud::Validations.register_validator!(:dummy_validator, InvalidSubclassValidator) }.to raise_error(ArgumentError)
12
+ end
13
+
14
+ it 'should raise an error if validator does not implement validate_param' do
15
+ expect { Rosebud::Validations.register_validator!(:dummy_validator, NotImplementedValidator) }.to raise_error(NotImplementedError)
16
+ end
17
+ end
18
+ end
metadata ADDED
@@ -0,0 +1,253 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rosebud
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Anthony Smith
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-11-22 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: virtus
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: 1.0.0
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: 1.0.0
27
+ - !ruby/object:Gem::Dependency
28
+ name: errawr
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ~>
32
+ - !ruby/object:Gem::Version
33
+ version: 1.1.5
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ~>
39
+ - !ruby/object:Gem::Version
40
+ version: 1.1.5
41
+ - !ruby/object:Gem::Dependency
42
+ name: errawr-rails
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ~>
46
+ - !ruby/object:Gem::Version
47
+ version: 1.0.0
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ~>
53
+ - !ruby/object:Gem::Version
54
+ version: 1.0.0
55
+ - !ruby/object:Gem::Dependency
56
+ name: bundler
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: '1.3'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ~>
67
+ - !ruby/object:Gem::Version
68
+ version: '1.3'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rake
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - '>='
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - '>='
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: rspec-rails
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - '>='
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - '>='
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ description: Rails API parameter validation
98
+ email:
99
+ - anthony@sticksnleaves.com
100
+ executables: []
101
+ extensions: []
102
+ extra_rdoc_files: []
103
+ files:
104
+ - .gitignore
105
+ - .rspec
106
+ - .travis.yml
107
+ - Gemfile
108
+ - LICENSE.txt
109
+ - README.md
110
+ - Rakefile
111
+ - lib/rosebud.rb
112
+ - lib/rosebud/locale/en.yml
113
+ - lib/rosebud/params_scope.rb
114
+ - lib/rosebud/validations.rb
115
+ - lib/rosebud/validations/presence_validator.rb
116
+ - lib/rosebud/validations/regex_validator.rb
117
+ - lib/rosebud/validations/type_validator.rb
118
+ - lib/rosebud/validator.rb
119
+ - lib/rosebud/version.rb
120
+ - rosebud.gemspec
121
+ - spec/dummy/.gitignore
122
+ - spec/dummy/README.rdoc
123
+ - spec/dummy/Rakefile
124
+ - spec/dummy/app/assets/images/.keep
125
+ - spec/dummy/app/assets/javascripts/application.js
126
+ - spec/dummy/app/assets/stylesheets/application.css
127
+ - spec/dummy/app/controllers/application_controller.rb
128
+ - spec/dummy/app/controllers/concerns/.keep
129
+ - spec/dummy/app/helpers/application_helper.rb
130
+ - spec/dummy/app/mailers/.keep
131
+ - spec/dummy/app/models/.keep
132
+ - spec/dummy/app/models/concerns/.keep
133
+ - spec/dummy/app/views/layouts/application.html.erb
134
+ - spec/dummy/bin/bundle
135
+ - spec/dummy/bin/rails
136
+ - spec/dummy/bin/rake
137
+ - spec/dummy/config.ru
138
+ - spec/dummy/config/application.rb
139
+ - spec/dummy/config/boot.rb
140
+ - spec/dummy/config/database.yml
141
+ - spec/dummy/config/environment.rb
142
+ - spec/dummy/config/environments/development.rb
143
+ - spec/dummy/config/environments/production.rb
144
+ - spec/dummy/config/environments/test.rb
145
+ - spec/dummy/config/initializers/backtrace_silencers.rb
146
+ - spec/dummy/config/initializers/filter_parameter_logging.rb
147
+ - spec/dummy/config/initializers/inflections.rb
148
+ - spec/dummy/config/initializers/mime_types.rb
149
+ - spec/dummy/config/initializers/secret_token.rb
150
+ - spec/dummy/config/initializers/session_store.rb
151
+ - spec/dummy/config/initializers/wrap_parameters.rb
152
+ - spec/dummy/config/locales/en.yml
153
+ - spec/dummy/config/routes.rb
154
+ - spec/dummy/db/seeds.rb
155
+ - spec/dummy/lib/assets/.keep
156
+ - spec/dummy/lib/tasks/.keep
157
+ - spec/dummy/log/.keep
158
+ - spec/dummy/public/404.html
159
+ - spec/dummy/public/422.html
160
+ - spec/dummy/public/500.html
161
+ - spec/dummy/public/favicon.ico
162
+ - spec/dummy/public/robots.txt
163
+ - spec/dummy/vendor/assets/javascripts/.keep
164
+ - spec/dummy/vendor/assets/stylesheets/.keep
165
+ - spec/optional_spec.rb
166
+ - spec/presence_validator_spec.rb
167
+ - spec/regex_validator_spec.rb
168
+ - spec/requires_spec.rb
169
+ - spec/spec_helper.rb
170
+ - spec/support/dummy_validator.rb
171
+ - spec/support/invalid_subclass_validator.rb
172
+ - spec/support/not_implemented_validator.rb
173
+ - spec/type_validator_spec.rb
174
+ - spec/validations_spec.rb
175
+ homepage: http://www.github.com/anthonator/rosebud
176
+ licenses:
177
+ - MIT
178
+ metadata: {}
179
+ post_install_message:
180
+ rdoc_options: []
181
+ require_paths:
182
+ - lib
183
+ required_ruby_version: !ruby/object:Gem::Requirement
184
+ requirements:
185
+ - - '>='
186
+ - !ruby/object:Gem::Version
187
+ version: '0'
188
+ required_rubygems_version: !ruby/object:Gem::Requirement
189
+ requirements:
190
+ - - '>='
191
+ - !ruby/object:Gem::Version
192
+ version: '0'
193
+ requirements: []
194
+ rubyforge_project:
195
+ rubygems_version: 2.0.3
196
+ signing_key:
197
+ specification_version: 4
198
+ summary: Finally! An easy way to validate your Rails API parameters.
199
+ test_files:
200
+ - spec/dummy/.gitignore
201
+ - spec/dummy/README.rdoc
202
+ - spec/dummy/Rakefile
203
+ - spec/dummy/app/assets/images/.keep
204
+ - spec/dummy/app/assets/javascripts/application.js
205
+ - spec/dummy/app/assets/stylesheets/application.css
206
+ - spec/dummy/app/controllers/application_controller.rb
207
+ - spec/dummy/app/controllers/concerns/.keep
208
+ - spec/dummy/app/helpers/application_helper.rb
209
+ - spec/dummy/app/mailers/.keep
210
+ - spec/dummy/app/models/.keep
211
+ - spec/dummy/app/models/concerns/.keep
212
+ - spec/dummy/app/views/layouts/application.html.erb
213
+ - spec/dummy/bin/bundle
214
+ - spec/dummy/bin/rails
215
+ - spec/dummy/bin/rake
216
+ - spec/dummy/config.ru
217
+ - spec/dummy/config/application.rb
218
+ - spec/dummy/config/boot.rb
219
+ - spec/dummy/config/database.yml
220
+ - spec/dummy/config/environment.rb
221
+ - spec/dummy/config/environments/development.rb
222
+ - spec/dummy/config/environments/production.rb
223
+ - spec/dummy/config/environments/test.rb
224
+ - spec/dummy/config/initializers/backtrace_silencers.rb
225
+ - spec/dummy/config/initializers/filter_parameter_logging.rb
226
+ - spec/dummy/config/initializers/inflections.rb
227
+ - spec/dummy/config/initializers/mime_types.rb
228
+ - spec/dummy/config/initializers/secret_token.rb
229
+ - spec/dummy/config/initializers/session_store.rb
230
+ - spec/dummy/config/initializers/wrap_parameters.rb
231
+ - spec/dummy/config/locales/en.yml
232
+ - spec/dummy/config/routes.rb
233
+ - spec/dummy/db/seeds.rb
234
+ - spec/dummy/lib/assets/.keep
235
+ - spec/dummy/lib/tasks/.keep
236
+ - spec/dummy/log/.keep
237
+ - spec/dummy/public/404.html
238
+ - spec/dummy/public/422.html
239
+ - spec/dummy/public/500.html
240
+ - spec/dummy/public/favicon.ico
241
+ - spec/dummy/public/robots.txt
242
+ - spec/dummy/vendor/assets/javascripts/.keep
243
+ - spec/dummy/vendor/assets/stylesheets/.keep
244
+ - spec/optional_spec.rb
245
+ - spec/presence_validator_spec.rb
246
+ - spec/regex_validator_spec.rb
247
+ - spec/requires_spec.rb
248
+ - spec/spec_helper.rb
249
+ - spec/support/dummy_validator.rb
250
+ - spec/support/invalid_subclass_validator.rb
251
+ - spec/support/not_implemented_validator.rb
252
+ - spec/type_validator_spec.rb
253
+ - spec/validations_spec.rb