module SparkEngine
From: github.com/nachokb/block_helpers Inlined becuase the project is inactive and current forks aren't published to RubyGems.org
Constants
- VERSION
Attributes
plugin[RW]
Public Instance Methods
at_gem_root?()
click to toggle source
# File lib/spark_engine.rb, line 81 def at_gem_root? !Dir['*.gemspec'].empty? end
at_rails_root?()
click to toggle source
# File lib/spark_engine.rb, line 54 def at_rails_root? File.exist?("bin/rails") end
data()
click to toggle source
# File lib/spark_engine.rb, line 24 def data if production? @data ||= SparkEngine::Data.read else SparkEngine::Data.read end end
gem_path()
click to toggle source
# File lib/spark_engine.rb, line 85 def gem_path if at_gem_root? Dir.pwd elsif at_rails_root? "../" end end
load_helpers()
click to toggle source
# File lib/spark_engine.rb, line 44 def load_helpers require "spark_engine/helpers/asset_helpers" require "spark_engine/helpers/layout_helpers" SparkEngine::Helpers.constants.each do |c| helper = SparkEngine::Helpers.const_get(c) ActionView::Base.send :include, helper if defined? ActionView::Base end end
load_plugin()
click to toggle source
# File lib/spark_engine.rb, line 74 def load_plugin plugin || if spec = plugin_spec require spec.name unless spec.name == 'spark_engine' return plugin end end
patch_rails()
click to toggle source
# File lib/spark_engine.rb, line 40 def patch_rails load_helpers end
plugin_gemspec()
click to toggle source
# File lib/spark_engine.rb, line 58 def plugin_gemspec if gem_path path = File.join(gem_path, "*.gemspec") Dir[path].first end end
plugin_spec()
click to toggle source
# File lib/spark_engine.rb, line 65 def plugin_spec @plugin_spec ||= begin if file = plugin_gemspec spec = Gem::Specification.load(file) spec if spec.name != 'spark_engine' end end end
production?()
click to toggle source
# File lib/spark_engine.rb, line 16 def production? ENV['CI'] || ENV['RAILS_ENV'] == 'production' || ( defined?(Command) && Command.production? ) end
rails_path(sub=nil)
click to toggle source
# File lib/spark_engine.rb, line 93 def rails_path(sub=nil) path = if at_rails_root? Dir.pwd else dir = Dir["**/bin/rails"] if !dir.empty? dir.first.split('/').first end end path = File.join(path, sub) if sub path end
register(plugin_module, options={}, &block)
click to toggle source
# File lib/spark_engine.rb, line 32 def register(plugin_module, options={}, &block) @plugin = plugin_module.new(options) if defined? Rails @plugin.create_engine(&block) patch_rails end end