anodator 0.0.5 → 1.0.0.pre1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (43) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +12 -0
  3. data/.rspec +1 -0
  4. data/.travis.yml +5 -0
  5. data/Gemfile +5 -13
  6. data/LICENSE.txt +18 -17
  7. data/{README.ja.rdoc → README.ja.md} +2 -4
  8. data/README.md +39 -0
  9. data/Rakefile +3 -47
  10. data/anodator.gemspec +21 -103
  11. data/bin/console +14 -0
  12. data/bin/setup +8 -0
  13. data/lib/anodator/check_result.rb +1 -1
  14. data/lib/anodator/input_spec.rb +2 -2
  15. data/lib/anodator/rule.rb +2 -2
  16. data/lib/anodator/utils.rb +4 -4
  17. data/lib/anodator/validator/format_validator.rb +1 -1
  18. data/lib/anodator/version.rb +3 -0
  19. data/lib/anodator.rb +1 -2
  20. metadata +70 -131
  21. data/Gemfile.lock +0 -29
  22. data/README.rdoc +0 -41
  23. data/spec/anodator/check_result_spec.rb +0 -101
  24. data/spec/anodator/checker_spec.rb +0 -273
  25. data/spec/anodator/input_spec_item_spec.rb +0 -100
  26. data/spec/anodator/input_spec_spec.rb +0 -584
  27. data/spec/anodator/message_spec.rb +0 -112
  28. data/spec/anodator/output_spec_spec.rb +0 -355
  29. data/spec/anodator/rule_set_spec.rb +0 -190
  30. data/spec/anodator/rule_spec.rb +0 -278
  31. data/spec/anodator/utils_spec.rb +0 -48
  32. data/spec/anodator/validator/base_spec.rb +0 -214
  33. data/spec/anodator/validator/blank_validator_spec.rb +0 -52
  34. data/spec/anodator/validator/complex_validator_spec.rb +0 -268
  35. data/spec/anodator/validator/date_validator_spec.rb +0 -350
  36. data/spec/anodator/validator/format_validator_spec.rb +0 -158
  37. data/spec/anodator/validator/inclusion_validator_spec.rb +0 -77
  38. data/spec/anodator/validator/length_validator_spec.rb +0 -236
  39. data/spec/anodator/validator/numeric_validator_spec.rb +0 -538
  40. data/spec/anodator/validator/presence_validator_spec.rb +0 -52
  41. data/spec/anodator/validator_spec.rb +0 -16
  42. data/spec/anodator_spec.rb +0 -2
  43. data/spec/spec_helper.rb +0 -12
@@ -1,100 +0,0 @@
1
- require "spec_helper"
2
-
3
- # Anodator::InputSpecItem
4
- require "anodator/input_spec_item"
5
-
6
- include Anodator
7
-
8
- describe InputSpecItem, ".new" do
9
- context "with no parameter" do
10
- it "should raise error ArgumentError" do
11
- lambda {
12
- InputSpecItem.new
13
- }.should raise_error ArgumentError
14
- end
15
- end
16
-
17
- context "with only number parameter" do
18
- it "should raise ArgumentError" do
19
- lambda {
20
- InputSpecItem.new("1")
21
- }.should raise_error ArgumentError
22
- end
23
- end
24
-
25
- context "with blank number parameter" do
26
- it "should raise ArgumentError" do
27
- lambda {
28
- InputSpecItem.new("", "item_1")
29
- }.should raise_error ArgumentError
30
- end
31
- end
32
-
33
- context "with nil number parameter" do
34
- it "should raise ArgumentError" do
35
- lambda {
36
- InputSpecItem.new(nil, "item_1")
37
- }.should raise_error ArgumentError
38
- end
39
- end
40
-
41
- context "with blank name parameter" do
42
- it "should raise ArgumentError" do
43
- lambda {
44
- InputSpecItem.new("1", "")
45
- }.should raise_error ArgumentError
46
- end
47
- end
48
-
49
- context "with nil name parameter" do
50
- it "should raise ArgumentError" do
51
- lambda {
52
- InputSpecItem.new("1", nil)
53
- }.should raise_error ArgumentError
54
- end
55
- end
56
-
57
- context "with number and name parameter" do
58
- before(:all) do
59
- @new_proc = lambda {
60
- InputSpecItem.new("1", "item_1")
61
- }
62
- end
63
-
64
- it "should not raise error" do
65
- @new_proc.should_not raise_error
66
- end
67
-
68
- context "after generated" do
69
- before(:all) do
70
- @input_spec_item = @new_proc.call
71
- end
72
-
73
- it { @input_spec_item.number.should == "1" }
74
- it { @input_spec_item.name.should == "item_1" }
75
- it { @input_spec_item.type.should == "STRING" }
76
- end
77
- end
78
-
79
- context "with number, name and type(NUMERIC) parameter" do
80
- before(:all) do
81
- @new_proc = lambda {
82
- InputSpecItem.new("1", "item_1", "NUMERIC")
83
- }
84
- end
85
-
86
- it "should not raise error" do
87
- @new_proc.should_not raise_error
88
- end
89
-
90
- context "after generated" do
91
- before(:all) do
92
- @input_spec_item = @new_proc.call
93
- end
94
-
95
- it { @input_spec_item.number.should == "1" }
96
- it { @input_spec_item.name.should == "item_1" }
97
- it { @input_spec_item.type.should == "NUMERIC" }
98
- end
99
- end
100
- end
@@ -1,584 +0,0 @@
1
- require "spec_helper"
2
-
3
- # Anodator::InputSpec
4
- require "anodator/input_spec"
5
-
6
- include Anodator
7
-
8
- describe InputSpec, ".new" do
9
- context "with no parameters" do
10
- it "should not raise error" do
11
- lambda {
12
- InputSpec.new
13
- }.should_not raise_error
14
- end
15
-
16
- it "@spec_items.count should be zero" do
17
- input_spec = InputSpec.new
18
- input_spec.instance_eval("@spec_items.count").should be_zero
19
- end
20
- end
21
-
22
- context "with several items parameter" do
23
- before(:all) do
24
- @new_proc = lambda {
25
- InputSpec.new([
26
- { :number => "1", :name => "item_1" },
27
- { :number => "2", :name => "item_2" },
28
- { :number => "3", :name => "item_3" },
29
- { :number => "4", :name => "item_4" },
30
- { :number => "5", :name => "item_5", :type => InputSpecItem::TYPE_NUMERIC },
31
- { :number => "6", :name => "item_6" },
32
- { :number => "7", :name => "item_7" },
33
- { :number => "8", :name => "item_8" },
34
- { :number => "9", :name => "item_9" },
35
- ])
36
- }
37
- end
38
-
39
- it "should not raise error" do
40
- @new_proc.should_not raise_error
41
- end
42
-
43
- it "@spec_items.count should be 9" do
44
- input_spec = @new_proc.call
45
- input_spec.instance_eval("@spec_items.count").should == 9
46
- end
47
-
48
- it "@spec_items.each type.should be STRING" do
49
- input_spec = @new_proc.call
50
- input_spec.instance_eval("@spec_items").each do |input_spec_item|
51
- if input_spec_item.number == "5"
52
- input_spec_item.type.should == InputSpecItem::TYPE_NUMERIC
53
- else
54
- input_spec_item.type.should == InputSpecItem::TYPE_STRING
55
- end
56
- end
57
- end
58
- end
59
- end
60
-
61
- describe InputSpec, "after generated" do
62
- before(:each) do
63
- @input_spec = InputSpec.new([
64
- { :number => "1", :name => "item_1" },
65
- { :number => "2", :name => "item_2" },
66
- { :number => "3", :name => "item_3" },
67
- { :number => "4", :name => "item_4" },
68
- { :number => "5", :name => "item_5", :type => InputSpecItem::TYPE_NUMERIC },
69
- { :number => "6", :name => "item_6", :type => InputSpecItem::TYPE_NUMERIC },
70
- { :number => "7", :name => "item_7" },
71
- { :number => "8", :name => "item_8" },
72
- { :number => "9", :name => "item_9" },
73
- ])
74
- end
75
-
76
- describe "#source=" do
77
- context "with valid array values" do
78
- before(:each) do
79
- @values = %W(1 2 3 4 5 6 7 8 9)
80
- @proc = lambda {
81
- @input_spec.source = @values
82
- }
83
- end
84
-
85
- it "should not raise error" do
86
- @proc.should_not raise_error
87
- end
88
-
89
- it "@source should equal presented values" do
90
- @proc.should change { @input_spec.instance_eval("@source") }.
91
- from(nil).to(@values)
92
- end
93
- end
94
-
95
- context "with invalid fixnum value" do
96
- it "should raise ArgumentError" do
97
- lambda {
98
- @input_spec.source = nil
99
- }.should raise_error ArgumentError
100
- end
101
- end
102
- end
103
-
104
- describe "#clear_source" do
105
- before(:each) do
106
- @values = %W(1 2 3 4 5 6 7 8 9)
107
- @input_spec.source = @values
108
- @proc = lambda {
109
- @input_spec.clear_source
110
- }
111
- end
112
-
113
- it "@source should change to nil" do
114
- @proc.should change { @input_spec.instance_eval("@source") }.
115
- from(@values).to(nil)
116
- end
117
- end
118
-
119
- describe "#[]" do
120
- context "when initialized source" do
121
- before(:each) do
122
- @values = %W(1 2 3 4 5 6 7 8 9)
123
- @input_spec.source = @values
124
- end
125
-
126
- context "when access existing index" do
127
- before(:each) do
128
- @proc = lambda {
129
- @input_spec[3]
130
- }
131
- end
132
-
133
- it "should get value" do
134
- @proc.call.should == @values[3]
135
- end
136
- end
137
-
138
- context "when access non-existing index" do
139
- before(:each) do
140
- @proc = lambda {
141
- @input_spec[@values.size]
142
- }
143
- end
144
-
145
- it "should raise error UnknownTargetExpressionError" do
146
- @proc.should raise_error UnknownTargetExpressionError
147
- end
148
- end
149
-
150
- context "when access existing number" do
151
- before(:each) do
152
- @proc = lambda {
153
- @input_spec["7"]
154
- }
155
- end
156
-
157
- it "should get value" do
158
- @proc.call.should == @values[6]
159
- end
160
- end
161
-
162
- context "when access non-existing number" do
163
- before(:each) do
164
- @proc = lambda {
165
- @input_spec[(@values.size + 1).to_s]
166
- }
167
- end
168
-
169
- it "should raise error UnknownTargetExpressionError" do
170
- @proc.should raise_error UnknownTargetExpressionError
171
- end
172
- end
173
-
174
- context "when access existing name" do
175
- before(:each) do
176
- @proc = lambda {
177
- @input_spec["item_2"]
178
- }
179
- end
180
-
181
- it "should get value" do
182
- @proc.call.should == @values[1]
183
- end
184
- end
185
-
186
- context "when access non-existing name" do
187
- before(:each) do
188
- @proc = lambda {
189
- @input_spec["unknown"]
190
- }
191
- end
192
-
193
- it "should raise error UnknownTargetExpressionError" do
194
- @proc.should raise_error UnknownTargetExpressionError
195
- end
196
- end
197
-
198
- context "when access valid calculation expression" do
199
- before(:each) do
200
- @proc = lambda {
201
- @input_spec["CALC::[[1]]+[[2]]"]
202
- }
203
- end
204
-
205
- it "should not raise error" do
206
- @proc.should_not raise_error
207
- end
208
-
209
- it { @proc.call.should == "12" }
210
- end
211
-
212
- context "when access invalid calculation expression with unknown number" do
213
- before(:each) do
214
- @proc = lambda {
215
- @input_spec["CALC::[[1]]+[[12]]"]
216
- }
217
- end
218
-
219
- it "should raise UnknownTargetExpressionError" do
220
- @proc.should raise_error UnknownTargetExpressionError
221
- end
222
- end
223
-
224
- context "when access invalid calculation expression with syntax error" do
225
- before(:each) do
226
- @proc = lambda {
227
- @input_spec["CALC::[[1]][[2]]"]
228
- }
229
- end
230
-
231
- it "should raise UnknownTargetExpressionError" do
232
- @proc.should_not raise_error UnknownTargetExpressionError
233
- end
234
- end
235
-
236
- context "when access valid calculation expression for numeric add" do
237
- before(:each) do
238
- @proc = lambda {
239
- @input_spec["CALC::[[5]]+[[6]]"]
240
- }
241
- end
242
-
243
- it "should not raise error" do
244
- @proc.should_not raise_error
245
- end
246
-
247
- it { @proc.call.should == "11.0" }
248
- end
249
-
250
- context "when access invalid calculation expression for numeric and string add" do
251
- before(:each) do
252
- @proc = lambda {
253
- @input_spec["CALC::[[1]]+[[6]]"]
254
- }
255
- end
256
-
257
- it "should raise UnknownTargetExpressionError" do
258
- @proc.should raise_error UnknownTargetExpressionError
259
- end
260
- end
261
- end
262
-
263
- context "when not initialized source" do
264
- it "should raise error" do
265
- lambda {
266
- @input_spec[0]
267
- }.should raise_error SourceDataNotProvidedError
268
- end
269
- end
270
- end
271
-
272
- describe "#value_at" do
273
- context "when initialized source" do
274
- before(:each) do
275
- @values = %W(1 2 3 4 5 6 7 8 9)
276
- @input_spec.source = @values
277
- end
278
-
279
- context "when access existing index" do
280
- before(:each) do
281
- @proc = lambda {
282
- @input_spec.value_at(3)
283
- }
284
- end
285
-
286
- it "should get value" do
287
- @proc.call.should == @values[3]
288
- end
289
- end
290
-
291
- context "when access non-existing index" do
292
- before(:each) do
293
- @proc = lambda {
294
- @input_spec.value_at(@values.size)
295
- }
296
- end
297
-
298
- it "should raise error UnknownTargetExpressionError" do
299
- @proc.should raise_error UnknownTargetExpressionError
300
- end
301
- end
302
- end
303
-
304
- context "when not initialized source" do
305
- it "should raise error" do
306
- lambda {
307
- @input_spec.value_at(0)
308
- }.should raise_error SourceDataNotProvidedError
309
- end
310
- end
311
- end
312
-
313
- describe "#value_at_by_number" do
314
- context "when initialized source" do
315
- before(:each) do
316
- @values = %W(1 2 3 4 5 6 7 8 9)
317
- @input_spec.source = @values
318
- end
319
-
320
- context "when access existing number" do
321
- before(:each) do
322
- @proc = lambda {
323
- @input_spec.value_at_by_number("7")
324
- }
325
- end
326
-
327
- it "should get value" do
328
- @proc.call.should == @values[6]
329
- end
330
- end
331
-
332
- context "when access non-existing number" do
333
- before(:each) do
334
- @proc = lambda {
335
- @input_spec.value_at_by_number((@values.size + 1).to_s)
336
- }
337
- end
338
-
339
- it "should raise error UnknownTargetExpressionError" do
340
- @proc.should raise_error UnknownTargetExpressionError
341
- end
342
- end
343
- end
344
-
345
- context "when not initialized source" do
346
- it "should raise error" do
347
- lambda {
348
- @input_spec.value_at_by_number("0")
349
- }.should raise_error SourceDataNotProvidedError
350
- end
351
- end
352
- end
353
-
354
- describe "#value_at_by_name" do
355
- context "when initialized source" do
356
- before(:each) do
357
- @values = %W(1 2 3 4 5 6 7 8 9)
358
- @input_spec.source = @values
359
- end
360
-
361
- context "when access existing name" do
362
- before(:each) do
363
- @proc = lambda {
364
- @input_spec.value_at_by_name("item_2")
365
- }
366
- end
367
-
368
- it "should get value" do
369
- @proc.call.should == @values[1]
370
- end
371
- end
372
-
373
- context "when access non-existing name" do
374
- before(:each) do
375
- @proc = lambda {
376
- @input_spec.value_at_by_name("unknown")
377
- }
378
- end
379
-
380
- it "should raise error UnknownTargetExpressionError" do
381
- @proc.should raise_error UnknownTargetExpressionError
382
- end
383
- end
384
- end
385
-
386
- context "when not initialized source" do
387
- it "should raise error" do
388
- lambda {
389
- @input_spec.value_at_by_name("item_3")
390
- }.should raise_error SourceDataNotProvidedError
391
- end
392
- end
393
- end
394
-
395
- describe "#spec_item_by_expression" do
396
- context "when access existing index" do
397
- before(:each) do
398
- @proc = lambda {
399
- @input_spec.spec_item_by_expression(3)
400
- }
401
- end
402
-
403
- it "should get spec item" do
404
- @proc.call.number.should == "4"
405
- end
406
- end
407
-
408
- context "when access non-existing index" do
409
- before(:each) do
410
- @proc = lambda {
411
- @input_spec.spec_item_by_expression(9)
412
- }
413
- end
414
-
415
- it "should raise error UnknownTargetExpressionError" do
416
- @proc.should raise_error UnknownTargetExpressionError
417
- end
418
- end
419
-
420
- context "when access existing number" do
421
- before(:each) do
422
- @proc = lambda {
423
- @input_spec.spec_item_by_expression("7")
424
- }
425
- end
426
-
427
- it "should get spec item" do
428
- @proc.call.number.should == "7"
429
- end
430
- end
431
-
432
- context "when access non-existing number" do
433
- before(:each) do
434
- @proc = lambda {
435
- @input_spec.spec_item_by_expression("10")
436
- }
437
- end
438
-
439
- it "should raise error UnknownTargetExpressionError" do
440
- @proc.should raise_error UnknownTargetExpressionError
441
- end
442
- end
443
-
444
- context "when access existing name" do
445
- before(:each) do
446
- @proc = lambda {
447
- @input_spec.spec_item_by_expression("item_2")
448
- }
449
- end
450
-
451
- it "should get spec item" do
452
- @proc.call.number.should == "2"
453
- end
454
- end
455
-
456
- context "when access non-existing name" do
457
- before(:each) do
458
- @proc = lambda {
459
- @input_spec.spec_item_by_expression("unknown")
460
- }
461
- end
462
-
463
- it "should raise error UnknownTargetExpressionError" do
464
- @proc.should raise_error UnknownTargetExpressionError
465
- end
466
- end
467
-
468
- context "when access valid calculation expression" do
469
- before(:each) do
470
- @proc = lambda {
471
- @input_spec.spec_item_by_expression("CALC::[[1]]+[[2]]")
472
- }
473
- end
474
-
475
- it "should not raise error" do
476
- @proc.should_not raise_error
477
- end
478
-
479
- it { @proc.call.should == [@input_spec.spec_item_at_by_number("1"),
480
- @input_spec.spec_item_at_by_number("2")] }
481
- end
482
-
483
- context "when access invalid calculation expression with unknown number" do
484
- before(:each) do
485
- @proc = lambda {
486
- @input_spec.spec_item_by_expression("CALC::[[1]]+[[12]]")
487
- }
488
- end
489
-
490
- it "should raise UnknownTargetExpressionError" do
491
- @proc.should raise_error UnknownTargetExpressionError
492
- end
493
- end
494
-
495
- context "when access invalid calculation expression with syntax error" do
496
- before(:each) do
497
- @proc = lambda {
498
- @input_spec.spec_item_by_expression("CALC::[[1]][[2]]")
499
- }
500
- end
501
-
502
- it { @proc.call.should == [@input_spec.spec_item_at_by_number("1"),
503
- @input_spec.spec_item_at_by_number("2")] }
504
- end
505
- end
506
-
507
- describe "#spec_item_at" do
508
- context "when access existing index" do
509
- before(:each) do
510
- @proc = lambda {
511
- @input_spec.spec_item_at(3)
512
- }
513
- end
514
-
515
- it "should get spec item" do
516
- @proc.call.number.should == "4"
517
- end
518
- end
519
-
520
- context "when access non-existing index" do
521
- before(:each) do
522
- @proc = lambda {
523
- @input_spec.spec_item_at(9)
524
- }
525
- end
526
-
527
- it "should raise error UnknownTargetExpressionError" do
528
- @proc.should raise_error UnknownTargetExpressionError
529
- end
530
- end
531
- end
532
-
533
- describe "#spec_item_at_by_number" do
534
- context "when access existing number" do
535
- before(:each) do
536
- @proc = lambda {
537
- @input_spec.spec_item_at_by_number("7")
538
- }
539
- end
540
-
541
- it "should get spec item" do
542
- @proc.call.number.should == "7"
543
- end
544
- end
545
-
546
- context "when access non-existing number" do
547
- before(:each) do
548
- @proc = lambda {
549
- @input_spec.spec_item_at_by_number("10")
550
- }
551
- end
552
-
553
- it "should raise error UnknownTargetExpressionError" do
554
- @proc.should raise_error UnknownTargetExpressionError
555
- end
556
- end
557
- end
558
-
559
- describe "#spec_item_at_by_name" do
560
- context "when access existing name" do
561
- before(:each) do
562
- @proc = lambda {
563
- @input_spec.spec_item_at_by_name("item_2")
564
- }
565
- end
566
-
567
- it "should get spec item" do
568
- @proc.call.number.should == "2"
569
- end
570
- end
571
-
572
- context "when access non-existing name" do
573
- before(:each) do
574
- @proc = lambda {
575
- @input_spec.spec_item_at_by_name("unknown")
576
- }
577
- end
578
-
579
- it "should raise error UnknownTargetExpressionError" do
580
- @proc.should raise_error UnknownTargetExpressionError
581
- end
582
- end
583
- end
584
- end