Class: Idb::LocalOperations

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

Instance Method Summary collapse

Instance Method Details

#dir_glob(path, pattern) ⇒ Object



37
38
39
40
# File 'lib/lib/local_operations.rb', line 37

def dir_glob(path, pattern)
  full_path = "#{path}/#{pattern}"
  Dir.glob(full_path)
end

#directory?(path) ⇒ Boolean

Returns:

  • (Boolean)


12
13
14
# File 'lib/lib/local_operations.rb', line 12

def directory?(path)
  File.directory? path
end

#download(a, b) ⇒ Object



7
8
9
10
# File 'lib/lib/local_operations.rb', line 7

def download(a, b)
  FileUtils.copy_file(a, b)
  true
end

#execute(cmd) ⇒ Object



46
47
48
# File 'lib/lib/local_operations.rb', line 46

def execute(cmd)
  `#{cmd}`
end

#execute_fork(cmd) ⇒ Object



50
51
52
# File 'lib/lib/local_operations.rb', line 50

def execute_fork(cmd)
  (pid = fork) ? Process.detach(pid) : exec(cmd)
end

#file?(path) ⇒ Boolean

Returns:

  • (Boolean)


3
4
5
# File 'lib/lib/local_operations.rb', line 3

def file?(path)
  File.file? path
end

#file_exists?(file) ⇒ Boolean

Returns:

  • (Boolean)


42
43
44
# File 'lib/lib/local_operations.rb', line 42

def file_exists?(file)
  File.exist? file
end

#launch_app(command, app) ⇒ Object



54
55
56
57
# File 'lib/lib/local_operations.rb', line 54

def launch_app(command, app)
  $log.info "Executing #{command} #{app}"
  execute_fork("#{command} \"#{app}\"")
end

#list_dir(path) ⇒ Object



29
30
31
# File 'lib/lib/local_operations.rb', line 29

def list_dir(path)
  Dir.entries path
end

#list_dir_full(path) ⇒ Object



33
34
35
# File 'lib/lib/local_operations.rb', line 33

def list_dir_full(path)
  Dir.entries path
end

#mtime(path) ⇒ Object



16
17
18
# File 'lib/lib/local_operations.rb', line 16

def mtime(path)
  File.mtime path
end

#open(path) ⇒ Object



20
21
22
23
24
25
26
27
# File 'lib/lib/local_operations.rb', line 20

def open(path)
  Launchy.open path
  return true
rescue StandardError => e
  $log.error "Could not open file #{path}: #{e.message}"
  $log.error e.backtrace
  return false
end