pagify 0.7.0 → 0.7.1

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGES CHANGED
@@ -1,5 +1,9 @@
1
1
  = pagify changes history
2
2
 
3
+ == pagify 0.7.1 / 2010-04-26
4
+ * fix the problem that RUBY_VERSION is forzen,
5
+ just use lexical string comparsion then.
6
+
3
7
  == pagify 0.7.0 / 2009-11-16
4
8
  * added innate helper.
5
9
  * some internal refactoring
data/README CHANGED
@@ -1,4 +1,4 @@
1
- = pagify 0.6.2
1
+ = pagify 0.7.1
2
2
  by Lin Jen-Shin (aka godfat-真常[http://godfat.org])
3
3
  godfat (XD) godfat.org
4
4
 
@@ -10,16 +10,18 @@ by Lin Jen-Shin (aka godfat-真常[http://godfat.org])
10
10
  == DESCRIPTION:
11
11
 
12
12
  Pagination tools for Array(or custom class), DataMapper and ActiveRecord
13
+ Helpers for Innate/Ramaze and Rails included.
13
14
 
14
15
  == FEATURES:
15
16
 
16
17
  * Aims to be as flexible as possible
17
18
  * Separate intrusive "pagify" method and Array/DataMapper/ActiveRecord Pager.
18
19
  * Separate view helpers. There's only html helper right now.
20
+ * Web framework specific helper included. Currently for Innate/Ramaze and Rails.
19
21
 
20
22
  == SYNOPSIS:
21
23
 
22
- # for fast will_paginate replacement:
24
+ # for fast Rails will_paginate replacement:
23
25
  require 'pagify/active_record'
24
26
  require 'pagify/helper/rails'
25
27
 
@@ -31,6 +33,20 @@ by Lin Jen-Shin (aka godfat-真常[http://godfat.org])
31
33
 
32
34
 
33
35
 
36
+ # for Innate/Ramaze:
37
+ require 'pagify'
38
+ require 'pagify/helper/innate'
39
+
40
+ # in controller, say you want pagify helper:
41
+ class Controller < Ramaze::Controller
42
+ helper :pagify
43
+ end
44
+
45
+ # for the data part, see DataMapperPager or ActiveRecordPager
46
+ # in view, same as in Rails
47
+
48
+
49
+
34
50
  # basic DataMapper usage:
35
51
  require 'pagify/data_mapper'
36
52
 
@@ -109,8 +125,9 @@ by Lin Jen-Shin (aka godfat-真常[http://godfat.org])
109
125
 
110
126
  * ruby 1.8+ or 1.9.1+
111
127
  * for Basic/ArrayPager: only ruby is needed
112
- * for DataMapperPager: dm-core and dm-aggregates 0.9.9+
113
- * for ActiveRecordPager: activerecord 2.1.1+
128
+ * for DataMapperPager: dm-core and dm-aggregates 0.10.1+
129
+ * for ActiveRecordPager: activerecord 2.3.4+
130
+ * for Innate helper: innate 2009.07+
114
131
 
115
132
  == INSTALL:
116
133
 
data/Rakefile CHANGED
@@ -1,44 +1,33 @@
1
1
  # encoding: utf-8
2
2
 
3
- SUDO = '' # this prevent `rake gem:install` to use sudo
4
-
5
- require 'bones'
6
- Bones.setup
7
-
8
- PROJ.name = 'pagify'
9
- PROJ.authors = 'Lin Jen-Shin (aka godfat 真常)'
10
- PROJ.email = 'godfat (XD) godfat.org'
11
- PROJ.url = "http://github.com/godfat/#{PROJ.name}"
12
- PROJ.rubyforge.name = 'ludy'
13
-
14
- PROJ.gem.development_dependencies << ['dm-core', '>=0.9.9'] <<
15
- ['dm-aggregates', '>=0.9.9'] <<
16
- ['activerecord', '>=2.1.1']
17
-
18
- # supress warnings, there's too many warnings in dm-core
19
- PROJ.ruby_opts.delete '-w'
20
-
21
- PROJ.description = PROJ.summary = paragraphs_of('README', 'description').join("\n\n")
22
- PROJ.changes = paragraphs_of('CHANGES', 0..1).join("\n\n")
23
- PROJ.version = File.read("lib/#{PROJ.name}/version.rb").gsub(/.*VERSION = '(.*)'.*/m, '\1')
3
+ begin
4
+ require 'bones'
5
+ rescue LoadError
6
+ abort '### Please install the "bones" gem ###'
7
+ end
24
8
 
25
- PROJ.exclude += ['^tmp', 'tmp$', '^pkg', '^\.gitignore$',
26
- '^ann-', '\.sqlite3$', '\.db$']
9
+ ensure_in_path 'lib'
10
+ proj = 'pagify'
11
+ require "#{proj}/version"
27
12
 
28
- PROJ.rdoc.remote_dir = PROJ.name
13
+ Bones{
14
+ version Pagify::VERSION
29
15
 
30
- PROJ.readme_file = 'README'
31
- PROJ.rdoc.main = 'README'
32
- PROJ.rdoc.exclude += ['Rakefile', '^tasks', '^test']
33
- PROJ.rdoc.include << '\w+'
34
- # PROJ.rdoc.opts << '--diagram' if !Rake::WIN32 and `which dot` =~ %r/\/dot/
35
- PROJ.rdoc.opts += ['--charset=utf-8', '--inline-source',
36
- '--line-numbers', '--promiscuous']
16
+ ruby_opts [''] # silence warning, too many in addressable and/or dm-core
17
+ depend_on 'dm-core', :development => true, :version => '>=0.10.1'
18
+ depend_on 'dm-aggregates', :development => true, :version => '>=0.10.1'
19
+ depend_on 'activerecord', :development => true, :version => '>=2.3.4'
37
20
 
38
- PROJ.spec.opts << '--color'
21
+ name proj
22
+ url "http://github.com/godfat/#{proj}"
23
+ authors 'Lin Jen-Shin (aka godfat 真常)'
24
+ email 'godfat (XD) godfat.org'
39
25
 
40
- PROJ.ann.file = "ann-#{PROJ.name}-#{PROJ.version}"
41
- PROJ.ann.paragraphs.concat %w[LINKS SYNOPSIS REQUIREMENTS INSTALL LICENSE]
26
+ history_file 'CHANGES'
27
+ readme_file 'README'
28
+ ignore_file '.gitignore'
29
+ rdoc.include ['\w+']
30
+ }
42
31
 
43
32
  CLEAN.include Dir['**/*.rbc']
44
33
 
@@ -46,11 +35,3 @@ task :default do
46
35
  Rake.application.options.show_task_pattern = /./
47
36
  Rake.application.display_tasks_and_comments
48
37
  end
49
-
50
- namespace :gem do
51
- desc "create #{PROJ.name}.gemspec"
52
- task 'gemspec' do
53
- puts "rake gem:debug > #{PROJ.name}.gemspec"
54
- File.open("#{PROJ.name}.gemspec", 'w'){|spec| spec << `rake gem:debug`.sub(/.*/, '')}
55
- end
56
- end
data/TODO CHANGED
@@ -1,5 +1,9 @@
1
1
  = pagify todo list
2
2
 
3
+ == 1.0-
4
+ * more docs
5
+ * remove would_paginate
6
+
3
7
  == 1.0+
4
8
  * default chinese html setting
5
9
  * cooperate with DataMapper::Collection,
@@ -8,7 +8,7 @@ module Pagify
8
8
  # call Page#fetch
9
9
  class BasicPage
10
10
  # prvent Page#to_a return [#<Page:0x12345>]
11
- undef_method :to_a if Gem::Version.new(RUBY_VERSION) < Gem::Version.new('1.9.0')
11
+ undef_method :to_a if RUBY_VERSION < '1.9.0'
12
12
 
13
13
  # pager to get the original pager; page to get the number of this page
14
14
  attr_reader :pager, :page
@@ -1,4 +1,4 @@
1
1
 
2
2
  module Pagify
3
- VERSION = '0.7.0'
3
+ VERSION = '0.7.1'
4
4
  end
@@ -0,0 +1,70 @@
1
+ from: Lin Jen-Shin (aka godfat 真常)
2
+ date: Wed, Nov 18, 2009 at 1:41 AM
3
+ subject: pagination tool i wrote
4
+
5
+ Sorry that I can't express clearly in English speaking... :s
6
+ Here's the source for pagify I mentioned before:
7
+ http://github.com/godfat/pagify
8
+
9
+ I broke things into 4 parts:
10
+ 1. pager
11
+ 2. page
12
+ 3. pagifier
13
+ 4. helper
14
+
15
+ Pager is which uses `fetcher' and 'counter' to
16
+ calculate offset and limit. In ActiveRecord,
17
+ they are :find and :count.
18
+ http://github.com/godfat/pagify/blob/master/lib/pagify/pager/active_record.rb
19
+ In DataMapper, they are :all and :count.
20
+ You can build your own by using:
21
+ NullPager =
22
+ BasicPager.new(:fetcher => lambda{|*a|[]}, :counter => lambda{0})
23
+ Or just extending BasicPager.
24
+ NullPager is which always return nothing,
25
+ used to pretend that there's no data at all.
26
+
27
+ Page is which roughly equal to WillPaginate::Collection.
28
+ Currently there are only BasicPage and NullPage.
29
+ http://github.com/godfat/pagify/blob/master/lib/pagify/page/basic.rb
30
+
31
+ NullPage is something like empty WillPaginate::Collection.
32
+ Sometimes you would want:
33
+ Message.pagify(:page => random_page).each{ |m|
34
+ puts m
35
+ }
36
+ always work even if random_page is really out of range.
37
+
38
+ Pagifier is which make Message.pagify work right.
39
+ http://github.com/godfat/pagify/blob/master/lib/pagify/pagifier/active_record.rb
40
+
41
+ Note that `User.pagify.some_filter.another_filter` would work
42
+ under DataMapper but not ActiveRecord, and you have to make
43
+ Array "pagified" too, or ActiveRecord would fail on some places.
44
+ DataMapper isn't suffering from this, so Array should be clean.
45
+ (never monkey patch too many things in build-in classes)
46
+
47
+ Helper is which deal with HTML generating.
48
+ There's HTML, Rails, and Innate helper currently.
49
+
50
+ Links are generated by `request.path` and appended with
51
+ a page query string in URL in Rails. You could provide a
52
+ block to override this default:
53
+ pagify_links(@messages){ your_awesome_url }
54
+ Or a lower level operation:
55
+ @messages.html.links{ |page|
56
+ "/message/list.html?page=#{page}"
57
+ }
58
+
59
+ Setting is per pager basis:
60
+ @pager.html.setting[:prev_text] = '<<'
61
+ Or global default:
62
+ Pagify::Helper::HTML.setting[:prev_text] = '<='
63
+
64
+ It's fun to invent something when I know that
65
+ it's not a very hard task and I could probably
66
+ do better. No matter whether do I really do better,
67
+ at least I know what I've written, and I know where
68
+ should I look into if there's something wrong.
69
+
70
+ cheers,
@@ -7,7 +7,8 @@ Gem::Specification.new do |s|
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["Lin Jen-Shin (aka godfat 真常)"]
9
9
  s.date = %q{2009-11-16}
10
- s.description = %q{ Pagination tools for Array(or custom class), DataMapper and ActiveRecord}
10
+ s.description = %q{ Pagination tools for Array(or custom class), DataMapper and ActiveRecord
11
+ Helpers for Innate/Ramaze and Rails included.}
11
12
  s.email = %q{godfat (XD) godfat.org}
12
13
  s.extra_rdoc_files = ["CHANGES", "LICENSE", "NOTICE", "README", "TODO", "pagify.gemspec"]
13
14
  s.files = ["CHANGES", "LICENSE", "NOTICE", "README", "Rakefile", "TODO", "lib/pagify.rb", "lib/pagify/active_record.rb", "lib/pagify/array.rb", "lib/pagify/data_mapper.rb", "lib/pagify/helper/abstract.rb", "lib/pagify/helper/detail/setting.rb", "lib/pagify/helper/detail/setup.rb", "lib/pagify/helper/detail/web.rb", "lib/pagify/helper/html.rb", "lib/pagify/helper/innate.rb", "lib/pagify/helper/rails.rb", "lib/pagify/page/basic.rb", "lib/pagify/page/null.rb", "lib/pagify/pager/active_record.rb", "lib/pagify/pager/array.rb", "lib/pagify/pager/basic.rb", "lib/pagify/pager/data_mapper.rb", "lib/pagify/pager/detail/page_accept_string_or_blank.rb", "lib/pagify/pager/null.rb", "lib/pagify/pagifier/abstract.rb", "lib/pagify/pagifier/active_record.rb", "lib/pagify/pagifier/array.rb", "lib/pagify/pagifier/data_mapper.rb", "lib/pagify/version.rb", "pagify.gemspec", "spec/pagify_spec.rb", "spec/spec_helper.rb", "test/helper.rb", "test/helper_model.rb", "test/helper_pagify.rb", "test/helper_web.rb", "test/test_active_record.rb", "test/test_array.rb", "test/test_basic.rb", "test/test_data_mapper.rb", "test/test_html.rb", "test/test_innate.rb", "test/test_null.rb", "test/test_rails.rb"]
@@ -16,7 +17,7 @@ Gem::Specification.new do |s|
16
17
  s.require_paths = ["lib"]
17
18
  s.rubyforge_project = %q{ludy}
18
19
  s.rubygems_version = %q{1.3.5}
19
- s.summary = %q{Pagination tools for Array(or custom class), DataMapper and ActiveRecord}
20
+ s.summary = %q{Pagination tools for Array(or custom class), DataMapper and ActiveRecord Helpers for Innate/Ramaze and Rails included.}
20
21
  s.test_files = ["test/test_active_record.rb", "test/test_array.rb", "test/test_basic.rb", "test/test_data_mapper.rb", "test/test_html.rb", "test/test_innate.rb", "test/test_null.rb", "test/test_rails.rb"]
21
22
 
22
23
  if s.respond_to? :specification_version then
@@ -25,19 +26,19 @@ Gem::Specification.new do |s|
25
26
 
26
27
  if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
27
28
  s.add_development_dependency(%q<bones>, [">= 2.5.1"])
28
- s.add_development_dependency(%q<dm-core>, [">= 0.9.9"])
29
- s.add_development_dependency(%q<dm-aggregates>, [">= 0.9.9"])
30
- s.add_development_dependency(%q<activerecord>, [">= 2.1.1"])
29
+ s.add_development_dependency(%q<dm-core>, [">= 0.10.1"])
30
+ s.add_development_dependency(%q<dm-aggregates>, [">= 0.10.1"])
31
+ s.add_development_dependency(%q<activerecord>, [">= 2.3.4"])
31
32
  else
32
33
  s.add_dependency(%q<bones>, [">= 2.5.1"])
33
- s.add_dependency(%q<dm-core>, [">= 0.9.9"])
34
- s.add_dependency(%q<dm-aggregates>, [">= 0.9.9"])
35
- s.add_dependency(%q<activerecord>, [">= 2.1.1"])
34
+ s.add_dependency(%q<dm-core>, [">= 0.10.1"])
35
+ s.add_dependency(%q<dm-aggregates>, [">= 0.10.1"])
36
+ s.add_dependency(%q<activerecord>, [">= 2.3.4"])
36
37
  end
37
38
  else
38
39
  s.add_dependency(%q<bones>, [">= 2.5.1"])
39
- s.add_dependency(%q<dm-core>, [">= 0.9.9"])
40
- s.add_dependency(%q<dm-aggregates>, [">= 0.9.9"])
41
- s.add_dependency(%q<activerecord>, [">= 2.1.1"])
40
+ s.add_dependency(%q<dm-core>, [">= 0.10.1"])
41
+ s.add_dependency(%q<dm-aggregates>, [">= 0.10.1"])
42
+ s.add_dependency(%q<activerecord>, [">= 2.3.4"])
42
43
  end
43
44
  end
@@ -15,7 +15,7 @@ require 'dm-core'
15
15
  require 'dm-aggregates'
16
16
  require 'active_record'
17
17
 
18
- if Gem::Version.new(RUBY_VERSION) < Gem::Version.new('1.8.7')
18
+ if RUBY_VERSION < '1.8.7'
19
19
  class Symbol
20
20
  def to_proc
21
21
  lambda{ |*args| args.shift.__send__(self, *args) }
@@ -42,7 +42,7 @@ class TestActiveRecord < TestCase
42
42
  end
43
43
  property :id, Serial
44
44
  property :name, String
45
- property :user_id, Integer, :nullable => true
45
+ property :user_id, Integer, :required => false
46
46
  storage_names[default_repository_name] = 'pets'
47
47
  auto_migrate!
48
48
  end
@@ -42,7 +42,7 @@ class TestDataMapper < TestCase
42
42
  include DataMapper::Resource
43
43
  property :id, Serial
44
44
  property :name, String
45
- belongs_to :user, :nullable => true
45
+ belongs_to :user, :required => false
46
46
  end
47
47
 
48
48
  User.auto_migrate!
metadata CHANGED
@@ -1,7 +1,12 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pagify
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.0
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 7
8
+ - 1
9
+ version: 0.7.1
5
10
  platform: ruby
6
11
  authors:
7
12
  - "Lin Jen-Shin (aka godfat \xE7\x9C\x9F\xE5\xB8\xB8)"
@@ -9,50 +14,66 @@ autorequire:
9
14
  bindir: bin
10
15
  cert_chain: []
11
16
 
12
- date: 2009-11-16 00:00:00 +08:00
17
+ date: 2010-04-26 00:00:00 +08:00
13
18
  default_executable:
14
19
  dependencies:
15
- - !ruby/object:Gem::Dependency
16
- name: bones
17
- type: :development
18
- version_requirement:
19
- version_requirements: !ruby/object:Gem::Requirement
20
- requirements:
21
- - - ">="
22
- - !ruby/object:Gem::Version
23
- version: 2.5.1
24
- version:
25
20
  - !ruby/object:Gem::Dependency
26
21
  name: dm-core
27
- type: :development
28
- version_requirement:
29
- version_requirements: !ruby/object:Gem::Requirement
22
+ prerelease: false
23
+ requirement: &id001 !ruby/object:Gem::Requirement
30
24
  requirements:
31
25
  - - ">="
32
26
  - !ruby/object:Gem::Version
33
- version: 0.9.9
34
- version:
27
+ segments:
28
+ - 0
29
+ - 10
30
+ - 1
31
+ version: 0.10.1
32
+ type: :development
33
+ version_requirements: *id001
35
34
  - !ruby/object:Gem::Dependency
36
35
  name: dm-aggregates
37
- type: :development
38
- version_requirement:
39
- version_requirements: !ruby/object:Gem::Requirement
36
+ prerelease: false
37
+ requirement: &id002 !ruby/object:Gem::Requirement
40
38
  requirements:
41
39
  - - ">="
42
40
  - !ruby/object:Gem::Version
43
- version: 0.9.9
44
- version:
41
+ segments:
42
+ - 0
43
+ - 10
44
+ - 1
45
+ version: 0.10.1
46
+ type: :development
47
+ version_requirements: *id002
45
48
  - !ruby/object:Gem::Dependency
46
49
  name: activerecord
50
+ prerelease: false
51
+ requirement: &id003 !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - ">="
54
+ - !ruby/object:Gem::Version
55
+ segments:
56
+ - 2
57
+ - 3
58
+ - 4
59
+ version: 2.3.4
47
60
  type: :development
48
- version_requirement:
49
- version_requirements: !ruby/object:Gem::Requirement
61
+ version_requirements: *id003
62
+ - !ruby/object:Gem::Dependency
63
+ name: bones
64
+ prerelease: false
65
+ requirement: &id004 !ruby/object:Gem::Requirement
50
66
  requirements:
51
67
  - - ">="
52
68
  - !ruby/object:Gem::Version
53
- version: 2.1.1
54
- version:
55
- description: " Pagination tools for Array(or custom class), DataMapper and ActiveRecord"
69
+ segments:
70
+ - 3
71
+ - 4
72
+ - 1
73
+ version: 3.4.1
74
+ type: :development
75
+ version_requirements: *id004
76
+ description: " Pagination tools for Array(or custom class), DataMapper and ActiveRecord\n Helpers for Innate/Ramaze and Rails included."
56
77
  email: godfat (XD) godfat.org
57
78
  executables: []
58
79
 
@@ -63,7 +84,9 @@ extra_rdoc_files:
63
84
  - LICENSE
64
85
  - NOTICE
65
86
  - README
87
+ - Rakefile
66
88
  - TODO
89
+ - misc.txt
67
90
  - pagify.gemspec
68
91
  files:
69
92
  - CHANGES
@@ -96,22 +119,10 @@ files:
96
119
  - lib/pagify/pagifier/array.rb
97
120
  - lib/pagify/pagifier/data_mapper.rb
98
121
  - lib/pagify/version.rb
122
+ - misc.txt
99
123
  - pagify.gemspec
100
124
  - spec/pagify_spec.rb
101
125
  - spec/spec_helper.rb
102
- - tasks/ann.rake
103
- - tasks/bones.rake
104
- - tasks/gem.rake
105
- - tasks/git.rake
106
- - tasks/notes.rake
107
- - tasks/post_load.rake
108
- - tasks/rdoc.rake
109
- - tasks/rubyforge.rake
110
- - tasks/setup.rb
111
- - tasks/spec.rake
112
- - tasks/svn.rake
113
- - tasks/test.rake
114
- - tasks/zentest.rake
115
126
  - test/helper.rb
116
127
  - test/helper_model.rb
117
128
  - test/helper_pagify.rb
@@ -130,10 +141,6 @@ licenses: []
130
141
 
131
142
  post_install_message:
132
143
  rdoc_options:
133
- - --charset=utf-8
134
- - --inline-source
135
- - --line-numbers
136
- - --promiscuous
137
144
  - --main
138
145
  - README
139
146
  require_paths:
@@ -142,21 +149,23 @@ required_ruby_version: !ruby/object:Gem::Requirement
142
149
  requirements:
143
150
  - - ">="
144
151
  - !ruby/object:Gem::Version
152
+ segments:
153
+ - 0
145
154
  version: "0"
146
- version:
147
155
  required_rubygems_version: !ruby/object:Gem::Requirement
148
156
  requirements:
149
157
  - - ">="
150
158
  - !ruby/object:Gem::Version
159
+ segments:
160
+ - 0
151
161
  version: "0"
152
- version:
153
162
  requirements: []
154
163
 
155
- rubyforge_project: ludy
156
- rubygems_version: 1.3.5
164
+ rubyforge_project: pagify
165
+ rubygems_version: 1.3.6
157
166
  signing_key:
158
167
  specification_version: 3
159
- summary: Pagination tools for Array(or custom class), DataMapper and ActiveRecord
168
+ summary: Pagination tools for Array(or custom class), DataMapper and ActiveRecord Helpers for Innate/Ramaze and Rails included
160
169
  test_files:
161
170
  - test/test_active_record.rb
162
171
  - test/test_array.rb