full_path and gear sorting fixes require_dependency

pull/11671/head
Juan Ignacio Sánchez Lara 8 years ago
parent 1a9fa7c144
commit 56e9950e87

@ -194,6 +194,6 @@ require 'varnish/lib/cartodb-varnish'
$pool = CartoDB::ConnectionPool.new
Carto::CartoGearsSupport.new.gears.select { |g| !g.install }.each do |gear|
$LOAD_PATH << File::join(gear.path, 'lib')
$LOAD_PATH << File::join(gear.full_path, 'lib')
require gear.name
end

@ -7,7 +7,7 @@ CartoDB::Application.configure do
ActiveSupport::Dependencies.autoload_paths << File::join(Rails.root, 'lib')
Carto::CartoGearsSupport.new.gears.each do |gear|
ActiveSupport::Dependencies.autoload_paths << File::join(gear.path, 'lib')
ActiveSupport::Dependencies.autoload_paths << File::join(gear.full_path, 'lib')
end
# ActiveSupport::Dependencies.autoload_paths << File::join( Rails.root, 'lib/central')

@ -5,8 +5,9 @@ module Carto
# Returns gears found at:
# - `/gears`. Should be "installed" (added to `Gemfile.lock``)
# - `/private_gears` (shouldn't be installed)
# Returns install gears first.
def gears
(public_gears + private_gears)
(public_gears + private_gears).sort { |a, b| a.install ? -1 : 1 }
end
private
@ -31,6 +32,8 @@ module Carto
@install = install
end
# path should only be used from CARTO Gemfile, because Rails is not yet available and relative path is good enough.
# If you need access to the gear path, use full_path instead.
attr_reader :name, :path, :install
def engine
@ -42,5 +45,9 @@ module Carto
def gemspec
Gem::Specification::load(File::join(path, "#{name}.gemspec"))
end
def full_path
Rails.root.join(path)
end
end
end

Loading…
Cancel
Save