Class: Rsense::Server::Command::Preload

Inherits:
Object
  • Object
show all
Defined in:
lib/rsense/server/command/preload.rb

Defined Under Namespace

Classes: SourceCode

Class Method Summary collapse

Class Method Details

.code(libs) ⇒ Object



28
29
30
31
32
# File 'lib/rsense/server/command/preload.rb', line 28

def self.code(libs)
  libs.each do |l|
    l.files = Dir.glob(Pathname.new(l.path).join("**/*.rb"))
  end
end

.concat_files(paths) ⇒ Object



34
35
36
37
# File 'lib/rsense/server/command/preload.rb', line 34

def self.concat_files(paths)
  code = paths.files.map { |f| Pathname.new(f).read }
  paths.source = code.join("\n")
end

.dependency_code(dependencies) ⇒ Object



16
17
18
19
20
21
22
# File 'lib/rsense/server/command/preload.rb', line 16

def self.dependency_code(dependencies)
  paths = dependencies.map { |d| gen_source(d) }.compact!
  return [] unless paths
  lib_dirs(paths)
  code(paths)
  paths.each { |l| concat_files(l) }
end

.find_lib(path) ⇒ Object



45
46
47
48
49
# File 'lib/rsense/server/command/preload.rb', line 45

def self.find_lib(path)
  p = Pathname.new(path.path).expand_path
  return p.dirname if p.file?
  return p
end

.gen_source(d) ⇒ Object



24
25
26
# File 'lib/rsense/server/command/preload.rb', line 24

def self.gen_source(d)
  SourceCode.new(d.name, d.full_name, d.path.first) if d.path.first
end

.lib_dirs(paths) ⇒ Object



39
40
41
42
43
# File 'lib/rsense/server/command/preload.rb', line 39

def self.lib_dirs(paths)
  paths.each { |p|
    p.path = find_lib(p)
  }
end

.load(project_manager, path) ⇒ Object



11
12
13
14
# File 'lib/rsense/server/command/preload.rb', line 11

def self.load(project_manager, path)
  PROJMAN.roptions = Rsense::Server::Options.new(stub_data(path))
  PROJMAN.rcommand = Rsense::Server::Command::Command.new(PROJMAN.roptions)
end

.stub_data(path) ⇒ Object



7
8
9
# File 'lib/rsense/server/command/preload.rb', line 7

def self.stub_data(path)
  { "project" => path.to_s }
end