Class: RakeDotNet::Cli

Inherits:
Object
  • Object
show all
Defined in:
lib/rake_dotnet.rb

Direct Known Subclasses

BcpCmd, SqlCmd, SvnCmd

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(params = {}) ⇒ Cli

Returns a new instance of Cli.



100
101
102
103
104
105
106
107
# File 'lib/rake_dotnet.rb', line 100

def initialize(params={})
	@bin = params[:exe] || nil
	@exe_name = params[:exe_name] #required for inferring path

	# guessable / defaultable
	@search_paths = params[:search_paths] || []
	@search_paths << nil # use the one that will be found in %PATH%
end

Instance Attribute Details

#binObject

Returns the value of attribute bin.



98
99
100
# File 'lib/rake_dotnet.rb', line 98

def bin
  @bin
end

#search_pathsObject

Returns the value of attribute search_paths.



98
99
100
# File 'lib/rake_dotnet.rb', line 98

def search_paths
  @search_paths
end

Instance Method Details

#cmdObject



117
118
119
# File 'lib/rake_dotnet.rb', line 117

def cmd
	return "\"#{exe}\""
end

#exeObject



109
110
111
112
113
114
115
# File 'lib/rake_dotnet.rb', line 109

def exe
	return @bin unless @bin.nil?

	@bin = "#{search_for_exe}"

	return @bin
end

#search_for_exeObject

Raises:

  • (ArgumentError)


121
122
123
124
125
126
127
128
129
130
131
# File 'lib/rake_dotnet.rb', line 121

def search_for_exe
	@search_paths.each do |sp|
		if sp.nil?
			return @exe_name #because we add bare exe as last element in array
		else
			path = File.join(sp, @exe_name)
			return File.expand_path(path) if File.exist? path
		end
	end
	raise(ArgumentError, "No executable found in search-paths or system-PATH", caller)
end