Permalink
Browse files

gemified rails plugin

  • Loading branch information...
1 parent 467ea00 commit 29b1b689f4c086e163c21c6a425f45a75b014629 @menostos menostos committed Feb 4, 2013
View
17 .gitignore
@@ -0,0 +1,17 @@
+*.gem
+*.rbc
+.bundle
+.config
+.yardoc
+Gemfile.lock
+InstalledFiles
+_yardoc
+coverage
+doc/
+lib/bundler/man
+pkg
+rdoc
+spec/reports
+test/tmp
+test/version_tmp
+tmp
View
5 Gemfile
@@ -0,0 +1,5 @@
+source 'https://rubygems.org'
+
+gemspec
+
+gem 'activesupport', '~> 3.2.0'
View
9 README.md
@@ -16,7 +16,7 @@ Provided methods:
## Installation
- $ rails plugin install git://github.com/shell/rails3_before_render.git
+ gem 'rails3_before_render'
Warning: Rails 3 only. Rails2 users can use [before_render](<https://github.com/xtoddx/before_render>) by Todd Willey.
@@ -42,13 +42,6 @@ Provided methods:
Method ping will be executed after your actions and before template is rendered.
-## Testing
-
- After installing plugin in your app:
-
- $ cd vendor/plugins/rails3_before_render
- $ rake test
-
## TODO
## Author
View
16 Rakefile 100644 → 100755
@@ -1,14 +1,2 @@
-require 'rake'
-require 'rake/testtask'
-require 'rake/rdoctask'
-
-desc 'Default: run unit tests.'
-task :default => :test
-
-desc 'Test the rails3_before_render plugin.'
-Rake::TestTask.new(:test) do |t|
- t.libs << 'lib'
- t.libs << 'test'
- t.pattern = 'test/**/*_test.rb'
- t.verbose = true
-end
+#!/usr/bin/env rake
+require "bundler/gem_tasks"
View
2 init.rb
@@ -1,2 +0,0 @@
-AbstractController::Base.send :extend, BeforeRender
-ActionController::Base.send :include, BeforeRenderInstance
View
25 lib/before_render.rb
@@ -1,25 +0,0 @@
-module BeforeRender
-
- def append_before_render_filter(*names, &blk)
- _insert_callbacks(names, blk) do |name, options|
- set_callback(:render, :before, name, options)
- end
- end
-
- def prepend_before_render_filter(*names, &blk)
- _insert_callbacks(names, blk) do |name, options|
- set_callback(:render, :before, name, options.merge(:prepend => true))
- end
- end
-
- def skip_before_render_filter(*names, &blk)
- _insert_callbacks(names, blk) do |name, options|
- skip_callback(:render, :before, name, options)
- end
- end
-
- alias_method :before_render, :append_before_render_filter
- alias_method :prepend_before_render, :prepend_before_render_filter
- alias_method :skip_before_render, :skip_before_render_filter
-
-end
View
13 lib/before_render_instance.rb
@@ -1,13 +0,0 @@
-module BeforeRenderInstance
- def self.included klass
- klass.send :alias_method_chain, :render, :before_render_filter
- klass.send :define_callbacks, :render
- end
-
- def render_with_before_render_filter *opts, &blk
- run_callbacks :render, action_name do
- render_without_before_render_filter(*opts, &blk)
- end
- end
-
-end
View
8 lib/rails3_before_render.rb
@@ -0,0 +1,8 @@
+require 'rails3_before_render/version'
+require 'active_support/concern'
+require 'rails3_before_render/before_render'
+require 'rails3_before_render/before_render_instance'
+
+module Rails3BeforeRender
+
+end
View
34 lib/rails3_before_render/before_render.rb
@@ -0,0 +1,34 @@
+module Rails3BeforeRender
+ module BeforeRender
+
+ extend ActiveSupport::Concern
+
+ module ClassMethods
+
+ def append_before_render_filter(*names, &blk)
+ _insert_callbacks(names, blk) do |name, options|
+ set_callback(:render, :before, name, options)
+ end
+ end
+
+ def prepend_before_render_filter(*names, &blk)
+ _insert_callbacks(names, blk) do |name, options|
+ set_callback(:render, :before, name, options.merge(:prepend => true))
+ end
+ end
+
+ def skip_before_render_filter(*names, &blk)
+ _insert_callbacks(names, blk) do |name, options|
+ skip_callback(:render, :before, name, options)
+ end
+ end
+
+ alias_method :before_render, :append_before_render_filter
+ alias_method :prepend_before_render, :prepend_before_render_filter
+ alias_method :skip_before_render, :skip_before_render_filter
+ end
+
+ end
+end
+
+AbstractController::Base.send :include, Rails3BeforeRender::BeforeRender
View
19 lib/rails3_before_render/before_render_instance.rb
@@ -0,0 +1,19 @@
+module Rails3BeforeRender
+ module BeforeRenderInstance
+
+ extend ActiveSupport::Concern
+
+ included do
+ alias_method_chain :render, :before_render_filter
+ define_callbacks :render
+ end
+
+ def render_with_before_render_filter *opts, &blk
+ run_callbacks :render, action_name do
+ render_without_before_render_filter(*opts, &blk)
+ end
+ end
+
+ end
+end
+ActionController::Base.send :include, Rails3BeforeRender::BeforeRenderInstance
View
3 lib/rails3_before_render/version.rb
@@ -0,0 +1,3 @@
+module Rails3BeforeRender
+ VERSION = "1.0.0"
+end
View
17 rails3_before_render.gemspec
@@ -0,0 +1,17 @@
+# -*- encoding: utf-8 -*-
+require File.expand_path('../lib/rails3_before_render/version', __FILE__)
+
+Gem::Specification.new do |gem|
+ gem.authors = ["shell"]
+ gem.email = ["shell"]
+ gem.description = %q{provides a before_render method for action_controllers}
+ gem.summary = %q{before_render will be called after your action and before the view is rendered}
+ gem.homepage = ""
+
+ gem.files = `git ls-files`.split($\)
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
+ gem.name = "rails3_before_render"
+ gem.require_paths = ["lib"]
+ gem.version = Rails3BeforeRender::VERSION
+end

0 comments on commit 29b1b68

Please sign in to comment.