Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix before_filter > before_action deprecation error (backward compatible) #67

Open
wants to merge 21 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .ruby-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
2.5.0
48 changes: 0 additions & 48 deletions .rvmrc

This file was deleted.

8 changes: 7 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
language: ruby
rvm:
- 1.9.3
- 2.0.0
- 2.5.0
gemfile:
- gemfiles/rails3_2.gemfile
- gemfiles/rails4_0.gemfile
- gemfiles/rails5_0.gemfile

matrix:
exclude:
- rvm: 2.0.0
gemfile: gemfiles/rails5_0.gemfile
14 changes: 12 additions & 2 deletions Appraisals
Original file line number Diff line number Diff line change
@@ -1,9 +1,19 @@
appraise "rails3_2" do
appraise 'rails3_2' do
gem 'activesupport', '>= 3.0', '< 4'
gem 'actionpack', '>= 3.0', '< 4'
end

appraise "rails4_0" do
appraise 'rails4_0' do
gem 'activesupport', '>= 4.0.0.beta', '< 5'
gem 'actionpack', '>= 4.0.0.beta', '< 5'
end

appraise 'rails5_0' do
gem 'activesupport', '~> 5.0'
gem 'actionpack', '~> 5.0'
end

appraise 'rails5_1' do
gem 'activesupport', '~> 5.1.0'
gem 'actionpack', '~> 5.1.0'
end
5 changes: 5 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
2.0.0
Copy link

@uzairfaisal uzairfaisal Sep 14, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think there's any major incompatible API changes ... maybe better to stick to 1.9.0?

* [ADDED] Adds support for Rails 5.1 and above.
* [ADDED] Adds ruby 2.5.0 to .travis.yml
* [BREAKING] Removes support for ruby 1.9.3

1.8.0
* [ADDED] You can now set each parameters individually for each crumb
* [ADDED] You can now set each crumb on right or left side
Expand Down
4 changes: 2 additions & 2 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
source "https://rubygems.org"
source 'https://rubygems.org'

gemspec
gemspec
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Crummy is a simple and tasty way to add breadcrumbs to your Rails applications.
Simply add the dependency to your Gemfile:

```ruby
gem "crummy", "~> 1.8.0"
gem "crummy", "~> 2.0.0" # "~> 1.8.0" for ruby < 2.0
```

# Example
Expand All @@ -27,7 +27,7 @@ end
class BusinessController < ApplicationController
add_crumb("Businesses") { |instance| instance.send :businesses_path }
add_crumb("Comments", only: "comments") { |instance| instance.send :businesses_comments_path }
before_filter :load_comment, only: "show"
before_action :load_comment, only: "show"
add_crumb :comment, only: "show"

# Example for nested routes:
Expand Down Expand Up @@ -180,7 +180,7 @@ See `lib/crummy.rb` for a list of these parameters and their defaults.
```ruby
add_crumb support_link, {:right_side => true, :links => "/support", : li_class => "my_class", :li_right_class => "pull-right hidden-phone"}
```
Simple add that parameter to options hash.
Simple add that parameter to options hash.


## Live example application
Expand All @@ -192,7 +192,7 @@ An example application is available right inside this gem. That application is d
- Accept collections of models as a single argument
- Accept instances of models as a single argument
- Allow for variables in names. (The workaround is to do your own
before\_filter for that currently)
before_filter for that currently)
- Make a crumbs? type method

## Credits
Expand Down
2 changes: 1 addition & 1 deletion Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ require 'bundler/gem_tasks'
require 'appraisal'

desc 'Default: run unit tests.'
task :default => :test
task default: :test

require 'rake/testtask'
desc 'Test the crummy plugin.'
Expand Down
32 changes: 16 additions & 16 deletions crummy.gemspec
Original file line number Diff line number Diff line change
@@ -1,31 +1,31 @@
# -*- encoding: utf-8 -*-
$:.push File.expand_path("../lib", __FILE__)
require "crummy/version"
$LOAD_PATH.push File.expand_path('../lib', __FILE__)
require 'crummy/version'

Gem::Specification.new do |s|
s.name = "crummy"
s.name = 'crummy'
s.version = Crummy::VERSION
s.platform = Gem::Platform::RUBY
s.licenses = ['MIT']

s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
s.authors = ["Zach Inglis", "Andrew Nesbitt"]
s.summary = "Tasty breadcrumbs!"
s.description = "Crummy is a simple and tasty way to add breadcrumbs to your Rails applications."
s.email = "[email protected]"
s.extra_rdoc_files = ["README.md"]
s.required_rubygems_version = Gem::Requirement.new('>= 0') if s.respond_to? :required_rubygems_version=
s.authors = ['Zach Inglis', 'Andrew Nesbitt']
s.summary = 'Tasty breadcrumbs!'
s.description = 'Crummy is a simple and tasty way to add breadcrumbs to your Rails applications.'
s.email = '[email protected]'
s.extra_rdoc_files = ['README.md']

s.files = `git ls-files`.split("\n")
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")

s.homepage = "http://github.com/zachinglis/crummy"
s.require_paths = [%q{lib}]
s.rubygems_version = %q{1.8.8}
s.homepage = 'http://github.com/zachinglis/crummy'
s.require_paths = ['lib']
s.rubygems_version = '2.0.0'

s.add_development_dependency 'rake'
s.add_development_dependency 'bundler', '~> 1.0'
s.add_development_dependency 'activesupport'
s.add_development_dependency 'actionpack'
s.add_development_dependency 'activesupport'
s.add_development_dependency 'appraisal'
s.add_development_dependency 'bundler', '~> 1.0'
s.add_development_dependency('rails-dom-testing')
s.add_development_dependency 'rake'
s.add_development_dependency 'test-unit'
end
8 changes: 4 additions & 4 deletions example/Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,21 @@ gem 'sqlite3'
# Gems used only for assets and not required
# in production environments by default.
group :assets do
gem 'sass-rails', '~> 3.1.4'
gem 'coffee-rails', '~> 3.1.1'
gem 'sass-rails', '~> 3.1.4'
gem 'uglifier', '>= 1.0.3'
end

gem 'jquery-rails'

gem 'crummy', path: '../'
gem 'haml'
gem 'crummy', :path => '../'

group :test do
# Pretty printed test output
gem 'turn', :require => false
gem 'turn', require: false
end

group :test, :development do
gem "rspec-rails", "~> 2.0"
gem 'rspec-rails', '~> 2.0'
end
6 changes: 3 additions & 3 deletions example/app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
class ApplicationController < ActionController::Base
add_crumb("Homepage") { |instance| instance.send :root_url }
add_crumb("Customer Dashboard", '/')
add_crumb('Homepage') { |instance| instance.send :root_url }
add_crumb('Customer Dashboard', '/')

protect_from_forgery
end
1 change: 0 additions & 1 deletion example/app/controllers/pages_controller.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
class PagesController < ApplicationController
def index
end

end
10 changes: 5 additions & 5 deletions example/app/controllers/posts_controller.rb
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
class PostsController < ApplicationController
add_crumb "Posts", :posts_url, :except => [:new]
add_crumb 'Posts', :posts_url, except: [:new]

def index
@posts = Post.all
end

def show
@post = Post.find params[:id]

@post.categories.each do |category|
add_crumb category.title, "#"
add_crumb category.title, '#'
end
end

def new
add_crumb "Forever Alone"
add_crumb 'Forever Alone'
end
end
2 changes: 1 addition & 1 deletion example/app/helpers/application_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ def page_title
if @page_title
"Crummy Test - #{@page_title}"
else
"Crummy Test"
'Crummy Test'
end
end
end
2 changes: 1 addition & 1 deletion example/app/models/category.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
class Category < ActiveRecord::Base
belongs_to :category

has_many :categories
has_many :posts
end
8 changes: 4 additions & 4 deletions example/app/models/post.rb
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
class Post < ActiveRecord::Base
belongs_to :category

def categories
category = self.category
categories = []

while category.present?
categories << category
category = category.category
end

categories.reverse
end

def to_s
title
end
Expand Down
2 changes: 1 addition & 1 deletion example/config.ru
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# This file is used by Rack-based servers to start the application.

require ::File.expand_path('../config/environment', __FILE__)
require ::File.expand_path('../config/environment', __FILE__)
run CrummyTest::Application
4 changes: 2 additions & 2 deletions example/config/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

if defined?(Bundler)
# If you precompile assets before deploying to production, use this line
Bundler.require(*Rails.groups(:assets => %w(development test)))
Bundler.require(*Rails.groups(assets: %w[development test]))
# If you want your assets lazily compiled in production, use this line
# Bundler.require(:default, :assets, Rails.env)
end
Expand Down Expand Up @@ -34,7 +34,7 @@ class Application < Rails::Application
# config.i18n.default_locale = :de

# Configure the default encoding used in templates for Ruby 1.9.
config.encoding = "utf-8"
config.encoding = 'utf-8'

# Configure sensitive parameters which will be filtered from the log file.
config.filter_parameters += [:password]
Expand Down
2 changes: 1 addition & 1 deletion example/config/boot.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
# Set up gems listed in the Gemfile.
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)

require 'bundler/setup' if File.exists?(ENV['BUNDLE_GEMFILE'])
require 'bundler/setup' if File.exist?(ENV['BUNDLE_GEMFILE'])
4 changes: 2 additions & 2 deletions example/config/environments/test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

# Configure static asset server for tests with Cache-Control for performance
config.serve_static_assets = true
config.static_cache_control = "public, max-age=3600"
config.static_cache_control = 'public, max-age=3600'

# Log error messages when you accidentally call methods on nil
config.whiny_nils = true
Expand All @@ -22,7 +22,7 @@
config.action_dispatch.show_exceptions = false

# Disable request forgery protection in test environment
config.action_controller.allow_forgery_protection = false
config.action_controller.allow_forgery_protection = false

# Tell Action Mailer not to deliver emails to the real world.
# The :test delivery method accumulates sent emails in the
Expand Down
2 changes: 1 addition & 1 deletion example/config/initializers/session_store.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Be sure to restart your server when you modify this file.

CrummyTest::Application.config.session_store :cookie_store, :key => '_crummy-test_session'
CrummyTest::Application.config.session_store :cookie_store, key: '_crummy-test_session'

# Use the database for sessions instead of the cookie-based default,
# which shouldn't be used to store highly confidential information
Expand Down
2 changes: 1 addition & 1 deletion example/config/initializers/wrap_parameters.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

# Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array.
ActiveSupport.on_load(:action_controller) do
wrap_parameters :format => [:json]
wrap_parameters format: [:json]
end

# Disable root element in JSON by default.
Expand Down
4 changes: 2 additions & 2 deletions example/config/routes.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
CrummyTest::Application.routes.draw do
resources :posts
root :to => "pages#index"

root to: 'pages#index'
end
4 changes: 2 additions & 2 deletions example/db/migrate/20111104103738_create_categories.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ def change
create_table :categories do |t|
t.string :title
t.string :slug

t.string :category_id # Can have a category as a parent

t.timestamps
end
end
Expand Down
Loading