Class: Idb::LocalOperations
- Inherits:
-
Object
- Object
- Idb::LocalOperations
- Defined in:
- lib/lib/local_operations.rb
Instance Method Summary collapse
- #dir_glob(path, pattern) ⇒ Object
- #directory?(path) ⇒ Boolean
- #download(a, b) ⇒ Object
- #execute(cmd) ⇒ Object
- #execute_fork(cmd) ⇒ Object
- #file?(path) ⇒ Boolean
- #file_exists?(file) ⇒ Boolean
- #launch_app(command, app) ⇒ Object
- #list_dir(path) ⇒ Object
- #list_dir_full(path) ⇒ Object
- #mtime(path) ⇒ Object
- #open(path) ⇒ Object
Instance Method Details
#dir_glob(path, pattern) ⇒ Object
43 44 45 46 |
# File 'lib/lib/local_operations.rb', line 43 def dir_glob path, pattern full_path = "#{path}/#{pattern}" Dir.glob(full_path) end |
#directory?(path) ⇒ Boolean
16 17 18 |
# File 'lib/lib/local_operations.rb', line 16 def directory? path File.directory? path end |
#download(a, b) ⇒ Object
10 11 12 13 |
# File 'lib/lib/local_operations.rb', line 10 def download a, b FileUtils.copy_file(a,b) return true end |
#execute(cmd) ⇒ Object
52 53 54 |
# File 'lib/lib/local_operations.rb', line 52 def execute cmd `#{cmd}` end |
#execute_fork(cmd) ⇒ Object
56 57 58 |
# File 'lib/lib/local_operations.rb', line 56 def execute_fork cmd (pid = fork) ? Process.detach(pid) : exec(cmd) end |
#file?(path) ⇒ Boolean
5 6 7 |
# File 'lib/lib/local_operations.rb', line 5 def file? path File.file? path end |
#file_exists?(file) ⇒ Boolean
48 49 50 |
# File 'lib/lib/local_operations.rb', line 48 def file_exists? file File.exists? file end |
#launch_app(command, app) ⇒ Object
60 61 62 63 |
# File 'lib/lib/local_operations.rb', line 60 def launch_app command, app $log.info "Executing #{command} #{app}" self.execute_fork("#{command} \"#{app}\"") end |
#list_dir(path) ⇒ Object
35 36 37 |
# File 'lib/lib/local_operations.rb', line 35 def list_dir path Dir.entries path end |
#list_dir_full(path) ⇒ Object
39 40 41 |
# File 'lib/lib/local_operations.rb', line 39 def list_dir_full path Dir.entries path end |
#mtime(path) ⇒ Object
20 21 22 |
# File 'lib/lib/local_operations.rb', line 20 def mtime path File.mtime path end |
#open(path) ⇒ Object
24 25 26 27 28 29 30 31 32 33 |
# File 'lib/lib/local_operations.rb', line 24 def open path begin Launchy.open path return true rescue Exception => e $log.error "Could not open file #{path}: #{e.message}" $log.error e.backtrace return false end end |