Module: L::Util
- Defined in:
- lib/rub/l/util.rb
Overview
General purpose build tools.
Defined Under Namespace
Classes: TargetUninstall
Class Method Summary collapse
-
.install(what, where, mode: nil, require: []) ⇒ Array<Pathname>
Install a file.
-
.install_to(from, to, mode: nil, require: []) ⇒ Array<Pathname>
Install a file to a specific location.
-
.link(target, name, type = :sym, expand_target: true) ⇒ Pathname
Create a link.
-
.uninstall(what) ⇒ void
Uninstall a file.
Class Method Details
.install(what, where, mode: nil, require: []) ⇒ Array<Pathname>
Install a file
Installs what
into the directory where
. Source files are added to the =all tag and installed files are added to the =install tag.
150 151 152 153 154 155 156 157 158 159 160 161 162 |
# File 'lib/rub/l/util.rb', line 150 def self.install(what, where, mode: nil, require: []) what = R::Tool.make_set_paths what where = Pathname.new(where) require = R::Tool.make_set_paths require what.map do |f| if f.directory? install(f.children, where+f.basename) else install_to(f, where+f.basename) end end.flatten.to_set end |
.install_to(from, to, mode: nil, require: []) ⇒ Array<Pathname>
Install a file to a specific location.
Similar to #install but the basename is not used as the name in the new location. If from is a dirtectory it is installed and renamed but it’s contents are preserved with the same names.
109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 |
# File 'lib/rub/l/util.rb', line 109 def self.install_to(from, to, mode: nil, require: []) from = C.path(from) to = Pathname.new(to).(D :prefix) if from.directory? return install(from.children, to) end C.generator( Set[from].merge(require), ['install', "-D#{mode!=nil ? "m#{mode}" : "" }", from, to], to, desc: 'Installing' ).each do |o| C.tag(:all ).require(from) C.tag(:install).require(to) end uninstall to Set[from] end |
.link(target, name, type = :sym, expand_target: true) ⇒ Pathname
Create a link
79 80 81 82 83 84 85 86 87 88 89 90 |
# File 'lib/rub/l/util.rb', line 79 def self.link(target, name, type = :sym, expand_target: true) target = ? C.path(target) : target name = C.path name C.generator( [], #target, ['ln', '-f', (type == :sym ? '-s' : nil), target, name].compact, name, desc: 'Linking' ) name end |
.uninstall(what) ⇒ void
This method returns an undefined value.
Uninstall a file.
Adds the file to the :uninstall tag.
62 63 64 65 66 67 68 |
# File 'lib/rub/l/util.rb', line 62 def self.uninstall(what) what = R::Tool.make_set_paths what what.each do |f| TargetUninstall.instance.add f end end |