module Cyborg

Constants

VERSION

Attributes

plugin[RW]

Public Instance Methods

at_gem_root() click to toggle source
# File lib/cyborg.rb, line 58
def at_gem_root
  !Dir['*.gemspec'].empty?
end
at_rails_root() click to toggle source
# File lib/cyborg.rb, line 54
def at_rails_root
  File.exist?("bin/rails")
end
config_data() click to toggle source
# File lib/cyborg.rb, line 30
def config_data
  Cyborg::ConfigData.read(Cyborg.plugin.root, Rails.root)
end
gem_path() click to toggle source
# File lib/cyborg.rb, line 62
def gem_path
  if at_gem_root
    Dir.pwd
  elsif at_rails_root
    "../"
  end
end
load_helpers() click to toggle source
# 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() click to toggle source
# File lib/cyborg.rb, line 40
def patch_rails
  load_helpers
end
production?() click to toggle source
# File lib/cyborg.rb, line 18
def production?
  ENV['CI'] || ENV['RAILS_ENV'] == 'production' || Command.production?
end
rails5?() click to toggle source
# File lib/cyborg.rb, line 22
def rails5?
 Gem::Version.new(Rails.version) >= Gem::Version.new('5') 
end
rails_path(sub=nil) click to toggle source
# 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) click to toggle source
# File lib/cyborg.rb, line 34
def register(plugin_module, options={}, &block)
  @plugin = plugin_module.new(options)
  @plugin.create_engine(&block)
  patch_rails
end