module R
Rub internals.
Internal functions intended for library developers only.
#
This software is provided ‘as-is’, without any express or implied # warranty. In no event will the authors be held liable for any damages # arising from the use of this software. #
#
Permission is granted to anyone to use this software for any purpose, # including commercial applications, and to alter it and redistribute it # freely, subject to the following restrictions: #
#
-
The origin of this software must not be misrepresented; you must not # claim that you wrote the original software. If you use this software in # a product, an acknowledgment in the product documentation would be # appreciated but is not required. #
#
-
Altered source versions must be plainly marked as such, and must not be # misrepresented as being the original software. #
#
-
This notice may not be removed or altered from any source distribution. #
#
#
This software is provided ‘as-is’, without any express or implied # warranty. In no event will the authors be held liable for any damages # arising from the use of this software. #
#
Permission is granted to anyone to use this software for any purpose, # including commercial applications, and to alter it and redistribute it # freely, subject to the following restrictions: #
#
-
The origin of this software must not be misrepresented; you must not # claim that you wrote the original software. If you use this software in # a product, an acknowledgment in the product documentation would be # appreciated but is not required. #
#
-
Altered source versions must be plainly marked as such, and must not be # misrepresented as being the original software. #
#
-
This notice may not be removed or altered from any source distribution. #
#
#
This software is provided ‘as-is’, without any express or implied # warranty. In no event will the authors be held liable for any damages # arising from the use of this software. #
#
Permission is granted to anyone to use this software for any purpose, # including commercial applications, and to alter it and redistribute it # freely, subject to the following restrictions: #
#
-
The origin of this software must not be misrepresented; you must not # claim that you wrote the original software. If you use this software in # a product, an acknowledgment in the product documentation would be # appreciated but is not required. #
#
-
Altered source versions must be plainly marked as such, and must not be # misrepresented as being the original software. #
#
-
This notice may not be removed or altered from any source distribution. #
#
Constants
- VersionPure
Public Class Methods
Clear all caches.
# File lib/rub/r/persist.rb, line 65 def self.clear_cache clear_system_cache clear_project_cache end
Clear the project cache.
# File lib/rub/r/persist.rb, line 61 def self.clear_project_cache @ppersistant.clear end
Clear the system cache.
# File lib/rub/r/persist.rb, line 57 def self.clear_system_cache @spersistant.clear end
Find a target.
Returns a target for path
or nil.
@param path [Pathname,String] The path of the target. @return [Target,nil] The target.
# File lib/rub/r/target.rb, line 43 def self.find_target(path) path = C.path(path) @targets[path] || @sources[path] end
Get a target.
This function get’s an existing target if it exists or returns a new source target if there is no existing target to build it.
@param path [Pathname,String] The path of the target. @return [Target,TargetSource]
# File lib/rub/r/target.rb, line 55 def self.get_target(path) path = C.path(path) find_target(path) or @sources[path] ||= TargetSource.new(path) end
Run a command as part of the build.
The command will be run and status will be printed.
@param cmd [Array<String,#to_s>] The command to execute. @param desc [String] The verb describing what the command is doing. @param importance [Symbol] The importance of this step. Affects printing. @return [true,false] true if the command was successful.
# File lib/rub/r/command.rb, line 177 def R.run(cmd, desc, importance: :med) cmd = cmd.dup bs = R::BuildStep.new bs.desc = desc bs.cmd = cmd bs.importance = importance cpath = C.find_command cmd[0] if not cpath raise "Could not find #{cmd[0]}. Please install it or add it to your path." end cmd[0] = cpath cmd.map!{|a| a.to_s} c = R::Command.new(cmd) c.mergeouts = true c.run bs.out = c.stdout bs.status = c.status.exitstatus bs.print c.success? end
Set a target to a path.
This function registers target
as a way to build path
.
@param path [Pathname,String] The path that is build by the target. @param target [Target] The target that builds path
. @return [void]
@see Target#register
.
# File lib/rub/r/target.rb, line 70 def self.set_target(path, target) if find_target(path) $stderr.puts "Warning: #{path} can be built two ways." end @targets[C.path(path)] = target end