| Upgrade to rails 3.2 and rspec 2.8. Drop Rails 2.x support. - reportable - Fork… | |
| Log | |
| Files | |
| Refs | |
| README | |
| --- | |
| commit 61c74a867822300de464ac378c4163a976a912ee | |
| parent baa264091414b2ddd9642a806f22d04649388926 | |
| Author: Dieter Komendera <[email protected]> | |
| Date: Wed, 1 Feb 2012 11:17:37 +0100 | |
| Upgrade to rails 3.2 and rspec 2.8. Drop Rails 2.x support. | |
| Diffstat: | |
| M Gemfile | 10 +++++----- | |
| M Rakefile | 6 +++--- | |
| M lib/saulabs/reportable.rb | 6 ++---- | |
| M lib/saulabs/reportable/railtie.rb | 12 +++++++++++- | |
| M lib/saulabs/reportable/report_cach… | 1 + | |
| D rails/init.rb | 11 ----------- | |
| D spec/boot.rb | 22 ---------------------- | |
| M spec/other/report_method_spec.rb | 17 ++++++++++------- | |
| M spec/other/report_tag_helper_spec.… | 2 ++ | |
| M spec/spec_helper.rb | 43 ++++++++++++++++++++++-------… | |
| 10 files changed, 65 insertions(+), 65 deletions(-) | |
| --- | |
| diff --git a/Gemfile b/Gemfile | |
| @@ -1,9 +1,9 @@ | |
| source "http://rubygems.org" | |
| -gem 'rails', '~> 2.3.0' | |
| -gem 'activerecord', '~> 2.3.0', :require => 'active_record' | |
| -gem 'activesupport', '~> 2.3.0', :require => 'active_support' | |
| -gem 'actionpack', '~> 2.3.0', :require => 'action_pack' | |
| +gem 'rails', '~> 3.2.0' | |
| +gem 'activerecord', '~> 3.2.0', :require => 'active_record' | |
| +gem 'activesupport', '~> 3.2.0', :require => 'active_support' | |
| +gem 'actionpack', '~> 3.2.0', :require => 'action_pack' | |
| gem 'sqlite3-ruby', '>= 1.2.0' | |
| gem 'mysql', '>= 2.8.0' | |
| @@ -11,7 +11,7 @@ gem 'pg', '>= 0.9.0' | |
| gem 'tzinfo', '>= 0.3.0' | |
| gem 'rake', '>= 0.8.7' | |
| -gem 'rspec', '~> 1.3.0' | |
| +gem 'rspec', '~> 2.8.0' | |
| gem 'simplecov' | |
| gem 'excellent', '>= 1.5.4' | |
| gem 'yard', '>= 0.4.0' | |
| diff --git a/Rakefile b/Rakefile | |
| @@ -12,9 +12,9 @@ task :default => :spec | |
| desc 'Run the specs' | |
| Spec::Rake::SpecTask.new(:spec) do |t| | |
| - t.rcov_opts << '--exclude "gems/*,spec/*,init.rb"' | |
| - t.rcov = true | |
| - t.rcov_dir = 'doc/coverage' | |
| + # t.rcov_opts << '--exclude "gems/*,spec/*,init.rb"' | |
| + # t.rcov = true | |
| + # t.rcov_dir = 'doc/coverage' | |
| t.spec_files = FileList['spec/**/*_spec.rb'] | |
| end | |
| diff --git a/lib/saulabs/reportable.rb b/lib/saulabs/reportable.rb | |
| @@ -1,5 +1,7 @@ | |
| + | |
| require 'saulabs/reportable/report' | |
| require 'saulabs/reportable/cumulated_report' | |
| +require 'saulabs/reportable/railtie' | |
| module Saulabs | |
| @@ -9,10 +11,6 @@ module Saulabs | |
| # | |
| module RailsAdapter | |
| - IS_RAILS3 = defined?(Rails) && Rails::VERSION::MAJOR >= 3 | |
| - | |
| - require 'saulabs/reportable/railtie' if IS_RAILS3 | |
| - | |
| # Extends the {Saulabs::Reportable::ClassMethods#reportable} method into… | |
| # | |
| def self.included(base) | |
| diff --git a/lib/saulabs/reportable/railtie.rb b/lib/saulabs/reportable/railtie… | |
| @@ -10,7 +10,17 @@ module Saulabs | |
| GEM_ROOT = File.join(File.dirname(__FILE__), '..', '..', '..') | |
| initializer 'saulabs.reportable.initialization' do | |
| - require File.join(GEM_ROOT, 'rails', 'init') | |
| + ActiveSupport.on_load :active_record do | |
| + ActiveRecord::Base.class_eval do | |
| + include Saulabs::Reportable::RailsAdapter | |
| + end | |
| + end | |
| + ActiveSupport.on_load :action_view do | |
| + ActionView::Base.class_eval do | |
| + include Saulabs::Reportable::ReportTagHelper | |
| + end | |
| + end | |
| + | |
| end | |
| generators do | |
| diff --git a/lib/saulabs/reportable/report_cache.rb b/lib/saulabs/reportable/re… | |
| @@ -1,5 +1,6 @@ | |
| require 'saulabs/reportable/reporting_period' | |
| require 'saulabs/reportable/result_set' | |
| +require 'active_record' | |
| module Saulabs | |
| diff --git a/rails/init.rb b/rails/init.rb | |
| @@ -1,11 +0,0 @@ | |
| -require 'action_view' | |
| -require 'saulabs/reportable' | |
| -require 'saulabs/reportable/report_tag_helper' | |
| - | |
| -ActiveRecord::Base.class_eval do | |
| - include Saulabs::Reportable::RailsAdapter | |
| -end | |
| - | |
| -ActionView::Base.class_eval do | |
| - include Saulabs::Reportable::ReportTagHelper | |
| -end | |
| diff --git a/spec/boot.rb b/spec/boot.rb | |
| @@ -1,22 +0,0 @@ | |
| -plugin_root = File.join(File.dirname(__FILE__), '..') | |
| - | |
| -$:.unshift "#{plugin_root}/lib" | |
| - | |
| -Bundler.require | |
| -require 'initializer' | |
| - | |
| -RAILS_ROOT = File.expand_path(File.dirname(__FILE__) + '/../') unless defined?… | |
| -Rails::Initializer.run(:set_load_path) | |
| -Rails::Initializer.run(:set_autoload_paths) | |
| -Rails::Initializer.run(:initialize_time_zone) do |config| | |
| - config.time_zone = 'Pacific Time (US & Canada)' | |
| -end | |
| - | |
| -require File.join(File.dirname(__FILE__), '..', 'rails', 'init.rb') | |
| - | |
| -FileUtils.mkdir_p File.join(File.dirname(__FILE__), 'log') | |
| -ActiveRecord::Base.logger = Logger.new(File.join(File.dirname(__FILE__), 'log'… | |
| - | |
| -databases = YAML::load(IO.read(File.join(File.dirname(__FILE__), 'db', 'databa… | |
| -ActiveRecord::Base.establish_connection(databases[ENV['DB'] || 'sqlite3']) | |
| -load(File.join(File.dirname(__FILE__), 'db', 'schema.rb')) | |
| diff --git a/spec/other/report_method_spec.rb b/spec/other/report_method_spec.rb | |
| @@ -1,7 +1,17 @@ | |
| require File.join(File.dirname(File.dirname(File.expand_path(__FILE__))),'spec… | |
| describe Saulabs::Reportable do | |
| + | |
| + ActiveRecord::Base.class_eval do | |
| + include Saulabs::Reportable::RailsAdapter | |
| + end | |
| + | |
| + class User < ActiveRecord::Base | |
| + reportable :registrations, :limit => 10 | |
| + end | |
| + class SpecialUser < User; end | |
| + | |
| before(:all) do | |
| User.create!(:login => 'test 1', :created_at => Time.now - 1.days, :profi… | |
| User.create!(:login => 'test 2', :created_at => Time.now - 2.days, :profil… | |
| @@ -59,10 +69,3 @@ describe Saulabs::Reportable do | |
| end | |
| -class User < ActiveRecord::Base | |
| - | |
| - reportable :registrations, :limit => 10 | |
| - | |
| -end | |
| - | |
| -class SpecialUser < User; end | |
| diff --git a/spec/other/report_tag_helper_spec.rb b/spec/other/report_tag_helpe… | |
| @@ -1,5 +1,7 @@ | |
| require File.join(File.dirname(File.dirname(File.expand_path(__FILE__))),'spec… | |
| +require 'reportable/report_tag_helper' | |
| + | |
| describe Saulabs::Reportable::ReportTagHelper do | |
| before do | |
| diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb | |
| @@ -1,19 +1,39 @@ | |
| ENV['RAILS_ENV'] = 'test' | |
| require 'rubygems' | |
| -require 'bundler' | |
| -Bundler.setup | |
| - | |
| -require File.join(File.dirname(__FILE__), 'boot') | |
| - | |
| -class User < ActiveRecord::Base; end | |
| - | |
| -class YieldMatchException < Exception; end | |
| +require 'bundler/setup' | |
| +require 'active_record' | |
| +require 'active_record/version' | |
| +require 'active_support' | |
| begin | |
| require 'ruby-debug' | |
| - Debugger.start | |
| - Debugger.settings[:autoeval] = true if Debugger.respond_to?(:settings) | |
| + # Debugger.start | |
| + # Debugger.settings[:autoeval] = true if Debugger.respond_to?(:settings) | |
| rescue LoadError | |
| # ruby-debug wasn't available so neither can the debugging be | |
| -end | |
| -\ No newline at end of file | |
| +end | |
| + | |
| +ROOT = Pathname(File.expand_path(File.join(File.dirname(__FILE__), '..'))) | |
| + | |
| +$LOAD_PATH << File.join(ROOT, 'lib') | |
| +$LOAD_PATH << File.join(ROOT, 'lib/saulabs') | |
| + | |
| +require File.join(ROOT, 'lib', 'saulabs', 'reportable.rb') | |
| + | |
| +# Rails::Initializer.run(:set_load_path) | |
| +# Rails::Initializer.run(:set_autoload_paths) | |
| +# Rails::Initializer.run(:initialize_time_zone) do |config| | |
| +# config.time_zone = 'Pacific Time (US & Canada)' | |
| +# end | |
| + | |
| +FileUtils.mkdir_p File.join(File.dirname(__FILE__), 'log') | |
| +ActiveRecord::Base.logger = ActiveSupport::BufferedLogger.new(File.dirname(__F… | |
| + | |
| +databases = YAML::load(IO.read(File.join(File.dirname(__FILE__), 'db', 'databa… | |
| +ActiveRecord::Base.establish_connection(databases[ENV['DB'] || 'sqlite3']) | |
| +load(File.join(File.dirname(__FILE__), 'db', 'schema.rb')) | |
| + | |
| +class User < ActiveRecord::Base; end | |
| + | |
| +class YieldMatchException < Exception; end |