Permalink
Browse files

Take status of assets pipeline into account

  • Loading branch information...
1 parent 3854502 commit b3e584b09dd56a7ed9af466c7fa2f3169fc33678 @apneadiving committed Mar 11, 2012
@@ -1,6 +1,6 @@
<% #thanks to enable_css, user can avoid this css to be loaded
if enable_css == true && options[:scripts].nil? %>
- <% if Rails::VERSION::MAJOR >= 3 && Rails::VERSION::MINOR < 1 %>
+ <% unless gmaps4rails_pipeline_enabled? %>
<% content_for :head do %>
<%= stylesheet_link_tag 'gmaps4rails' %>
<% end %>
@@ -19,7 +19,7 @@
<% end %>
<% end %>
- <% if Rails::VERSION::MAJOR >= 3 && Rails::VERSION::MINOR < 1 %>
+ <% if gmaps4rails_pipeline_enabled? %>
<% unless scripts.try(:to_sym) == :api %>
<%= javascript_include_tag 'gmaps4rails/gmaps4rails.base.js' %>
<% end %>
View
@@ -1,36 +1,34 @@
-if defined?(Rails) && Rails::VERSION::MAJOR == 3
- module Gmaps4rails
- require 'rails'
- require 'gmaps4rails/base'
-
- class Engine < Rails::Engine
-
- initializer "gmaps4rails view helpers" do |app|
- ActionView::Base.send :include, Gmaps4railsHelper
+module Gmaps4rails
+ require 'rails'
+ require 'gmaps4rails/base'
+
+ class Engine < Rails::Engine
+
+ initializer "gmaps4rails view helpers" do |app|
+ ActionView::Base.send :include, Gmaps4railsHelper
+ end
+
+ initializer "add asset directories to pipeline" do |app|
+ if Rails::VERSION::MAJOR >= 3 && Rails::VERSION::MINOR >= 1
+ app.config.assets.paths << "#{root}/public/stylesheets"
+ else
+ app.middleware.use ::ActionDispatch::Static, "#{root}/public"
end
-
- initializer "add asset directories to pipeline" do |app|
- if Rails::VERSION::MINOR >= 1
- app.config.assets.paths << "#{root}/public/stylesheets"
- else
- app.middleware.use ::ActionDispatch::Static, "#{root}/public"
- end
+ end
+
+ end
+
+ class Railtie < Rails::Railtie
+
+ initializer "include acts_as_gmappable within ORM" do
+ ActiveSupport.on_load(:active_record) do
+ ActiveRecord::Base.send(:include, Gmaps4rails::ActsAsGmappable)
end
- end
-
- class Railtie < Rails::Railtie
-
- initializer "include acts_as_gmappable within ORM" do
- ActiveSupport.on_load(:active_record) do
- ActiveRecord::Base.send(:include, Gmaps4rails::ActsAsGmappable)
- end
-
- ActiveSupport.on_load(:mongoid) do
- Mongoid::Document.send(:include, Gmaps4rails::ActsAsGmappable)
- end
+ ActiveSupport.on_load(:mongoid) do
+ Mongoid::Document.send(:include, Gmaps4rails::ActsAsGmappable)
end
-
- end
+ end
+
end
-end
+end
@@ -46,4 +46,8 @@ def gmaps4rails_js_files(map_options = nil, scripts = nil, enable_js = true, mar
def gmaps4rails_html(map_options = nil)
render "/gmaps4rails/html", :map_options => map_options
end
+
+ def gmaps4rails_pipeline_enabled?
+ Rails.configuration.methods.include?(:assets) && Rails.configuration.assets.enabled
+ end
end
View
@@ -1,7 +1,7 @@
PATH
remote: ../../
specs:
- gmaps4rails (1.4.6)
+ gmaps4rails (1.4.7)
json
GEM
@@ -13,7 +13,7 @@ GIT
PATH
remote: ../../
specs:
- gmaps4rails (1.4.5)
+ gmaps4rails (1.4.7)
json
GEM
@@ -1,7 +1,7 @@
PATH
remote: ../..
specs:
- gmaps4rails (1.4.5)
+ gmaps4rails (1.4.7)
json
GEM

0 comments on commit b3e584b

Please sign in to comment.