acts_as_tokenizable 0.4.0 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.4.0
1
+ 0.5.0
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{acts_as_tokenizable}
8
- s.version = "0.4.0"
8
+ s.version = "0.5.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = [%q{Enrique Garcia Cota}, %q{Francisco de Juan}]
@@ -27,10 +27,8 @@ Gem::Specification.new do |s|
27
27
  "init.rb",
28
28
  "lib/acts_as_tokenizable.rb",
29
29
  "lib/acts_as_tokenizable/acts_as_tokenizable.rb",
30
- "lib/acts_as_tokenizable/string_extensions.rb",
30
+ "lib/acts_as_tokenizable/string_utils.rb",
31
31
  "lib/tasks/acts_as_tokenizable.rake",
32
- "pkg/acts_as_tokenizable-0.1.0.gem",
33
- "pkg/acts_as_tokenizable-0.2.0.gem",
34
32
  "test/helper.rb",
35
33
  "test/test_acts_as_tokenizable.rb"
36
34
  ]
@@ -1,4 +1,4 @@
1
- require 'acts_as_tokenizable/string_extensions'
1
+ require 'acts_as_tokenizable/string_utils'
2
2
 
3
3
  module ActsAsTokenizable
4
4
 
@@ -21,7 +21,7 @@ module ActsAsTokenizable
21
21
  # stop words, replacing words.
22
22
  # By default it tokenizes each word and removes duplicates.
23
23
  def prepare_search_token(search_token)
24
- StringExtensions::words_to_token(search_token)
24
+ StringUtils::words_to_token(search_token)
25
25
  end
26
26
  end
27
27
 
@@ -1,11 +1,8 @@
1
- module ActsAsTokenizable
1
+ require 'babosa' # ensure that the babosa gem is loaded
2
2
 
3
- module StringExtensions
3
+ module ActsAsTokenizable
4
4
 
5
- #converts accented letters into ascii equivalents (i.e. ñ becomes n)
6
- def self.normalize(str)
7
- str.mb_chars.normalize(:d).gsub(/[^\x00-\x7F]/n,'').to_s
8
- end
5
+ module StringUtils
9
6
 
10
7
  #returns true if numeric, false, otherwise
11
8
  def self.numeric?(str)
@@ -49,16 +46,12 @@ module ActsAsTokenizable
49
46
 
50
47
  #convert into something that can be used as an indexation key
51
48
  def self.to_token(str, max_length=255)
52
- str = normalize(str).strip.downcase.gsub(/[^\w|-]/, '') #remove all non-alphanumeric but hyphen (-)
49
+ # to_slug and normalize are provided by the 'babosa' gem
50
+ str = str.to_slug.normalize.strip.downcase.gsub(/[^\w|-]/, '') #remove all non-alphanumeric but hyphen (-)
53
51
  str = str.squeeze unless numeric?(str) #remove duplicates, except on pure numbers
54
52
  return str[0..(max_length-1)]
55
53
  end
56
54
 
57
- #convert into something that can be used on links
58
- def self.to_slug(str, separator='-')
59
- words(normalize(str.strip.downcase)).join(separator)
60
- end
61
-
62
55
  #tokenizes each word individually, and joins the word with the separator char.
63
56
  def self.words_to_token(str, max_length=255, separator = ' ')
64
57
  words(str).collect{|w| to_token(w)}.uniq.join(separator)[0..(max_length-1)]
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: acts_as_tokenizable
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.5.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -14,7 +14,7 @@ date: 2012-03-20 00:00:00.000000000Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: thoughtbot-shoulda
17
- requirement: &9777180 !ruby/object:Gem::Requirement
17
+ requirement: &17156500 !ruby/object:Gem::Requirement
18
18
  none: false
19
19
  requirements:
20
20
  - - ! '>='
@@ -22,7 +22,7 @@ dependencies:
22
22
  version: '0'
23
23
  type: :development
24
24
  prerelease: false
25
- version_requirements: *9777180
25
+ version_requirements: *17156500
26
26
  description: Make ActiveRecord models easily searchable via tokens.
27
27
  email: github@splendeo.es
28
28
  executables: []
@@ -41,10 +41,8 @@ files:
41
41
  - init.rb
42
42
  - lib/acts_as_tokenizable.rb
43
43
  - lib/acts_as_tokenizable/acts_as_tokenizable.rb
44
- - lib/acts_as_tokenizable/string_extensions.rb
44
+ - lib/acts_as_tokenizable/string_utils.rb
45
45
  - lib/tasks/acts_as_tokenizable.rake
46
- - pkg/acts_as_tokenizable-0.1.0.gem
47
- - pkg/acts_as_tokenizable-0.2.0.gem
48
46
  - test/helper.rb
49
47
  - test/test_acts_as_tokenizable.rb
50
48
  homepage: http://github.com/splendeo/acts_as_tokenizable
Binary file
Binary file