Module: IRODS4r::ICommands
- Defined in:
- lib/irods4r/icommands.rb
Overview
This module interfaces directly with the IRODS system
Defined Under Namespace
Classes: ICommandException
Class Method Summary collapse
- .exist?(path) ⇒ Boolean
-
.export(path, file_path, create_parent_path = true) ⇒ Object
Copy the resource at ‘path’ in iRODS to ‘file_path’ in the local file system.
-
.ls(path) ⇒ Object
Return the list of files found at ‘path’.
-
.read(path) ⇒ Object
Return content of resource at ‘path’.
-
.write(path, content) ⇒ Object
Return content of resource at ‘path’.
Class Method Details
.exist?(path) ⇒ Boolean
44 45 46 47 |
# File 'lib/irods4r/icommands.rb', line 44 def self.exist?(path) `ils #{path}` $?.exitstatus == 0 end |
.export(path, file_path, create_parent_path = true) ⇒ Object
Copy the resource at ‘path’ in iRODS to ‘file_path’ in the local file system.
52 53 54 55 56 57 58 59 60 |
# File 'lib/irods4r/icommands.rb', line 52 def self.export(path, file_path, create_parent_path = true) #puts ">>>> #{path} -> #{file_path}" if create_parent_path require 'fileutils' FileUtils.mkpath ::File.dirname(file_path) end `iget -f #{path} #{file_path}` raise ICommandException.new($?) unless $?.exitstatus == 0 end |
.ls(path) ⇒ Object
Return the list of files found at ‘path’.
12 13 14 15 16 17 18 19 |
# File 'lib/irods4r/icommands.rb', line 12 def self.ls(path) r = `ils #{path}` #raise ICommandException.new($?) unless $?.exitstatus == 0 if r.empty? raise NotFoundException.new("Can't find resource '#{path}'") end r.lines end |
.read(path) ⇒ Object
Return content of resource at ‘path’
23 24 25 26 27 28 29 30 31 |
# File 'lib/irods4r/icommands.rb', line 23 def self.read(path) f = Tempfile.new('irods4r') `iget -f #{path} #{f.path}` raise ICommandException.new($?) unless $?.exitstatus == 0 content = f.read f.close f.unlink content end |
.write(path, content) ⇒ Object
Return content of resource at ‘path’
35 36 37 38 39 40 41 42 |
# File 'lib/irods4r/icommands.rb', line 35 def self.write(path, content) f = Tempfile.new('irods4r') f.write(content) f.close `iput -f #{f.path} #{path}` raise ICommandException.new($?) unless $?.exitstatus == 0 f.unlink end |