Class: Freely::Binary
- Inherits:
-
Object
- Object
- Freely::Binary
- Defined in:
- lib/freely/binary.rb
Instance Attribute Summary collapse
-
#dependencies ⇒ Object
readonly
Returns the value of attribute dependencies.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
Instance Method Summary collapse
-
#copy_all(path) ⇒ Object
Copy all dep libraries and self (if I’m a library too).
-
#copy_dep(dependency, path) ⇒ Object
Copy the specified dependency to the given path.
-
#initialize(path) ⇒ Binary
constructor
A new instance of Binary.
-
#relink_deps(root, prefix, verbose) ⇒ Object
Relink references in a binary at path.
Constructor Details
#initialize(path) ⇒ Binary
Returns a new instance of Binary.
12 13 14 15 16 |
# File 'lib/freely/binary.rb', line 12 def initialize path @path = path @name = Tools.read_name path @dependencies = Tools.fyi(Dependency.from_path(path).map!{|d| d.track}) end |
Instance Attribute Details
#dependencies ⇒ Object (readonly)
Returns the value of attribute dependencies.
10 11 12 |
# File 'lib/freely/binary.rb', line 10 def dependencies @dependencies end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
9 10 11 |
# File 'lib/freely/binary.rb', line 9 def name @name end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
8 9 10 |
# File 'lib/freely/binary.rb', line 8 def path @path end |
Instance Method Details
#copy_all(path) ⇒ Object
Copy all dep libraries and self (if I’m a library too)
19 20 21 22 |
# File 'lib/freely/binary.rb', line 19 def copy_all path @dependencies.each {|dep| copy_dep dep, path} copy_dep self, path if Tools.is_lib? @name end |
#copy_dep(dependency, path) ⇒ Object
Copy the specified dependency to the given path
25 26 27 28 29 30 |
# File 'lib/freely/binary.rb', line 25 def copy_dep dependency, path new_path = '%s/%s' % [path, dependency.name] FileUtils.mkdir path unless File.exist? path FileUtils.cp dependency.path, new_path unless File.exist? new_path FileUtils.chmod 0755, new_path end |
#relink_deps(root, prefix, verbose) ⇒ Object
Relink references in a binary at path
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/freely/binary.rb', line 33 def relink_deps root, prefix, verbose @dependencies.each do |d| new_path = '%s/%s' % [prefix, d.name] Tools.replace_deps @path, d.path, new_path if verbose puts "\t#{d.path} => #{new_path}" puts "\t\t..replacing subsequent dependencies" unless d.dependencies.empty? end Tools.fyi(d.dependencies).each do |sub| Tools.replace_deps "#{root}/#{new_path}", sub.path, "#{prefix}/#{sub.name}" end end end |