Class: LockOMotion::App

Inherits:
Object show all
Defined in:
lib/lock-o-motion/app.rb

Constant Summary collapse

GEM_LOTION =
".lotion.rb"
USER_LOTION =
"lotion.rb"

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(app) ⇒ App

Returns a new instance of App.



11
12
13
# File 'lib/lock-o-motion/app.rb', line 11

def initialize(app)
  @app = app
end

Class Method Details

.setup(app, &block) ⇒ Object



7
8
9
# File 'lib/lock-o-motion/app.rb', line 7

def self.setup(app, &block)
  new(app).send :setup, &block
end

Instance Method Details

#dependency(call, path, internal = false) ⇒ Object



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/lock-o-motion/app.rb', line 23

def dependency(call, path, internal = false)
  call = "BUNDLER" if call.match(/\bbundler\b/)
  if call == __FILE__
    call = internal ? "GEM_LOTION" : "USER_LOTION"
  end

  ($: + LockOMotion.gem_paths).each do |load_path|
    if File.exists?(absolute_path = "#{load_path}/#{path}.bundle") ||
       File.exists?(absolute_path = "#{load_path}/#{path}.rb")
      if absolute_path.match(/\.rb$/)
        register_dependency call, absolute_path
        $:.unshift load_path unless $:.include?(load_path)
      else
        puts "   Warning #{call}\n           requires #{absolute_path}".red
      end
      return
    end
  end

  if path.match(/^\//) && File.exists?(path)
    register_dependency call, path
  else
    puts "   Warning Could not resolve dependency \"#{path}\"".red
  end
end

#ignore_require(path) ⇒ Object



19
20
21
# File 'lib/lock-o-motion/app.rb', line 19

def ignore_require(path)
  @ignored_requires << path
end

#require(path, internal = false) ⇒ Object



15
16
17
# File 'lib/lock-o-motion/app.rb', line 15

def require(path, internal = false)
  Kernel.require path, internal
end