isuggest 0.0.3 → 0.0.4

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d627b9309e261248217e56348d55a35b1ae6bbcf
4
- data.tar.gz: 85ebdb80e408d31e6e797f0ba37c39de7bd2a01c
3
+ metadata.gz: a08df9e13a1e7e586a2a8e93ac8e38212d7c6fdf
4
+ data.tar.gz: e3d5a60db96468519f1812c25387c14e8b36036a
5
5
  SHA512:
6
- metadata.gz: b211697f7980b45e57a0721d7187d650c9f5409c4f3463863a4f0418351cd4c01410e22f9b6024cc0779413fd0418d937494f9b4af60683f949eb6bb81987b49
7
- data.tar.gz: a7f8f04bf0c0607be77a887b8ed02a07f16994e6f3458e891b4413d47d6d2dabb9c6cfd5f35f63ec2b22e1d9d2d406584611eca46d0fe625fc2690b05c509a3f
6
+ metadata.gz: 3f21c1ddcf9970852f49a9c25a5eaedb30bdac1cfa11800a37eecdf58f01fe4150c3d48fc13e2c94815797ac84b5062625a7c090675617b5a1d7b5e45d913d69
7
+ data.tar.gz: 869ad010881169731403a212bc169129ef1ed9a0c0eadc5a9f9d0e10630b0f9244517bbdabe00fd07af3436809bb6d1f2f579a86996b1a053db012dac27a4611
data/CHANGELOG.md CHANGED
@@ -3,6 +3,8 @@
3
3
  This gem generates a list of suggested name/ email if there already exists a value in the DB. This
4
4
  could be user in signup pages when new user creates an account if the email/username is not unique we provide suggesstions
5
5
 
6
+ ## 0.0.4
7
+ - Added support to add suffix to the suggestions
6
8
 
7
9
  ## 0.0.3
8
10
  - seperator option now accepts array of characters, default is ['', '_']
data/README.md CHANGED
@@ -1,8 +1,11 @@
1
1
  # Isuggest
2
2
 
3
+ [![Gem Version](https://badge.fury.io/rb/isuggest.svg)](http://badge.fury.io/rb/isuggest)
4
+
3
5
  This gem generates a list of suggested name/ email if there already exists a value in the DB. This
4
6
  could be user in signup pages when new user creates an account if the email/username is not unique we provide suggesstions
5
7
 
8
+ [![Gem Version](https://badge.fury.io/rb/isuggest.svg)](http://badge.fury.io/rb/isuggest)
6
9
 
7
10
  ## Installation
8
11
 
data/lib/isuggest.rb CHANGED
@@ -7,7 +7,7 @@ module Isuggest
7
7
  raise ArgumentError, "Hash expected, got #{options.class.name}" if !options.empty? && !options.is_a?(Hash)
8
8
  raise ArgumentError, 'No column provides' if options[:on].blank?
9
9
  raise ArgumentError, 'No column provides' if options[:on].present? && !options[:on].is_a?(Array)
10
- self.isuggest_options = {total_suggestions: 5, seperator: ['', '_'] }
10
+ self.isuggest_options = {total_suggestions: 5, seperator: ['', '_'], suffix: nil }
11
11
  self.isuggest_options.merge!(options)
12
12
  self.send(:include, Isuggest::Finder)
13
13
  end
@@ -11,6 +11,7 @@ module Isuggest
11
11
  def total_results
12
12
  isuggest_options[:total_suggestions].to_i
13
13
  end
14
+
14
15
  end
15
16
 
16
17
  module InstanceMethods
@@ -19,9 +20,10 @@ module Isuggest
19
20
  return !self.class.exists?(column_name => self.send(column_name))
20
21
  end
21
22
 
22
- def suggestions
23
+ def suggestions(with_suffix=nil)
23
24
  me_suggests = []
24
25
  radix = 10
26
+ @suffix = with_suffix unless with_suffix.nil?
25
27
  while me_suggests.length < self.class.total_results
26
28
  me_suggests = filter_suggestions(me_suggests, radix)
27
29
  radix = radix * 10
@@ -63,6 +65,8 @@ module Isuggest
63
65
  if is_email?
64
66
  base_value = base_value.split('@')
65
67
  return "#{base_value.first}#{options[:seperator].sample}#{rand(num)}@#{base_value.last}"
68
+ elsif @suffix.present?
69
+ return "#{base_value}#{options[:seperator].sample}#{rand(num)}#{@suffix}"
66
70
  else
67
71
  return "#{base_value}#{options[:seperator].sample}#{rand(num)}"
68
72
  end
@@ -1,3 +1,3 @@
1
1
  module Isuggest
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: isuggest
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - roshandevadiga
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-11-30 00:00:00.000000000 Z
11
+ date: 2015-06-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -76,7 +76,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
76
76
  version: '0'
77
77
  requirements: []
78
78
  rubyforge_project:
79
- rubygems_version: 2.2.2
79
+ rubygems_version: 2.4.6
80
80
  signing_key:
81
81
  specification_version: 4
82
82
  summary: This gem will give suggestions for the fields that should be unique.