From 48c144ed34e2d5977bb8e5af8a9c7e8dfc253361 Mon Sep 17 00:00:00 2001 From: Kir Date: Mon, 31 Oct 2011 21:43:34 +0400 Subject: Small changed --- lib/generators/inboxes/views_generator.rb | 25 +++++++++++++++++++++++++ lib/inboxes.rb | 26 +++++++++++++++++++++++--- lib/inboxes/railtie.rb | 24 +++++++++++++++++------- 3 files changed, 65 insertions(+), 10 deletions(-) create mode 100644 lib/generators/inboxes/views_generator.rb (limited to 'lib') diff --git a/lib/generators/inboxes/views_generator.rb b/lib/generators/inboxes/views_generator.rb new file mode 100644 index 0000000..c69812e --- /dev/null +++ b/lib/generators/inboxes/views_generator.rb @@ -0,0 +1,25 @@ +require 'rails/generators' + +module Inboxes + module Generators + class ViewsGenerator < Rails::Generators::Base + source_root File.expand_path('../../../../app/views', __FILE__) + class_option :template_engine, :type => :string, :aliases => '-e', :desc => 'Template engine for the views. Available options are "erb" and "haml".' + + def copy_or_fetch + # puts "Generating views" + filename_pattern = File.join self.class.source_root, "*/*.html.#{template_engine}" + # puts (Dir.glob(filename_pattern).map {|f| File.basename f}).inspect + # Dir.glob(filename_pattern).map {|f| File.basename f}.each do |f| + # copy_file f, "app/views/#{f}" + # end + end + + private + + def template_engine + options[:template_engine].try(:to_s).try(:downcase) || 'erb' + end + end + end +end \ No newline at end of file diff --git a/lib/inboxes.rb b/lib/inboxes.rb index 29bb078..9759f07 100644 --- a/lib/inboxes.rb +++ b/lib/inboxes.rb @@ -2,6 +2,26 @@ require "inboxes/version" require "inboxes/railtie" require "inboxes/engine" -# module Inboxes -# # Your code goes here... -# end +module Inboxes + # Your code goes here... + + def self.configure(&block) + yield @config ||= Inboxes::Configuration.new + end + + # Global settings for Inboxes + def self.config + @config + end + + # need a Class for 3.0 + class Configuration #:nodoc: + include ActiveSupport::Configurable + config_accessor :user_name + + def param_name + config.param_name.respond_to?(:call) ? config.param_name.call() : config.param_name + end + end + +end diff --git a/lib/inboxes/railtie.rb b/lib/inboxes/railtie.rb index 5be6db5..06ab0d3 100644 --- a/lib/inboxes/railtie.rb +++ b/lib/inboxes/railtie.rb @@ -2,15 +2,25 @@ require 'rails' module Inboxes class Railtie < ::Rails::Railtie #:nodoc: - initializer 'inboxes' do |app| - ActiveSupport.on_load(:active_record) do - # require 'kaminari/models/active_record_extension' - # ::ActiveRecord::Base.send :include, Kaminari::ActiveRecordExtension + config.inboxes = ActiveSupport::OrderedOptions.new + + initializer "inboxes.configure" do |app| + Inboxes.configure do |config| + config.user_name = app.config.inboxes[:user_name] || "email" end - ActiveSupport.on_load(:action_view) do - # ::ActionView::Base.send :include, Kaminari::ActionViewExtension - end + # app.config.middleware.insert_before "::Rails::Rack::Logger", "Inboxes::Middleware" end + + # initializer 'inboxes' do |app| + # ActiveSupport.on_load(:active_record) do + # # require 'kaminari/models/active_record_extension' + # # ::ActiveRecord::Base.send :include, Kaminari::ActiveRecordExtension + # end + # + # ActiveSupport.on_load(:action_view) do + # # ::ActionView::Base.send :include, Kaminari::ActionViewExtension + # end + # end end end \ No newline at end of file -- cgit v1.2.3