some stuff for better rails integration

This commit is contained in:
John Bintz 2012-10-02 15:48:01 -04:00
parent 051766915f
commit 1ab0f26aec
5 changed files with 33 additions and 13 deletions

View File

@ -6,16 +6,6 @@ require 'bullseye/sass/bullseye_functions'
module Bullseye
class Configuration
attr_accessor :js_controller_search, :js_action_search, :css_selector, :html_tag, :fuzzy_search
def initialize
@js_controller_search = %{$('body').data('controller')}
@js_action_search = %{$('body').data('action')}
@css_selector = %{body[data-action=':action'][data-controller=':controller']}
@html_tag = { 'data-action' => ':action', 'data-controller' => ':controller' }
@fuzzy_search = false
end
end
class << self
@ -28,3 +18,4 @@ module Bullseye
end
end
end

View File

@ -12,5 +12,23 @@ module Bullseye
app.assets.register_engine '.bullseye', Bullseye::Tilt::BullseyeTemplate
end
end
class InstallGenerator < ::Rails::Generators::Base
source_root File.expand_path('../../../skel', __FILE__)
def create_initializer_file
copy_file "config/initializers/bullseye.rb", "config/initializers/bullseye.rb"
puts
puts "Add to your main application.js file:"
puts
puts "//= require bullseye"
puts
puts "and replace your body tag layouts/application.html with a call to bullseye_body:"
puts
puts "= bullseye_body do"
puts
end
end
end

View File

@ -1,11 +1,13 @@
module Bullseye
module FindParts
SEPARATOR = '-'
def actions
parts.last.split('-')
parts.last.split(SEPARATOR)
end
def controller
parts[0..-2].join('-')
parts[0..-2].join(SEPARATOR)
end
def parts

View File

@ -15,7 +15,7 @@ module Bullseye
end
def __bullseye_controller
@__bullseye_controller || controller_path
@__bullseye_controller || controller_path.gsub('/', Bullseye::FindParts::SEPARATOR)
end
end
end

View File

@ -0,0 +1,9 @@
Bullseye.configure do |c|
c.js_controller_search = %{$('body').data('controller')}
c.js_action_search = %{$('body').data('action')}
c.css_selector = %{body[data-action=':action'][data-controller=':controller']}
c.html_tag = { 'data-action' => ':action', 'data-controller' => ':controller' }
c.fuzzy_search = false
end