Class: Nu::Loader
- Inherits:
-
HasOutAndLog
- Object
- HasOutAndLog
- Nu::Loader
- Defined in:
- lib/nu/loader.rb
Instance Attribute Summary collapse
-
#gem_name ⇒ Object
readonly
Returns the value of attribute gem_name.
-
#location ⇒ Object
readonly
Returns the value of attribute location.
-
#version ⇒ Object
readonly
Returns the value of attribute version.
Instance Method Summary collapse
- #copy_dest ⇒ Object
- #copy_source ⇒ Object
- #copy_to_lib ⇒ Object
- #gemspec ⇒ Object
-
#initialize(name, version, location, long_names, out, log) ⇒ Loader
constructor
A new instance of Loader.
- #load_gem ⇒ Object
Constructor Details
#initialize(name, version, location, long_names, out, log) ⇒ Loader
Returns a new instance of Loader.
14 15 16 17 18 19 20 21 22 23 |
# File 'lib/nu/loader.rb', line 14 def initialize(name, version, location, long_names, out, log) #improve the crap out of this @long_names = long_names @gem_name = name @location = location @version = version @lib_tools = Nu::LibTools.new @gem_tools = Nu::GemTools.new super(out, log) end |
Instance Attribute Details
#gem_name ⇒ Object (readonly)
Returns the value of attribute gem_name.
10 11 12 |
# File 'lib/nu/loader.rb', line 10 def gem_name @gem_name end |
#location ⇒ Object (readonly)
Returns the value of attribute location.
11 12 13 |
# File 'lib/nu/loader.rb', line 11 def location @location end |
#version ⇒ Object (readonly)
Returns the value of attribute version.
12 13 14 |
# File 'lib/nu/loader.rb', line 12 def version @version end |
Instance Method Details
#copy_dest ⇒ Object
62 63 64 |
# File 'lib/nu/loader.rb', line 62 def copy_dest @lib_tools.folder_for(gemspec, @location, @long_names) end |
#copy_source ⇒ Object
58 59 60 |
# File 'lib/nu/loader.rb', line 58 def copy_source @gem_tools.lib_for(@gem_name, @version).gsub '{lib}','lib' end |
#copy_to_lib ⇒ Object
43 44 45 46 47 48 49 50 51 52 |
# File 'lib/nu/loader.rb', line 43 def copy_to_lib start_here = copy_source log "Copy From: #{start_here}" to = copy_dest log "Copy To: #{to}" FileUtils.copy_entry start_here, to @gem_tools.write_spec(gemspec, to) end |
#gemspec ⇒ Object
54 55 56 |
# File 'lib/nu/loader.rb', line 54 def gemspec @gem_tools.spec_for(@gem_name, @version) end |
#load_gem ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/nu/loader.rb', line 25 def load_gem if (!Gem.available? @gem_name, @version) or (@version == nil) out "Getting #{(@gem_name + " #{@version}").strip}..." begin inst = Gem::DependencyInstaller.new inst.install @gem_name, @version inst.installed_gems.each do |spec| out "Got #{spec.full_name}" end rescue Gem::GemNotFoundException => e out "ERROR: #{e.}" return false end else return true end end |