komainu 0.0.7 → 0.0.8

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore CHANGED
@@ -3,3 +3,4 @@
3
3
  Gemfile.lock
4
4
  pkg/*
5
5
  *.swp
6
+ .vimlocal
data/.rvmrc ADDED
@@ -0,0 +1 @@
1
+ rvm 1.9.2
@@ -0,0 +1,9 @@
1
+ rvm:
2
+ - 1.8.7
3
+ - 1.9.2
4
+ - 1.9.3
5
+ - rbx
6
+ - rbx-2.0
7
+ - ree
8
+ - jruby
9
+ - ruby-head
data/README.md CHANGED
@@ -3,12 +3,16 @@ komainu
3
3
 
4
4
  A very simple text search tool.
5
5
 
6
+ [![Build Status](https://secure.travis-ci.org/AndrewVos/komainu.png)](http://travis-ci.org/AndrewVos/komainu)
6
7
 
7
8
  ## Examples
8
9
 
9
10
  ### Simple Search
10
11
 
11
12
  ```ruby
13
+ require "komainu"
14
+ require "ostruct"
15
+
12
16
  item1 = OpenStruct.new
13
17
  item1.text = "hello"
14
18
  item2 = OpenStruct.new
@@ -20,11 +24,15 @@ Komainu.search("world", searchables)
20
24
  ```
21
25
 
22
26
  ### Suggestions
27
+
23
28
  ```ruby
29
+ require "komainu"
30
+ require "ostruct"
31
+
24
32
  item = OpenStruct.new
25
33
  item.text = "Batman has no parents :("
26
34
  searchables = [item]
27
- Komainu.search("bertman", searchables)
35
+ Komainu.search("betman", searchables)
28
36
 
29
37
  #=> {:suggestion=>"Batman", :items=>[]}
30
38
  ```
@@ -3,6 +3,7 @@ komainu
3
3
 
4
4
  A very simple text search tool.
5
5
 
6
+ [![Build Status](https://secure.travis-ci.org/AndrewVos/komainu.png)](http://travis-ci.org/AndrewVos/komainu)
6
7
 
7
8
  ## Examples
8
9
 
@@ -10,6 +11,9 @@ A very simple text search tool.
10
11
 
11
12
  ```ruby
12
13
  :example:
14
+ require "komainu"
15
+ require "ostruct"
16
+
13
17
  item1 = OpenStruct.new
14
18
  item1.text = "hello"
15
19
  item2 = OpenStruct.new
@@ -22,11 +26,17 @@ Komainu.search("world", searchables)
22
26
  ```
23
27
 
24
28
  ### Suggestions
29
+
25
30
  ```ruby
31
+ :example:
32
+ require "komainu"
33
+ require "ostruct"
34
+
26
35
  item = OpenStruct.new
27
36
  item.text = "Batman has no parents :("
28
37
  searchables = [item]
29
- Komainu.search("bertman", searchables)
38
+ Komainu.search("betman", searchables)
30
39
 
31
40
  #=> {:suggestion=>"Batman", :items=>[]}
41
+ :end:
32
42
  ```
data/Rakefile CHANGED
@@ -1,42 +1,13 @@
1
1
  require "bundler/gem_tasks"
2
2
 
3
- require 'rake/testtask'
3
+ task :default => :spec
4
+
5
+ require "rake/testtask"
4
6
  Rake::TestTask.new(:spec) do |task|
5
7
  task.test_files = FileList['spec/**/*_spec.rb']
6
8
  end
7
9
 
8
- task :execute_examples do
9
- execute_examples("README.md.docu")
10
- end
11
-
12
- def execute_examples(file)
13
- require "komainu"
14
- puts "Executing Examples..."
15
- errors = []
16
- contents = File.read(file)
17
- contents.scan(/:example:((?:(?!^:end:).)*)/m).flatten.each do |example|
18
- if example.include?("#=>")
19
- expected = example.scan(/#=>\s*(.*)/).first.first
20
- actual = eval(example).inspect
21
- if actual == expected
22
- print "."
23
- else
24
- print "F"
25
- errors << "Assertion does not match example. Expected \"#{actual}\" to equal \"#{expected}\"."
26
- end
27
- end
28
- end
29
- puts
30
-
31
- if errors.any?
32
- errors.each do |error|
33
- puts error
34
- end
35
- exit 1
36
- else
37
- puts "All examples passed!"
38
- File.open(file.chomp(File.extname(file)), "w") do |file|
39
- file.write contents.gsub(":example:\n", "").gsub(":end:\n", "")
40
- end
41
- end
10
+ require "docu/rake/task"
11
+ Docu::Rake::Task.new do |task|
12
+ task.file = "README.md.docu"
42
13
  end
@@ -19,5 +19,7 @@ Gem::Specification.new do |s|
19
19
  s.require_paths = ["lib"]
20
20
 
21
21
  s.add_development_dependency "minitest"
22
+ s.add_development_dependency "rake"
23
+ s.add_development_dependency "docu"
22
24
  # s.add_runtime_dependency "rest-client"
23
25
  end
@@ -9,10 +9,6 @@ module Komainu
9
9
  end
10
10
  end
11
11
 
12
- def best_match word
13
- "Batman"
14
- end
15
-
16
12
  def search word, maximum_distance
17
13
  current_row = (0..word.length).to_a
18
14
  results = {}
@@ -30,7 +26,7 @@ module Komainu
30
26
  insert_cost = current_row[column - 1] + 1
31
27
  delete_cost = previous_row[column] + 1
32
28
 
33
- if word[column - 1] != letter
29
+ if word[column - 1] != letter[0]
34
30
  replace_cost = previous_row[column - 1] + 1
35
31
  else
36
32
  replace_cost = previous_row[column - 1]
@@ -1,3 +1,3 @@
1
1
  module Komainu
2
- VERSION = "0.0.7"
2
+ VERSION = "0.0.8"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: komainu
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.7
4
+ version: 0.0.8
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-11-23 00:00:00.000000000Z
12
+ date: 2011-11-25 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: minitest
16
- requirement: &70148385079500 !ruby/object:Gem::Requirement
16
+ requirement: &70133062670220 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,7 +21,29 @@ dependencies:
21
21
  version: '0'
22
22
  type: :development
23
23
  prerelease: false
24
- version_requirements: *70148385079500
24
+ version_requirements: *70133062670220
25
+ - !ruby/object:Gem::Dependency
26
+ name: rake
27
+ requirement: &70133062669200 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ! '>='
31
+ - !ruby/object:Gem::Version
32
+ version: '0'
33
+ type: :development
34
+ prerelease: false
35
+ version_requirements: *70133062669200
36
+ - !ruby/object:Gem::Dependency
37
+ name: docu
38
+ requirement: &70133062668160 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ! '>='
42
+ - !ruby/object:Gem::Version
43
+ version: '0'
44
+ type: :development
45
+ prerelease: false
46
+ version_requirements: *70133062668160
25
47
  description: ''
26
48
  email:
27
49
  - andrew.vos@gmail.com
@@ -30,6 +52,8 @@ extensions: []
30
52
  extra_rdoc_files: []
31
53
  files:
32
54
  - .gitignore
55
+ - .rvmrc
56
+ - .travis.yml
33
57
  - Gemfile
34
58
  - README.md
35
59
  - README.md.docu