anodator 0.0.1

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 (53) hide show
  1. data/.document +5 -0
  2. data/.rspec +1 -0
  3. data/Gemfile +13 -0
  4. data/Gemfile.lock +28 -0
  5. data/LICENSE.txt +20 -0
  6. data/README.ja.rdoc +33 -0
  7. data/README.rdoc +41 -0
  8. data/Rakefile +50 -0
  9. data/VERSION +1 -0
  10. data/example/example_01.rb +129 -0
  11. data/lib/anodator/anodator_error.rb +5 -0
  12. data/lib/anodator/check_result.rb +41 -0
  13. data/lib/anodator/checker.rb +58 -0
  14. data/lib/anodator/input_spec.rb +199 -0
  15. data/lib/anodator/input_spec_item.rb +33 -0
  16. data/lib/anodator/message.rb +59 -0
  17. data/lib/anodator/output_spec.rb +164 -0
  18. data/lib/anodator/rule.rb +97 -0
  19. data/lib/anodator/rule_set.rb +52 -0
  20. data/lib/anodator/utils.rb +234 -0
  21. data/lib/anodator/validator/base.rb +168 -0
  22. data/lib/anodator/validator/blank_validator.rb +14 -0
  23. data/lib/anodator/validator/complex_validator.rb +60 -0
  24. data/lib/anodator/validator/configuration_error.rb +8 -0
  25. data/lib/anodator/validator/date_validator.rb +151 -0
  26. data/lib/anodator/validator/format_validator.rb +48 -0
  27. data/lib/anodator/validator/inclusion_validator.rb +21 -0
  28. data/lib/anodator/validator/length_validator.rb +37 -0
  29. data/lib/anodator/validator/numeric_validator.rb +46 -0
  30. data/lib/anodator/validator/presence_validator.rb +14 -0
  31. data/lib/anodator/validator.rb +10 -0
  32. data/lib/anodator.rb +3 -0
  33. data/spec/anodator/check_result_spec.rb +101 -0
  34. data/spec/anodator/checker_spec.rb +273 -0
  35. data/spec/anodator/input_spec_item_spec.rb +100 -0
  36. data/spec/anodator/input_spec_spec.rb +584 -0
  37. data/spec/anodator/message_spec.rb +112 -0
  38. data/spec/anodator/output_spec_spec.rb +355 -0
  39. data/spec/anodator/rule_set_spec.rb +190 -0
  40. data/spec/anodator/rule_spec.rb +169 -0
  41. data/spec/anodator/validator/base_spec.rb +214 -0
  42. data/spec/anodator/validator/blank_validator_spec.rb +52 -0
  43. data/spec/anodator/validator/complex_validator_spec.rb +268 -0
  44. data/spec/anodator/validator/date_validator_spec.rb +350 -0
  45. data/spec/anodator/validator/format_validator_spec.rb +158 -0
  46. data/spec/anodator/validator/inclusion_validator_spec.rb +77 -0
  47. data/spec/anodator/validator/length_validator_spec.rb +236 -0
  48. data/spec/anodator/validator/numeric_validator_spec.rb +468 -0
  49. data/spec/anodator/validator/presence_validator_spec.rb +52 -0
  50. data/spec/anodator/validator_spec.rb +16 -0
  51. data/spec/anodator_spec.rb +2 -0
  52. data/spec/spec_helper.rb +12 -0
  53. metadata +188 -0
@@ -0,0 +1,52 @@
1
+ require "spec_helper"
2
+
3
+ # Anodator::Validator::PresenceValidator
4
+ require "anodator/validator/presence_validator"
5
+
6
+ describe Anodator::Validator::PresenceValidator, ".new" do
7
+ context "with no parameters" do
8
+ it "should raise ArgumentError" do
9
+ lambda {
10
+ Anodator::Validator::PresenceValidator.new
11
+ }.should raise_error ArgumentError
12
+ end
13
+ end
14
+
15
+ context "with only target parameter" do
16
+ it "should not raise error" do
17
+ lambda {
18
+ Anodator::Validator::PresenceValidator.new("1")
19
+ }.should_not raise_error
20
+ end
21
+ end
22
+ end
23
+
24
+ describe Anodator::Validator::PresenceValidator, "#valid?" do
25
+ before(:each) do
26
+ @validator = Anodator::Validator::PresenceValidator.new("1")
27
+ end
28
+
29
+ context "target value is blank" do
30
+ before(:each) do
31
+ Anodator::Validator::Base.values = { "1" => "" }
32
+ end
33
+
34
+ it { @validator.should_not be_valid }
35
+ end
36
+
37
+ context "target value is '1'" do
38
+ before(:each) do
39
+ Anodator::Validator::Base.values = { "1" => "1" }
40
+ end
41
+
42
+ it { @validator.should be_valid }
43
+ end
44
+
45
+ context "target value is 'some message'" do
46
+ before(:each) do
47
+ Anodator::Validator::Base.values = { "1" => "some message" }
48
+ end
49
+
50
+ it { @validator.should be_valid }
51
+ end
52
+ end
@@ -0,0 +1,16 @@
1
+ require "spec_helper"
2
+
3
+ # Anodator::Validator
4
+ require "anodator/validator"
5
+
6
+ describe "require validators" do
7
+ it { Anodator::Validator::Base.should_not be_nil }
8
+ it { Anodator::Validator::BlankValidator.should_not be_nil }
9
+ it { Anodator::Validator::ComplexValidator.should_not be_nil }
10
+ it { Anodator::Validator::FormatValidator.should_not be_nil }
11
+ it { Anodator::Validator::InclusionValidator.should_not be_nil }
12
+ it { Anodator::Validator::LengthValidator.should_not be_nil }
13
+ it { Anodator::Validator::NumericValidator.should_not be_nil }
14
+ it { Anodator::Validator::PresenceValidator.should_not be_nil }
15
+ end
16
+
@@ -0,0 +1,2 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
+
@@ -0,0 +1,12 @@
1
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
2
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
3
+ require 'rspec'
4
+ require 'anodator'
5
+
6
+ # Requires supporting files with custom matchers and macros, etc,
7
+ # in ./support/ and its subdirectories.
8
+ Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
9
+
10
+ RSpec.configure do |config|
11
+
12
+ end
metadata ADDED
@@ -0,0 +1,188 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: anodator
3
+ version: !ruby/object:Gem::Version
4
+ hash: 29
5
+ prerelease: false
6
+ segments:
7
+ - 0
8
+ - 0
9
+ - 1
10
+ segments_generated: true
11
+ version: 0.0.1
12
+ platform: ruby
13
+ authors:
14
+ - Tetsuhisa MAKINO
15
+ autorequire:
16
+ bindir: bin
17
+ cert_chain: []
18
+
19
+ date: 2011-10-19 00:00:00 +09:00
20
+ default_executable:
21
+ dependencies:
22
+ - !ruby/object:Gem::Dependency
23
+ prerelease: false
24
+ name: rspec
25
+ version_requirements: &id001 !ruby/object:Gem::Requirement
26
+ none: false
27
+ requirements:
28
+ - - ~>
29
+ - !ruby/object:Gem::Version
30
+ hash: 3
31
+ segments:
32
+ - 2
33
+ - 3
34
+ - 0
35
+ segments_generated: true
36
+ version: 2.3.0
37
+ requirement: *id001
38
+ type: :development
39
+ - !ruby/object:Gem::Dependency
40
+ prerelease: false
41
+ name: bundler
42
+ version_requirements: &id002 !ruby/object:Gem::Requirement
43
+ none: false
44
+ requirements:
45
+ - - ~>
46
+ - !ruby/object:Gem::Version
47
+ hash: 23
48
+ segments:
49
+ - 1
50
+ - 0
51
+ - 0
52
+ segments_generated: true
53
+ version: 1.0.0
54
+ requirement: *id002
55
+ type: :development
56
+ - !ruby/object:Gem::Dependency
57
+ prerelease: false
58
+ name: jeweler
59
+ version_requirements: &id003 !ruby/object:Gem::Requirement
60
+ none: false
61
+ requirements:
62
+ - - ~>
63
+ - !ruby/object:Gem::Version
64
+ hash: 7
65
+ segments:
66
+ - 1
67
+ - 6
68
+ - 4
69
+ segments_generated: true
70
+ version: 1.6.4
71
+ requirement: *id003
72
+ type: :development
73
+ - !ruby/object:Gem::Dependency
74
+ prerelease: false
75
+ name: rcov
76
+ version_requirements: &id004 !ruby/object:Gem::Requirement
77
+ none: false
78
+ requirements:
79
+ - - ">="
80
+ - !ruby/object:Gem::Version
81
+ hash: 3
82
+ segments:
83
+ - 0
84
+ segments_generated: true
85
+ version: "0"
86
+ requirement: *id004
87
+ type: :development
88
+ description: anodator is Anonymous Data Validator.
89
+ email: tim.makino at gmail.com
90
+ executables: []
91
+
92
+ extensions: []
93
+
94
+ extra_rdoc_files:
95
+ - LICENSE.txt
96
+ - README.ja.rdoc
97
+ - README.rdoc
98
+ files:
99
+ - .document
100
+ - .rspec
101
+ - Gemfile
102
+ - Gemfile.lock
103
+ - LICENSE.txt
104
+ - README.ja.rdoc
105
+ - README.rdoc
106
+ - Rakefile
107
+ - VERSION
108
+ - example/example_01.rb
109
+ - lib/anodator.rb
110
+ - lib/anodator/anodator_error.rb
111
+ - lib/anodator/check_result.rb
112
+ - lib/anodator/checker.rb
113
+ - lib/anodator/input_spec.rb
114
+ - lib/anodator/input_spec_item.rb
115
+ - lib/anodator/message.rb
116
+ - lib/anodator/output_spec.rb
117
+ - lib/anodator/rule.rb
118
+ - lib/anodator/rule_set.rb
119
+ - lib/anodator/utils.rb
120
+ - lib/anodator/validator.rb
121
+ - lib/anodator/validator/base.rb
122
+ - lib/anodator/validator/blank_validator.rb
123
+ - lib/anodator/validator/complex_validator.rb
124
+ - lib/anodator/validator/configuration_error.rb
125
+ - lib/anodator/validator/date_validator.rb
126
+ - lib/anodator/validator/format_validator.rb
127
+ - lib/anodator/validator/inclusion_validator.rb
128
+ - lib/anodator/validator/length_validator.rb
129
+ - lib/anodator/validator/numeric_validator.rb
130
+ - lib/anodator/validator/presence_validator.rb
131
+ - spec/anodator/check_result_spec.rb
132
+ - spec/anodator/checker_spec.rb
133
+ - spec/anodator/input_spec_item_spec.rb
134
+ - spec/anodator/input_spec_spec.rb
135
+ - spec/anodator/message_spec.rb
136
+ - spec/anodator/output_spec_spec.rb
137
+ - spec/anodator/rule_set_spec.rb
138
+ - spec/anodator/rule_spec.rb
139
+ - spec/anodator/validator/base_spec.rb
140
+ - spec/anodator/validator/blank_validator_spec.rb
141
+ - spec/anodator/validator/complex_validator_spec.rb
142
+ - spec/anodator/validator/date_validator_spec.rb
143
+ - spec/anodator/validator/format_validator_spec.rb
144
+ - spec/anodator/validator/inclusion_validator_spec.rb
145
+ - spec/anodator/validator/length_validator_spec.rb
146
+ - spec/anodator/validator/numeric_validator_spec.rb
147
+ - spec/anodator/validator/presence_validator_spec.rb
148
+ - spec/anodator/validator_spec.rb
149
+ - spec/anodator_spec.rb
150
+ - spec/spec_helper.rb
151
+ has_rdoc: true
152
+ homepage: https://github.com/maki-tetsu/anodator
153
+ licenses:
154
+ - MIT
155
+ post_install_message:
156
+ rdoc_options: []
157
+
158
+ require_paths:
159
+ - lib
160
+ required_ruby_version: !ruby/object:Gem::Requirement
161
+ none: false
162
+ requirements:
163
+ - - ">="
164
+ - !ruby/object:Gem::Version
165
+ hash: 3
166
+ segments:
167
+ - 0
168
+ segments_generated: true
169
+ version: "0"
170
+ required_rubygems_version: !ruby/object:Gem::Requirement
171
+ none: false
172
+ requirements:
173
+ - - ">="
174
+ - !ruby/object:Gem::Version
175
+ hash: 3
176
+ segments:
177
+ - 0
178
+ segments_generated: true
179
+ version: "0"
180
+ requirements: []
181
+
182
+ rubyforge_project:
183
+ rubygems_version: 1.3.7
184
+ signing_key:
185
+ specification_version: 3
186
+ summary: anodator is Anonymous Data Validator.
187
+ test_files: []
188
+