Top Level Namespace

Defined Under Namespace

Modules: Ree Classes: Object

Instance Method Summary collapse

Instance Method Details

#package_file_exists?(path) ⇒ Boolean

Returns:

  • (Boolean)


28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/ree/dsl/package_require.rb', line 28

def package_file_exists?(path)
  list = path.split('/')
  package_name = list.shift.to_sym
  packages_facade = Ree.container.packages_facade
  package = packages_facade.get_package(package_name)

  return false if package.dir.nil?

  path = File.join(
    Ree::PathHelper.abs_package_module_dir(package), list.join('/')
  )

  return true if File.exist?(path)

  path = path + '.rb'
  File.exist?(path)
end

#package_require(path) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/ree/dsl/package_require.rb', line 3

def package_require(path)
  list = path.split('/')
  package_name = list.shift.to_sym
  packages_facade = Ree.container.packages_facade
  package = packages_facade.get_package(package_name)

  return false if package.dir.nil?

  path = File.join(
    Ree::PathHelper.abs_package_module_dir(package), list.join('/')
  )

  if !File.exist?(path)
    path = path + '.rb'
  end

  if !File.exist?(path)
    raise Ree::Error.new("file not found: #{path}")
  end

  Ree.logger.debug("package_require(#{path})")
  packages_facade.load_package_entry(package_name)
  packages_facade.load_file(path, package_name)
end