the_array_comparator 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (54) hide show
  1. data/.gitignore +16 -0
  2. data/.rspec +2 -0
  3. data/.ruby-version +1 -0
  4. data/.travis.yml +6 -0
  5. data/CONTRIBUTIONS.md +7 -0
  6. data/Gemfile +30 -0
  7. data/Gemfile.lock +122 -0
  8. data/LICENSE.md +20 -0
  9. data/README.md +121 -0
  10. data/RELEASE_NOTES.md +0 -0
  11. data/Rakefile +93 -0
  12. data/TODO.md +1 -0
  13. data/gemfiles/Gemfile.default +30 -0
  14. data/gemfiles/Gemfile.travis +15 -0
  15. data/lib/the_array_comparator/check.rb +27 -0
  16. data/lib/the_array_comparator/comparator.rb +123 -0
  17. data/lib/the_array_comparator/exceptions.rb +21 -0
  18. data/lib/the_array_comparator/result.rb +21 -0
  19. data/lib/the_array_comparator/sample.rb +28 -0
  20. data/lib/the_array_comparator/strategies/base.rb +41 -0
  21. data/lib/the_array_comparator/strategies/contains_all.rb +35 -0
  22. data/lib/the_array_comparator/strategies/contains_all_with_substring_search.rb +39 -0
  23. data/lib/the_array_comparator/strategies/contains_any.rb +34 -0
  24. data/lib/the_array_comparator/strategies/contains_any_with_substring_search.rb +33 -0
  25. data/lib/the_array_comparator/strategies/contains_not.rb +32 -0
  26. data/lib/the_array_comparator/strategies/contains_not_with_substring_search.rb +33 -0
  27. data/lib/the_array_comparator/strategies/is_equal.rb +30 -0
  28. data/lib/the_array_comparator/strategies/is_not_equal.rb +30 -0
  29. data/lib/the_array_comparator/testing_helper/data_set.rb +63 -0
  30. data/lib/the_array_comparator/testing_helper/test_data.rb +33 -0
  31. data/lib/the_array_comparator/testing_helper.rb +55 -0
  32. data/lib/the_array_comparator/version.rb +6 -0
  33. data/lib/the_array_comparator.rb +34 -0
  34. data/script/console +8 -0
  35. data/script/terminal +12 -0
  36. data/spec/benchmark/benchmark_spec.rb +28 -0
  37. data/spec/check_spec.rb +30 -0
  38. data/spec/comparator/base_spec.rb +16 -0
  39. data/spec/comparator/comparator_spec.rb +198 -0
  40. data/spec/comparator/contains_all_spec.rb +52 -0
  41. data/spec/comparator/contains_all_with_substring_search_spec.rb +41 -0
  42. data/spec/comparator/contains_any_spec.rb +45 -0
  43. data/spec/comparator/contains_any_with_substring_search_spec.rb +35 -0
  44. data/spec/comparator/contains_not_spec.rb +45 -0
  45. data/spec/comparator/contains_not_with_substring_search_spec.rb +28 -0
  46. data/spec/comparator/is_equal_spec.rb +51 -0
  47. data/spec/comparator/is_not_equal_spec.rb +39 -0
  48. data/spec/result_spec.rb +31 -0
  49. data/spec/sample_spec.rb +24 -0
  50. data/spec/spec_helper.rb +38 -0
  51. data/spec/strategies_helper.rb +11 -0
  52. data/spec/testing_helper/testing_helper_spec.rb +27 -0
  53. data/the_array_comparator.gemspec +21 -0
  54. metadata +132 -0
data/.gitignore ADDED
@@ -0,0 +1,16 @@
1
+ .$*$
2
+ .bundle
3
+ coverage/
4
+ doc/yardoc/
5
+ *.gem
6
+ !.git*
7
+ nohup*
8
+ *.old
9
+ *.out
10
+ pkg/
11
+ pkg/*
12
+ .rvmrc
13
+ *.s??
14
+ tmp/
15
+ doc/*
16
+ .yardoc/
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format Fuubar
2
+ --t "~bm"
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 1.9.3-p374
data/.travis.yml ADDED
@@ -0,0 +1,6 @@
1
+ language: ruby
2
+ gemfile: gemfiles/Gemfile.travis
3
+ rvm:
4
+ - 1.9.3
5
+ # - 1.9.2
6
+ script: bundle exec rake test:travis_specs
data/CONTRIBUTIONS.md ADDED
@@ -0,0 +1,7 @@
1
+ # Contributing
2
+
3
+ 1. Fork it
4
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
5
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
6
+ 4. Push to the branch (`git push origin my-new-feature`)
7
+ 5. Create new Pull Request
data/Gemfile ADDED
@@ -0,0 +1,30 @@
1
+ source :rubygems
2
+
3
+ gemspec
4
+
5
+ group :test do
6
+ gem 'rake'
7
+ gem 'rspec'
8
+ gem 'simplecov'
9
+ gem 'aruba'
10
+ gem 'fuubar'
11
+ gem 'ffaker'
12
+ end
13
+
14
+ group :documentation do
15
+ gem 'yard'
16
+ gem 'redcarpet'
17
+ gem 'github-markup'
18
+ end
19
+
20
+ group :development do
21
+ gem 'tmrb'
22
+ gem 'debugger'
23
+ gem 'pry'
24
+ gem 'pry-doc'
25
+ gem 'awesome_print'
26
+ gem 'travis-lint'
27
+ gem 'activesupport'
28
+ gem 'fuubar'
29
+ gem 'churn'
30
+ end
data/Gemfile.lock ADDED
@@ -0,0 +1,122 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ the_array_comparator (0.1.1)
5
+ active_support
6
+
7
+ GEM
8
+ remote: http://rubygems.org/
9
+ specs:
10
+ active_support (3.0.0)
11
+ activesupport (= 3.0.0)
12
+ activesupport (3.0.0)
13
+ arrayfields (4.7.4)
14
+ aruba (0.5.1)
15
+ childprocess (~> 0.3.6)
16
+ cucumber (>= 1.1.1)
17
+ rspec-expectations (>= 2.7.0)
18
+ awesome_print (1.1.0)
19
+ builder (3.1.4)
20
+ childprocess (0.3.7)
21
+ ffi (~> 1.0, >= 1.0.6)
22
+ chronic (0.9.0)
23
+ churn (0.0.27)
24
+ chronic (>= 0.2.3)
25
+ hirb
26
+ json_pure
27
+ main
28
+ ruby_parser (~> 3.1.0)
29
+ sexp_processor (~> 4.1.0)
30
+ coderay (1.0.8)
31
+ columnize (0.3.6)
32
+ cucumber (1.2.1)
33
+ builder (>= 2.1.2)
34
+ diff-lcs (>= 1.1.3)
35
+ gherkin (~> 2.11.0)
36
+ json (>= 1.4.6)
37
+ debugger (1.3.0)
38
+ columnize (>= 0.3.1)
39
+ debugger-linecache (~> 1.1.1)
40
+ debugger-ruby_core_source (~> 1.1.7)
41
+ debugger-linecache (1.1.2)
42
+ debugger-ruby_core_source (>= 1.1.1)
43
+ debugger-ruby_core_source (1.1.7)
44
+ diff-lcs (1.1.3)
45
+ fattr (2.2.1)
46
+ ffaker (1.15.0)
47
+ ffi (1.3.1)
48
+ fuubar (1.1.0)
49
+ rspec (~> 2.0)
50
+ rspec-instafail (~> 0.2.0)
51
+ ruby-progressbar (~> 1.0.0)
52
+ gherkin (2.11.5)
53
+ json (>= 1.4.6)
54
+ github-markup (0.7.5)
55
+ hashr (0.0.22)
56
+ hirb (0.7.1)
57
+ json (1.7.6)
58
+ json_pure (1.7.6)
59
+ main (5.1.1)
60
+ arrayfields (>= 4.7.4)
61
+ chronic (>= 0.6.2)
62
+ fattr (>= 2.2.0)
63
+ map (>= 5.1.0)
64
+ map (6.2.0)
65
+ method_source (0.8.1)
66
+ multi_json (1.5.0)
67
+ pry (0.9.11.4)
68
+ coderay (~> 1.0.5)
69
+ method_source (~> 0.8)
70
+ slop (~> 3.4)
71
+ pry-doc (0.4.4)
72
+ pry (>= 0.9.9.6)
73
+ yard (~> 0.8.1)
74
+ rake (10.0.3)
75
+ redcarpet (2.2.2)
76
+ rspec (2.12.0)
77
+ rspec-core (~> 2.12.0)
78
+ rspec-expectations (~> 2.12.0)
79
+ rspec-mocks (~> 2.12.0)
80
+ rspec-core (2.12.2)
81
+ rspec-expectations (2.12.1)
82
+ diff-lcs (~> 1.1.3)
83
+ rspec-instafail (0.2.4)
84
+ rspec-mocks (2.12.2)
85
+ ruby-progressbar (1.0.2)
86
+ ruby_parser (3.1.1)
87
+ sexp_processor (~> 4.1)
88
+ sexp_processor (4.1.4)
89
+ simplecov (0.7.1)
90
+ multi_json (~> 1.0)
91
+ simplecov-html (~> 0.7.1)
92
+ simplecov-html (0.7.1)
93
+ slop (3.4.3)
94
+ thor (0.17.0)
95
+ tmrb (1.2.7)
96
+ thor
97
+ travis-lint (1.5.0)
98
+ hashr (~> 0.0.22)
99
+ yard (0.8.3)
100
+
101
+ PLATFORMS
102
+ ruby
103
+
104
+ DEPENDENCIES
105
+ activesupport
106
+ aruba
107
+ awesome_print
108
+ churn
109
+ debugger
110
+ ffaker
111
+ fuubar
112
+ github-markup
113
+ pry
114
+ pry-doc
115
+ rake
116
+ redcarpet
117
+ rspec
118
+ simplecov
119
+ the_array_comparator!
120
+ tmrb
121
+ travis-lint
122
+ yard
data/LICENSE.md ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (C) 2013 Max Meyer
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
4
+ this software and associated documentation files (the "Software"), to deal in
5
+ the Software without restriction, including without limitation the rights to
6
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
7
+ of the Software, and to permit persons to whom the Software is furnished to do
8
+ so, subject to the following conditions:
9
+
10
+ The above copyright notice and this permission notice shall be included in all
11
+ copies or substantial portions of the Software.
12
+
13
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19
+ SOFTWARE.
20
+
data/README.md ADDED
@@ -0,0 +1,121 @@
1
+ # The Array Comparator
2
+
3
+ [![Code Climate](https://codeclimate.com/badge.png)](https://codeclimate.com/github/maxmeyer/the_array_comparator)
4
+ [![Build Status](https://travis-ci.org/maxmeyer/the_array_comparator.png?branch=master)](https://travis-ci.org/maxmeyer/the_array_comparator)
5
+
6
+ Can be used to compare to arrays with a consistent api.
7
+
8
+ ## Installation
9
+
10
+ Add this line to your application's Gemfile:
11
+
12
+ gem 'comparator'
13
+
14
+ And then execute:
15
+
16
+ $ bundle
17
+
18
+ Or install it yourself as:
19
+
20
+ $ gem install comparator
21
+
22
+ ## Usage
23
+
24
+ Currently the following strategies are supported
25
+ <table>
26
+ <tr>
27
+ <th>Strategy</th>
28
+ <th>Description</th>
29
+ </tr>
30
+ <tr>
31
+ <td>:contains_all</td>
32
+ <td>True if all of the given keywords are part of the data</td>
33
+ </tr>
34
+ <tr>
35
+ <td>:contains_any</td>
36
+ <td>True if any of the given keywords are part of the data</td>
37
+ </tr>
38
+ <tr>
39
+ <td>:not_contains</td>
40
+ <td>True if the given keywords are not part of the data</td>
41
+ </tr>
42
+ <tr>
43
+ <td>:contains_all_as_substring</td>
44
+ <td>True if all given keywords are a substring of an data element</td>
45
+ </tr>
46
+ <tr>
47
+ <td>:contains_any_as_substring</td>
48
+ <td>True if any given keyword are a substring of an data element</td>
49
+ </tr>
50
+ <tr>
51
+ <td>:not_contains_substring</td>
52
+ <td>True if none of the given keywords is a substring of an data element</td>
53
+ </tr>
54
+ <tr>
55
+ <td>:is_equal</td>
56
+ <td>True if both, the keywords and the data, are identical</td>
57
+ </tr>
58
+ <tr>
59
+ <td>:is_not_equal</td>
60
+ <td>True if the keywords are didfferent from the data</td>
61
+ </tr>
62
+ </table>
63
+
64
+ ### Simple example
65
+
66
+ ```ruby
67
+ require 'the_array_comparator'
68
+ comparator = TheArrayComparator::Comparator.new
69
+ data = %w{ a b c d }
70
+ keyword_overlap = %w{ a b }
71
+
72
+ comparator.add_check data , :contains_all , keyword_overlap
73
+
74
+ result = comparator.success?
75
+ puts result #should be true
76
+ ```
77
+
78
+ ### Example with substrings
79
+
80
+ ```ruby
81
+ require 'the_array_comparator'
82
+ comparator = TheArrayComparator::Comparator.new
83
+ data = %w{ acd b }
84
+ keyword_overlap = %w{ cd b }
85
+
86
+ comparator.add_check data , :contains_all_as_substring, keyword_overlap
87
+
88
+ result = comparator.success?
89
+ puts result #should be true
90
+ ```
91
+
92
+ ### Example with exceptions
93
+
94
+ ```ruby
95
+ require 'the_array_comparator'
96
+ comparator = TheArrayComparator::Comparator.new
97
+ data = %w{ acd b }
98
+ keyword_overlap = %w{ a b }
99
+ exceptions = %w{ cd }
100
+
101
+ comparator.add_check data , :contains_all_as_substring, keyword_overlap, exceptions
102
+
103
+ result = comparator.success?
104
+ puts result #should be false
105
+ ```
106
+
107
+ ### Extend the library
108
+
109
+ If you wish to write your own comparators you can do so. Just register those classes with a keyword.
110
+
111
+ ```ruby
112
+ TheArrayComparator::Comparator.register :my_contains, Strategies::MyContains
113
+ ```
114
+
115
+ ## Contributing
116
+
117
+ Please see CONTRIBUTIONS.md
118
+
119
+ ## Copyright
120
+
121
+ (c) 2013 Max Meyer. All rights reserved. Please also see LICENSE.md
data/RELEASE_NOTES.md ADDED
File without changes
data/Rakefile ADDED
@@ -0,0 +1,93 @@
1
+ #!/usr/bin/env rake
2
+
3
+ unless ENV['TRAVIS_CI'] == 'true'
4
+ namespace :gem do
5
+ require 'bundler/gem_tasks'
6
+ end
7
+
8
+ require 'yard'
9
+ require 'rubygems/package_task'
10
+ require 'active_support/core_ext/string/strip'
11
+ end
12
+
13
+ YARD::Rake::YardocTask.new() do |y|
14
+ y.options << '--verbose'
15
+ end
16
+
17
+ desc 'start tmux'
18
+ task :terminal do
19
+ sh "script/terminal"
20
+ end
21
+
22
+ task :term => :terminal
23
+ task :t => :terminal
24
+
25
+ namespace :version do
26
+ version_file = Dir.glob('lib/**/version.rb').first
27
+
28
+ desc 'bump version of library to new version'
29
+ task :bump do
30
+
31
+ new_version = ENV['VERSION'] || ENV['version']
32
+
33
+ raw_module_name = File.open(version_file, "r").readlines.grep(/module/).first
34
+ module_name = raw_module_name.chomp.match(/module\s+(\S+)/) {$1}
35
+
36
+ version_string = %Q{#main #{module_name}
37
+ module #{module_name}
38
+ VERSION = '#{new_version}'
39
+ end}
40
+
41
+ File.open(version_file, "w") do |f|
42
+ f.write version_string.strip_heredoc
43
+ end
44
+
45
+ sh "git add #{version_file}"
46
+ sh "git commit -m 'version bump to #{new_version}'"
47
+ project = 'the_array_comparator'
48
+ sh "git tag #{project}-v#{new_version}"
49
+ end
50
+
51
+ desc 'show version of library'
52
+ task :show do
53
+ raw_version = File.open(version_file, "r").readlines.grep(/VERSION/).first
54
+
55
+ if raw_version
56
+ version = raw_version.chomp.match(/VERSION\s+=\s+["']([^'"]+)["']/) { $1 }
57
+ puts version
58
+ else
59
+ warn "Could not parse version file \"#{version_file}\""
60
+ end
61
+
62
+ end
63
+
64
+ desc 'Restore version file from git repository'
65
+ task :restore do
66
+ sh "git checkout #{version_file}"
67
+ end
68
+
69
+ end
70
+
71
+ namespace :travis do
72
+ desc 'Runs travis-lint to check .travis.yml'
73
+ task :check do
74
+ sh 'travis-lint'
75
+ end
76
+ end
77
+
78
+ namespace :test do
79
+ desc 'Run specs'
80
+ task :specs do
81
+ sh 'bundle exec rspec spec'
82
+ end
83
+
84
+ desc 'Run tests in "travis mode"'
85
+ task :travis_specs do
86
+ ENV['TRAVIS_CI'] = 'true'
87
+ sh 'rspec spec'
88
+ end
89
+ end
90
+
91
+ task :console do
92
+ sh 'script/console'
93
+ end
data/TODO.md ADDED
@@ -0,0 +1 @@
1
+ * Add clear (last) probe
@@ -0,0 +1,30 @@
1
+ source :rubygems
2
+
3
+ gemspec
4
+
5
+ group :test do
6
+ gem 'rake'
7
+ gem 'rspec'
8
+ gem 'simplecov'
9
+ gem 'aruba'
10
+ gem 'fuubar'
11
+ gem 'ffaker'
12
+ end
13
+
14
+ group :documentation do
15
+ gem 'yard'
16
+ gem 'redcarpet'
17
+ gem 'github-markup'
18
+ end
19
+
20
+ group :development do
21
+ gem 'tmrb'
22
+ gem 'debugger'
23
+ gem 'pry'
24
+ gem 'pry-doc'
25
+ gem 'awesome_print'
26
+ gem 'travis-lint'
27
+ gem 'activesupport'
28
+ gem 'fuubar'
29
+ gem 'churn'
30
+ end
@@ -0,0 +1,15 @@
1
+ source :rubygems
2
+
3
+ gemspec path: '../'
4
+
5
+ group :test do
6
+ gem 'rake'
7
+ gem 'rspec'
8
+ gem 'fuubar'
9
+ end
10
+
11
+ group :documentation do
12
+ gem 'yard'
13
+ gem 'redcarpet'
14
+ gem 'github-markup'
15
+ end
@@ -0,0 +1,27 @@
1
+ #encoding: utf-8
2
+
3
+ # the main module
4
+ module TheArrayComparator
5
+ # the check
6
+ class Check
7
+ extend Forwardable
8
+
9
+ # Delegates success? to check
10
+ def_delegator :@check, :success?
11
+
12
+ # @!attribute [r] sample
13
+ # the sample of the check
14
+ attr_reader :sample
15
+
16
+ # Creates new check
17
+ def initialize(strategy_klass,sample)
18
+ @check = strategy_klass.new(sample)
19
+ @sample = sample
20
+ end
21
+
22
+ # Checks for success
23
+ def success?
24
+ @check.success?
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,123 @@
1
+ #encoding: utf-8
2
+
3
+ # the main module
4
+ module TheArrayComparator
5
+ # the main comparator shell class
6
+ class Comparator
7
+
8
+ # VARIABLE to store strategies
9
+ @comparators = {}
10
+ class << self
11
+
12
+ # @!attribute [rw] command
13
+ # Return all available comparator strategies
14
+ attr_accessor :comparators
15
+
16
+ # Register a new comparator strategy
17
+ #
18
+ # @param [String,Symbol] name
19
+ # The name which can be used to refer to the registered strategy
20
+ #
21
+ # @param [Comparator] klass
22
+ # The strategy class which should be registered
23
+ #
24
+ # @raise Exceptions::IncompatibleComparator
25
+ # Raise exception if an incompatible comparator class is given
26
+ def register(name,klass)
27
+ @comparators ||= {}
28
+
29
+ if klass.new.respond_to?(:success?)
30
+ @comparators[name.to_sym] = klass
31
+ else
32
+ raise Exceptions::IncompatibleComparator, "Registering #{klass} failed. It does not support \"success?\"-instance-method"
33
+ end
34
+ end
35
+ end
36
+
37
+ # Create a new comparator instance
38
+ # and register default comparators
39
+ #
40
+ # @return [Comparator]
41
+ # a new comparator
42
+ def initialize
43
+ @checks = []
44
+ end
45
+
46
+ # Add a check to test against
47
+ #
48
+ # @param [Array] data
49
+ # the data which should be used as check, will be passed to the concrete comparator strategy
50
+ #
51
+ # @param [Symbol] type
52
+ # the comparator strategy (needs to be registered first)
53
+ #
54
+ # @param [Array] keywords
55
+ # what to look for in the data, will be passed to the concrete comparator strategy
56
+ #
57
+ # @param [Hash] options
58
+ # exception, should not be considered as match
59
+ #
60
+ # @option options [Hash] exceptions
61
+ # the exceptions from keywords
62
+ #
63
+ # @option options [String] tag
64
+ # a tag to identify the check
65
+ #
66
+ # @raise [Exceptions::UnknownCheckType]
67
+ # if a unknown strategy is given (needs to be registered first)
68
+ def add_check(data,type,keywords,options={})
69
+ raise Exceptions::UnknownCheckType, "Unknown check type \":#{type}\" given. Did you register it in advance?" unless Comparator.comparators.has_key?(type)
70
+ opts = {
71
+ exceptions: [],
72
+ tag:'',
73
+ }.merge options
74
+
75
+ sample = Sample.new(data,keywords,opts[:exceptions],opts[:tag])
76
+ strategy_klass = Comparator.comparators[type]
77
+ check = Check.new(strategy_klass,sample)
78
+
79
+ @checks << check
80
+ return check
81
+ end
82
+
83
+ def result
84
+ @checks.each { |c| return Result.new(c.sample) unless c.success? }
85
+
86
+ Result.new
87
+ end
88
+
89
+ # Run all checks
90
+ #
91
+ # @return [TrueClass, FalseClass]
92
+ # the result of all checks. if at least one fails the result will be
93
+ # 'false'. If all are true, the result will be true.
94
+ def success?
95
+ result.of_checks
96
+ end
97
+
98
+ # Delete check
99
+ #
100
+ # @param [Integer] number
101
+ # the index of the check which should be deleted
102
+ def delete_check(number)
103
+ if @checks[number]
104
+ @checks.delete_at(number)
105
+ else
106
+ raise Exceptions::CheckDoesNotExist, "You tried to delete a check, which does not exist!"
107
+ end
108
+ end
109
+
110
+ # Delete the last check added
111
+ def delete_last_check
112
+ delete_check(-1)
113
+ end
114
+
115
+ # List all added checks
116
+ #
117
+ # @return [Array]
118
+ # all available checks
119
+ def list_checks
120
+ @checks
121
+ end
122
+ end
123
+ end
@@ -0,0 +1,21 @@
1
+ # the main module
2
+ module TheArrayComparator
3
+ # exceptions which are going to be raised under
4
+ # certain conditions
5
+ module Exceptions
6
+ # Used when one tries to add an unknown
7
+ # probe type to check for
8
+ class UnknownCheckType < Exception
9
+ end
10
+
11
+ # Used if one tries to register an
12
+ # incompatible comparator
13
+ class IncompatibleComparator < Exception
14
+ end
15
+
16
+ # Used if one tries to delete an
17
+ # unexisting probe
18
+ class CheckDoesNotExist < Exception
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,21 @@
1
+ #encoding: utf-8
2
+
3
+ # the main module
4
+ module TheArrayComparator
5
+ # the check result
6
+ class Result
7
+ def initialize(sample=nil)
8
+ @sample = sample
9
+ end
10
+
11
+ def of_checks
12
+ return true if @sample.blank?
13
+ false
14
+ end
15
+
16
+ def failed_sample
17
+ @sample
18
+ end
19
+
20
+ end
21
+ end
@@ -0,0 +1,28 @@
1
+ #encoding: utf-8
2
+
3
+ # the main module
4
+ module TheArrayComparator
5
+ # class holding the data for the comparism
6
+ class Sample
7
+ # @!attribute [rw] keywords
8
+ # data used to search in other data set
9
+ #
10
+ # @!attribute [rw] data
11
+ # test data
12
+ #
13
+ # @!attribute [rw] exceptions
14
+ # exceptions from data search
15
+ #
16
+ # @!attribute [rw] tag
17
+ # description of the probe
18
+ attr_accessor :data, :keywords, :exceptions, :tag
19
+
20
+ def initialize(data=[],keywords=[],exceptions=[],tag=nil)
21
+ @keywords = keywords
22
+ @data = data
23
+ @exceptions = exceptions
24
+ @tag = tag
25
+ end
26
+
27
+ end
28
+ end