alphabetical_paginate 1.6.0 → 1.6.1
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.
- data/lib/alphabetical_paginate/array.rb +7 -6
 - data/lib/alphabetical_paginate/controller_helper.rb +5 -4
 - data/lib/alphabetical_paginate/language.rb +12 -14
 - data/lib/alphabetical_paginate/version.rb +1 -1
 - data/lib/alphabetical_paginate/view_helpers.rb +2 -2
 - data/spec/alphabetical_paginate_spec.rb +11 -11
 - data/spec/language_spec.rb +16 -13
 - data/vendor/assets/javascripts/alphabetical_paginate.js +1 -1
 - metadata +2 -2
 
| 
         @@ -1,9 +1,9 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            # coding: utf-8
         
     | 
| 
       2 
2 
     | 
    
         
             
            class Array
         
     | 
| 
       3 
3 
     | 
    
         
             
              def alpha_paginate current_field, params = {enumerate:false, default_field: "a", 
         
     | 
| 
       4 
     | 
    
         
            -
             
     | 
| 
       5 
     | 
    
         
            -
             
     | 
| 
       6 
     | 
    
         
            -
             
     | 
| 
      
 4 
     | 
    
         
            +
                                                          paginate_all: false, numbers: true, include_all: true,
         
     | 
| 
      
 5 
     | 
    
         
            +
                                                          others: true, pagination_class: "pagination-centered",
         
     | 
| 
      
 6 
     | 
    
         
            +
                                                          js: true, support_language: :en}
         
     | 
| 
       7 
7 
     | 
    
         
             
                params[:paginate_all] ||= false
         
     | 
| 
       8 
8 
     | 
    
         
             
                params[:support_language] ||= :en
         
     | 
| 
       9 
9 
     | 
    
         
             
                params[:language] = AlphabeticalPaginate::Language.new(params[:support_language])
         
     | 
| 
         @@ -18,7 +18,8 @@ class Array 
     | 
|
| 
       18 
18 
     | 
    
         
             
                if current_field == nil
         
     | 
| 
       19 
19 
     | 
    
         
             
                  current_field = params[:default_field]
         
     | 
| 
       20 
20 
     | 
    
         
             
                end
         
     | 
| 
       21 
     | 
    
         
            -
                 
     | 
| 
      
 21 
     | 
    
         
            +
                current_field = current_field.mb_chars.downcase.to_s
         
     | 
| 
      
 22 
     | 
    
         
            +
                all = params[:include_all] && current_field == "all"
         
     | 
| 
       22 
23 
     | 
    
         | 
| 
       23 
24 
     | 
    
         
             
                self.each do |x|
         
     | 
| 
       24 
25 
     | 
    
         
             
                  field_val = block_given? ? yield(x).to_s : x.id.to_s
         
     | 
| 
         @@ -41,8 +42,8 @@ class Array 
     | 
|
| 
       41 
42 
     | 
    
         
             
                  end
         
     | 
| 
       42 
43 
     | 
    
         
             
                end
         
     | 
| 
       43 
44 
     | 
    
         | 
| 
       44 
     | 
    
         
            -
                params[:availableLetters] = availableLetters.collect{|k,v| k.to_s}
         
     | 
| 
       45 
     | 
    
         
            -
                params[:currentField] = current_field
         
     | 
| 
      
 45 
     | 
    
         
            +
                params[:availableLetters] = availableLetters.collect{ |k,v| k.mb_chars.capitalize.to_s }
         
     | 
| 
      
 46 
     | 
    
         
            +
                params[:currentField] = current_field.mb_chars.capitalize.to_s
         
     | 
| 
       46 
47 
     | 
    
         
             
                output.sort! {|x, y| block_given? ? (yield(x).to_s <=> yield(y).to_s) : (x.id.to_s <=> y.id.to_s) }
         
     | 
| 
       47 
48 
     | 
    
         
             
                return output, params
         
     | 
| 
       48 
49 
     | 
    
         
             
              end
         
     | 
| 
         @@ -28,7 +28,8 @@ module AlphabeticalPaginate 
     | 
|
| 
       28 
28 
     | 
    
         
             
                  if current_field == nil
         
     | 
| 
       29 
29 
     | 
    
         
             
                    current_field = params[:default_field]
         
     | 
| 
       30 
30 
     | 
    
         
             
                  end
         
     | 
| 
       31 
     | 
    
         
            -
                   
     | 
| 
      
 31 
     | 
    
         
            +
                  current_field = current_field.mb_chars.downcase.to_s
         
     | 
| 
      
 32 
     | 
    
         
            +
                  all = params[:include_all] && current_field == "all"
         
     | 
| 
       32 
33 
     | 
    
         | 
| 
       33 
34 
     | 
    
         
             
                  if params[:db_mode]
         
     | 
| 
       34 
35 
     | 
    
         
             
                    if !ActiveRecord::Base.connection.adapter_name.downcase.include? "mysql"
         
     | 
| 
         @@ -40,7 +41,7 @@ module AlphabeticalPaginate 
     | 
|
| 
       40 
41 
     | 
    
         
             
                    if all
         
     | 
| 
       41 
42 
     | 
    
         
             
                      output = self
         
     | 
| 
       42 
43 
     | 
    
         
             
                    else
         
     | 
| 
       43 
     | 
    
         
            -
                      case current_field 
     | 
| 
      
 44 
     | 
    
         
            +
                      case current_field
         
     | 
| 
       44 
45 
     | 
    
         
             
                      when params[:language].letters_regexp
         
     | 
| 
       45 
46 
     | 
    
         
             
                        output = self.where("LOWER(%s) REGEXP '^%s.*'" % [params[:db_field], current_field])
         
     | 
| 
       46 
47 
     | 
    
         
             
                      when /[0-9]/
         
     | 
| 
         @@ -77,10 +78,10 @@ module AlphabeticalPaginate 
     | 
|
| 
       77 
78 
     | 
    
         
             
                          output << x if all || current_field == "*"
         
     | 
| 
       78 
79 
     | 
    
         
             
                      end
         
     | 
| 
       79 
80 
     | 
    
         
             
                    end
         
     | 
| 
       80 
     | 
    
         
            -
                    params[:availableLetters] = availableLetters.collect{|k,v| k.to_s}
         
     | 
| 
      
 81 
     | 
    
         
            +
                    params[:availableLetters] = availableLetters.collect{ |k,v| k.mb_chars.capitalize.to_s }
         
     | 
| 
       81 
82 
     | 
    
         
             
                    output.sort! {|x, y| block_given? ? (yield(x).to_s <=> yield(y).to_s) : (x.id.to_s <=> y.id.to_s) }
         
     | 
| 
       82 
83 
     | 
    
         
             
                  end
         
     | 
| 
       83 
     | 
    
         
            -
                  params[:currentField] = current_field
         
     | 
| 
      
 84 
     | 
    
         
            +
                  params[:currentField] = current_field.mb_chars.capitalize.to_s
         
     | 
| 
       84 
85 
     | 
    
         
             
                  return output, params
         
     | 
| 
       85 
86 
     | 
    
         
             
                end
         
     | 
| 
       86 
87 
     | 
    
         
             
              end
         
     | 
| 
         @@ -12,34 +12,32 @@ module AlphabeticalPaginate 
     | 
|
| 
       12 
12 
     | 
    
         
             
                end
         
     | 
| 
       13 
13 
     | 
    
         | 
| 
       14 
14 
     | 
    
         
             
                def letters_regexp
         
     | 
| 
       15 
     | 
    
         
            -
                  russian? ? /[ 
     | 
| 
      
 15 
     | 
    
         
            +
                  russian? ? /[а-яА-Я]/ : /[a-zA-Z]/
         
     | 
| 
       16 
16 
     | 
    
         
             
                end
         
     | 
| 
       17 
17 
     | 
    
         | 
| 
      
 18 
     | 
    
         
            +
                def default_letter
         
     | 
| 
      
 19 
     | 
    
         
            +
                  russian? ? "а" : "a" # First 'a' is russian, second - english
         
     | 
| 
      
 20 
     | 
    
         
            +
                end
         
     | 
| 
      
 21 
     | 
    
         
            +
             
     | 
| 
      
 22 
     | 
    
         
            +
                # used in view_helper
         
     | 
| 
       18 
23 
     | 
    
         
             
                def letters_range
         
     | 
| 
       19 
24 
     | 
    
         
             
                  if russian?
         
     | 
| 
       20 
25 
     | 
    
         
             
                    letters = []
         
     | 
| 
       21 
     | 
    
         
            -
                     
     | 
| 
      
 26 
     | 
    
         
            +
                    "АБВГДЕЖЗИКЛМНОПРСТУФХЦЧШЭЮЯ".each_char{ |x| letters << x }
         
     | 
| 
       22 
27 
     | 
    
         
             
                    letters
         
     | 
| 
       23 
28 
     | 
    
         
             
                  else
         
     | 
| 
       24 
     | 
    
         
            -
                    (' 
     | 
| 
      
 29 
     | 
    
         
            +
                    ('A'..'Z').to_a
         
     | 
| 
       25 
30 
     | 
    
         
             
                  end
         
     | 
| 
       26 
31 
     | 
    
         
             
                end
         
     | 
| 
       27 
32 
     | 
    
         | 
| 
      
 33 
     | 
    
         
            +
                # used in view_helper
         
     | 
| 
       28 
34 
     | 
    
         
             
                def output_letter(l)
         
     | 
| 
       29 
     | 
    
         
            -
                  (l == " 
     | 
| 
      
 35 
     | 
    
         
            +
                  (l == "All") ? all_field : l
         
     | 
| 
       30 
36 
     | 
    
         
             
                end
         
     | 
| 
       31 
37 
     | 
    
         | 
| 
      
 38 
     | 
    
         
            +
                # used in view_helper
         
     | 
| 
       32 
39 
     | 
    
         
             
                def all_field
         
     | 
| 
       33 
     | 
    
         
            -
                  russian? ? ' 
     | 
| 
       34 
     | 
    
         
            -
                end
         
     | 
| 
       35 
     | 
    
         
            -
             
     | 
| 
       36 
     | 
    
         
            -
                def default_letter
         
     | 
| 
       37 
     | 
    
         
            -
                  russian? ? "а" : "a" # First 'a' is russian, second - english
         
     | 
| 
      
 40 
     | 
    
         
            +
                  russian? ? 'Все' : "All"
         
     | 
| 
       38 
41 
     | 
    
         
             
                end
         
     | 
| 
       39 
     | 
    
         
            -
             
     | 
| 
       40 
     | 
    
         
            -
                private
         
     | 
| 
       41 
     | 
    
         
            -
                  def russian_letters
         
     | 
| 
       42 
     | 
    
         
            -
                    "абвгдежзиклмнопрстуфхцчшэюя"
         
     | 
| 
       43 
     | 
    
         
            -
                  end
         
     | 
| 
       44 
42 
     | 
    
         
             
              end
         
     | 
| 
       45 
43 
     | 
    
         
             
            end
         
     | 
| 
         @@ -17,7 +17,7 @@ module AlphabeticalPaginate 
     | 
|
| 
       17 
17 
     | 
    
         
             
                    elsif params[:numbers]
         
     | 
| 
       18 
18 
     | 
    
         
             
                      range = ["0-9"] + range
         
     | 
| 
       19 
19 
     | 
    
         
             
                    end
         
     | 
| 
       20 
     | 
    
         
            -
                    range.unshift " 
     | 
| 
      
 20 
     | 
    
         
            +
                    range.unshift "All" if params[:include_all]
         
     | 
| 
       21 
21 
     | 
    
         
             
                    range.each do |l|
         
     | 
| 
       22 
22 
     | 
    
         
             
                      value = params[:language].output_letter(l)
         
     | 
| 
       23 
23 
     | 
    
         
             
                      if l == params[:currentField]
         
     | 
| 
         @@ -31,7 +31,7 @@ module AlphabeticalPaginate 
     | 
|
| 
       31 
31 
     | 
    
         
             
                  else
         
     | 
| 
       32 
32 
     | 
    
         
             
                    params[:availableLetters].sort!
         
     | 
| 
       33 
33 
     | 
    
         
             
                    params[:availableLetters] = params[:availableLetters][1..-1] + ["*"] if params[:availableLetters][0] == "*"
         
     | 
| 
       34 
     | 
    
         
            -
                    params[:availableLetters].unshift " 
     | 
| 
      
 34 
     | 
    
         
            +
                    params[:availableLetters].unshift "All" if params[:include_all]
         
     | 
| 
       35 
35 
     | 
    
         
             
                    params[:availableLetters] -= (1..9).to_a.map{|x| x.to_s} if !params[:numbers]
         
     | 
| 
       36 
36 
     | 
    
         
             
                    params[:availableLetters] -= ["*"] if !params[:others]
         
     | 
| 
       37 
37 
     | 
    
         | 
| 
         @@ -109,8 +109,8 @@ module AlphabeticalPaginate 
     | 
|
| 
       109 
109 
     | 
    
         
             
                describe "#alphabetical_paginate" do
         
     | 
| 
       110 
110 
     | 
    
         
             
                  before :each do
         
     | 
| 
       111 
111 
     | 
    
         
             
                    @list = []
         
     | 
| 
       112 
     | 
    
         
            -
                    (["@!#"] + (0..9).to_a.map{|x| x.to_s} + (" 
     | 
| 
       113 
     | 
    
         
            -
                      (" 
     | 
| 
      
 112 
     | 
    
         
            +
                    (["@!#"] + (0..9).to_a.map{|x| x.to_s} + ("A".."Z").to_a).each do |x|
         
     | 
| 
      
 113 
     | 
    
         
            +
                      ("A".."Y").to_a.each do |y|
         
     | 
| 
       114 
114 
     | 
    
         
             
                        @list << x + y
         
     | 
| 
       115 
115 
     | 
    
         
             
                      end
         
     | 
| 
       116 
116 
     | 
    
         
             
                    end
         
     | 
| 
         @@ -128,7 +128,7 @@ module AlphabeticalPaginate 
     | 
|
| 
       128 
128 
     | 
    
         
             
                  it "should include a numbers and others field" do
         
     | 
| 
       129 
129 
     | 
    
         
             
                    index, params = @list.alpha_paginate(nil)
         
     | 
| 
       130 
130 
     | 
    
         
             
                    pagination = alphabetical_paginate(params)
         
     | 
| 
       131 
     | 
    
         
            -
                    (["*"] + ["0-9"] + (" 
     | 
| 
      
 131 
     | 
    
         
            +
                    (["*"] + ["0-9"] + ("A".."Z").to_a.map{|x|
         
     | 
| 
       132 
132 
     | 
    
         
             
                      'data-letter="%s"'%x}).each do |x|
         
     | 
| 
       133 
133 
     | 
    
         
             
                      pagination.should include x
         
     | 
| 
       134 
134 
     | 
    
         
             
                    end
         
     | 
| 
         @@ -137,7 +137,7 @@ module AlphabeticalPaginate 
     | 
|
| 
       137 
137 
     | 
    
         
             
                  it "should default all values when necessary" do
         
     | 
| 
       138 
138 
     | 
    
         
             
                    index, params = @list.alpha_paginate(nil, {})
         
     | 
| 
       139 
139 
     | 
    
         
             
                    pagination = alphabetical_paginate(params)
         
     | 
| 
       140 
     | 
    
         
            -
                    (["*"] + ["0-9"] + (" 
     | 
| 
      
 140 
     | 
    
         
            +
                    (["*"] + ["0-9"] + ("A".."Z").to_a.map{|x|
         
     | 
| 
       141 
141 
     | 
    
         
             
                      'data-letter="%s"'%x}).each do |x|
         
     | 
| 
       142 
142 
     | 
    
         
             
                      pagination.should include x
         
     | 
| 
       143 
143 
     | 
    
         
             
                    end
         
     | 
| 
         @@ -146,11 +146,11 @@ module AlphabeticalPaginate 
     | 
|
| 
       146 
146 
     | 
    
         
             
                  it "should hide values that don't exist" do
         
     | 
| 
       147 
147 
     | 
    
         
             
                    index, params = @list.alpha_paginate(nil){|x| x.word}
         
     | 
| 
       148 
148 
     | 
    
         
             
                    pagination = alphabetical_paginate(params)
         
     | 
| 
       149 
     | 
    
         
            -
                    ((" 
     | 
| 
      
 149 
     | 
    
         
            +
                    (("A".."Y").to_a.map{|x|
         
     | 
| 
       150 
150 
     | 
    
         
             
                      'data-letter="%s"'%x}).each do |x|
         
     | 
| 
       151 
151 
     | 
    
         
             
                      pagination.should include x
         
     | 
| 
       152 
152 
     | 
    
         
             
                    end
         
     | 
| 
       153 
     | 
    
         
            -
                    pagination.should_not include 'data-letter=" 
     | 
| 
      
 153 
     | 
    
         
            +
                    pagination.should_not include 'data-letter="Z"', 'data-letter="*"',
         
     | 
| 
       154 
154 
     | 
    
         
             
                      'data-letter="0-9"'
         
     | 
| 
       155 
155 
     | 
    
         
             
                  end
         
     | 
| 
       156 
156 
     | 
    
         | 
| 
         @@ -168,7 +168,7 @@ module AlphabeticalPaginate 
     | 
|
| 
       168 
168 
     | 
    
         
             
                    index, params = @list.alpha_paginate(nil, {paginate_all: true,
         
     | 
| 
       169 
169 
     | 
    
         
             
                                                         enumerate: true}){|x| x.word}
         
     | 
| 
       170 
170 
     | 
    
         
             
                    pagination = alphabetical_paginate(params)
         
     | 
| 
       171 
     | 
    
         
            -
                    (["*"] + (0..9).to_a.map{|x| x.to_s} + (" 
     | 
| 
      
 171 
     | 
    
         
            +
                    (["*"] + (0..9).to_a.map{|x| x.to_s} + ("A".."Z").to_a.map{|x|
         
     | 
| 
       172 
172 
     | 
    
         
             
                      'data-letter="%s"'%x}).each do |x|
         
     | 
| 
       173 
173 
     | 
    
         
             
                      pagination.should include x
         
     | 
| 
       174 
174 
     | 
    
         
             
                    end
         
     | 
| 
         @@ -177,7 +177,7 @@ module AlphabeticalPaginate 
     | 
|
| 
       177 
177 
     | 
    
         
             
                  it "should include 'all' and '0-9' fields" do
         
     | 
| 
       178 
178 
     | 
    
         
             
                    index, params = @list.alpha_paginate(nil, { include_all: true })
         
     | 
| 
       179 
179 
     | 
    
         
             
                    pagination = alphabetical_paginate(params)
         
     | 
| 
       180 
     | 
    
         
            -
                    ([" 
     | 
| 
      
 180 
     | 
    
         
            +
                    (["All", "0-9"].map{|x|
         
     | 
| 
       181 
181 
     | 
    
         
             
                      'data-letter="%s"'%x}).each do |x|
         
     | 
| 
       182 
182 
     | 
    
         
             
                      pagination.should include x
         
     | 
| 
       183 
183 
     | 
    
         
             
                    end
         
     | 
| 
         @@ -187,8 +187,8 @@ module AlphabeticalPaginate 
     | 
|
| 
       187 
187 
     | 
    
         
             
                describe "#alphabetical_paginate in russian characters" do
         
     | 
| 
       188 
188 
     | 
    
         
             
                  before :each do
         
     | 
| 
       189 
189 
     | 
    
         
             
                    @list = []
         
     | 
| 
       190 
     | 
    
         
            -
                    (" 
     | 
| 
       191 
     | 
    
         
            -
                      (" 
     | 
| 
      
 190 
     | 
    
         
            +
                    ("А".."Я").to_a.each do |x|
         
     | 
| 
      
 191 
     | 
    
         
            +
                      ("А".."Т").to_a.each do |y|
         
     | 
| 
       192 
192 
     | 
    
         
             
                        @list << x + y
         
     | 
| 
       193 
193 
     | 
    
         
             
                      end
         
     | 
| 
       194 
194 
     | 
    
         
             
                    end
         
     | 
| 
         @@ -196,7 +196,7 @@ module AlphabeticalPaginate 
     | 
|
| 
       196 
196 
     | 
    
         
             
                      AlphaExample.new(x)
         
     | 
| 
       197 
197 
     | 
    
         
             
                    end
         
     | 
| 
       198 
198 
     | 
    
         
             
                    @russian_array = []
         
     | 
| 
       199 
     | 
    
         
            -
                    " 
     | 
| 
      
 199 
     | 
    
         
            +
                    "АБВГДЕЖЗИКЛМНОПРСТУФХЦЧШЭЮЯ".each_char{ |x| @russian_array << x }
         
     | 
| 
       200 
200 
     | 
    
         
             
                  end
         
     | 
| 
       201 
201 
     | 
    
         | 
| 
       202 
202 
     | 
    
         
             
                  it "should display russian characters through additional attribute(language)" do
         
     | 
    
        data/spec/language_spec.rb
    CHANGED
    
    | 
         @@ -1,26 +1,28 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            # coding: utf-8
         
     | 
| 
      
 2 
     | 
    
         
            +
            require 'alphabetical_paginate'
         
     | 
| 
       2 
3 
     | 
    
         | 
| 
       3 
4 
     | 
    
         
             
            module AlphabeticalPaginate
         
     | 
| 
       4 
5 
     | 
    
         
             
              describe Language do
         
     | 
| 
       5 
6 
     | 
    
         
             
                context "English language" do
         
     | 
| 
       6 
7 
     | 
    
         
             
                  before(:all) do
         
     | 
| 
       7 
     | 
    
         
            -
                     
     | 
| 
      
 8 
     | 
    
         
            +
                    I18n.locale = :en
         
     | 
| 
      
 9 
     | 
    
         
            +
                    @language = AlphabeticalPaginate::Language.new(I18n.locale)
         
     | 
| 
       8 
10 
     | 
    
         
             
                  end
         
     | 
| 
       9 
11 
     | 
    
         | 
| 
       10 
12 
     | 
    
         
             
                  it "should return false on russian? method" do
         
     | 
| 
       11 
13 
     | 
    
         
             
                    @language.russian?.should be_false
         
     | 
| 
       12 
14 
     | 
    
         
             
                  end
         
     | 
| 
       13 
15 
     | 
    
         | 
| 
       14 
     | 
    
         
            -
                  it "should return /[a- 
     | 
| 
       15 
     | 
    
         
            -
                    @language.letters_regexp.should eq(/[a- 
     | 
| 
      
 16 
     | 
    
         
            +
                  it "should return /[a-zA-Z]/ regexp" do
         
     | 
| 
      
 17 
     | 
    
         
            +
                    @language.letters_regexp.should eq(/[a-zA-Z]/)
         
     | 
| 
       16 
18 
     | 
    
         
             
                  end
         
     | 
| 
       17 
19 
     | 
    
         | 
| 
       18 
20 
     | 
    
         
             
                  it "should return array of english letters" do
         
     | 
| 
       19 
     | 
    
         
            -
                    @language.letters_range.should eq((" 
     | 
| 
      
 21 
     | 
    
         
            +
                    @language.letters_range.should eq(("A".."Z").to_a)
         
     | 
| 
       20 
22 
     | 
    
         
             
                  end
         
     | 
| 
       21 
23 
     | 
    
         | 
| 
       22 
     | 
    
         
            -
                  it "should return english representation of ' 
     | 
| 
       23 
     | 
    
         
            -
                    ([" 
     | 
| 
      
 24 
     | 
    
         
            +
                  it "should return english representation of 'All' field and other english letters (for view helper)" do
         
     | 
| 
      
 25 
     | 
    
         
            +
                    (["All"] + ("A".."Z").to_a).map do |l|
         
     | 
| 
       24 
26 
     | 
    
         
             
                      @language.output_letter(l).should eq(l)
         
     | 
| 
       25 
27 
     | 
    
         
             
                    end
         
     | 
| 
       26 
28 
     | 
    
         
             
                  end
         
     | 
| 
         @@ -32,8 +34,9 @@ module AlphabeticalPaginate 
     | 
|
| 
       32 
34 
     | 
    
         | 
| 
       33 
35 
     | 
    
         
             
                context "Russian language" do
         
     | 
| 
       34 
36 
     | 
    
         
             
                  before(:all) do
         
     | 
| 
       35 
     | 
    
         
            -
                     
     | 
| 
       36 
     | 
    
         
            -
                    @ 
     | 
| 
      
 37 
     | 
    
         
            +
                    I18n.locale = :ru
         
     | 
| 
      
 38 
     | 
    
         
            +
                    @language = AlphabeticalPaginate::Language.new(I18n.locale)
         
     | 
| 
      
 39 
     | 
    
         
            +
                    @russian_string = "АБВГДЕЖЗИКЛМНОПРСТУФХЦЧШЭЮЯ"
         
     | 
| 
       37 
40 
     | 
    
         
             
                    @russian_array = []
         
     | 
| 
       38 
41 
     | 
    
         
             
                    @russian_string.each_char{ |x| @russian_array << x }
         
     | 
| 
       39 
42 
     | 
    
         
             
                  end
         
     | 
| 
         @@ -42,21 +45,21 @@ module AlphabeticalPaginate 
     | 
|
| 
       42 
45 
     | 
    
         
             
                    @language.russian?.should be_true
         
     | 
| 
       43 
46 
     | 
    
         
             
                  end
         
     | 
| 
       44 
47 
     | 
    
         | 
| 
       45 
     | 
    
         
            -
                  it "should return /[ 
     | 
| 
       46 
     | 
    
         
            -
                    @language.letters_regexp.should eq(/[ 
     | 
| 
      
 48 
     | 
    
         
            +
                  it "should return /[а-яА-Я]/ regexp" do
         
     | 
| 
      
 49 
     | 
    
         
            +
                    @language.letters_regexp.should eq(/[а-яА-Я]/)
         
     | 
| 
       47 
50 
     | 
    
         
             
                  end
         
     | 
| 
       48 
51 
     | 
    
         | 
| 
       49 
52 
     | 
    
         
             
                  it "should return array of russian letters" do
         
     | 
| 
       50 
53 
     | 
    
         
             
                    @language.letters_range.should eq(@russian_array)
         
     | 
| 
       51 
54 
     | 
    
         
             
                  end
         
     | 
| 
       52 
55 
     | 
    
         | 
| 
       53 
     | 
    
         
            -
                  it "should return russian representation of ' 
     | 
| 
       54 
     | 
    
         
            -
                    ([" 
     | 
| 
      
 56 
     | 
    
         
            +
                  it "should return russian representation of 'All' field and other russian letters (for view helper)" do
         
     | 
| 
      
 57 
     | 
    
         
            +
                    (["Все"] + @russian_array).map do |l|
         
     | 
| 
       55 
58 
     | 
    
         
             
                      @language.output_letter(l).should eq(l)
         
     | 
| 
       56 
59 
     | 
    
         
             
                    end
         
     | 
| 
       57 
60 
     | 
    
         
             
                  end
         
     | 
| 
       58 
61 
     | 
    
         | 
| 
       59 
     | 
    
         
            -
                  it "should return russian representation of ' 
     | 
| 
      
 62 
     | 
    
         
            +
                  it "should return russian representation of 'а' letter" do
         
     | 
| 
       60 
63 
     | 
    
         
             
                    @language.default_letter.should eq("а")
         
     | 
| 
       61 
64 
     | 
    
         
             
                  end
         
     | 
| 
       62 
65 
     | 
    
         
             
                end
         
     | 
    
        metadata
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            --- !ruby/object:Gem::Specification
         
     | 
| 
       2 
2 
     | 
    
         
             
            name: alphabetical_paginate
         
     | 
| 
       3 
3 
     | 
    
         
             
            version: !ruby/object:Gem::Version
         
     | 
| 
       4 
     | 
    
         
            -
              version: 1.6. 
     | 
| 
      
 4 
     | 
    
         
            +
              version: 1.6.1
         
     | 
| 
       5 
5 
     | 
    
         
             
              prerelease: 
         
     | 
| 
       6 
6 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       7 
7 
     | 
    
         
             
            authors:
         
     | 
| 
         @@ -9,7 +9,7 @@ authors: 
     | 
|
| 
       9 
9 
     | 
    
         
             
            autorequire: 
         
     | 
| 
       10 
10 
     | 
    
         
             
            bindir: bin
         
     | 
| 
       11 
11 
     | 
    
         
             
            cert_chain: []
         
     | 
| 
       12 
     | 
    
         
            -
            date: 2013- 
     | 
| 
      
 12 
     | 
    
         
            +
            date: 2013-09-09 00:00:00.000000000 Z
         
     | 
| 
       13 
13 
     | 
    
         
             
            dependencies:
         
     | 
| 
       14 
14 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       15 
15 
     | 
    
         
             
              name: bundler
         
     |