Skip to content

Commit

Permalink
add gemspec file. change rake manifest to auto-update the gemspec. ge…
Browse files Browse the repository at this point in the history
…t rid of rubyforge release task
  • Loading branch information
mislav committed Apr 26, 2008
1 parent 9616603 commit 3334327
Show file tree
Hide file tree
Showing 4 changed files with 83 additions and 68 deletions.
13 changes: 13 additions & 0 deletions CHANGELOG
Original file line number Original file line Diff line number Diff line change
@@ -1,3 +1,16 @@
== 2.2.3, released 2008-04-26

* will_paginate gem is no longer published on RubyForge, but on
gems.github.com:

gem sources -a http://gems.github.com/ (you only need to do this once)
gem install mislav-will_paginate

* extract reusable pagination testing stuff into WillPaginate::View
* rethink the page URL construction mechanizm to be more bulletproof when
combined with custom routing for page parameter
* test that anchor parameter can be used in pagination links

== 2.2.2, released 2008-04-21 == 2.2.2, released 2008-04-21


* Add support for page parameter in custom routes like "/foo/page/2" * Add support for page parameter in custom routes like "/foo/page/2"
Expand Down
74 changes: 37 additions & 37 deletions README.rdoc
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -11,44 +11,43 @@ can.


Some resources to get you started: Some resources to get you started:


* Your mind reels with questions? Join our Google * Your mind reels with questions? Join our
group[http://groups.google.com/group/will_paginate]. {Google group}[http://groups.google.com/group/will_paginate].
* The will_paginate project page: http://github.com/mislav/will_paginate * The will_paginate project page: http://github.com/mislav/will_paginate
* How to report bugs: http://github.com/mislav/will_paginate/wikis/report-bugs * How to report bugs: http://github.com/mislav/will_paginate/wikis/report-bugs
* Ryan Bates made an awesome screencast[http://railscasts.com/episodes/51], * Ryan Bates made an awesome screencast[http://railscasts.com/episodes/51],
check it out. check it out.


== Installation == Installation


Previously, the plugin was available on the following SVN location: The recommended way is that you get the gem:


svn://errtheblog.com/svn/plugins/will_paginate # add GitHub to your local list of gem sources:
gem sources -a http://gems.github.com/

# install the gem:
gem install mislav-will_paginate


In February 2008, it moved to GitHub to be tracked with git version control. After that you don't need the will_paginate <i>plugin</i> in your Rails
The SVN repo continued to have updates for some time, but now it doesn't. application anymore. Just add a simple require to the end of

"config/environment.rb":
You should switch to using the gem:

gem install will_paginate

After that, you can remove the plugin from your application and add
a simple require to the end of config/environment.rb:


gem 'mislav-will_paginate', '~> 2.2'
require 'will_paginate' require 'will_paginate'


That's it, just remember to install the gem on all machines that That's it. Remember to install the gem on <b>all</b> machines that you are
you are deploying to. deploying to.


<i>There are extensive <i>There are extensive
installation[http://github.com/mislav/will_paginate/wikis/installation] {installation instructions}[http://github.com/mislav/will_paginate/wikis/installation]
instructions on the wiki[http://github.com/mislav/will_paginate/wikis].</i> on {the wiki}[http://github.com/mislav/will_paginate/wikis].</i>




== Example usage == Example usage


Use a paginate finder in the controller: Use a paginate finder in the controller:


@posts = Post.paginate_by_board_id @board.id, :page => params[:page], :order => 'updated_at DESC' @posts = Post.paginate_by_board_id @board.id, :page => params[:page], :order => 'updated_at DESC'


Yeah, +paginate+ works just like +find+ -- it just doesn't fetch all the Yeah, +paginate+ works just like +find+ -- it just doesn't fetch all the
records. Don't forget to tell it which page you want, or it will complain! records. Don't forget to tell it which page you want, or it will complain!
Expand All @@ -57,44 +56,44 @@ Read more on WillPaginate::Finder::ClassMethods.
Render the posts in your view like you would normally do. When you need to render Render the posts in your view like you would normally do. When you need to render
pagination, just stick this in: pagination, just stick this in:


<%= will_paginate @posts %> <%= will_paginate @posts %>


You're done. (Copy and paste the example fancy CSS styles from the bottom.) You You're done. (Copy and paste the example fancy CSS styles from the bottom.) You
can find the option list at WillPaginate::ViewHelpers. can find the option list at WillPaginate::ViewHelpers.


How does it know how much items to fetch per page? It asks your model by calling How does it know how much items to fetch per page? It asks your model by calling
its <tt>per_page</tt> class method. You can define it like this: its <tt>per_page</tt> class method. You can define it like this:


class Post < ActiveRecord::Base class Post < ActiveRecord::Base
cattr_reader :per_page cattr_reader :per_page
@@per_page = 50 @@per_page = 50
end end


... or like this: ... or like this:


class Post < ActiveRecord::Base class Post < ActiveRecord::Base
def self.per_page def self.per_page
50 50
end
end end
end


... or don't worry about it at all. WillPaginate defines it to be <b>30</b> by default. ... or don't worry about it at all. WillPaginate defines it to be <b>30</b> by default.
But you can always specify the count explicitly when calling +paginate+: But you can always specify the count explicitly when calling +paginate+:


@posts = Post.paginate :page => params[:page], :per_page => 50 @posts = Post.paginate :page => params[:page], :per_page => 50


The +paginate+ finder wraps the original finder and returns your resultset that now has The +paginate+ finder wraps the original finder and returns your resultset that now has
some new properties. You can use the collection as you would with any ActiveRecord some new properties. You can use the collection as you would with any ActiveRecord
resultset. WillPaginate view helpers also need that object to be able to render pagination: resultset. WillPaginate view helpers also need that object to be able to render pagination:


<ol> <ol>
<% for post in @posts -%> <% for post in @posts -%>
<li>Render `post` in some nice way.</li> <li>Render `post` in some nice way.</li>
<% end -%> <% end -%>
</ol> </ol>


<p>Now let's render us some pagination!</p> <p>Now let's render us some pagination!</p>
<%= will_paginate @posts %> <%= will_paginate @posts %>


More detailed documentation: More detailed documentation:


Expand Down Expand Up @@ -131,5 +130,6 @@ More reading about pagination as design pattern:
* Pagination on Yahoo Design Pattern Library: * Pagination on Yahoo Design Pattern Library:
http://developer.yahoo.com/ypatterns/parent.php?pattern=pagination http://developer.yahoo.com/ypatterns/parent.php?pattern=pagination


Want to discuss, request features, ask questions? Join the Google group: Want to discuss, request features, ask questions? Join the
http://groups.google.com/group/will_paginate {Google group}[http://groups.google.com/group/will_paginate].

43 changes: 12 additions & 31 deletions Rakefile
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -73,45 +73,26 @@ Rake::RDocTask.new(:rdoc) do |rdoc|
end end


task :manifest do task :manifest do
list = Dir['**/*'] list = Dir['**/*'].sort
spec_file = Dir['*.gemspec'].first
list -= [spec_file]


File.read('.gitignore').each_line do |glob| File.read('.gitignore').each_line do |glob|
glob = glob.chomp.sub(/^\//, '') glob = glob.chomp.sub(/^\//, '')
list -= Dir[glob] list -= Dir[glob]
list -= Dir["#{glob}/**/*"] if File.directory?(glob) and !File.symlink?(glob) list -= Dir["#{glob}/**/*"] if File.directory?(glob) and !File.symlink?(glob)
puts "excluding #{glob}" puts "excluding #{glob}"
end end

File.open('.manifest', 'w') do |file|
file.write list.sort.join("\n")
end
end


desc 'Package and upload the release to rubyforge.' spec = File.read spec_file
task :release do spec.gsub! /^(\s* s.(test_)?files \s* = \s* )( \[ [^\]]* \] | %w\( [^)]* \) )/mx do
require 'yaml' assignment = $1
require 'rubyforge' bunch = $2 ? list.grep(/^test\//) : list

'%s%%w(%s)' % [assignment, bunch.join(' ')]
meta = YAML::load open('.gemified') end
version = meta[:version]

File.open(spec_file, 'w') {|f| f << spec }
v = ENV['VERSION'] or abort "Must supply VERSION=x.y.z" File.open('.manifest', 'w') {|f| f << list.join("\n") }
abort "Version doesn't match #{version}" if v != version

gem = "#{meta[:name]}-#{version}.gem"
project = meta[:rubyforge_project]

rf = RubyForge.new
puts "Logging in to RubyForge"
rf.login

c = rf.userconfig
c['release_notes'] = meta[:summary]
c['release_changes'] = File.read('CHANGELOG').split(/^== .+\n/)[1].strip
c['preformatted'] = true

puts "Releasing #{meta[:name]} #{version}"
rf.add_release project, project, version, gem
end end


task :examples do task :examples do
Expand Down
21 changes: 21 additions & 0 deletions will_paginate.gemspec
Original file line number Original file line Diff line number Diff line change
@@ -0,0 +1,21 @@
Gem::Specification.new do |s|
s.name = 'will_paginate'
s.version = '2.2.3'
s.date = '2008-04-26'

s.summary = "Most awesome pagination solution for Rails"
s.description = "The will_paginate library provides a simple, yet powerful and extensible API for ActiveRecord pagination and rendering of pagination links in ActionView templates."

s.authors = ['Mislav Marohnić', 'PJ Hyett']
s.email = 'mislav.marohnic@gmail.com'
s.homepage = 'http://github.com/mislav/will_paginate/wikis'

s.has_rdoc = true
s.rdoc_options = ['--main', 'README.rdoc']
s.rdoc_options << '--inline-source' << '--charset=UTF-8'
s.extra_rdoc_files = ['README.rdoc', 'LICENSE', 'CHANGELOG']
# s.add_dependency 'actionpack', ['>= 1.13.6']

s.files = %w(CHANGELOG LICENSE README.rdoc Rakefile examples examples/apple-circle.gif examples/index.haml examples/index.html examples/pagination.css examples/pagination.sass init.rb lib lib/will_paginate lib/will_paginate.rb lib/will_paginate/array.rb lib/will_paginate/collection.rb lib/will_paginate/core_ext.rb lib/will_paginate/finder.rb lib/will_paginate/named_scope.rb lib/will_paginate/named_scope_patch.rb lib/will_paginate/version.rb lib/will_paginate/view_helpers.rb test test/boot.rb test/collection_test.rb test/console test/database.yml test/finder_test.rb test/fixtures test/fixtures/admin.rb test/fixtures/developer.rb test/fixtures/developers_projects.yml test/fixtures/project.rb test/fixtures/projects.yml test/fixtures/replies.yml test/fixtures/reply.rb test/fixtures/schema.rb test/fixtures/topic.rb test/fixtures/topics.yml test/fixtures/user.rb test/fixtures/users.yml test/helper.rb test/lib test/lib/activerecord_test_case.rb test/lib/activerecord_test_connector.rb test/lib/load_fixtures.rb test/lib/view_test_process.rb test/view_test.rb)
s.test_files = %w(test/boot.rb test/collection_test.rb test/console test/database.yml test/finder_test.rb test/fixtures test/fixtures/admin.rb test/fixtures/developer.rb test/fixtures/developers_projects.yml test/fixtures/project.rb test/fixtures/projects.yml test/fixtures/replies.yml test/fixtures/reply.rb test/fixtures/schema.rb test/fixtures/topic.rb test/fixtures/topics.yml test/fixtures/user.rb test/fixtures/users.yml test/helper.rb test/lib test/lib/activerecord_test_case.rb test/lib/activerecord_test_connector.rb test/lib/load_fixtures.rb test/lib/view_test_process.rb test/view_test.rb)
end

0 comments on commit 3334327

Please sign in to comment.