Class: Nu::Loader

Inherits:
Object
  • Object
show all
Defined in:
lib/nu/loader.rb

Class Method Summary collapse

Class Method Details

.get_copy_fromObject



60
61
62
63
64
65
# File 'lib/nu/loader.rb', line 60

def self.get_copy_from
  libdir = get_libdir @gem_to_copy
  #puts File.expand_path libdir
    #try Dir.glob("{bin,lib}/**/*")
  libdir.gsub '{lib}','lib'
end

.get_copy_toObject



73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
# File 'lib/nu/loader.rb', line 73

def self.get_copy_to
    proj = Nu::Project.new
    
  spec = get_gemspec @gem_to_copy
  #to be used in copying
    if proj.should_use_long_names?
    name = spec.full_name
    else
    name = spec.name
    end
  to = Dir.pwd + "/#{@location}/#{name}"
  if Dir[to] == [] #may need a smarter guy here
    FileUtils.mkpath to
  end
  to
end

.get_filesObject



67
68
69
70
71
# File 'lib/nu/loader.rb', line 67

def self.get_files
  spec = get_gemspec @gem_to_copy
  files = spec.lib_files #get full path
  files
end

.get_gemspec(name) ⇒ Object



55
56
57
58
# File 'lib/nu/loader.rb', line 55

def self.get_gemspec(name)
    gems = Gem.source_index.find_name name
    return gems.last if gems.length > 0
end

.get_libdir(name) ⇒ Object



46
47
48
49
50
51
52
53
# File 'lib/nu/loader.rb', line 46

def self.get_libdir(name)
  g = get_gemspec name
  #puts "GemSpec #{g.full_gem_path}"
  l = g.full_gem_path
  d = File.join(l,"lib")
  #puts d
  d
end

.load(name, location) ⇒ Object



7
8
9
# File 'lib/nu/loader.rb', line 7

def self.load(name)
  load(name, 'lib')
end

.process_dependenciesObject



90
91
92
93
94
95
96
97
98
99
100
101
# File 'lib/nu/loader.rb', line 90

def self.process_dependencies
  spec = get_gemspec @gem_to_copy
  spec.dependencies.each do |d|
    if Gem.available? d.name
      puts "loading #{d.name}"
      load d.name, @location
    else
      puts "#{d.name} is not installed locally"
      puts "please run 'gem install #{d.name}"
    end
  end
end