diff --git a/lib/assets/javascripts/reporting_engine/reporting_engine.js b/lib/assets/javascripts/reporting_engine/reporting_engine.js index 22d9faeff8..706cc83dc2 100644 --- a/lib/assets/javascripts/reporting_engine/reporting_engine.js +++ b/lib/assets/javascripts/reporting_engine/reporting_engine.js @@ -1,3 +1,4 @@ +//= require prototype //= require reporting_engine/reporting //= require reporting_engine/sortable //= require reporting_engine/cordinc_tooltip diff --git a/lib/reporting_engine/engine_module.rb b/lib/engine.rb similarity index 100% rename from lib/reporting_engine/engine_module.rb rename to lib/engine.rb diff --git a/lib/reporting_engine/report.rb b/lib/report.rb similarity index 98% rename from lib/reporting_engine/report.rb rename to lib/report.rb index 7099f5e111..a166c89927 100644 --- a/lib/reporting_engine/report.rb +++ b/lib/report.rb @@ -1,7 +1,4 @@ -require_dependency 'reporting_engine/engine_module' - class Report < ActiveRecord::Base - extend ProactiveAutoloader extend Forwardable include Enumerable include Engine diff --git a/lib/reporting_engine/report/chainable.rb b/lib/report/chainable.rb similarity index 100% rename from lib/reporting_engine/report/chainable.rb rename to lib/report/chainable.rb diff --git a/lib/reporting_engine/report/controller.rb b/lib/report/controller.rb similarity index 100% rename from lib/reporting_engine/report/controller.rb rename to lib/report/controller.rb diff --git a/lib/reporting_engine/report/filter.rb b/lib/report/filter.rb similarity index 66% rename from lib/reporting_engine/report/filter.rb rename to lib/report/filter.rb index d1bbef886d..9455bcd085 100644 --- a/lib/reporting_engine/report/filter.rb +++ b/lib/report/filter.rb @@ -1,9 +1,6 @@ require "set" class Report::Filter - extend ProactiveAutoloader - autoload :Base, 'reporting_engine/report/filter/base' - autoload :NoFilter, 'reporting_engine/report/filter/no_filter' def self.all @all ||= Set[] diff --git a/lib/reporting_engine/report/filter/base.rb b/lib/report/filter/base.rb similarity index 99% rename from lib/reporting_engine/report/filter/base.rb rename to lib/report/filter/base.rb index 66288f95cc..9818aa3bb0 100644 --- a/lib/reporting_engine/report/filter/base.rb +++ b/lib/report/filter/base.rb @@ -1,7 +1,6 @@ class Report::Filter class Base < Report::Chainable include Report::QueryUtils - engine::Operator.load inherited_attribute :available_operators, diff --git a/lib/reporting_engine/report/filter/multi_choice.rb b/lib/report/filter/multi_choice.rb similarity index 100% rename from lib/reporting_engine/report/filter/multi_choice.rb rename to lib/report/filter/multi_choice.rb diff --git a/lib/reporting_engine/report/filter/no_filter.rb b/lib/report/filter/no_filter.rb similarity index 100% rename from lib/reporting_engine/report/filter/no_filter.rb rename to lib/report/filter/no_filter.rb diff --git a/lib/reporting_engine/report/group_by.rb b/lib/report/group_by.rb similarity index 51% rename from lib/reporting_engine/report/group_by.rb rename to lib/report/group_by.rb index bb91659122..84cd9b7ac0 100644 --- a/lib/reporting_engine/report/group_by.rb +++ b/lib/report/group_by.rb @@ -1,12 +1,7 @@ require "set" class Report::GroupBy - extend ProactiveAutoloader include Report::QueryUtils - autoload :Base, 'reporting_engine/report/group_by/base' - autoload :RubyAggregation, 'reporting_engine/report/group_by/ruby_aggregation' - autoload :SingletonValue, 'reporting_engine/report/group_by/singleton_value.rb' - autoload :SqlAggregation, 'reporting_engine/report/group_by/sql_aggregation' def self.all Set[engine::GroupBy::SingletonValue] diff --git a/lib/reporting_engine/report/group_by/base.rb b/lib/report/group_by/base.rb similarity index 100% rename from lib/reporting_engine/report/group_by/base.rb rename to lib/report/group_by/base.rb diff --git a/lib/reporting_engine/report/group_by/ruby_aggregation.rb b/lib/report/group_by/ruby_aggregation.rb similarity index 100% rename from lib/reporting_engine/report/group_by/ruby_aggregation.rb rename to lib/report/group_by/ruby_aggregation.rb diff --git a/lib/reporting_engine/report/group_by/singleton_value.rb b/lib/report/group_by/singleton_value.rb similarity index 100% rename from lib/reporting_engine/report/group_by/singleton_value.rb rename to lib/report/group_by/singleton_value.rb diff --git a/lib/reporting_engine/report/group_by/sql_aggregation.rb b/lib/report/group_by/sql_aggregation.rb similarity index 100% rename from lib/reporting_engine/report/group_by/sql_aggregation.rb rename to lib/report/group_by/sql_aggregation.rb diff --git a/lib/reporting_engine/report/inherited_attribute.rb b/lib/report/inherited_attribute.rb similarity index 97% rename from lib/reporting_engine/report/inherited_attribute.rb rename to lib/report/inherited_attribute.rb index b9dcf6b98d..3d4656cfaf 100644 --- a/lib/reporting_engine/report/inherited_attribute.rb +++ b/lib/report/inherited_attribute.rb @@ -1,5 +1,4 @@ require 'set' -require_dependency 'reporting_engine/report' module Report::InheritedAttribute include Report::QueryUtils diff --git a/lib/reporting_engine/report/operator.rb b/lib/report/operator.rb similarity index 100% rename from lib/reporting_engine/report/operator.rb rename to lib/report/operator.rb diff --git a/lib/reporting_engine/report/query_utils.rb b/lib/report/query_utils.rb similarity index 100% rename from lib/reporting_engine/report/query_utils.rb rename to lib/report/query_utils.rb diff --git a/lib/reporting_engine/report/result.rb b/lib/report/result.rb similarity index 100% rename from lib/reporting_engine/report/result.rb rename to lib/report/result.rb diff --git a/lib/reporting_engine/report/sql_statement.rb b/lib/report/sql_statement.rb similarity index 100% rename from lib/reporting_engine/report/sql_statement.rb rename to lib/report/sql_statement.rb diff --git a/lib/reporting_engine/report/table.rb b/lib/report/table.rb similarity index 100% rename from lib/reporting_engine/report/table.rb rename to lib/report/table.rb diff --git a/lib/reporting_engine/report/transformer.rb b/lib/report/transformer.rb similarity index 100% rename from lib/reporting_engine/report/transformer.rb rename to lib/report/transformer.rb diff --git a/lib/reporting_engine/report/validation.rb b/lib/report/validation.rb similarity index 85% rename from lib/reporting_engine/report/validation.rb rename to lib/report/validation.rb index 7fa890b268..edef0897b4 100644 --- a/lib/reporting_engine/report/validation.rb +++ b/lib/report/validation.rb @@ -1,9 +1,5 @@ module Report::Validation - extend ProactiveAutoloader include Report::QueryUtils - # autoload :Dates, 'report/validation/dates' - # autoload :Integers, 'report/validation/integers' - # autoload :Sql, 'report/validation/sql' def register_validations(*validation_methods) validation_methods.flatten.each do |val_method| diff --git a/lib/reporting_engine/report/validation/dates.rb b/lib/report/validation/dates.rb similarity index 100% rename from lib/reporting_engine/report/validation/dates.rb rename to lib/report/validation/dates.rb diff --git a/lib/reporting_engine/report/validation/integers.rb b/lib/report/validation/integers.rb similarity index 100% rename from lib/reporting_engine/report/validation/integers.rb rename to lib/report/validation/integers.rb diff --git a/lib/reporting_engine/report/validation/sql.rb b/lib/report/validation/sql.rb similarity index 100% rename from lib/reporting_engine/report/validation/sql.rb rename to lib/report/validation/sql.rb diff --git a/lib/reporting_engine/report/walker.rb b/lib/report/walker.rb similarity index 100% rename from lib/reporting_engine/report/walker.rb rename to lib/report/walker.rb diff --git a/lib/reporting_engine/engine.rb b/lib/reporting_engine/engine.rb index b5e8cb2c42..0738606a5f 100644 --- a/lib/reporting_engine/engine.rb +++ b/lib/reporting_engine/engine.rb @@ -12,9 +12,12 @@ module ReportingEngine config.to_prepare do - require_dependency 'reporting_engine/patches' - require_dependency 'reporting_engine/patches/big_decimal_patch' - require_dependency 'reporting_engine/patches/to_date_patch' + require 'reporting_engine/patches' + require 'reporting_engine/patches/big_decimal_patch' + require 'reporting_engine/patches/to_date_patch' + #We have to require this here because Ruby will otherwise find Date + #as Object::Date and Rails wont autoload Widget::Filters::Date + require_dependency 'widget/filters/date' end config.after_initialize do diff --git a/lib/reporting_engine/proactive_autoloader.rb b/lib/reporting_engine/proactive_autoloader.rb deleted file mode 100644 index 5334d8f70d..0000000000 --- a/lib/reporting_engine/proactive_autoloader.rb +++ /dev/null @@ -1,71 +0,0 @@ -## -# From Urban Dictionary: -# proactive (91 up, 9 down) -# -# Originally a psychological term indicating an empowered, self-reliant -# individual, this has evolved through misuse into a neo-antonym of 'reactive', -# and is used as such to emphasise the preferability of one attitude or course -# of action over another. It connotes alertness, awareness and preparedness, and -# seeks to dispel any conceivable impression of incompetence. -# -# 'Proactive' is interesting in that it is perhaps the classic example of the -# unnecessary neologism. It serves as an antonym to 'reactive', yet 'reactive' -# is itself the antonym of 'active'. -# -# Arguably, since 'proactive' is now perhaps more widely used than 'active' for -# the specific purpose covered by the newer word, 'proactive' must be recognised -# as a legitimate word. The cult of hatred that has understandably grown up -# around the word can only help it endure further. -# -# One is 'active' as opposed to being 'passive' or 'reactive'. One is -# 'proactive' as opposed to 'speaking English'. -module ProactiveAutoloader - extend self - - ## - # Improved Module#autoload: - # * if path is not given, generate path according to ruby common sense - # * allow passing multiple constant names as symbols - # - # Example: - # autoload :Foo, :Bar, :Blah - def autoload(*list) - return super if list.size == 2 and String === list.last - list.each do |const| - super const, "#{name.underscore}/#{const.to_s.underscore}" - end - end - - ## - # Sets up autoload hooks in +klass+ for all Ruby files in +dir+, following - # common naming conventions. Subdirectories are *not* scanned. - def setup_autoloaders(klass, dir) - Dir.glob File.expand_path('*.rb', dir) do |file| - klass.autoload File.basename(file, '.rb').camelize, file - end - end - - ## - # If subclassed, say in foo/bar.rb and there is a directory foo/bar, - # set up autoload hooks in subclass for all ruby files in foo/bar - # (see setup_autoloaders). - def inherited(klass) - auto_setup_autoloaders(klass) - super - end - - ## - # If extending a class, say in foo/bar.rb and there is a directory foo/bar, - # set up autoload hooks in subclass for all ruby files in foo/bar - # (see setup_autoloaders). - def self.extended(klass) - auto_setup_autoloaders(klass) if klass.respond_to? :autoload - super - end - - private - - def auto_setup_autoloaders(klass) - setup_autoloaders klass, caller[1][/^((?!\.[^\.]+:\d+).)+/] - end -end diff --git a/lib/reporting_engine/widget.rb b/lib/widget.rb similarity index 94% rename from lib/reporting_engine/widget.rb rename to lib/widget.rb index 8362446e47..a0a7acff3f 100644 --- a/lib/reporting_engine/widget.rb +++ b/lib/widget.rb @@ -1,6 +1,4 @@ require_dependency 'reporting_engine/helpers/reporting_helper' -require_dependency 'reporting_engine/proactive_autoloader' - class Widget < ActionView::Base include ActionView::Helpers::TagHelper @@ -11,8 +9,6 @@ class Widget < ActionView::Base attr_accessor :output_buffer, :controller, :config, :_content_for, :_routes, :subject - extend ProactiveAutoloader - def self.new(subject) super(subject).tap do |o| o.subject = subject diff --git a/lib/reporting_engine/widget/base.rb b/lib/widget/base.rb similarity index 100% rename from lib/reporting_engine/widget/base.rb rename to lib/widget/base.rb diff --git a/lib/reporting_engine/widget/controls.rb b/lib/widget/controls.rb similarity index 79% rename from lib/reporting_engine/widget/controls.rb rename to lib/widget/controls.rb index eeb7459b32..fdfe16ad4a 100644 --- a/lib/reporting_engine/widget/controls.rb +++ b/lib/widget/controls.rb @@ -1,5 +1,4 @@ class Widget::Controls < Widget::Base - extend ProactiveAutoloader def cache_key "#{super}#{@subject.new_record? ? 1 : 0}" diff --git a/lib/reporting_engine/widget/controls/apply.rb b/lib/widget/controls/apply.rb similarity index 100% rename from lib/reporting_engine/widget/controls/apply.rb rename to lib/widget/controls/apply.rb diff --git a/lib/reporting_engine/widget/controls/clear.rb b/lib/widget/controls/clear.rb similarity index 100% rename from lib/reporting_engine/widget/controls/clear.rb rename to lib/widget/controls/clear.rb diff --git a/lib/reporting_engine/widget/controls/delete.rb b/lib/widget/controls/delete.rb similarity index 100% rename from lib/reporting_engine/widget/controls/delete.rb rename to lib/widget/controls/delete.rb diff --git a/lib/reporting_engine/widget/controls/query_name.rb b/lib/widget/controls/query_name.rb similarity index 100% rename from lib/reporting_engine/widget/controls/query_name.rb rename to lib/widget/controls/query_name.rb diff --git a/lib/reporting_engine/widget/controls/save.rb b/lib/widget/controls/save.rb similarity index 100% rename from lib/reporting_engine/widget/controls/save.rb rename to lib/widget/controls/save.rb diff --git a/lib/reporting_engine/widget/controls/save_as.rb b/lib/widget/controls/save_as.rb similarity index 100% rename from lib/reporting_engine/widget/controls/save_as.rb rename to lib/widget/controls/save_as.rb diff --git a/lib/reporting_engine/widget/filters.rb b/lib/widget/filters.rb similarity index 82% rename from lib/reporting_engine/widget/filters.rb rename to lib/widget/filters.rb index 0cc150456b..ef7f99c9d0 100644 --- a/lib/reporting_engine/widget/filters.rb +++ b/lib/widget/filters.rb @@ -1,5 +1,4 @@ class Widget::Filters < Widget::Base - extend ProactiveAutoloader def render table = content_tag :table, :width => "100%" do @@ -59,29 +58,29 @@ class Widget::Filters < Widget::Base def render_filter(f_cls, f_inst) f = f_inst || f_cls html = ''.html_safe - render_widget Filters::Label, f, :to => html - render_widget Filters::Operators, f, :to => html + render_widget Label, f, :to => html + render_widget Operators, f, :to => html if f_cls.heavy? - render_widget Filters::Heavy, f, :to => html + render_widget Heavy, f, :to => html elsif engine::Operator.string_operators.all? { |o| f_cls.available_operators.include? o } - render_widget Filters::TextBox, f, :to => html + render_widget TextBox, f, :to => html elsif engine::Operator.time_operators.all? { |o| f_cls.available_operators.include? o } - render_widget Filters::Date, f, :to => html + render_widget Date, f, :to => html elsif engine::Operator.integer_operators.all? {|o| f_cls.available_operators.include? o } if f_cls.available_values.empty? - render_widget Filters::TextBox, f, :to => html + render_widget TextBox, f, :to => html else - render_widget Filters::MultiValues, f, :to => html, :lazy => true + render_widget MultiValues, f, :to => html, :lazy => true end else if f_cls.is_multiple_choice? - render_widget Filters::MultiChoice, f, :to => html + render_widget MultiChoice, f, :to => html else - render_widget Filters::MultiValues, f, :to => html, :lazy => true + render_widget MultiValues, f, :to => html, :lazy => true end end render_filter_help f, :to => html - render_widget Filters::RemoveButton, f, :to => html + render_widget RemoveButton, f, :to => html end ##Renders help for a filter (chainable) diff --git a/lib/reporting_engine/widget/filters/base.rb b/lib/widget/filters/base.rb similarity index 100% rename from lib/reporting_engine/widget/filters/base.rb rename to lib/widget/filters/base.rb diff --git a/lib/reporting_engine/widget/filters/date.rb b/lib/widget/filters/date.rb similarity index 91% rename from lib/reporting_engine/widget/filters/date.rb rename to lib/widget/filters/date.rb index 0bcda1b88d..0f622cbe54 100644 --- a/lib/reporting_engine/widget/filters/date.rb +++ b/lib/widget/filters/date.rb @@ -1,3 +1,6 @@ +#make sure to require Widget::Filters::Base first because otherwise +#ruby might find Base within Widget and Rails will not load it +require_dependency 'widget/filters/base' class Widget::Filters::Date < Widget::Filters::Base def calendar_for(field_id) diff --git a/lib/reporting_engine/widget/filters/heavy.rb b/lib/widget/filters/heavy.rb similarity index 93% rename from lib/reporting_engine/widget/filters/heavy.rb rename to lib/widget/filters/heavy.rb index b2cb8cbfac..a7f1089e40 100644 --- a/lib/reporting_engine/widget/filters/heavy.rb +++ b/lib/widget/filters/heavy.rb @@ -2,7 +2,9 @@ # The select-box. This way we allow our JS to pretend this is just another # Filter. This is overhead... # But well this is again one of those temporary solutions. - +#make sure to require Widget::Filters::Base first because otherwise +#ruby might find Base within Widget and Rails will not load it +require_dependency 'widget/filters/base' class Widget::Filters::Heavy < Widget::Filters::Base def render diff --git a/lib/reporting_engine/widget/filters/label.rb b/lib/widget/filters/label.rb similarity index 70% rename from lib/reporting_engine/widget/filters/label.rb rename to lib/widget/filters/label.rb index 6d634f7e50..9313866f77 100644 --- a/lib/reporting_engine/widget/filters/label.rb +++ b/lib/widget/filters/label.rb @@ -1,4 +1,6 @@ - +#make sure to require Widget::Filters::Base first because otherwise +#ruby might find Base within Widget and Rails will not load it +require_dependency 'widget/filters/base' class Widget::Filters::Label < Widget::Filters::Base def render write(content_tag(:td, :width => 150) do diff --git a/lib/reporting_engine/widget/filters/multi_choice.rb b/lib/widget/filters/multi_choice.rb similarity index 87% rename from lib/reporting_engine/widget/filters/multi_choice.rb rename to lib/widget/filters/multi_choice.rb index f80f8cb722..cf6d646f26 100644 --- a/lib/reporting_engine/widget/filters/multi_choice.rb +++ b/lib/widget/filters/multi_choice.rb @@ -1,4 +1,6 @@ - +#make sure to require Widget::Filters::Base first because otherwise +#ruby might find Base within Widget and Rails will not load it +require_dependency 'widget/filters/base' class Widget::Filters::MultiChoice < Widget::Filters::Base def render diff --git a/lib/reporting_engine/widget/filters/multi_values.rb b/lib/widget/filters/multi_values.rb similarity index 94% rename from lib/reporting_engine/widget/filters/multi_values.rb rename to lib/widget/filters/multi_values.rb index a97c4404d0..ff77aee900 100644 --- a/lib/reporting_engine/widget/filters/multi_values.rb +++ b/lib/widget/filters/multi_values.rb @@ -1,3 +1,6 @@ +#make sure to require Widget::Filters::Base first because otherwise +#ruby might find Base within Widget and Rails will not load it +require_dependency 'widget/filters/base' class Widget::Filters::MultiValues < Widget::Filters::Base def render diff --git a/lib/reporting_engine/widget/filters/operators.rb b/lib/widget/filters/operators.rb similarity index 90% rename from lib/reporting_engine/widget/filters/operators.rb rename to lib/widget/filters/operators.rb index b068b039a0..dc33b1556b 100644 --- a/lib/reporting_engine/widget/filters/operators.rb +++ b/lib/widget/filters/operators.rb @@ -1,3 +1,6 @@ +#make sure to require Widget::Filters::Base first because otherwise +#ruby might find Base within Widget and Rails will not load it +require_dependency 'widget/filters/base' class Widget::Filters::Operators < Widget::Filters::Base def render write(content_tag(:td, :width => 100) do diff --git a/lib/reporting_engine/widget/filters/option.rb b/lib/widget/filters/option.rb similarity index 86% rename from lib/reporting_engine/widget/filters/option.rb rename to lib/widget/filters/option.rb index 62e84e67e7..25326b6463 100644 --- a/lib/reporting_engine/widget/filters/option.rb +++ b/lib/widget/filters/option.rb @@ -2,7 +2,9 @@ # Accepts option :content, which expects an enumerable of [name, id, *args] # as it would appear in a filters available values. If given, it renders the # option-tags from the content array instead of the filters available values. - +#make sure to require Widget::Filters::Base first because otherwise +#ruby might find Base within Widget and Rails will not load it +require_dependency 'widget/filters/base' class Widget::Filters::Option < Widget::Filters::Base def render first = true diff --git a/lib/reporting_engine/widget/filters/remove_button.rb b/lib/widget/filters/remove_button.rb similarity index 76% rename from lib/reporting_engine/widget/filters/remove_button.rb rename to lib/widget/filters/remove_button.rb index 015784de56..58967482e5 100644 --- a/lib/reporting_engine/widget/filters/remove_button.rb +++ b/lib/widget/filters/remove_button.rb @@ -1,3 +1,6 @@ +#make sure to require Widget::Filters::Base first because otherwise +#ruby might find Base within Widget and Rails will not load it +require_dependency 'widget/filters/base' class Widget::Filters::RemoveButton < Widget::Filters::Base def render write(content_tag(:td, :width => "25px") do diff --git a/lib/reporting_engine/widget/filters/text_box.rb b/lib/widget/filters/text_box.rb similarity index 81% rename from lib/reporting_engine/widget/filters/text_box.rb rename to lib/widget/filters/text_box.rb index e9454ec51c..b6f32ba4f1 100644 --- a/lib/reporting_engine/widget/filters/text_box.rb +++ b/lib/widget/filters/text_box.rb @@ -1,3 +1,6 @@ +#make sure to require Widget::Filters::Base first because otherwise +#ruby might find Base within Widget and Rails will not load it +require_dependency 'widget/filters/base' class Widget::Filters::TextBox < Widget::Filters::Base def render write(content_tag(:td) do diff --git a/lib/reporting_engine/widget/group_bys.rb b/lib/widget/group_bys.rb similarity index 98% rename from lib/reporting_engine/widget/group_bys.rb rename to lib/widget/group_bys.rb index 28f30d4f63..9c4cbfb6d7 100644 --- a/lib/reporting_engine/widget/group_bys.rb +++ b/lib/widget/group_bys.rb @@ -1,5 +1,4 @@ class Widget::GroupBys < Widget::Base - extend ProactiveAutoloader def render_options(group_by_ary) group_by_ary.sort_by do |group_by| diff --git a/lib/reporting_engine/widget/help.rb b/lib/widget/help.rb similarity index 100% rename from lib/reporting_engine/widget/help.rb rename to lib/widget/help.rb diff --git a/lib/reporting_engine/widget/settings.rb b/lib/widget/settings.rb similarity index 100% rename from lib/reporting_engine/widget/settings.rb rename to lib/widget/settings.rb diff --git a/lib/reporting_engine/widget/settings/fieldset.rb b/lib/widget/settings/fieldset.rb similarity index 100% rename from lib/reporting_engine/widget/settings/fieldset.rb rename to lib/widget/settings/fieldset.rb diff --git a/lib/reporting_engine/widget/table.rb b/lib/widget/table.rb similarity index 97% rename from lib/reporting_engine/widget/table.rb rename to lib/widget/table.rb index 34b9b4b160..3e6a2057e7 100644 --- a/lib/reporting_engine/widget/table.rb +++ b/lib/widget/table.rb @@ -1,5 +1,3 @@ -require_dependency 'reporting_engine/report/inherited_attribute' - class Widget::Table < Widget::Base extend Report::InheritedAttribute include ReportingHelper diff --git a/lib/reporting_engine/widget/table/progressbar.rb b/lib/widget/table/progressbar.rb similarity index 100% rename from lib/reporting_engine/widget/table/progressbar.rb rename to lib/widget/table/progressbar.rb diff --git a/lib/reporting_engine/widget/table/report_table.rb b/lib/widget/table/report_table.rb similarity index 100% rename from lib/reporting_engine/widget/table/report_table.rb rename to lib/widget/table/report_table.rb