From e228d0a90e23f1f3ef26e0bc57fa60cac7abc3b4 Mon Sep 17 00:00:00 2001 From: Tee Parham Date: Thu, 26 Dec 2013 14:39:51 -0700 Subject: [PATCH] Drop support for Rails 3.0 and 3.1 Rails 3.0 and 3.1 are no longer supported, matching the official Maintenance Policy for Ruby on Rails. See http://weblog.rubyonrails.org/2013/2/24/maintenance-policy-for-ruby-on-r ails/ * Remove Rails 3.0 and 3.1 Gemfiles. * Remove Rails 3.0 and 3.1 from the Travis build matrix. * Require Rails >= 3.2 in the gemspec. * The Haml::Plugin class does not need to inherit from anything. --- .travis.yml | 12 ------------ CHANGELOG.md | 3 +++ haml.gemspec | 2 +- lib/haml/helpers/action_view_mods.rb | 9 ++------- lib/haml/template/plugin.rb | 15 ++------------- lib/haml/util.rb | 12 ++++-------- test/gemfiles/Gemfile.rails-3.0.x | 4 ---- test/gemfiles/Gemfile.rails-3.1.x | 4 ---- test/helper_test.rb | 6 ------ 9 files changed, 12 insertions(+), 55 deletions(-) delete mode 100644 test/gemfiles/Gemfile.rails-3.0.x delete mode 100644 test/gemfiles/Gemfile.rails-3.1.x diff --git a/.travis.yml b/.travis.yml index d6899322..75002aee 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,30 +6,18 @@ rvm: - jruby - rbx-19mode gemfile: - - test/gemfiles/Gemfile.rails-3.0.x - - test/gemfiles/Gemfile.rails-3.1.x - test/gemfiles/Gemfile.rails-3.2.x - test/gemfiles/Gemfile.rails-4.0.x matrix: exclude: # Don't kill Travis: just test against the latest version on 2.0, JRuby # and Rubinius. - - { rvm: jruby, gemfile: test/gemfiles/Gemfile.rails-3.0.x } - - { rvm: jruby, gemfile: test/gemfiles/Gemfile.rails-3.1.x } - { rvm: jruby, gemfile: test/gemfiles/Gemfile.rails-3.2.x } - - - { rvm: rbx-19mode, gemfile: test/gemfiles/Gemfile.rails-3.0.x } - - { rvm: rbx-19mode, gemfile: test/gemfiles/Gemfile.rails-3.1.x } - { rvm: rbx-19mode, gemfile: test/gemfiles/Gemfile.rails-3.2.x } - { rvm: 1.9.2, gemfile: test/gemfiles/Gemfile.rails-4.0.x } - - { rvm: 2.0.0, gemfile: test/gemfiles/Gemfile.rails-3.0.x } - - { rvm: 2.0.0, gemfile: test/gemfiles/Gemfile.rails-3.1.x } - { rvm: 2.0.0, gemfile: test/gemfiles/Gemfile.rails-3.2.x } - - - { rvm: 2.1.0, gemfile: test/gemfiles/Gemfile.rails-3.0.x } - - { rvm: 2.1.0, gemfile: test/gemfiles/Gemfile.rails-3.1.x } - { rvm: 2.1.0, gemfile: test/gemfiles/Gemfile.rails-3.2.x } allow_failures: diff --git a/CHANGELOG.md b/CHANGELOG.md index b5a402d4..daf68f19 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,9 @@ ## 4.1.0 (Unreleased) * Haml now requires Ruby 1.9.2 or above. +* Rails 3.0 and 3.1 are no longer supported, matching the official + [Maintenance Policy for Ruby on Rails](http://weblog.rubyonrails.org/2013/2/24/maintenance-policy-for-ruby-on-rails/). + (Tee Parham) * Fix for attribute merging. When an attribute method (or literal nested hash) was used in an old style attribute hash and there is also a (non-static) new style hash there is an error. The fix can result in different behavior in diff --git a/haml.gemspec b/haml.gemspec index 119ab4af..ff119bbe 100644 --- a/haml.gemspec +++ b/haml.gemspec @@ -21,7 +21,7 @@ Gem::Specification.new do |spec| spec.add_dependency 'tilt' - spec.add_development_dependency 'rails', '>= 3.0.0' + spec.add_development_dependency 'rails', '>= 3.2.0' spec.add_development_dependency 'rbench' spec.add_development_dependency 'minitest', '~> 4.0' spec.add_development_dependency 'nokogiri', '~> 1.6.0' diff --git a/lib/haml/helpers/action_view_mods.rb b/lib/haml/helpers/action_view_mods.rb index 588b8e45..2507dcd9 100644 --- a/lib/haml/helpers/action_view_mods.rb +++ b/lib/haml/helpers/action_view_mods.rb @@ -42,12 +42,7 @@ module ActionView #double assignment is to avoid warnings _hamlout = _hamlout = eval('_hamlout', block.binding) # Necessary since capture_haml checks _hamlout - str = capture_haml(*args, &block) - - # NonCattingString is present in Rails less than 3.1.0. When support - # for 3.0 is dropped, this can be removed. - return ActionView::NonConcattingString.new(str) if str && defined?(ActionView::NonConcattingString) - return str + capture_haml(*args, &block) else capture_without_haml(*args, &block) end @@ -144,4 +139,4 @@ module ActionView alias_method :form_for, :form_for_with_haml end end -end \ No newline at end of file +end diff --git a/lib/haml/template/plugin.rb b/lib/haml/template/plugin.rb index e712abff..322e4456 100644 --- a/lib/haml/template/plugin.rb +++ b/lib/haml/template/plugin.rb @@ -1,17 +1,7 @@ module Haml # This module makes Haml work with Rails using the template handler API. - class Plugin < ActionView::Template::Handlers::ERB.superclass - - # Rails 3.1+, template handlers don't inherit from anything. In <= 3.0, they - # do. To avoid messy logic figuring this out, we just inherit from whatever - # the ERB handler does. - - # In Rails 3.1+, we don't need to include Compilable. - if (ActionPack::VERSION::MAJOR == 3) && (ActionPack::VERSION::MINOR < 1) - include ActionView::Template::Handlers::Compilable - end - + class Plugin def handles_encoding?; true; end def compile(template) @@ -25,7 +15,6 @@ module Haml Haml::Engine.new(template.source, options).compiler.precompiled_with_ambles([]) end - # In Rails 3.1+, #call takes the place of #compile def self.call(template) new.compile(template) end @@ -38,4 +27,4 @@ module Haml end end -ActionView::Template.register_template_handler(:haml, Haml::Plugin) \ No newline at end of file +ActionView::Template.register_template_handler(:haml, Haml::Plugin) diff --git a/lib/haml/util.rb b/lib/haml/util.rb index 24a6113d..083e5c03 100644 --- a/lib/haml/util.rb +++ b/lib/haml/util.rb @@ -56,17 +56,13 @@ module Haml $stderr = the_real_stderr end - # Returns an ActionView::Template* class. - # In pre-3.0 versions of Rails, most of these classes - # were of the form `ActionView::TemplateFoo`, - # while afterwards they were of the form `ActionView::Template::Foo`. + # Returns an ActionView::Template::* class. + # These classes are of the form `ActionView::Template::Foo`. # # @param name [#to_s] The name of the class to get. - # For example, `:Error` will return `ActionView::TemplateError` - # or `ActionView::Template::Error`. + # For example, `:Error` will return `ActionView::Template::Error`. def av_template_class(name) - return ActionView.const_get("Template#{name}") if ActionView.const_defined?("Template#{name}") - return ActionView::Template.const_get(name.to_s) + ActionView::Template.const_get(name.to_s) end ## Rails XSS Safety diff --git a/test/gemfiles/Gemfile.rails-3.0.x b/test/gemfiles/Gemfile.rails-3.0.x deleted file mode 100644 index 78af45bd..00000000 --- a/test/gemfiles/Gemfile.rails-3.0.x +++ /dev/null @@ -1,4 +0,0 @@ -source "https://rubygems.org" - -gem 'rails', '~> 3.0.0' -gemspec :path => "../.." diff --git a/test/gemfiles/Gemfile.rails-3.1.x b/test/gemfiles/Gemfile.rails-3.1.x deleted file mode 100644 index 19491e1f..00000000 --- a/test/gemfiles/Gemfile.rails-3.1.x +++ /dev/null @@ -1,4 +0,0 @@ -source "https://rubygems.org" - -gem 'rails', '~> 3.1.0' -gemspec :path => "../.." diff --git a/test/helper_test.rb b/test/helper_test.rb index de62eb13..261357cf 100644 --- a/test/helper_test.rb +++ b/test/helper_test.rb @@ -34,12 +34,6 @@ class HelperTest < MiniTest::Unit::TestCase @base = ActionView::Base.new @base.controller = ActionController::Base.new @base.view_paths << File.expand_path("../templates", __FILE__) - - if defined?(ActionController::Response) - # This is needed for >=3.0.0 - @base.controller.response = ActionController::Response.new - end - @base.instance_variable_set('@post', Post.new("Foo bar\nbaz", nil, PostErrors.new)) end