Module: Cyborg
- Extended by:
- Cyborg
- Included in:
- Cyborg
- Defined in:
- lib/cyborg.rb,
lib/cyborg/assets.rb,
lib/cyborg/plugin.rb,
lib/cyborg/command.rb,
lib/cyborg/version.rb,
lib/cyborg/command/npm.rb,
lib/cyborg/command/help.rb,
lib/cyborg/command/scaffold.rb,
lib/cyborg/plugin/assets/svgs.rb,
lib/cyborg/plugin/assets/asset.rb,
lib/cyborg/helpers/asset_helpers.rb,
lib/cyborg/helpers/layout_helpers.rb,
lib/cyborg/plugin/assets/javascripts.rb,
lib/cyborg/plugin/assets/stylesheets.rb
Defined Under Namespace
Modules: Assets, Command, Help, Helpers, NPM
Classes: Plugin, Scaffold
Constant Summary
collapse
- VERSION =
"0.4.10"
Instance Attribute Summary collapse
Instance Method Summary
collapse
Instance Attribute Details
#plugin ⇒ Object
Returns the value of attribute plugin.
12
13
14
|
# File 'lib/cyborg.rb', line 12
def plugin
@plugin
end
|
Instance Method Details
#at_gem_root ⇒ Object
46
47
48
|
# File 'lib/cyborg.rb', line 46
def at_gem_root
!Dir['*.gemspec'].empty?
end
|
#at_rails_root ⇒ Object
42
43
44
|
# File 'lib/cyborg.rb', line 42
def at_rails_root
File.exist?("bin/rails")
end
|
#gem_path ⇒ Object
50
51
52
53
54
55
56
|
# File 'lib/cyborg.rb', line 50
def gem_path
if at_gem_root
Dir.pwd
elsif at_rails_root
"../"
end
end
|
#load_helpers ⇒ Object
32
33
34
35
36
37
38
39
40
|
# File 'lib/cyborg.rb', line 32
def load_helpers
require "cyborg/helpers/asset_helpers"
require "cyborg/helpers/layout_helpers"
Cyborg::Helpers.constants.each do |c|
helper = Cyborg::Helpers.const_get(c)
ActionView::Base.send :include, helper if defined? ActionView::Base
end
end
|
#patch_rails ⇒ Object
28
29
30
|
# File 'lib/cyborg.rb', line 28
def patch_rails
load_helpers
end
|
#production? ⇒ Boolean
14
15
16
|
# File 'lib/cyborg.rb', line 14
def production?
ENV['CI'] || ENV['RAILS_ENV'] == 'production' || Command.production?
end
|
#rails_path(sub = nil) ⇒ Object
58
59
60
61
62
63
64
65
66
67
68
69
|
# File 'lib/cyborg.rb', line 58
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 = {}) ⇒ Object
22
23
24
25
26
|
# File 'lib/cyborg.rb', line 22
def register(plugin_module, options={})
@plugin = plugin_module.new(options)
@plugin.create_engine
patch_rails
end
|