Permalink
Browse files

Reorganizing plugin to be packaged and focused specifically for Merb

  • Loading branch information...
1 parent df23a9e commit e48fc02d073b32d6c0237388e821d097ba426046 @merbjedi committed Jan 31, 2009
Showing with 70 additions and 67 deletions.
  1. +1 −0 .gitignore
  2. +46 −57 Rakefile
  3. +17 −0 lib/merbtasks.rb
  4. +1 −6 lib/will_paginate.rb
  5. +2 −0 lib/will_paginate/array.rb
  6. +1 −1 lib/will_paginate/view_helpers/merb.rb
  7. +1 −1 spec/collection_spec.rb
  8. +0 −1 spec/spec_helper.rb
  9. +1 −1 spec/tasks.rake
View
@@ -2,3 +2,4 @@
/rails
*.gem
/coverage
+.DS_Store
View
103 Rakefile
@@ -1,70 +1,59 @@
require 'rubygems'
-begin
- hanna_dir = '/Users/mislav/Projects/Hanna/lib'
- $:.unshift hanna_dir if File.exists? hanna_dir
- require 'hanna/rdoctask'
-rescue LoadError
- require 'rake'
- require 'rake/rdoctask'
-end
+require 'rake/gempackagetask'
+
+require 'merb-core'
+require 'merb-core/tasks/merb'
+
load 'spec/tasks.rake'
desc 'Default: run specs.'
task :default => :spec
-desc 'Generate RDoc documentation for the will_paginate plugin.'
-Rake::RDocTask.new(:rdoc) do |rdoc|
- rdoc.rdoc_files.include('README.rdoc', 'LICENSE', 'CHANGELOG.rdoc').
- include('lib/**/*.rb').
- exclude('lib/will_paginate/finders/active_record/named_scope*').
- exclude('lib/will_paginate/finders/sequel.rb').
- exclude('lib/will_paginate/view_helpers/merb.rb').
- exclude('lib/will_paginate/deprecation.rb').
- exclude('lib/will_paginate/core_ext.rb').
- exclude('lib/will_paginate/version.rb')
-
- rdoc.main = "README.rdoc" # page to start on
- rdoc.title = "will_paginate documentation"
+GEM_NAME = "merb_paginate"
+GEM_VERSION = "0.9.0"
+AUTHORS = ['Jacques Crocker', 'Mislav Marohnić', 'PJ Hyett']
+EMAIL = 'merbjedi@gmail.com'
+HOMEPAGE = 'http://github.com/merbjedi/merb_paginate'
+SUMMARY = "merb_paginate is a fork of will_paginate agnostic branch, refocused to work specifically with Merb"
+
+spec = Gem::Specification.new do |s|
+ s.rubyforge_project = 'merb'
+ s.name = GEM_NAME
+ s.version = GEM_VERSION
+ s.platform = Gem::Platform::RUBY
+ s.has_rdoc = true
+ s.extra_rdoc_files = ["README.rdoc", "LICENSE"]
+ s.summary = SUMMARY
+ s.description = s.summary
+ s.authors = AUTHORS
+ s.email = EMAIL
+ s.homepage = HOMEPAGE
- rdoc.rdoc_dir = 'doc' # rdoc output folder
- rdoc.options << '--inline-source' << '--charset=UTF-8'
- rdoc.options << '--webcvs=http://github.com/mislav/will_paginate/tree/master/'
+ s.add_dependency('merb-core', '>= 1.0')
+
+ s.require_path = 'lib'
+ s.files = %w(LICENSE README.rdoc CHANGELOG.rdoc Rakefile) + Dir.glob("{lib,spec}/**/*")
end
-desc %{Update ".manifest" with the latest list of project filenames. Respect\
-.gitignore by excluding everything that git ignores. Update `files` and\
-`test_files` arrays in "*.gemspec" file if it's present.}
-task :manifest do
- list = Dir['**/*'].sort
- spec_file = Dir['*.gemspec'].first
- list -= [spec_file] if spec_file
-
- ignores = File.read('.gitignore').to_a
- ignores << 'website'
-
- ignores.each do |glob|
- glob = glob.chomp.sub(/^\//, '')
- list -= Dir[glob]
- list -= Dir["#{glob}/**/*"] if File.directory?(glob) and !File.symlink?(glob)
- puts "excluding #{glob}"
- end
+Rake::GemPackageTask.new(spec) do |pkg|
+ pkg.gem_spec = spec
+end
- if spec_file
- spec = File.read spec_file
- spec.gsub! /^(\s* s.(test_)?files \s* = \s* )( \[ [^\]]* \] | %w\( [^)]* \) )/mx do
- assignment = $1
- bunch = $2 ? list.grep(/^(test|spec)\//) : list
- '%s%%w(%s)' % [assignment, bunch.join(' ')]
- end
-
- File.open(spec_file, 'w') {|f| f << spec }
- end
- File.open('.manifest', 'w') {|f| f << list.join("\n") }
+desc "install the plugin as a gem"
+task :install do
+ Merb::RakeHelper.install(GEM_NAME, :version => GEM_VERSION)
end
-task :website do
- Dir.chdir('website') do
- %x(haml index.haml index.html)
- %x(sass pagination.sass pagination.css)
+desc "Uninstall the gem"
+task :uninstall do
+ Merb::RakeHelper.uninstall(GEM_NAME, :version => GEM_VERSION)
+end
+
+desc "Create a gemspec file"
+task :gemspec do
+ File.open("#{GEM_NAME}.gemspec", "w") do |file|
+ file.puts spec.to_ruby
end
-end
+end
+
+require 'lib/merbtasks'
View
@@ -0,0 +1,17 @@
+namespace :app_config do
+ desc "Create a blank config/app_config.yml file"
+ task :init do
+ puts "Setting up AppConfig files..."
+ `mkdir -p config/app_config`
+
+ ["config/app_config.yml",
+ "config/app_config/development.yml",
+ "config/app_config/production.yml"
+ ].each do |path|
+ `touch #{path}`
+ puts "Created: #{path}"
+ end
+ puts "Complete!"
+ puts "Add key/value pairs to your yaml file,\nthen access them in your Merb project via AppConfig.[key]"
+ end
+end
View
@@ -31,15 +31,10 @@ def self.enable_named_scope(patch = true)
end
end
-if defined?(Rails)
- require 'will_paginate/view_helpers/action_view' if defined?(ActionController)
- require 'will_paginate/finders/active_record' if defined?(ActiveRecord)
-end
-
if defined?(Merb::Plugins)
require 'will_paginate/view_helpers/merb'
# auto-load the right ORM adapter
if adapter = { :datamapper => 'data_mapper', :activerecord => 'active_record', :sequel => 'sequel' }[Merb.orm]
require "will_paginate/finders/#{adapter}"
end
-end
+end
@@ -30,4 +30,6 @@ def paginate(options = {})
pager.replace self[pager.offset, pager.per_page].to_a
end
end
+
+ alias :total_entries :size
end
@@ -10,4 +10,4 @@ def url(page)
end
end
-Merb::AbstractController.send(:include, WillPaginate::ViewHelpers::Base)
+Merb::AbstractController.send(:include, WillPaginate::ViewHelpers::Base)
View
@@ -10,7 +10,7 @@
it "should be a subset of original collection" do
@simple.paginate(:page => 1, :per_page => 3).should == %w( a b c )
end
-
+
it "can be shorter than per_page if on last page" do
@simple.paginate(:page => 2, :per_page => 3).should == %w( d e )
end
View
@@ -1,5 +1,4 @@
require 'rubygems'
-gem 'dchelimsky-rspec', '~> 1.1.11'
require 'spec'
module MyExtras
View
@@ -12,7 +12,7 @@ Spec::Rake::SpecTask.new(:spec) do |t|
end
namespace :spec do
- desc 'Run specs for core, ActiveRecord and ActionView'
+ desc 'Run specs for core, ActiveRecord'
Spec::Rake::SpecTask.new(:rails) do |t|
t.libs << 'lib' << 'spec'
t.spec_opts = ['--options', spec_opts]

0 comments on commit e48fc02

Please sign in to comment.