kosher 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.
- data/.gitignore +3 -0
- data/.rspec +2 -0
- data/.rvmrc +1 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +24 -0
- data/LICENSE +22 -0
- data/README.md +8 -0
- data/Rakefile +2 -0
- data/kosher.gemspec +23 -0
- data/lib/kosher/regexps.rb +7 -0
- data/lib/kosher/string.rb +50 -0
- data/lib/kosher/version.rb +3 -0
- data/lib/kosher.rb +9 -0
- data/spec/kosher/string_spec.rb +49 -0
- data/spec/kosher_spec.rb +9 -0
- data/spec/spec_helper.rb +7 -0
- data/walter_benjamin.jpg +0 -0
- metadata +101 -0
data/.gitignore
ADDED
data/.rspec
ADDED
data/.rvmrc
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
rvm --create use ree@kosher
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
kosher (0.0.1)
|
5
|
+
|
6
|
+
GEM
|
7
|
+
remote: http://rubygems.org/
|
8
|
+
specs:
|
9
|
+
diff-lcs (1.1.2)
|
10
|
+
rspec (2.2.0)
|
11
|
+
rspec-core (~> 2.2)
|
12
|
+
rspec-expectations (~> 2.2)
|
13
|
+
rspec-mocks (~> 2.2)
|
14
|
+
rspec-core (2.2.1)
|
15
|
+
rspec-expectations (2.2.0)
|
16
|
+
diff-lcs (~> 1.1.2)
|
17
|
+
rspec-mocks (2.2.0)
|
18
|
+
|
19
|
+
PLATFORMS
|
20
|
+
ruby
|
21
|
+
|
22
|
+
DEPENDENCIES
|
23
|
+
kosher!
|
24
|
+
rspec (~> 2.2.0)
|
data/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
(The MIT License)
|
2
|
+
|
3
|
+
Copyright (c) 2010 Paper Cavalier
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
'Software'), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
19
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
20
|
+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
21
|
+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
22
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
data/Rakefile
ADDED
data/kosher.gemspec
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "kosher/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "kosher"
|
7
|
+
s.version = Kosher::VERSION
|
8
|
+
s.platform = Gem::Platform::RUBY
|
9
|
+
s.authors = ["Paper Cavalier"]
|
10
|
+
s.email = ["code@papercvalier.com"]
|
11
|
+
s.homepage = ""
|
12
|
+
s.summary = %q{Kosher validates descriptions}
|
13
|
+
s.description = %q{Have you ever wondered if you should buy a book?}
|
14
|
+
|
15
|
+
s.rubyforge_project = "kosher"
|
16
|
+
|
17
|
+
s.files = `git ls-files`.split("\n")
|
18
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
19
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
20
|
+
s.require_paths = ["lib"]
|
21
|
+
|
22
|
+
s.add_development_dependency("rspec", ["~> 2.2.0"])
|
23
|
+
end
|
@@ -0,0 +1,7 @@
|
|
1
|
+
module Kosher
|
2
|
+
DAMAGED = "missing|torn|broken|split|different|discard|withdrawn|rent|stain|school|damaged|water"
|
3
|
+
EXLIBRARY = "(?:e?x|discarded|retired|former|has|have)[\\s._-]*lib"
|
4
|
+
MARKED = "(highlight|hilit|underlin)"
|
5
|
+
MISSING_VOL = "(vols?|volume) only"
|
6
|
+
REVIEW_COPY = "\\b(?:uncorrected|advanced?\\sreview|arc)\\b"
|
7
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
module Kosher
|
2
|
+
class String < String
|
3
|
+
def kosher?
|
4
|
+
!(present? && (
|
5
|
+
damaged? ||
|
6
|
+
ex_library? ||
|
7
|
+
marked? ||
|
8
|
+
missing_volume? ||
|
9
|
+
review_copy?))
|
10
|
+
end
|
11
|
+
|
12
|
+
private
|
13
|
+
|
14
|
+
def expect(str)
|
15
|
+
!!match(Regexp.new(str, true))
|
16
|
+
end
|
17
|
+
|
18
|
+
def do_not_expect(str)
|
19
|
+
!match(Regexp.new(str, true))
|
20
|
+
end
|
21
|
+
|
22
|
+
def damaged?
|
23
|
+
expect(DAMAGED)
|
24
|
+
end
|
25
|
+
|
26
|
+
def ex_library?
|
27
|
+
expect(EXLIBRARY) && do_not_expect(negation_of(EXLIBRARY))
|
28
|
+
end
|
29
|
+
|
30
|
+
def marked?
|
31
|
+
expect(MARKED) && do_not_expect(negation_of(MARKED))
|
32
|
+
end
|
33
|
+
|
34
|
+
def missing_volume?
|
35
|
+
expect(MISSING_VOL)
|
36
|
+
end
|
37
|
+
|
38
|
+
def negation_of(str)
|
39
|
+
"(?:no|not an?)\\s+#{str}"
|
40
|
+
end
|
41
|
+
|
42
|
+
def present?
|
43
|
+
self != ''
|
44
|
+
end
|
45
|
+
|
46
|
+
def review_copy?
|
47
|
+
expect(REVIEW_COPY)
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
data/lib/kosher.rb
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
module Kosher
|
4
|
+
describe String do
|
5
|
+
def this(val)
|
6
|
+
Kosher::String.new(val)
|
7
|
+
end
|
8
|
+
|
9
|
+
it "validates a blank description" do
|
10
|
+
this("").should be_kosher
|
11
|
+
end
|
12
|
+
|
13
|
+
it "validates a non-blank description" do
|
14
|
+
this("foo").should be_kosher
|
15
|
+
end
|
16
|
+
|
17
|
+
it "does not validate advance reviews" do
|
18
|
+
this("Uncorrected review copy").should_not be_kosher
|
19
|
+
this("arc").should_not be_kosher
|
20
|
+
this("arc.").should_not be_kosher
|
21
|
+
|
22
|
+
this("marc").should be_kosher
|
23
|
+
end
|
24
|
+
|
25
|
+
it "does not validate marked books" do
|
26
|
+
this("Some highlighting").should_not be_kosher
|
27
|
+
this("Underlining.").should_not be_kosher
|
28
|
+
this("Good. Hiliting.").should_not be_kosher
|
29
|
+
|
30
|
+
this("No highlighting.").should be_kosher
|
31
|
+
end
|
32
|
+
|
33
|
+
it "does not validate books with missing volumes" do
|
34
|
+
this("First vol only.").should_not be_kosher
|
35
|
+
end
|
36
|
+
|
37
|
+
it "does not validate damaged or worn books" do
|
38
|
+
this("Torn pages").should_not be_kosher
|
39
|
+
end
|
40
|
+
|
41
|
+
it "does not validate withdrawn library copies" do
|
42
|
+
this("xlib").should_not be_kosher
|
43
|
+
this("ex-library").should_not be_kosher
|
44
|
+
this("retired library copy").should_not be_kosher
|
45
|
+
|
46
|
+
this("Not an ex-library").should be_kosher
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
data/spec/kosher_spec.rb
ADDED
data/spec/spec_helper.rb
ADDED
data/walter_benjamin.jpg
ADDED
Binary file
|
metadata
ADDED
@@ -0,0 +1,101 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: kosher
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 29
|
5
|
+
prerelease: false
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 0
|
9
|
+
- 1
|
10
|
+
version: 0.0.1
|
11
|
+
platform: ruby
|
12
|
+
authors:
|
13
|
+
- Paper Cavalier
|
14
|
+
autorequire:
|
15
|
+
bindir: bin
|
16
|
+
cert_chain: []
|
17
|
+
|
18
|
+
date: 2010-12-09 00:00:00 +00:00
|
19
|
+
default_executable:
|
20
|
+
dependencies:
|
21
|
+
- !ruby/object:Gem::Dependency
|
22
|
+
name: rspec
|
23
|
+
prerelease: false
|
24
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ~>
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
hash: 7
|
30
|
+
segments:
|
31
|
+
- 2
|
32
|
+
- 2
|
33
|
+
- 0
|
34
|
+
version: 2.2.0
|
35
|
+
type: :development
|
36
|
+
version_requirements: *id001
|
37
|
+
description: Have you ever wondered if you should buy a book?
|
38
|
+
email:
|
39
|
+
- code@papercvalier.com
|
40
|
+
executables: []
|
41
|
+
|
42
|
+
extensions: []
|
43
|
+
|
44
|
+
extra_rdoc_files: []
|
45
|
+
|
46
|
+
files:
|
47
|
+
- .gitignore
|
48
|
+
- .rspec
|
49
|
+
- .rvmrc
|
50
|
+
- Gemfile
|
51
|
+
- Gemfile.lock
|
52
|
+
- LICENSE
|
53
|
+
- README.md
|
54
|
+
- Rakefile
|
55
|
+
- kosher.gemspec
|
56
|
+
- lib/kosher.rb
|
57
|
+
- lib/kosher/regexps.rb
|
58
|
+
- lib/kosher/string.rb
|
59
|
+
- lib/kosher/version.rb
|
60
|
+
- spec/kosher/string_spec.rb
|
61
|
+
- spec/kosher_spec.rb
|
62
|
+
- spec/spec_helper.rb
|
63
|
+
- walter_benjamin.jpg
|
64
|
+
has_rdoc: true
|
65
|
+
homepage: ""
|
66
|
+
licenses: []
|
67
|
+
|
68
|
+
post_install_message:
|
69
|
+
rdoc_options: []
|
70
|
+
|
71
|
+
require_paths:
|
72
|
+
- lib
|
73
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
74
|
+
none: false
|
75
|
+
requirements:
|
76
|
+
- - ">="
|
77
|
+
- !ruby/object:Gem::Version
|
78
|
+
hash: 3
|
79
|
+
segments:
|
80
|
+
- 0
|
81
|
+
version: "0"
|
82
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
83
|
+
none: false
|
84
|
+
requirements:
|
85
|
+
- - ">="
|
86
|
+
- !ruby/object:Gem::Version
|
87
|
+
hash: 3
|
88
|
+
segments:
|
89
|
+
- 0
|
90
|
+
version: "0"
|
91
|
+
requirements: []
|
92
|
+
|
93
|
+
rubyforge_project: kosher
|
94
|
+
rubygems_version: 1.3.7
|
95
|
+
signing_key:
|
96
|
+
specification_version: 3
|
97
|
+
summary: Kosher validates descriptions
|
98
|
+
test_files:
|
99
|
+
- spec/kosher/string_spec.rb
|
100
|
+
- spec/kosher_spec.rb
|
101
|
+
- spec/spec_helper.rb
|