Merge pull request #3 from finnlabs/feature/rails3_fix_autoload

Moved files around to get autoloaded by rails and removed the
pull/6827/head
Christian Rijke 12 years ago
commit b82dd87496
  1. 1
      lib/assets/javascripts/reporting_engine/reporting_engine.js
  2. 0
      lib/engine.rb
  3. 3
      lib/report.rb
  4. 0
      lib/report/chainable.rb
  5. 0
      lib/report/controller.rb
  6. 3
      lib/report/filter.rb
  7. 1
      lib/report/filter/base.rb
  8. 0
      lib/report/filter/multi_choice.rb
  9. 0
      lib/report/filter/no_filter.rb
  10. 5
      lib/report/group_by.rb
  11. 0
      lib/report/group_by/base.rb
  12. 0
      lib/report/group_by/ruby_aggregation.rb
  13. 0
      lib/report/group_by/singleton_value.rb
  14. 0
      lib/report/group_by/sql_aggregation.rb
  15. 1
      lib/report/inherited_attribute.rb
  16. 0
      lib/report/operator.rb
  17. 0
      lib/report/query_utils.rb
  18. 0
      lib/report/result.rb
  19. 0
      lib/report/sql_statement.rb
  20. 0
      lib/report/table.rb
  21. 0
      lib/report/transformer.rb
  22. 4
      lib/report/validation.rb
  23. 0
      lib/report/validation/dates.rb
  24. 0
      lib/report/validation/integers.rb
  25. 0
      lib/report/validation/sql.rb
  26. 0
      lib/report/walker.rb
  27. 9
      lib/reporting_engine/engine.rb
  28. 71
      lib/reporting_engine/proactive_autoloader.rb
  29. 4
      lib/widget.rb
  30. 0
      lib/widget/base.rb
  31. 1
      lib/widget/controls.rb
  32. 0
      lib/widget/controls/apply.rb
  33. 0
      lib/widget/controls/clear.rb
  34. 0
      lib/widget/controls/delete.rb
  35. 0
      lib/widget/controls/query_name.rb
  36. 0
      lib/widget/controls/save.rb
  37. 0
      lib/widget/controls/save_as.rb
  38. 21
      lib/widget/filters.rb
  39. 0
      lib/widget/filters/base.rb
  40. 3
      lib/widget/filters/date.rb
  41. 4
      lib/widget/filters/heavy.rb
  42. 4
      lib/widget/filters/label.rb
  43. 4
      lib/widget/filters/multi_choice.rb
  44. 3
      lib/widget/filters/multi_values.rb
  45. 3
      lib/widget/filters/operators.rb
  46. 4
      lib/widget/filters/option.rb
  47. 3
      lib/widget/filters/remove_button.rb
  48. 3
      lib/widget/filters/text_box.rb
  49. 1
      lib/widget/group_bys.rb
  50. 0
      lib/widget/help.rb
  51. 0
      lib/widget/settings.rb
  52. 0
      lib/widget/settings/fieldset.rb
  53. 2
      lib/widget/table.rb
  54. 0
      lib/widget/table/progressbar.rb
  55. 0
      lib/widget/table/report_table.rb

@ -1,3 +1,4 @@
//= require prototype
//= require reporting_engine/reporting
//= require reporting_engine/sortable
//= require reporting_engine/cordinc_tooltip

@ -1,7 +1,4 @@
require_dependency 'reporting_engine/engine_module'
class Report < ActiveRecord::Base
extend ProactiveAutoloader
extend Forwardable
include Enumerable
include Engine

@ -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[]

@ -1,7 +1,6 @@
class Report::Filter
class Base < Report::Chainable
include Report::QueryUtils
engine::Operator.load
inherited_attribute :available_operators,

@ -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]

@ -1,5 +1,4 @@
require 'set'
require_dependency 'reporting_engine/report'
module Report::InheritedAttribute
include Report::QueryUtils

@ -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|

@ -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

@ -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

@ -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

@ -1,5 +1,4 @@
class Widget::Controls < Widget::Base
extend ProactiveAutoloader
def cache_key
"#{super}#{@subject.new_record? ? 1 : 0}"

@ -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)

@ -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)

@ -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

@ -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

@ -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

@ -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

@ -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

@ -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

@ -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

@ -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

@ -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|

@ -1,5 +1,3 @@
require_dependency 'reporting_engine/report/inherited_attribute'
class Widget::Table < Widget::Base
extend Report::InheritedAttribute
include ReportingHelper
Loading…
Cancel
Save