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.
- checksums.yaml +7 -0
- data/.gitignore +12 -0
- data/.rspec +1 -0
- data/.travis.yml +5 -0
- data/Gemfile +5 -13
- data/LICENSE.txt +18 -17
- data/{README.ja.rdoc → README.ja.md} +2 -4
- data/README.md +39 -0
- data/Rakefile +3 -47
- data/anodator.gemspec +21 -103
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/lib/anodator/check_result.rb +1 -1
- data/lib/anodator/input_spec.rb +2 -2
- data/lib/anodator/rule.rb +2 -2
- data/lib/anodator/utils.rb +4 -4
- data/lib/anodator/validator/format_validator.rb +1 -1
- data/lib/anodator/version.rb +3 -0
- data/lib/anodator.rb +1 -2
- metadata +70 -131
- data/Gemfile.lock +0 -29
- data/README.rdoc +0 -41
- data/spec/anodator/check_result_spec.rb +0 -101
- data/spec/anodator/checker_spec.rb +0 -273
- data/spec/anodator/input_spec_item_spec.rb +0 -100
- data/spec/anodator/input_spec_spec.rb +0 -584
- data/spec/anodator/message_spec.rb +0 -112
- data/spec/anodator/output_spec_spec.rb +0 -355
- data/spec/anodator/rule_set_spec.rb +0 -190
- data/spec/anodator/rule_spec.rb +0 -278
- data/spec/anodator/utils_spec.rb +0 -48
- data/spec/anodator/validator/base_spec.rb +0 -214
- data/spec/anodator/validator/blank_validator_spec.rb +0 -52
- data/spec/anodator/validator/complex_validator_spec.rb +0 -268
- data/spec/anodator/validator/date_validator_spec.rb +0 -350
- data/spec/anodator/validator/format_validator_spec.rb +0 -158
- data/spec/anodator/validator/inclusion_validator_spec.rb +0 -77
- data/spec/anodator/validator/length_validator_spec.rb +0 -236
- data/spec/anodator/validator/numeric_validator_spec.rb +0 -538
- data/spec/anodator/validator/presence_validator_spec.rb +0 -52
- data/spec/anodator/validator_spec.rb +0 -16
- data/spec/anodator_spec.rb +0 -2
- data/spec/spec_helper.rb +0 -12
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: d8ee623260763c5a8a7dc7533de1a6190176437b
|
4
|
+
data.tar.gz: e26608fc23a6a59c47d6f5c7f1f8ed156b05899d
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 23ff4259940ea0c129cde70e27796b497c00830db5d65e1603f2b84e4036e07d1250007e93a28320259913c9261e4e22058684141af1dbbd6a9aabf763cf9b92
|
7
|
+
data.tar.gz: 1b1ddaefeb76efea2770ec4f94404c046923198e160d4aab3c1f673e65facc8ac0a5d881f3e3fe9945b5093827e315736c7a8cde7f8713dbcecbbe264b6d7414
|
data/.gitignore
ADDED
data/.rspec
CHANGED
data/.travis.yml
ADDED
data/Gemfile
CHANGED
@@ -1,14 +1,6 @@
|
|
1
|
-
source "
|
2
|
-
# Add dependencies required to use your gem here.
|
3
|
-
# Example:
|
4
|
-
# gem "activesupport", ">= 2.3.5"
|
1
|
+
source "https://rubygems.org"
|
5
2
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
gem "bundler", "~> 1.0.0"
|
11
|
-
gem "jeweler", "~> 1.6.4"
|
12
|
-
gem "rcov", ">= 0"
|
13
|
-
gem "rake", "= 0.8.7"
|
14
|
-
end
|
3
|
+
git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
|
4
|
+
|
5
|
+
# Specify your gem's dependencies in anodator.gemspec
|
6
|
+
gemspec
|
data/LICENSE.txt
CHANGED
@@ -1,20 +1,21 @@
|
|
1
|
-
|
1
|
+
The MIT License (MIT)
|
2
2
|
|
3
|
-
|
4
|
-
a copy of this software and associated documentation files (the
|
5
|
-
"Software"), to deal in the Software without restriction, including
|
6
|
-
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
-
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
-
permit persons to whom the Software is furnished to do so, subject to
|
9
|
-
the following conditions:
|
3
|
+
Copyright (c) 2017 Tetsuhisa MAKINO
|
10
4
|
|
11
|
-
|
12
|
-
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
13
11
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
@@ -5,8 +5,7 @@ anodator はテキストデータのチェックを支援するライブラリ
|
|
5
5
|
出力結果は二次元配列として出力されます。
|
6
6
|
anodator はチェックに際し、受け取るデータの仕様、チェックするためのルールセット、
|
7
7
|
および、出力時の仕様を受け取ることで、任意形式の入出力に対応します。
|
8
|
-
通常は Ruby
|
9
|
-
提供されます。
|
8
|
+
通常は Ruby コード上で各種仕様の受け渡し等を実施しますが、簡易的な設定方法も提供されます。
|
10
9
|
|
11
10
|
== インストール方法
|
12
11
|
|
@@ -28,6 +27,5 @@ Tetsuhisa MAKINO <tim.makino at gmail.com>
|
|
28
27
|
|
29
28
|
== Copyright
|
30
29
|
|
31
|
-
Copyright (c)
|
30
|
+
Copyright (c) 2017 Tetsuhisa MAKINO. See LICENSE.txt for
|
32
31
|
further details.
|
33
|
-
|
data/README.md
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
# Anodator
|
2
|
+
|
3
|
+
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/anodator`. To experiment with that code, run `bin/console` for an interactive prompt.
|
4
|
+
|
5
|
+
TODO: Delete this and the text above, and describe your gem
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
gem 'anodator'
|
13
|
+
```
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
$ gem install anodator
|
22
|
+
|
23
|
+
## Usage
|
24
|
+
|
25
|
+
TODO: Write usage instructions here
|
26
|
+
|
27
|
+
## Development
|
28
|
+
|
29
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
30
|
+
|
31
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
32
|
+
|
33
|
+
## Contributing
|
34
|
+
|
35
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/anodator.
|
36
|
+
|
37
|
+
## License
|
38
|
+
|
39
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
data/Rakefile
CHANGED
@@ -1,50 +1,6 @@
|
|
1
|
-
|
1
|
+
require "bundler/gem_tasks"
|
2
|
+
require "rspec/core/rake_task"
|
2
3
|
|
3
|
-
|
4
|
-
require 'bundler'
|
5
|
-
begin
|
6
|
-
Bundler.setup(:default, :development)
|
7
|
-
rescue Bundler::BundlerError => e
|
8
|
-
$stderr.puts e.message
|
9
|
-
$stderr.puts "Run `bundle install` to install missing gems"
|
10
|
-
exit e.status_code
|
11
|
-
end
|
12
|
-
require 'rake'
|
13
|
-
|
14
|
-
require 'jeweler'
|
15
|
-
Jeweler::Tasks.new do |gem|
|
16
|
-
# gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
|
17
|
-
gem.name = "anodator"
|
18
|
-
gem.homepage = "https://github.com/maki-tetsu/anodator"
|
19
|
-
gem.license = "MIT"
|
20
|
-
gem.summary = %Q{anodator is Anonymous Data Validator.}
|
21
|
-
gem.description = %Q{anodator is Anonymous Data Validator.}
|
22
|
-
gem.email = "tim.makino at gmail.com"
|
23
|
-
gem.authors = ["Tetsuhisa MAKINO"]
|
24
|
-
# dependencies defined in Gemfile
|
25
|
-
end
|
26
|
-
Jeweler::RubygemsDotOrgTasks.new
|
27
|
-
|
28
|
-
require 'rspec/core'
|
29
|
-
require 'rspec/core/rake_task'
|
30
|
-
RSpec::Core::RakeTask.new(:spec) do |spec|
|
31
|
-
spec.pattern = FileList['spec/**/*_spec.rb']
|
32
|
-
end
|
33
|
-
|
34
|
-
RSpec::Core::RakeTask.new(:rcov) do |spec|
|
35
|
-
spec.pattern = 'spec/**/*_spec.rb'
|
36
|
-
spec.rcov = true
|
37
|
-
end
|
4
|
+
RSpec::Core::RakeTask.new(:spec)
|
38
5
|
|
39
6
|
task :default => :spec
|
40
|
-
|
41
|
-
require 'rake/rdoctask'
|
42
|
-
Rake::RDocTask.new do |rdoc|
|
43
|
-
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
44
|
-
|
45
|
-
rdoc.rdoc_dir = 'rdoc'
|
46
|
-
rdoc.title = "anodator #{version}"
|
47
|
-
rdoc.rdoc_files.include('README*')
|
48
|
-
rdoc.rdoc_files.include('lib/**/*.rb')
|
49
|
-
rdoc.options << "--charset=utf8"
|
50
|
-
end
|
data/anodator.gemspec
CHANGED
@@ -1,108 +1,26 @@
|
|
1
|
-
#
|
2
|
-
|
3
|
-
|
4
|
-
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path("../lib", __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require "anodator/version"
|
5
5
|
|
6
|
-
Gem::Specification.new do |
|
7
|
-
|
8
|
-
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "anodator"
|
8
|
+
spec.version = Anodator::VERSION
|
9
|
+
spec.authors = ["Tetsuhisa MAKINO"]
|
10
|
+
spec.email = ["tim.makino at gmail.com"]
|
9
11
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
s.description = %q{anodator is Anonymous Data Validator.}
|
14
|
-
s.email = %q{tim.makino at gmail.com}
|
15
|
-
s.extra_rdoc_files = [
|
16
|
-
"LICENSE.txt",
|
17
|
-
"README.ja.rdoc",
|
18
|
-
"README.rdoc"
|
19
|
-
]
|
20
|
-
s.files = [
|
21
|
-
".document",
|
22
|
-
".rspec",
|
23
|
-
"Gemfile",
|
24
|
-
"Gemfile.lock",
|
25
|
-
"LICENSE.txt",
|
26
|
-
"README.ja.rdoc",
|
27
|
-
"README.rdoc",
|
28
|
-
"Rakefile",
|
29
|
-
"VERSION",
|
30
|
-
"anodator.gemspec",
|
31
|
-
"example/example_01.rb",
|
32
|
-
"lib/anodator.rb",
|
33
|
-
"lib/anodator/anodator_error.rb",
|
34
|
-
"lib/anodator/check_result.rb",
|
35
|
-
"lib/anodator/checker.rb",
|
36
|
-
"lib/anodator/input_spec.rb",
|
37
|
-
"lib/anodator/input_spec_item.rb",
|
38
|
-
"lib/anodator/message.rb",
|
39
|
-
"lib/anodator/output_spec.rb",
|
40
|
-
"lib/anodator/rule.rb",
|
41
|
-
"lib/anodator/rule_set.rb",
|
42
|
-
"lib/anodator/utils.rb",
|
43
|
-
"lib/anodator/validator.rb",
|
44
|
-
"lib/anodator/validator/base.rb",
|
45
|
-
"lib/anodator/validator/blank_validator.rb",
|
46
|
-
"lib/anodator/validator/complex_validator.rb",
|
47
|
-
"lib/anodator/validator/configuration_error.rb",
|
48
|
-
"lib/anodator/validator/date_validator.rb",
|
49
|
-
"lib/anodator/validator/format_validator.rb",
|
50
|
-
"lib/anodator/validator/inclusion_validator.rb",
|
51
|
-
"lib/anodator/validator/length_validator.rb",
|
52
|
-
"lib/anodator/validator/numeric_validator.rb",
|
53
|
-
"lib/anodator/validator/presence_validator.rb",
|
54
|
-
"lib/anodator/validator/value_proxy.rb",
|
55
|
-
"spec/anodator/check_result_spec.rb",
|
56
|
-
"spec/anodator/checker_spec.rb",
|
57
|
-
"spec/anodator/input_spec_item_spec.rb",
|
58
|
-
"spec/anodator/input_spec_spec.rb",
|
59
|
-
"spec/anodator/message_spec.rb",
|
60
|
-
"spec/anodator/output_spec_spec.rb",
|
61
|
-
"spec/anodator/rule_set_spec.rb",
|
62
|
-
"spec/anodator/rule_spec.rb",
|
63
|
-
"spec/anodator/utils_spec.rb",
|
64
|
-
"spec/anodator/validator/base_spec.rb",
|
65
|
-
"spec/anodator/validator/blank_validator_spec.rb",
|
66
|
-
"spec/anodator/validator/complex_validator_spec.rb",
|
67
|
-
"spec/anodator/validator/date_validator_spec.rb",
|
68
|
-
"spec/anodator/validator/format_validator_spec.rb",
|
69
|
-
"spec/anodator/validator/inclusion_validator_spec.rb",
|
70
|
-
"spec/anodator/validator/length_validator_spec.rb",
|
71
|
-
"spec/anodator/validator/numeric_validator_spec.rb",
|
72
|
-
"spec/anodator/validator/presence_validator_spec.rb",
|
73
|
-
"spec/anodator/validator_spec.rb",
|
74
|
-
"spec/anodator_spec.rb",
|
75
|
-
"spec/spec_helper.rb"
|
76
|
-
]
|
77
|
-
s.homepage = %q{https://github.com/maki-tetsu/anodator}
|
78
|
-
s.licenses = ["MIT"]
|
79
|
-
s.require_paths = ["lib"]
|
80
|
-
s.rubygems_version = %q{1.3.6}
|
81
|
-
s.summary = %q{anodator is Anonymous Data Validator.}
|
12
|
+
spec.summary = %q{anodator is Anonymous Data Validator.}
|
13
|
+
spec.homepage = "https://github.com/maki-tetsu/anodator"
|
14
|
+
spec.license = "MIT"
|
82
15
|
|
83
|
-
|
84
|
-
|
85
|
-
s.specification_version = 3
|
86
|
-
|
87
|
-
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
88
|
-
s.add_development_dependency(%q<rspec>, ["~> 2.3.0"])
|
89
|
-
s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
|
90
|
-
s.add_development_dependency(%q<jeweler>, ["~> 1.6.4"])
|
91
|
-
s.add_development_dependency(%q<rcov>, [">= 0"])
|
92
|
-
s.add_development_dependency(%q<rake>, ["= 0.8.7"])
|
93
|
-
else
|
94
|
-
s.add_dependency(%q<rspec>, ["~> 2.3.0"])
|
95
|
-
s.add_dependency(%q<bundler>, ["~> 1.0.0"])
|
96
|
-
s.add_dependency(%q<jeweler>, ["~> 1.6.4"])
|
97
|
-
s.add_dependency(%q<rcov>, [">= 0"])
|
98
|
-
s.add_dependency(%q<rake>, ["= 0.8.7"])
|
99
|
-
end
|
100
|
-
else
|
101
|
-
s.add_dependency(%q<rspec>, ["~> 2.3.0"])
|
102
|
-
s.add_dependency(%q<bundler>, ["~> 1.0.0"])
|
103
|
-
s.add_dependency(%q<jeweler>, ["~> 1.6.4"])
|
104
|
-
s.add_dependency(%q<rcov>, [">= 0"])
|
105
|
-
s.add_dependency(%q<rake>, ["= 0.8.7"])
|
16
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
17
|
+
f.match(%r{^(test|spec|features)/})
|
106
18
|
end
|
107
|
-
|
19
|
+
spec.bindir = "exe"
|
20
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
21
|
+
spec.require_paths = ["lib"]
|
108
22
|
|
23
|
+
spec.add_development_dependency "bundler", "~> 1.15"
|
24
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
25
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
26
|
+
end
|
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "anodator"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
data/lib/anodator/input_spec.rb
CHANGED
@@ -125,7 +125,7 @@ module Anodator
|
|
125
125
|
def [](target_expression)
|
126
126
|
raise SourceDataNotProvidedError.new if @source.nil?
|
127
127
|
|
128
|
-
if target_expression.is_a?
|
128
|
+
if target_expression.is_a? Integer
|
129
129
|
return value_at(target_expression)
|
130
130
|
elsif /^CALC::(.+)$/.match target_expression
|
131
131
|
return value_by_calculation($1)
|
@@ -171,7 +171,7 @@ module Anodator
|
|
171
171
|
private :spec_items_by_calculation
|
172
172
|
|
173
173
|
def spec_item_by_expression(target_expression)
|
174
|
-
if target_expression.is_a?
|
174
|
+
if target_expression.is_a? Integer
|
175
175
|
return spec_item_at(target_expression)
|
176
176
|
elsif /^CALC::(.+)$/.match target_expression
|
177
177
|
return spec_items_by_calculation($1)
|
data/lib/anodator/rule.rb
CHANGED
@@ -56,7 +56,7 @@ module Anodator
|
|
56
56
|
end
|
57
57
|
|
58
58
|
def initialize(target_expressions, message, validator, prerequisite = nil, level = ERROR_LEVELS.values.sort.last, description = nil)
|
59
|
-
@target_expressions = target_expressions.
|
59
|
+
@target_expressions = [target_expressions].flatten
|
60
60
|
@message = message
|
61
61
|
@validator = validator
|
62
62
|
@prerequisite = prerequisite
|
@@ -121,7 +121,7 @@ module Anodator
|
|
121
121
|
|
122
122
|
def self.level_expression(level)
|
123
123
|
if ERROR_LEVELS.values.include?(level)
|
124
|
-
return ERROR_LEVEL_NAMES[ERROR_LEVELS.
|
124
|
+
return ERROR_LEVEL_NAMES[ERROR_LEVELS.key(level)]
|
125
125
|
end
|
126
126
|
|
127
127
|
return nil
|
data/lib/anodator/utils.rb
CHANGED
@@ -17,7 +17,7 @@ module Anodator
|
|
17
17
|
first = true
|
18
18
|
header = nil
|
19
19
|
spec = []
|
20
|
-
CSV.
|
20
|
+
CSV.read(file_path).each do |row|
|
21
21
|
# skip header
|
22
22
|
if first
|
23
23
|
header = row
|
@@ -61,7 +61,7 @@ module Anodator
|
|
61
61
|
first = true
|
62
62
|
header = nil
|
63
63
|
spec = []
|
64
|
-
CSV.
|
64
|
+
CSV.read(file_path).each do |row|
|
65
65
|
# skip header
|
66
66
|
if first
|
67
67
|
header = row
|
@@ -122,7 +122,7 @@ module Anodator
|
|
122
122
|
header = nil
|
123
123
|
validators = { }
|
124
124
|
|
125
|
-
CSV.
|
125
|
+
CSV.read(file_path).each do |row|
|
126
126
|
# skip header
|
127
127
|
if first
|
128
128
|
header = row
|
@@ -191,7 +191,7 @@ module Anodator
|
|
191
191
|
header = nil
|
192
192
|
rule_set = RuleSet.new
|
193
193
|
|
194
|
-
CSV.
|
194
|
+
CSV.read(file_path).each do |row|
|
195
195
|
# skip header
|
196
196
|
if first
|
197
197
|
header = row
|
@@ -4,7 +4,7 @@ require "anodator/validator/configuration_error"
|
|
4
4
|
module Anodator
|
5
5
|
module Validator
|
6
6
|
class FormatValidator < Base
|
7
|
-
ALL_ZENKAKU_REGEXP = /(
|
7
|
+
ALL_ZENKAKU_REGEXP = /(?:[\xEF\xBD\xA1-\xEF\xBD\xBF]|[\xEF\xBE\x80-\xEF\xBE\x9F])|[\x20-\x7E]/
|
8
8
|
|
9
9
|
valid_option_keys :format, :all_zenkaku
|
10
10
|
default_options :all_zenkaku => false
|
data/lib/anodator.rb
CHANGED