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 +4 -4
 - data/CHANGELOG.md +2 -0
 - data/README.md +3 -0
 - data/lib/isuggest.rb +1 -1
 - data/lib/isuggest/finder.rb +5 -1
 - data/lib/isuggest/version.rb +1 -1
 - metadata +3 -3
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA1:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: a08df9e13a1e7e586a2a8e93ac8e38212d7c6fdf
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: e3d5a60db96468519f1812c25387c14e8b36036a
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 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 
     | 
    
         
            +
            [](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 
     | 
    
         
            +
            [](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
         
     | 
    
        data/lib/isuggest/finder.rb
    CHANGED
    
    | 
         @@ -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
         
     | 
    
        data/lib/isuggest/version.rb
    CHANGED
    
    
    
        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. 
     | 
| 
      
 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:  
     | 
| 
      
 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. 
     | 
| 
      
 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.
         
     |