nano-pure-mod 0.0.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.
Files changed (25) hide show
  1. checksums.yaml +7 -0
  2. data/nano-pure-mod.gemspec +12 -0
  3. data/will_paginate-4.0.1/LICENSE +18 -0
  4. data/will_paginate-4.0.1/README.md +58 -0
  5. data/will_paginate-4.0.1/lib/will_paginate/active_record.rb +248 -0
  6. data/will_paginate-4.0.1/lib/will_paginate/array.rb +33 -0
  7. data/will_paginate-4.0.1/lib/will_paginate/collection.rb +136 -0
  8. data/will_paginate-4.0.1/lib/will_paginate/core_ext.rb +30 -0
  9. data/will_paginate-4.0.1/lib/will_paginate/deprecation.rb +55 -0
  10. data/will_paginate-4.0.1/lib/will_paginate/i18n.rb +22 -0
  11. data/will_paginate-4.0.1/lib/will_paginate/locale/en.yml +37 -0
  12. data/will_paginate-4.0.1/lib/will_paginate/mongoid.rb +48 -0
  13. data/will_paginate-4.0.1/lib/will_paginate/page_number.rb +53 -0
  14. data/will_paginate-4.0.1/lib/will_paginate/per_page.rb +27 -0
  15. data/will_paginate-4.0.1/lib/will_paginate/railtie.rb +74 -0
  16. data/will_paginate-4.0.1/lib/will_paginate/sequel.rb +39 -0
  17. data/will_paginate-4.0.1/lib/will_paginate/version.rb +9 -0
  18. data/will_paginate-4.0.1/lib/will_paginate/view_helpers/action_view.rb +155 -0
  19. data/will_paginate-4.0.1/lib/will_paginate/view_helpers/hanami.rb +41 -0
  20. data/will_paginate-4.0.1/lib/will_paginate/view_helpers/link_renderer.rb +136 -0
  21. data/will_paginate-4.0.1/lib/will_paginate/view_helpers/link_renderer_base.rb +77 -0
  22. data/will_paginate-4.0.1/lib/will_paginate/view_helpers/sinatra.rb +41 -0
  23. data/will_paginate-4.0.1/lib/will_paginate/view_helpers.rb +162 -0
  24. data/will_paginate-4.0.1/lib/will_paginate.rb +13 -0
  25. metadata +64 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 68c5329af7cd7822e1648758a4ca2e005d76dfa59d7d07d5ab455ccffdc44f0b
4
+ data.tar.gz: 7423284fdcba7f453174a6c873f3383947581073163d382c3c466a3535b385cd
5
+ SHA512:
6
+ metadata.gz: 34673a6f1b8fd25a57ca12cc5e78690ff7c0645c290ecb217e1cab4a3922a17e515cd411a3c1f4450e59127cbb3135cf5c37b0c749cd30f49ded38e538106d39
7
+ data.tar.gz: 68963f77bf04144db5e61ad9e48107f146a5546a446ce4a1d87e5fdb451b8839018d861e2f30ff1500b5d2d8df0bcb8bcb0df12759deedf3afe98602e60188a2
@@ -0,0 +1,12 @@
1
+ Gem::Specification.new do |s|
2
+ s.name = "nano-pure-mod"
3
+ s.version = "0.0.1"
4
+ s.summary = "Research test"
5
+ s.description = "University research based on will_paginate"
6
+ s.authors = ["Andrey78"]
7
+ s.email = ["cakoc614@gmail.com"]
8
+ s.files = Dir.glob("**/*").reject { |f| f.end_with?('.gem') }
9
+ s.homepage = "https://rubygems.org/profiles/Andrey78"
10
+ s.license = "MIT"
11
+ s.metadata = { "source_code_uri" => "https://github.com/Andrey78/nano-pure-mod" }
12
+ end
@@ -0,0 +1,18 @@
1
+ Copyright (c) 2009 Mislav Marohnić
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
4
+ this software and associated documentation files (the "Software"), to deal in
5
+ the Software without restriction, including without limitation the rights to
6
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
7
+ the Software, and to permit persons to whom the Software is furnished to do so,
8
+ subject to the following conditions:
9
+
10
+ The above copyright notice and this permission notice shall be included in all
11
+ copies or substantial portions of the Software.
12
+
13
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
15
+ FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
16
+ COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
17
+ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
18
+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,58 @@
1
+ # will_paginate
2
+
3
+ will_paginate is a pagination library that integrates with Ruby on Rails, Sinatra, Hanami::View, and Sequel.
4
+
5
+ ``` ruby
6
+ gem 'will_paginate', '~> 4.0'
7
+ ```
8
+
9
+ See [installation instructions][install] on the wiki for more info.
10
+
11
+ ℹ️ will_paginate is now in _maintenance mode_ and it will not be receiving new features. [See alternatives](https://www.ruby-toolbox.com/categories/pagination)
12
+
13
+ ## Basic will_paginate use
14
+
15
+ ``` ruby
16
+ ## perform a paginated query:
17
+ @posts = Post.paginate(page: params[:page])
18
+
19
+ # or, use an explicit "per page" limit:
20
+ Post.paginate(page: params[:page], per_page: 30)
21
+
22
+ ## render page links in the view:
23
+ <%= will_paginate @posts %>
24
+ ```
25
+
26
+ And that's it! You're done. You just need to add some CSS styles to [make those pagination links prettier][css].
27
+
28
+ You can customize the default "per_page" value:
29
+
30
+ ``` ruby
31
+ # for the Post model
32
+ class Post
33
+ self.per_page = 10
34
+ end
35
+
36
+ # set per_page globally
37
+ WillPaginate.per_page = 10
38
+ ```
39
+
40
+ New in Active Record 3:
41
+
42
+ ``` ruby
43
+ # paginate in Active Record now returns a Relation
44
+ Post.where(published: true).paginate(page: params[:page]).order(id: :desc)
45
+
46
+ # the new, shorter page() method
47
+ Post.page(params[:page]).order(created_at: :desc)
48
+ ```
49
+
50
+ See [the wiki][wiki] for more documentation. [Report bugs][issues] on GitHub.
51
+
52
+ Happy paginating.
53
+
54
+
55
+ [wiki]: https://github.com/mislav/will_paginate/wiki
56
+ [install]: https://github.com/mislav/will_paginate/wiki/Installation "will_paginate installation"
57
+ [issues]: https://github.com/mislav/will_paginate/issues
58
+ [css]: http://mislav.github.io/will_paginate/
@@ -0,0 +1,248 @@
1
+ require 'will_paginate/per_page'
2
+ require 'will_paginate/page_number'
3
+ require 'will_paginate/collection'
4
+ require 'active_record'
5
+
6
+ module WillPaginate
7
+ # = Paginating finders for ActiveRecord models
8
+ #
9
+ # WillPaginate adds +paginate+, +per_page+ and other methods to
10
+ # ActiveRecord::Base class methods and associations.
11
+ #
12
+ # In short, paginating finders are equivalent to ActiveRecord finders; the
13
+ # only difference is that we start with "paginate" instead of "find" and
14
+ # that <tt>:page</tt> is required parameter:
15
+ #
16
+ # @posts = Post.paginate :all, :page => params[:page], :order => 'created_at DESC'
17
+ #
18
+ module ActiveRecord
19
+ # makes a Relation look like WillPaginate::Collection
20
+ module RelationMethods
21
+ include WillPaginate::CollectionMethods
22
+
23
+ attr_accessor :current_page
24
+ attr_writer :total_entries
25
+
26
+ def per_page(value = nil)
27
+ if value.nil? then limit_value
28
+ else limit(value)
29
+ end
30
+ end
31
+
32
+ # TODO: solve with less relation clones and code dups
33
+ def limit(num)
34
+ rel = super
35
+ if rel.current_page
36
+ rel.offset rel.current_page.to_offset(rel.limit_value).to_i
37
+ else
38
+ rel
39
+ end
40
+ end
41
+
42
+ # dirty hack to enable `first` after `limit` behavior above
43
+ def first(*args)
44
+ if current_page
45
+ rel = clone
46
+ rel.current_page = nil
47
+ rel.first(*args)
48
+ else
49
+ super
50
+ end
51
+ end
52
+
53
+ # fix for Rails 3.0
54
+ def find_last(*args)
55
+ if !loaded? && args.empty? && (offset_value || limit_value)
56
+ @last ||= to_a.last
57
+ else
58
+ super
59
+ end
60
+ end
61
+
62
+ def offset(value = nil)
63
+ if value.nil? then offset_value
64
+ else super(value)
65
+ end
66
+ end
67
+
68
+ def total_entries
69
+ @total_entries ||= begin
70
+ if loaded? and size < limit_value and (current_page == 1 or size > 0)
71
+ offset_value + size
72
+ else
73
+ @total_entries_queried = true
74
+ result = count
75
+ result = result.size if result.respond_to?(:size) and !result.is_a?(Integer)
76
+ result
77
+ end
78
+ end
79
+ end
80
+
81
+ def count(*args)
82
+ if limit_value
83
+ excluded = [:order, :limit, :offset, :reorder]
84
+ excluded << :includes unless eager_loading?
85
+ rel = self.except(*excluded)
86
+ column_name = if rel.select_values.present?
87
+ select = rel.select_values.join(", ")
88
+ select if select !~ /[,*]/
89
+ end || :all
90
+ rel.count(column_name)
91
+ else
92
+ super(*args)
93
+ end
94
+ end
95
+
96
+ # workaround for Active Record 3.0
97
+ def size
98
+ if !loaded? and limit_value and group_values.empty?
99
+ [super, limit_value].min
100
+ else
101
+ super
102
+ end
103
+ end
104
+
105
+ # overloaded to be pagination-aware
106
+ def empty?
107
+ if !loaded? and offset_value
108
+ total_entries <= offset_value
109
+ else
110
+ super
111
+ end
112
+ end
113
+
114
+ def clone
115
+ copy_will_paginate_data super
116
+ end
117
+
118
+ # workaround for Active Record 3.0
119
+ def scoped(options = nil)
120
+ copy_will_paginate_data super
121
+ end
122
+
123
+ def to_a
124
+ if current_page.nil? then super # workaround for Active Record 3.0
125
+ else
126
+ ::WillPaginate::Collection.create(current_page, limit_value) do |col|
127
+ col.replace super
128
+ col.total_entries ||= total_entries
129
+ end
130
+ end
131
+ end
132
+
133
+ private
134
+
135
+ def copy_will_paginate_data(other)
136
+ other.current_page = current_page unless other.current_page
137
+ other.total_entries = nil if defined? @total_entries_queried
138
+ other
139
+ end
140
+ end
141
+
142
+ module Pagination
143
+ def paginate(options)
144
+ options = options.dup
145
+ pagenum = options.fetch(:page) { raise ArgumentError, ":page parameter required" }
146
+ options.delete(:page)
147
+ per_page = options.delete(:per_page) || self.per_page
148
+ total = options.delete(:total_entries)
149
+
150
+ if options.any?
151
+ raise ArgumentError, "unsupported parameters: %p" % options.keys
152
+ end
153
+
154
+ rel = limit(per_page.to_i).page(pagenum)
155
+ rel.total_entries = total.to_i unless total.blank?
156
+ rel
157
+ end
158
+
159
+ def page(num)
160
+ rel = if ::ActiveRecord::Relation === self
161
+ self
162
+ elsif !defined?(::ActiveRecord::Scoping) or ::ActiveRecord::Scoping::ClassMethods.method_defined? :with_scope
163
+ # Active Record 3
164
+ scoped
165
+ else
166
+ # Active Record 4
167
+ all
168
+ end
169
+
170
+ rel = rel.extending(RelationMethods)
171
+ pagenum = ::WillPaginate::PageNumber(num.nil? ? 1 : num)
172
+ per_page = rel.limit_value || self.per_page
173
+ rel = rel.offset(pagenum.to_offset(per_page).to_i)
174
+ rel = rel.limit(per_page) unless rel.limit_value
175
+ rel.current_page = pagenum
176
+ rel
177
+ end
178
+ end
179
+
180
+ module BaseMethods
181
+ # Wraps +find_by_sql+ by simply adding LIMIT and OFFSET to your SQL string
182
+ # based on the params otherwise used by paginating finds: +page+ and
183
+ # +per_page+.
184
+ #
185
+ # Example:
186
+ #
187
+ # @developers = Developer.paginate_by_sql ['select * from developers where salary > ?', 80000],
188
+ # :page => params[:page], :per_page => 3
189
+ #
190
+ # A query for counting rows will automatically be generated if you don't
191
+ # supply <tt>:total_entries</tt>. If you experience problems with this
192
+ # generated SQL, you might want to perform the count manually in your
193
+ # application.
194
+ #
195
+ def paginate_by_sql(sql, options)
196
+ pagenum = options.fetch(:page) { raise ArgumentError, ":page parameter required" } || 1
197
+ per_page = options[:per_page] || self.per_page
198
+ total = options[:total_entries]
199
+
200
+ WillPaginate::Collection.create(pagenum, per_page, total) do |pager|
201
+ query = sanitize_sql(sql.dup)
202
+ original_query = query.dup
203
+ oracle = self.connection.adapter_name =~ /^(oracle|oci$)/i
204
+
205
+ # add limit, offset
206
+ if oracle
207
+ query = <<-SQL
208
+ SELECT * FROM (
209
+ SELECT rownum rnum, a.* FROM (#{query}) a
210
+ WHERE rownum <= #{pager.offset + pager.per_page}
211
+ ) WHERE rnum >= #{pager.offset}
212
+ SQL
213
+ elsif (self.connection.adapter_name =~ /^sqlserver/i)
214
+ query << " OFFSET #{pager.offset} ROWS FETCH NEXT #{pager.per_page} ROWS ONLY"
215
+ else
216
+ query << " LIMIT #{pager.per_page} OFFSET #{pager.offset}"
217
+ end
218
+
219
+ # perfom the find
220
+ pager.replace find_by_sql(query)
221
+
222
+ unless pager.total_entries
223
+ count_query = original_query.sub /\bORDER\s+BY\s+[\w`,\s.]+$/mi, ''
224
+ count_query = "SELECT COUNT(*) FROM (#{count_query})"
225
+ count_query << ' AS count_table' unless oracle
226
+ # perform the count query
227
+ pager.total_entries = count_by_sql(count_query)
228
+ end
229
+ end
230
+ end
231
+ end
232
+
233
+ # mix everything into Active Record
234
+ ::ActiveRecord::Base.extend PerPage
235
+ ::ActiveRecord::Base.extend Pagination
236
+ ::ActiveRecord::Base.extend BaseMethods
237
+
238
+ klasses = [::ActiveRecord::Relation]
239
+ if defined? ::ActiveRecord::Associations::CollectionProxy
240
+ klasses << ::ActiveRecord::Associations::CollectionProxy
241
+ else
242
+ klasses << ::ActiveRecord::Associations::AssociationCollection
243
+ end
244
+
245
+ # support pagination on associations and scopes
246
+ klasses.each { |klass| klass.send(:include, Pagination) }
247
+ end
248
+ end
@@ -0,0 +1,33 @@
1
+ require 'will_paginate/collection'
2
+
3
+ class Array
4
+ # Paginates a static array (extracting a subset of it). The result is a
5
+ # WillPaginate::Collection instance, which is an array with a few more
6
+ # properties about its paginated state.
7
+ #
8
+ # Parameters:
9
+ # * <tt>:page</tt> - current page, defaults to 1
10
+ # * <tt>:per_page</tt> - limit of items per page, defaults to 30
11
+ # * <tt>:total_entries</tt> - total number of items in the array, defaults to
12
+ # <tt>array.length</tt> (obviously)
13
+ #
14
+ # Example:
15
+ # arr = ['a', 'b', 'c', 'd', 'e']
16
+ # paged = arr.paginate(:per_page => 2) #-> ['a', 'b']
17
+ # paged.total_entries #-> 5
18
+ # arr.paginate(:page => 2, :per_page => 2) #-> ['c', 'd']
19
+ # arr.paginate(:page => 3, :per_page => 2) #-> ['e']
20
+ #
21
+ # This method was originally {suggested by Desi
22
+ # McAdam}[http://www.desimcadam.com/archives/8] and later proved to be the
23
+ # most useful method of will_paginate library.
24
+ def paginate(options = {})
25
+ page = options[:page] || 1
26
+ per_page = options[:per_page] || WillPaginate.per_page
27
+ total = options[:total_entries] || self.length
28
+
29
+ WillPaginate::Collection.create(page, per_page, total) do |pager|
30
+ pager.replace self[pager.offset, pager.per_page].to_a
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,136 @@
1
+ require 'will_paginate/per_page'
2
+ require 'will_paginate/page_number'
3
+
4
+ module WillPaginate
5
+ # Any will_paginate-compatible collection should have these methods:
6
+ #
7
+ # current_page, per_page, offset, total_entries, total_pages
8
+ #
9
+ # It can also define some of these optional methods:
10
+ #
11
+ # out_of_bounds?, previous_page, next_page
12
+ #
13
+ # This module provides few of these methods.
14
+ module CollectionMethods
15
+ def total_pages
16
+ total_entries.zero? ? 1 : (total_entries / per_page.to_f).ceil
17
+ end
18
+
19
+ # current_page - 1 or nil if there is no previous page
20
+ def previous_page
21
+ current_page > 1 ? (current_page - 1) : nil
22
+ end
23
+
24
+ # current_page + 1 or nil if there is no next page
25
+ def next_page
26
+ current_page < total_pages ? (current_page + 1) : nil
27
+ end
28
+
29
+ # Helper method that is true when someone tries to fetch a page with a
30
+ # larger number than the last page. Can be used in combination with flashes
31
+ # and redirecting.
32
+ def out_of_bounds?
33
+ current_page > total_pages
34
+ end
35
+ end
36
+
37
+ # = The key to pagination
38
+ # Arrays returned from paginating finds are, in fact, instances of this little
39
+ # class. You may think of WillPaginate::Collection as an ordinary array with
40
+ # some extra properties. Those properties are used by view helpers to generate
41
+ # correct page links.
42
+ #
43
+ # WillPaginate::Collection also assists in rolling out your own pagination
44
+ # solutions: see +create+.
45
+ #
46
+ # If you are writing a library that provides a collection which you would like
47
+ # to conform to this API, you don't have to copy these methods over; simply
48
+ # make your plugin/gem dependant on this library and do:
49
+ #
50
+ # require 'will_paginate/collection'
51
+ # # WillPaginate::Collection is now available for use
52
+ class Collection < Array
53
+ include CollectionMethods
54
+
55
+ attr_reader :current_page, :per_page, :total_entries
56
+
57
+ # Arguments to the constructor are the current page number, per-page limit
58
+ # and the total number of entries. The last argument is optional because it
59
+ # is best to do lazy counting; in other words, count *conditionally* after
60
+ # populating the collection using the +replace+ method.
61
+ def initialize(page, per_page = WillPaginate.per_page, total = nil)
62
+ @current_page = WillPaginate::PageNumber(page)
63
+ @per_page = per_page.to_i
64
+ self.total_entries = total if total
65
+ end
66
+
67
+ # Just like +new+, but yields the object after instantiation and returns it
68
+ # afterwards. This is very useful for manual pagination:
69
+ #
70
+ # @entries = WillPaginate::Collection.create(1, 10) do |pager|
71
+ # result = Post.find(:all, :limit => pager.per_page, :offset => pager.offset)
72
+ # # inject the result array into the paginated collection:
73
+ # pager.replace(result)
74
+ #
75
+ # unless pager.total_entries
76
+ # # the pager didn't manage to guess the total count, do it manually
77
+ # pager.total_entries = Post.count
78
+ # end
79
+ # end
80
+ #
81
+ # The possibilities with this are endless. For another example, here is how
82
+ # WillPaginate used to define pagination for Array instances:
83
+ #
84
+ # Array.class_eval do
85
+ # def paginate(page = 1, per_page = 15)
86
+ # WillPaginate::Collection.create(page, per_page, size) do |pager|
87
+ # pager.replace self[pager.offset, pager.per_page].to_a
88
+ # end
89
+ # end
90
+ # end
91
+ #
92
+ # The Array#paginate API has since then changed, but this still serves as a
93
+ # fine example of WillPaginate::Collection usage.
94
+ def self.create(page, per_page, total = nil)
95
+ pager = new(page, per_page, total)
96
+ yield pager
97
+ pager
98
+ end
99
+
100
+ # Current offset of the paginated collection. If we're on the first page,
101
+ # it is always 0. If we're on the 2nd page and there are 30 entries per page,
102
+ # the offset is 30. This property is useful if you want to render ordinals
103
+ # side by side with records in the view: simply start with offset + 1.
104
+ def offset
105
+ current_page.to_offset(per_page).to_i
106
+ end
107
+
108
+ def total_entries=(number)
109
+ @total_entries = number.to_i
110
+ end
111
+
112
+ # This is a magic wrapper for the original Array#replace method. It serves
113
+ # for populating the paginated collection after initialization.
114
+ #
115
+ # Why magic? Because it tries to guess the total number of entries judging
116
+ # by the size of given array. If it is shorter than +per_page+ limit, then we
117
+ # know we're on the last page. This trick is very useful for avoiding
118
+ # unnecessary hits to the database to do the counting after we fetched the
119
+ # data for the current page.
120
+ #
121
+ # However, after using +replace+ you should always test the value of
122
+ # +total_entries+ and set it to a proper value if it's +nil+. See the example
123
+ # in +create+.
124
+ def replace(array)
125
+ result = super
126
+
127
+ # The collection is shorter then page limit? Rejoice, because
128
+ # then we know that we are on the last page!
129
+ if total_entries.nil? and length < per_page and (current_page == 1 or length > 0)
130
+ self.total_entries = offset + length
131
+ end
132
+
133
+ result
134
+ end
135
+ end
136
+ end
@@ -0,0 +1,30 @@
1
+ require 'set'
2
+
3
+ # copied from ActiveSupport so we don't depend on it
4
+
5
+ unless Hash.method_defined? :except
6
+ Hash.class_eval do
7
+ # Returns a new hash without the given keys.
8
+ def except(*keys)
9
+ rejected = Set.new(respond_to?(:convert_key) ? keys.map { |key| convert_key(key) } : keys)
10
+ reject { |key,| rejected.include?(key) }
11
+ end
12
+
13
+ # Replaces the hash without only the given keys.
14
+ def except!(*keys)
15
+ replace(except(*keys))
16
+ end
17
+ end
18
+ end
19
+
20
+ unless String.method_defined? :underscore
21
+ String.class_eval do
22
+ def underscore
23
+ self.to_s.gsub(/::/, '/').
24
+ gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2').
25
+ gsub(/([a-z\d])([A-Z])/,'\1_\2').
26
+ tr("-", "_").
27
+ downcase
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,55 @@
1
+ module WillPaginate::Deprecation
2
+ class << self
3
+ def warn(message, stack = caller)
4
+ offending_line = origin_of_call(stack)
5
+ full_message = "DEPRECATION WARNING: #{message} (called from #{offending_line})"
6
+ logger = rails_logger || Kernel
7
+ logger.warn full_message
8
+ end
9
+
10
+ private
11
+
12
+ def rails_logger
13
+ defined?(Rails.logger) && Rails.logger
14
+ end
15
+
16
+ def origin_of_call(stack)
17
+ lib_root = File.expand_path('../../..', __FILE__)
18
+ stack.find { |line| line.index(lib_root) != 0 } || stack.first
19
+ end
20
+ end
21
+
22
+ class Hash < ::Hash
23
+ def initialize(values = {})
24
+ super()
25
+ update values
26
+ @deprecated = {}
27
+ end
28
+
29
+ def []=(key, value)
30
+ check_deprecated(key, value)
31
+ super
32
+ end
33
+
34
+ def deprecate_key(*keys, &block)
35
+ message = block_given? ? block : keys.pop
36
+ Array(keys).each { |key| @deprecated[key] = message }
37
+ end
38
+
39
+ def merge(another)
40
+ to_hash.update(another)
41
+ end
42
+
43
+ def to_hash
44
+ ::Hash.new.update(self)
45
+ end
46
+
47
+ private
48
+
49
+ def check_deprecated(key, value)
50
+ if msg = @deprecated[key] and (!msg.respond_to?(:call) or (msg = msg.call(key, value)))
51
+ WillPaginate::Deprecation.warn(msg)
52
+ end
53
+ end
54
+ end
55
+ end
@@ -0,0 +1,22 @@
1
+ module WillPaginate
2
+ module I18n
3
+ def self.locale_dir
4
+ File.expand_path('../locale', __FILE__)
5
+ end
6
+
7
+ def self.load_path
8
+ Dir["#{locale_dir}/*.{rb,yml}"]
9
+ end
10
+
11
+ def will_paginate_translate(keys, options = {}, &block)
12
+ if defined? ::I18n
13
+ defaults = Array(keys).dup
14
+ defaults << block if block_given?
15
+ ::I18n.translate(defaults.shift, **options.merge(:default => defaults, :scope => :will_paginate))
16
+ else
17
+ key = Array === keys ? keys.first : keys
18
+ yield key, options
19
+ end
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,37 @@
1
+ en:
2
+ will_paginate:
3
+ previous_label: "&#8592; Previous"
4
+ previous_aria_label: "Previous page"
5
+ next_label: "Next &#8594;"
6
+ next_aria_label: "Next page"
7
+ page_gap: "&hellip;"
8
+ container_aria_label: "Pagination"
9
+ page_aria_label: "Page %{page}"
10
+
11
+ page_entries_info:
12
+ single_page:
13
+ zero: "No %{model} found"
14
+ one: "Displaying 1 %{model}"
15
+ other: "Displaying all %{count} %{model}"
16
+ single_page_html:
17
+ zero: "No %{model} found"
18
+ one: "Displaying <b>1</b> %{model}"
19
+ other: "Displaying <b>all&nbsp;%{count}</b> %{model}"
20
+
21
+ multi_page: "Displaying %{model} %{from} - %{to} of %{count} in total"
22
+ multi_page_html: "Displaying %{model} <b>%{from}&nbsp;-&nbsp;%{to}</b> of <b>%{count}</b> in total"
23
+
24
+ # models:
25
+ # entry:
26
+ # zero: entries
27
+ # one: entry
28
+ # few: entries
29
+ # other: entries
30
+
31
+ # line_item:
32
+ # page_entries_info:
33
+ # single_page:
34
+ # zero: "Your shopping cart is empty"
35
+ # one: "Displaying one item in your cart"
36
+ # other: "Displaying all %{count} items"
37
+ # multi_page: "Displaying items %{from} - %{to} of %{count} in total"