Module: SparkEngine
- Extended by:
- SparkEngine
- Included in:
- SparkEngine
- Defined in:
- lib/spark_engine/helpers/block_helper.rb,
lib/spark_engine.rb,
lib/spark_engine/assets.rb,
lib/spark_engine/plugin.rb,
lib/spark_engine/command.rb,
lib/spark_engine/version.rb,
lib/spark_engine/scaffold.rb,
lib/spark_engine/middleware.rb,
lib/spark_engine/command/npm.rb,
lib/spark_engine/config_data.rb,
lib/spark_engine/command/help.rb,
lib/spark_engine/sass/importer.rb,
lib/spark_engine/plugin/assets/svgs.rb,
lib/spark_engine/plugin/assets/asset.rb,
lib/spark_engine/helpers/asset_helpers.rb,
lib/spark_engine/helpers/layout_helpers.rb,
lib/spark_engine/plugin/assets/javascripts.rb,
lib/spark_engine/plugin/assets/stylesheets.rb
Overview
Defined Under Namespace
Modules: Assets, Command, ConfigData, Help, Helpers, NPM, SassParser
Classes: BlockHelper, Importer, Plugin, Scaffold, StaticAssets
Constant Summary
collapse
- VERSION =
"1.2.9"
Instance Attribute Summary collapse
Instance Method Summary
collapse
Instance Attribute Details
#plugin ⇒ Object
Returns the value of attribute plugin.
16
17
18
|
# File 'lib/spark_engine.rb', line 16
def plugin
@plugin
end
|
Instance Method Details
#at_gem_root? ⇒ Boolean
79
80
81
|
# File 'lib/spark_engine.rb', line 79
def at_gem_root?
!Dir['*.gemspec'].empty?
end
|
#at_rails_root? ⇒ Boolean
52
53
54
|
# File 'lib/spark_engine.rb', line 52
def at_rails_root?
File.exist?("bin/rails")
end
|
#gem_path ⇒ Object
83
84
85
86
87
88
89
|
# File 'lib/spark_engine.rb', line 83
def gem_path
if at_gem_root?
Dir.pwd
elsif at_rails_root?
"../"
end
end
|
#load_helpers ⇒ Object
42
43
44
45
46
47
48
49
50
|
# File 'lib/spark_engine.rb', line 42
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 ⇒ Object
72
73
74
75
76
77
|
# File 'lib/spark_engine.rb', line 72
def load_plugin
plugin || if spec = plugin_spec
require spec.name unless spec.name == 'spark_engine'
return plugin
end
end
|
#patch_rails ⇒ Object
38
39
40
|
# File 'lib/spark_engine.rb', line 38
def patch_rails
load_helpers
end
|
#plugin_gemspec ⇒ Object
56
57
58
59
60
61
|
# File 'lib/spark_engine.rb', line 56
def plugin_gemspec
if gem_path
path = File.join(gem_path, "*.gemspec")
Dir[path].first
end
end
|
#plugin_spec ⇒ Object
63
64
65
66
67
68
69
70
|
# File 'lib/spark_engine.rb', line 63
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? ⇒ Boolean
18
19
20
|
# File 'lib/spark_engine.rb', line 18
def production?
ENV['CI'] || ENV['RAILS_ENV'] == 'production' || ( defined?(Command) && Command.production? )
end
|
#rails_path(sub = nil) ⇒ Object
91
92
93
94
95
96
97
98
99
100
101
102
|
# File 'lib/spark_engine.rb', line 91
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) ⇒ Object
30
31
32
33
34
35
36
|
# File 'lib/spark_engine.rb', line 30
def register(plugin_module, options={}, &block)
@plugin = plugin_module.new(options)
if defined? Rails
@plugin.create_engine(&block)
patch_rails
end
end
|