super_deduper 0.0.4 → 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 360030fe214b4d4b6c67a14f185fa4304471a24b
4
+ data.tar.gz: 2b7b0c3bafe8cc5f7c21f00ab8b3953ef0772681
5
+ SHA512:
6
+ metadata.gz: 10079a9444e3461f89c9eb8bcfc964b88eb16f10ff2b3b7baa0eea888187d5f2e214ade445cd61e7312838ac613e0994ce90407f7ed48778c641780dacd718fc
7
+ data.tar.gz: 25b2b6e57931b44c6f7c63013e1d1caadfdd2f9879286295e2d863c582b12e47ba7ef928e49b951a89280139eb3c9fb2064e816a2acd532d247869d07f64a24a
@@ -0,0 +1,15 @@
1
+ language: ruby
2
+
3
+ matrix:
4
+ allow_failures:
5
+ - rvm: ruby-head
6
+
7
+ rvm:
8
+ - 2.0.0
9
+ - 1.9.3
10
+ - 1.9.2
11
+ - jruby-19mode
12
+ - ruby-head
13
+ - jruby-head
14
+
15
+ script: bundle exec rake test
data/README.md CHANGED
@@ -2,8 +2,15 @@
2
2
 
3
3
  It's a super deduper.
4
4
 
5
+ [![Gem Version](https://badge.fury.io/rb/super_deduper.png)](http://badge.fury.io/rb/super_deduper)
6
+ [![Build Status](https://travis-ci.org/rthbound/super_deduper.png)](https://travis-ci.org/rthbound/super_deduper)
7
+ [![Code Climate](https://codeclimate.com/github/rthbound/super_deduper.png)](https://codeclimate.com/github/rthbound/super_deduper)
8
+ [![Coverage Status](https://coveralls.io/repos/rthbound/super_deduper/badge.png)](https://coveralls.io/r/rthbound/super_deduper)
9
+
5
10
  ## Installation
6
11
 
12
+ **Note** you will need postgres up and running in your app.
13
+
7
14
  Add this line to your application's Gemfile:
8
15
 
9
16
  gem 'super_deduper'
@@ -19,7 +26,7 @@ Or install it yourself as:
19
26
  ## Usage
20
27
 
21
28
  ```ruby
22
- SuperDeduper.new(enum: ["John Doe", "Jane Doe"], klass: Person, kolumn: "name")
29
+ SuperDeduper.new(enum: ["John Doe", "Jane Doe"], class: Person, column: "name")
23
30
  ```
24
31
 
25
32
  will tell you if anything matches either
data/Rakefile CHANGED
@@ -1 +1,9 @@
1
1
  require "bundler/gem_tasks"
2
+ require "rake/testtask"
3
+
4
+ Rake::TestTask.new do |t|
5
+ t.pattern = 'test/**/*_test.rb'
6
+ t.libs.push 'test'
7
+ end
8
+
9
+ task :default => :test
@@ -1,31 +1,31 @@
1
+ require "pay_dirt"
1
2
  module SuperDeduper
2
3
  class Check < PayDirt::Base
3
4
  def initialize(options)
4
- load_options(:enum, :klass, :kolumn, options)
5
+ options = {
6
+ delimiter: " "
7
+ }.merge(options) and load_options(:enum, :class, :column, options)
5
8
  end
6
9
 
7
10
  def execute!
8
- ret_hash = {}
9
-
10
11
  @enum.each do |term|
11
- ret_hash.merge!({
12
- "#{term}" => {}
13
- })
12
+ @ret ||= {}
13
+ @ret.merge!({ term => {} }) # Top level hash keys
14
14
 
15
- term.split(" ").each do |token|
16
- ret_hash[term][token] = @klass.where(["#{@kolumn} ilike ?", "%#{token}%"])
15
+ term.split(@delimiter).each do |token|
16
+ @ret[term][token] = @class.where(["#{@column} ilike ?", "%#{token}%"])
17
17
  end
18
18
  end
19
19
 
20
- if dupe_me_not(ret_hash)
20
+ if dupe_me_not
21
21
  return PayDirt::Result.new(success: true, data: "No matches found")
22
22
  else
23
- return PayDirt::Result.new(success: true, data: ret_hash)
23
+ return PayDirt::Result.new(success: true, data: @ret)
24
24
  end
25
25
  end
26
26
 
27
- def dupe_me_not(ret_hash)
28
- !ret_hash.any? { |k,v| v.any? { |kay,vee| vee != [] } }
27
+ def dupe_me_not
28
+ !@ret.any? { |k,v| v.any? { |kay,vee| vee != [] } }
29
29
  end
30
30
  end
31
31
  end
@@ -1,3 +1,3 @@
1
1
  module SuperDeduper
2
- VERSION = "0.0.4"
2
+ VERSION = "0.0.6"
3
3
  end
@@ -18,9 +18,12 @@ Gem::Specification.new do |spec|
18
18
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
19
  spec.require_paths = ["lib"]
20
20
 
21
- spec.add_runtime_dependency "pay_dirt"
21
+ spec.add_runtime_dependency "pay_dirt", "~> 1.0.0"
22
22
  spec.add_development_dependency "pry"
23
23
 
24
24
  spec.add_development_dependency "bundler", "~> 1.3"
25
25
  spec.add_development_dependency "rake"
26
+ spec.add_development_dependency "minitest", "~> 5.0.4"
27
+ spec.add_development_dependency "coveralls"
26
28
  end
29
+
@@ -0,0 +1,8 @@
1
+ require 'coveralls'
2
+ Coveralls.wear!
3
+ require "minitest/autorun"
4
+
5
+ # The gem
6
+ $: << File.dirname(__FILE__) + "/../lib"
7
+ $: << File.dirname(__FILE__)
8
+
@@ -0,0 +1,39 @@
1
+ require 'test_helper'
2
+
3
+ require_relative "../../../lib/super_deduper/check"
4
+
5
+ describe SuperDeduper::Check do
6
+ before do
7
+ @breakfast = MiniTest::Mock.new
8
+ @subject = SuperDeduper::Check
9
+ @options = {
10
+ enum: ["Bacon Eggs", "Sausage Biscuit"],
11
+ class: @breakfast,
12
+ column: "main_ingredient"
13
+ }
14
+ end
15
+
16
+ it "initializes" do
17
+ res = @subject.new(@options)
18
+ res.must_be_instance_of @subject
19
+ res.must_respond_to :execute!
20
+ end
21
+
22
+ it "returns empty" do
23
+ @options[:enum].map { |x| x.split(" ") }.flatten.each do |term|
24
+ @breakfast.expect(:where, MiniTest::Mock.new.expect(:!=, false, [[]]), [["main_ingredient ilike ?", "%#{term}%"]])
25
+ end
26
+
27
+ res = @subject.new(@options).execute!
28
+ res.successful?.must_equal true
29
+ end
30
+
31
+ it "returns not-empty" do
32
+ @options[:enum].map { |x| x.split(" ") }.flatten.each do |term|
33
+ @breakfast.expect(:where, MiniTest::Mock.new.expect(:!=, true, [[]]), [["main_ingredient ilike ?", "%#{term}%"]])
34
+ end
35
+
36
+ res = @subject.new(@options).execute!
37
+ res.successful?.must_equal true
38
+ end
39
+ end
metadata CHANGED
@@ -1,52 +1,46 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: super_deduper
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
5
- prerelease:
4
+ version: 0.0.6
6
5
  platform: ruby
7
6
  authors:
8
7
  - Tad Hosford
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2013-06-11 00:00:00.000000000 Z
11
+ date: 2013-07-01 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: pay_dirt
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
- - - ! '>='
17
+ - - ~>
20
18
  - !ruby/object:Gem::Version
21
- version: '0'
19
+ version: 1.0.0
22
20
  type: :runtime
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
- - - ! '>='
24
+ - - ~>
28
25
  - !ruby/object:Gem::Version
29
- version: '0'
26
+ version: 1.0.0
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: pry
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
- - - ! '>='
31
+ - - '>='
36
32
  - !ruby/object:Gem::Version
37
33
  version: '0'
38
34
  type: :development
39
35
  prerelease: false
40
36
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
37
  requirements:
43
- - - ! '>='
38
+ - - '>='
44
39
  - !ruby/object:Gem::Version
45
40
  version: '0'
46
41
  - !ruby/object:Gem::Dependency
47
42
  name: bundler
48
43
  requirement: !ruby/object:Gem::Requirement
49
- none: false
50
44
  requirements:
51
45
  - - ~>
52
46
  - !ruby/object:Gem::Version
@@ -54,7 +48,6 @@ dependencies:
54
48
  type: :development
55
49
  prerelease: false
56
50
  version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
51
  requirements:
59
52
  - - ~>
60
53
  - !ruby/object:Gem::Version
@@ -62,21 +55,47 @@ dependencies:
62
55
  - !ruby/object:Gem::Dependency
63
56
  name: rake
64
57
  requirement: !ruby/object:Gem::Requirement
65
- none: false
66
58
  requirements:
67
- - - ! '>='
59
+ - - '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - '>='
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: minitest
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ~>
74
+ - !ruby/object:Gem::Version
75
+ version: 5.0.4
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ~>
81
+ - !ruby/object:Gem::Version
82
+ version: 5.0.4
83
+ - !ruby/object:Gem::Dependency
84
+ name: coveralls
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - '>='
68
88
  - !ruby/object:Gem::Version
69
89
  version: '0'
70
90
  type: :development
71
91
  prerelease: false
72
92
  version_requirements: !ruby/object:Gem::Requirement
73
- none: false
74
93
  requirements:
75
- - - ! '>='
94
+ - - '>='
76
95
  - !ruby/object:Gem::Version
77
96
  version: '0'
78
- description: ! '"Checks an array of strings against records in the specified table
79
- & column. It''s a super-deee-duper dupe-checker."'
97
+ description: '"Checks an array of strings against records in the specified table &
98
+ column. It''s a super-deee-duper dupe-checker."'
80
99
  email:
81
100
  - tad.hosford@gmail.com
82
101
  executables: []
@@ -84,6 +103,7 @@ extensions: []
84
103
  extra_rdoc_files: []
85
104
  files:
86
105
  - .gitignore
106
+ - .travis.yml
87
107
  - Gemfile
88
108
  - LICENSE.txt
89
109
  - README.md
@@ -92,35 +112,32 @@ files:
92
112
  - lib/super_deduper/check.rb
93
113
  - lib/super_deduper/version.rb
94
114
  - super_deduper.gemspec
115
+ - test/test_helper.rb
116
+ - test/unit/super_deduper/check_test.rb
95
117
  homepage: ''
96
118
  licenses:
97
119
  - MIT
120
+ metadata: {}
98
121
  post_install_message:
99
122
  rdoc_options: []
100
123
  require_paths:
101
124
  - lib
102
125
  required_ruby_version: !ruby/object:Gem::Requirement
103
- none: false
104
126
  requirements:
105
- - - ! '>='
127
+ - - '>='
106
128
  - !ruby/object:Gem::Version
107
129
  version: '0'
108
- segments:
109
- - 0
110
- hash: -636433555
111
130
  required_rubygems_version: !ruby/object:Gem::Requirement
112
- none: false
113
131
  requirements:
114
- - - ! '>='
132
+ - - '>='
115
133
  - !ruby/object:Gem::Version
116
134
  version: '0'
117
- segments:
118
- - 0
119
- hash: -636433555
120
135
  requirements: []
121
136
  rubyforge_project:
122
- rubygems_version: 1.8.24
137
+ rubygems_version: 2.0.3
123
138
  signing_key:
124
- specification_version: 3
125
- summary: ! '"It''s a super deduper...errr, dupe checker"'
126
- test_files: []
139
+ specification_version: 4
140
+ summary: '"It''s a super deduper...errr, dupe checker"'
141
+ test_files:
142
+ - test/test_helper.rb
143
+ - test/unit/super_deduper/check_test.rb