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/middleware.rb,
lib/cyborg/command/npm.rb,
lib/cyborg/config_data.rb,
lib/cyborg/command/help.rb,
lib/cyborg/sass/importer.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, ConfigData, Help, Helpers, NPM, SassParser
Classes: Application, Importer, Plugin, Scaffold, StaticAssets
Constant Summary
collapse
- VERSION =
"0.7.1"
Instance Attribute Summary collapse
Instance Method Summary
collapse
Instance Attribute Details
#plugin ⇒ Object
Returns the value of attribute plugin.
15
16
17
|
# File 'lib/cyborg.rb', line 15
def plugin
@plugin
end
|
Instance Method Details
#at_gem_root ⇒ Object
58
59
60
|
# File 'lib/cyborg.rb', line 58
def at_gem_root
!Dir['*.gemspec'].empty?
end
|
#at_rails_root ⇒ Object
54
55
56
|
# File 'lib/cyborg.rb', line 54
def at_rails_root
File.exist?("bin/rails")
end
|
#gem_path ⇒ Object
62
63
64
65
66
67
68
|
# File 'lib/cyborg.rb', line 62
def gem_path
if at_gem_root
Dir.pwd
elsif at_rails_root
"../"
end
end
|
#load_helpers ⇒ Object
44
45
46
47
48
49
50
51
52
|
# File 'lib/cyborg.rb', line 44
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
40
41
42
|
# File 'lib/cyborg.rb', line 40
def patch_rails
load_helpers
end
|
#production? ⇒ Boolean
18
19
20
|
# File 'lib/cyborg.rb', line 18
def production?
ENV['CI'] || ENV['RAILS_ENV'] == 'production' || Command.production?
end
|
#rails5? ⇒ Boolean
22
23
24
|
# File 'lib/cyborg.rb', line 22
def rails5?
Gem::Version.new(Rails.version) >= Gem::Version.new('5')
end
|
#rails_path(sub = nil) ⇒ Object
70
71
72
73
74
75
76
77
78
79
80
81
|
# File 'lib/cyborg.rb', line 70
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
34
35
36
37
38
|
# File 'lib/cyborg.rb', line 34
def register(plugin_module, options={}, &block)
@plugin = plugin_module.new(options)
@plugin.create_engine(&block)
patch_rails
end
|