Module: R

Defined in:
lib/rub/r.rb,
lib/rub/help.rb,
lib/rub/r/target.rb,
lib/rub/r/persist.rb,
lib/rub/r/targetgenerator.rb

Overview

#

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:                              #
                                                                            #
1. 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.                                         #
                                                                            #
2. Altered source versions must be plainly marked as such, and must not be  #
   misrepresented as being the original software.                           #
                                                                            #
3. This notice may not be removed or altered from any source distribution.  #
                                                                            #

Defined Under Namespace

Modules: Env, I, Tool, Version Classes: BuildStep, Command, Target, TargetGenerator, TargetHelp, TargetHelpAll, TargetHelpBuilt, TargetHelpHelp, TargetHelpInstalled, TargetHelpTag, TargetSmart, TargetSource

Constant Summary collapse

VersionPure =
R::Version.dup

Class Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Class Attribute Details

.ppersistantHash (readonly)

Returns The project cache.

Returns:

  • (Hash)

    The project cache.



28
# File 'lib/rub/r/persist.rb', line 28

cattr_reader :ppersistant

.spersistantHash (readonly)

Returns The system cache.

Returns:

  • (Hash)

    The system cache.



32
# File 'lib/rub/r/persist.rb', line 32

cattr_reader :spersistant

Class Method Details

.clear_cacheObject

Clear all caches.



65
66
67
68
# File 'lib/rub/r/persist.rb', line 65

def self.clear_cache
	clear_system_cache
	clear_project_cache
end

.clear_project_cacheObject

Clear the project cache.



61
62
63
# File 'lib/rub/r/persist.rb', line 61

def self.clear_project_cache
	@ppersistant.clear
end

.clear_system_cacheObject

Clear the system cache.



57
58
59
# File 'lib/rub/r/persist.rb', line 57

def self.clear_system_cache
	@spersistant.clear
end

.find_target(path) ⇒ Target?

Find a target.

Returns a target for path or nil.

Parameters:

  • path (Pathname, String)

    The path of the target.

Returns:

  • (Target, nil)

    The target.



43
44
45
46
# File 'lib/rub/r/target.rb', line 43

def self.find_target(path)
	path = C.path(path)
	@targets[path] || @sources[path]
end

.get_target(path) ⇒ Target, TargetSource

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.

Parameters:

  • path (Pathname, String)

    The path of the target.

Returns:



55
56
57
58
59
# 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(cmd, desc, importance: :med) ⇒ true, false

Run a command as part of the build.

The command will be run and status will be printed.

Parameters:

  • cmd (Array<String,#to_s>)

    The command to execute.

  • desc (String)

    The verb describing what the command is doing.

  • importance (Symbol) (defaults to: :med)

    The importance of this step. Affects printing.

Returns:

  • (true, false)

    true if the command was successful.



177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
# 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_target(path, target) ⇒ void

This method returns an undefined value.

Set a target to a path.

This function registers target as a way to build path.

Parameters:

  • path (Pathname, String)

    The path that is build by the target.

  • target (Target)

    The target that builds path.

See Also:



70
71
72
73
74
75
# 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

Instance Method Details

#targetsHash{Pathname,Symbol=>Target}

All targets.

This should only be used for debugging. Use find_target, get_target and set_target instead.

Returns:

  • (Hash{Pathname,Symbol=>Target})


32
# File 'lib/rub/r/target.rb', line 32

cattr_reader :targets