lib/ruboss4ruby.rb in dima-ruboss4ruby-1.0.5 vs lib/ruboss4ruby.rb in dima-ruboss4ruby-1.1.0
- old
+ new
@@ -1,40 +1,60 @@
-module Ruboss
- VERSION = '1.0.5'
- RUBOSS_FRAMEWORK_VERSION = '1.0.5'
-
+module Ruboss4Ruby
+
+ # :stopdoc:
+ VERSION = '1.1.0'
+ RUBOSS_FRAMEWORK_VERSION = '1.1.0'
LIB_DIR = File.join(File.dirname(__FILE__), 'ruboss4ruby/')
+ # :startdoc:
+
+ # Returns the version string for the library.
+ #
+ def self.version
+ VERSION
+ end
+
+ # Utility method used to require all files ending in .rb that lie in the
+ # directory below this file that has the same name as the filename passed
+ # in. Optionally, a specific _directory_ name can be passed in such that
+ # the _filename_ does not have to be equivalent to the directory.
+ #
+ def self.require_all_libs_relative_to( fname, dir = nil )
+ dir ||= ::File.basename(fname, '.*')
+ search_me = ::File.expand_path(
+ ::File.join(::File.dirname(fname), dir, '*', '*.rb'))
+
+ Dir.glob(search_me).sort.each {|rb| require rb}
+ end
+
end
-# Merb specific handling
+require Ruboss4Ruby::LIB_DIR + 'configuration'
+
# make sure we're running inside Merb
if defined?(Merb::Plugins)
Merb::Plugins.add_rakefiles 'ruboss4ruby/tasks'
Merb::BootLoader.before_app_loads do
- require Ruboss::LIB_DIR + 'configuration'
if defined?(ActiveRecord::Base)
Merb.add_mime_type(:fxml, :to_fxml, %w[application/xml text/xml application/x-xml], :charset => "utf-8")
- require Ruboss::LIB_DIR + 'active_foo'
+ ['active_foo', 'active_record_default_methods'].each { |lib| require Ruboss4Ruby::LIB_DIR + lib }
Merb::Plugins.add_rakefiles 'ruboss4ruby/active_record_tasks'
else
Merb.add_mime_type(:fxml, :to_xml, %w[application/xml text/xml application/x-xml], :charset => "utf-8")
if defined?(Merb::Orms::DataMapper)
- require Ruboss::LIB_DIR + 'datamapper_foo'
+ require Ruboss4Ruby::LIB_DIR + 'datamapper_foo'
end
end
end
elsif defined?(ActionController::Base)
- # if we are not running in Merb, we've got to be running in Rails
+ # if we are not running in Merb, try to hook up Rails
Mime::Type.register_alias "application/xml", :fxml
- ['configuration', 'active_foo', 'rails/ruboss_helper',
- 'rails/ruboss_test_helpers'].each { |lib| require Ruboss::LIB_DIR + lib }
+ ['active_foo', 'active_record_default_methods', 'rails/swf_helper'].each { |lib| require Ruboss4Ruby::LIB_DIR + lib }
- ActionView::Base.send :include, RubossHelper unless ActionView::Base.included_modules.include?(RubossHelper)
- Test::Unit::TestCase.send :include, RubossTestHelpers unless Test::Unit::TestCase.included_modules.include?(RubossTestHelpers)
+ ActionView::Base.send :include, SWFHelper unless ActionView::Base.included_modules.include?(SWFHelper)
module ActionController
class Base
alias_method :old_render, :render unless method_defined?(:old_render)
@@ -50,11 +70,11 @@
end
end
end
end
- module RubossController
+ module Ruboss4RubyController
private
# Extract any keys named _metadata from the models in the params hash
# and put them in the root of the params hash.
def extract_metadata_from_params
@@ -74,10 +94,10 @@
delegate :to_fxml, :to => :proxy_found
end
end
end
- ActionController::Base.send :include, RubossController
+ ActionController::Base.send :include, Ruboss4RubyController
ActionController::Base.send :prepend_before_filter, :extract_metadata_from_params
# temporarily disable forgery protection site-wise
ActionController::Base.allow_forgery_protection = false
end
\ No newline at end of file