snl-kosher 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +7 -0
- data/Manifest.txt +8 -0
- data/README.rdoc +30 -3
- data/Rakefile +25 -0
- data/data/rules.yml +1 -1
- data/lib/kosher.rb +7 -3
- data/test/test_helper.rb +3 -0
- data/test/{kosher_test.rb → test_kosher.rb} +45 -42
- metadata +39 -11
data/History.txt
ADDED
data/Manifest.txt
ADDED
data/README.rdoc
CHANGED
@@ -1,10 +1,16 @@
|
|
1
|
-
=
|
1
|
+
= kosher
|
2
|
+
|
3
|
+
* http://github.com/snl/kosher
|
4
|
+
|
5
|
+
== DESCRIPTION:
|
2
6
|
|
3
7
|
People sell stuff online. Some are bad sellers. Some sell bad stuff. This module provides some basic methods to filter out those iffy listings you probably do not want to buy.
|
4
8
|
|
9
|
+
== FEATURES/PROBLEMS:
|
10
|
+
|
5
11
|
The current incarnation only works with Amazon sellers and book descriptions in English, but the idea is easily expandable to other product groups, venues, or languages.
|
6
12
|
|
7
|
-
==
|
13
|
+
== SYNOPSIS:
|
8
14
|
|
9
15
|
>> load "lib/kosher.rb"
|
10
16
|
=> true
|
@@ -23,4 +29,25 @@ The current incarnation only works with Amazon sellers and book descriptions in
|
|
23
29
|
>> Kosher.description? :book, "Some highlighting."
|
24
30
|
=> false
|
25
31
|
|
26
|
-
|
32
|
+
== LICENSE:
|
33
|
+
|
34
|
+
Copyright (c) 2009 Hakan Şenol Ensari
|
35
|
+
|
36
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
37
|
+
a copy of this software and associated documentation files (the
|
38
|
+
'Software'), to deal in the Software without restriction, including
|
39
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
40
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
41
|
+
permit persons to whom the Software is furnished to do so, subject to
|
42
|
+
the following conditions:
|
43
|
+
|
44
|
+
The above copyright notice and this permission notice shall be
|
45
|
+
included in all copies or substantial portions of the Software.
|
46
|
+
|
47
|
+
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
48
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
49
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
50
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
51
|
+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
52
|
+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
53
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/Rakefile
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
require 'rubygems' unless ENV['NO_RUBYGEMS']
|
2
|
+
%w[rake rake/clean fileutils newgem rubigen].each { |f| require f }
|
3
|
+
require File.dirname(__FILE__) + '/lib/kosher'
|
4
|
+
|
5
|
+
# Generate all the Rake tasks
|
6
|
+
# Run 'rake -T' to see list of generated tasks (from gem root directory)
|
7
|
+
$hoe = Hoe.new('kosher', Kosher::VERSION) do |p|
|
8
|
+
p.developer('Hakan Şenol Ensari', 'snl@theorydot.com')
|
9
|
+
p.changes = p.paragraphs_of("History.txt", 0..1).join("\n\n")
|
10
|
+
p.rubyforge_name = p.name
|
11
|
+
# p.extra_deps = [
|
12
|
+
# ['activesupport','>= 2.0.2'],
|
13
|
+
# ]
|
14
|
+
p.extra_dev_deps = [
|
15
|
+
['newgem', ">= #{::Newgem::VERSION}"]
|
16
|
+
]
|
17
|
+
|
18
|
+
p.clean_globs |= %w[**/.DS_Store tmp *.log]
|
19
|
+
path = (p.rubyforge_name == p.name) ? p.rubyforge_name : "\#{p.rubyforge_name}/\#{p.name}"
|
20
|
+
p.remote_rdoc_dir = File.join(path.gsub(/^#{p.rubyforge_name}\/?/,''), 'rdoc')
|
21
|
+
p.rsync_args = '-av --delete --ignore-errors'
|
22
|
+
end
|
23
|
+
|
24
|
+
require 'newgem/tasks' # load /tasks/*.rake
|
25
|
+
Dir['tasks/**/*.rake'].each { |t| load t }
|
data/data/rules.yml
CHANGED
@@ -5,4 +5,4 @@
|
|
5
5
|
- bad: \. *highlight|\. *hili|^ *highlight|^ *hili
|
6
6
|
- bad: missing|torn|broken|split|different|no cd|sticker|stain|damaged|water
|
7
7
|
- bad: discard|withdrawn|x.{0,2}lib|retired.*library|former.*library|has.*library|may have library|school
|
8
|
-
good: not a?n? ?(e?x.{0,2}lib|library)
|
8
|
+
good: not a?n? ?(e?x.{0,2}lib|library)
|
data/lib/kosher.rb
CHANGED
@@ -1,6 +1,10 @@
|
|
1
|
-
require
|
1
|
+
require 'yaml'
|
2
2
|
|
3
|
-
|
3
|
+
$:.unshift(File.dirname(__FILE__)) unless
|
4
|
+
$:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__)))
|
5
|
+
|
6
|
+
module Kosher
|
7
|
+
VERSION = '0.1.1'
|
4
8
|
RULES = File.open(File.join(File.dirname(__FILE__), "../data/rules.yml")) {|f| YAML.load(f)}
|
5
9
|
|
6
10
|
# Check if a book description is kosher.
|
@@ -35,4 +39,4 @@ module Kosher
|
|
35
39
|
end
|
36
40
|
end
|
37
41
|
end
|
38
|
-
end
|
42
|
+
end
|
data/test/test_helper.rb
ADDED
@@ -1,42 +1,45 @@
|
|
1
|
-
require
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
assert_equal
|
37
|
-
assert_equal
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
1
|
+
require File.dirname(__FILE__) + '/test_helper.rb'
|
2
|
+
|
3
|
+
class TestKosher < Test::Unit::TestCase
|
4
|
+
|
5
|
+
def setup
|
6
|
+
end
|
7
|
+
|
8
|
+
def test_book_descriptions
|
9
|
+
kosher_descriptions = {:en => {:book => [nil,
|
10
|
+
"",
|
11
|
+
"Lorem ipsum",
|
12
|
+
"Not exlib",
|
13
|
+
"No highlighting"]}}
|
14
|
+
unkosher_descriptions = {:en => {:book => ["Some underlining",
|
15
|
+
"Has highlighting",
|
16
|
+
"A withdrawn library copy",
|
17
|
+
"Awesome book. EXLIB!",
|
18
|
+
"A former school library book"]}}
|
19
|
+
kosher_descriptions.each do |language, product_groups|
|
20
|
+
product_groups.each do |product_group, descriptions|
|
21
|
+
descriptions.each do |description|
|
22
|
+
assert_equal true, (Kosher.description? product_group, description, language), description
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
unkosher_descriptions.each do |language, product_groups|
|
27
|
+
product_groups.each do |product_group, descriptions|
|
28
|
+
descriptions.each do |description|
|
29
|
+
assert_equal false, (Kosher.description? product_group, description, language), description
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
def test_amazon_sellers
|
36
|
+
assert_equal true, (Kosher.seller? :amazon, nil, 0), "Kosher new Amazon seller"
|
37
|
+
assert_equal true, (Kosher.seller? :amazon, 4.5, 1), "Kosher small Amazon seller"
|
38
|
+
assert_equal true, (Kosher.seller? :amazon, 4.9, 100), "Kosher big Amazon seller"
|
39
|
+
assert_equal false, (Kosher.seller? :amazon, 4, 1), "Unkosher small Amazon seller"
|
40
|
+
assert_equal false, (Kosher.seller? :amazon, 4.5, 100), "Unkosher big Amazon seller"
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
require 'test/unit/ui/console/testrunner'
|
45
|
+
Test::Unit::UI::Console::TestRunner.run(TestKosher)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: snl-kosher
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- "Hakan \xC5\x9Eenol Ensari"
|
@@ -9,28 +9,55 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-05-
|
12
|
+
date: 2009-05-08 00:00:00 -07:00
|
13
13
|
default_executable:
|
14
|
-
dependencies:
|
15
|
-
|
16
|
-
|
17
|
-
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: newgem
|
17
|
+
type: :development
|
18
|
+
version_requirement:
|
19
|
+
version_requirements: !ruby/object:Gem::Requirement
|
20
|
+
requirements:
|
21
|
+
- - ">="
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: 1.4.1
|
24
|
+
version:
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: hoe
|
27
|
+
type: :development
|
28
|
+
version_requirement:
|
29
|
+
version_requirements: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 1.8.0
|
34
|
+
version:
|
35
|
+
description: People sell stuff online. Some are bad sellers. Some sell bad stuff. This Ruby module provides some basic methods to filter out those iffy listings you probably do not want to buy.
|
36
|
+
email:
|
37
|
+
- snl@theorydot.com
|
18
38
|
executables: []
|
19
39
|
|
20
40
|
extensions: []
|
21
41
|
|
22
42
|
extra_rdoc_files:
|
43
|
+
- History.txt
|
44
|
+
- Manifest.txt
|
23
45
|
- README.rdoc
|
24
46
|
files:
|
25
47
|
- data/rules.yml
|
48
|
+
- History.txt
|
26
49
|
- lib/kosher.rb
|
50
|
+
- Manifest.txt
|
51
|
+
- Rakefile
|
27
52
|
- README.rdoc
|
53
|
+
- test/test_helper.rb
|
54
|
+
- test/test_kosher.rb
|
28
55
|
has_rdoc: true
|
29
56
|
homepage: http://github.com/snl/kosher
|
30
57
|
post_install_message:
|
31
58
|
rdoc_options:
|
32
|
-
- --
|
33
|
-
-
|
59
|
+
- --main
|
60
|
+
- README.rdoc
|
34
61
|
require_paths:
|
35
62
|
- lib
|
36
63
|
required_ruby_version: !ruby/object:Gem::Requirement
|
@@ -47,10 +74,11 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
47
74
|
version:
|
48
75
|
requirements: []
|
49
76
|
|
50
|
-
rubyforge_project:
|
77
|
+
rubyforge_project: kosher
|
51
78
|
rubygems_version: 1.2.0
|
52
79
|
signing_key:
|
53
80
|
specification_version: 2
|
54
|
-
summary: Kosher is a Ruby module that provides some methods to filter out iffy listings
|
81
|
+
summary: Kosher is a Ruby module that provides some methods to filter out iffy listings in online marketplaces.
|
55
82
|
test_files:
|
56
|
-
- test/
|
83
|
+
- test/test_helper.rb
|
84
|
+
- test/test_kosher.rb
|