Class: TinyTds::Bin
- Inherits:
-
Object
- Object
- TinyTds::Bin
- Defined in:
- lib/tiny_tds/bin.rb
Constant Summary collapse
- ROOT =
File. '../../..', __FILE__
- PATHS =
ENV['PATH'].split File::PATH_SEPARATOR
- EXTS =
(ENV['PATHEXT'] ? ENV['PATHEXT'].split(';') : ['']) | ['.exe']
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Class Method Summary collapse
Instance Method Summary collapse
- #info ⇒ Object
-
#initialize(name) ⇒ Bin
constructor
A new instance of Bin.
- #path ⇒ Object
- #run(*args) ⇒ Object
Constructor Details
#initialize(name) ⇒ Bin
Returns a new instance of Bin.
23 24 25 26 27 |
# File 'lib/tiny_tds/bin.rb', line 23 def initialize(name) @name = name @binstub = find_bin @exefile = find_exe end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
11 12 13 |
# File 'lib/tiny_tds/bin.rb', line 11 def name @name end |
Class Method Details
.exe(name, *args) ⇒ Object
15 16 17 18 19 |
# File 'lib/tiny_tds/bin.rb', line 15 def exe(name, *args) bin = new(name) puts bin.info bin.run(*args) end |
Instance Method Details
#info ⇒ Object
40 41 42 |
# File 'lib/tiny_tds/bin.rb', line 40 def info "[TinyTds][v#{TinyTds::VERSION}][#{name}]: #{path}" end |
#path ⇒ Object
35 36 37 38 |
# File 'lib/tiny_tds/bin.rb', line 35 def path return @path if defined?(@path) @path = @exefile && File.exists?(@exefile) ? @exefile : which end |
#run(*args) ⇒ Object
29 30 31 32 33 |
# File 'lib/tiny_tds/bin.rb', line 29 def run(*args) return nil unless path Kernel.system Shellwords.join(args.unshift(path)) $?.to_i end |