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/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: Application, Plugin, Scaffold

Constant Summary collapse

VERSION =
"0.3.2"

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#pluginObject

Returns the value of attribute plugin.



12
13
14
# File 'lib/cyborg.rb', line 12

def plugin
  @plugin
end

Instance Method Details

#at_gem_rootObject



47
48
49
# File 'lib/cyborg.rb', line 47

def at_gem_root
  !Dir['*.gemspec'].empty?
end

#at_rails_rootObject



43
44
45
# File 'lib/cyborg.rb', line 43

def at_rails_root
  File.exist?("bin/rails")
end

#gem_pathObject



51
52
53
54
55
56
57
# File 'lib/cyborg.rb', line 51

def gem_path
  if at_gem_root
    Dir.pwd
  elsif at_rails_root
    "../"
  end
end

#load_helpersObject



33
34
35
36
37
38
39
40
41
# File 'lib/cyborg.rb', line 33

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_railsObject



29
30
31
# File 'lib/cyborg.rb', line 29

def patch_rails
  load_helpers
end

#production?Boolean



15
16
17
# File 'lib/cyborg.rb', line 15

def production?
  ENV['CI'] || ENV['RAILS_ENV'] == 'production' || Command.production?
end

#rails_path(sub = nil) ⇒ Object



59
60
61
62
63
64
65
66
67
68
69
70
# File 'lib/cyborg.rb', line 59

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



23
24
25
26
27
# File 'lib/cyborg.rb', line 23

def register(plugin_module, options={})
  @plugin = plugin_module.new(options)
  @plugin.create_engine
  patch_rails
end