]> git.donarmstrong.com Git - biopieces.git/commitdiff
cleaning up ruby code dir
authormartinahansen <martinahansen@74ccb610-7750-0410-82ae-013aeee3265d>
Fri, 14 May 2010 13:09:25 +0000 (13:09 +0000)
committermartinahansen <martinahansen@74ccb610-7750-0410-82ae-013aeee3265d>
Fri, 14 May 2010 13:09:25 +0000 (13:09 +0000)
git-svn-id: http://biopieces.googlecode.com/svn/trunk@952 74ccb610-7750-0410-82ae-013aeee3265d

code_ruby/Maasha/lib/biopieces.rb [deleted file]
code_ruby/Maasha/lib/biopieces_old.rb [new file with mode: 0755]
code_ruby/Maasha/lib/bp_optparse.rb [deleted file]

diff --git a/code_ruby/Maasha/lib/biopieces.rb b/code_ruby/Maasha/lib/biopieces.rb
deleted file mode 100755 (executable)
index 61d9cd7..0000000
+++ /dev/null
@@ -1,62 +0,0 @@
-class BioPieces
-       RECORD_DELIMITER = "\n---\n"
-
-       class Record
-               attr_reader :__hash__
-               def initialize( data )
-                       @__hash__ = data
-               end
-       
-               def method_missing( name, *args, &block )
-                       if args.empty? && @__hash__.has_key?( name ) then
-                               @__hash__[ name ]
-                       else
-                               super # get the original exception
-                       end
-               end
-       
-               def to_s
-                       @__hash__.map { | key, value | "#{ key }: #{ value }" }.join( "\n" ) + RECORD_DELIMITER
-               end
-       
-               def to_hash
-                       @__hash__.dup
-               end
-       end
-       def self.file( path )
-               bp = new( File.open( path ) )
-               yield bp if block_given?
-               bp
-       ensure
-               # if no block was given, the user wants the BioPieces instance
-               # with a still open File so he can read it, so only close if a block
-               # had been given.
-               bp.close if block_given?
-       end
-       def initialize( stream )
-               @stream = stream
-       end
-       def close
-               @stream.close if @stream.respond_to? :close
-       end
-       def record_get
-               return unless block = @stream.gets( RECORD_DELIMITER )
-               block.chomp!( RECORD_DELIMITER )
-               data = Hash[ *block.split( /: |\n/, 2 ) ]
-               Record.new( data )
-       end
-  
-       def each
-               yield record_get until @stream.eof?
-               self # not to have a messy return value
-       end
-end
-
-
-__END__
diff --git a/code_ruby/Maasha/lib/biopieces_old.rb b/code_ruby/Maasha/lib/biopieces_old.rb
new file mode 100755 (executable)
index 0000000..61d9cd7
--- /dev/null
@@ -0,0 +1,62 @@
+class BioPieces
+       RECORD_DELIMITER = "\n---\n"
+
+       class Record
+               attr_reader :__hash__
+               def initialize( data )
+                       @__hash__ = data
+               end
+       
+               def method_missing( name, *args, &block )
+                       if args.empty? && @__hash__.has_key?( name ) then
+                               @__hash__[ name ]
+                       else
+                               super # get the original exception
+                       end
+               end
+       
+               def to_s
+                       @__hash__.map { | key, value | "#{ key }: #{ value }" }.join( "\n" ) + RECORD_DELIMITER
+               end
+       
+               def to_hash
+                       @__hash__.dup
+               end
+       end
+       def self.file( path )
+               bp = new( File.open( path ) )
+               yield bp if block_given?
+               bp
+       ensure
+               # if no block was given, the user wants the BioPieces instance
+               # with a still open File so he can read it, so only close if a block
+               # had been given.
+               bp.close if block_given?
+       end
+       def initialize( stream )
+               @stream = stream
+       end
+       def close
+               @stream.close if @stream.respond_to? :close
+       end
+       def record_get
+               return unless block = @stream.gets( RECORD_DELIMITER )
+               block.chomp!( RECORD_DELIMITER )
+               data = Hash[ *block.split( /: |\n/, 2 ) ]
+               Record.new( data )
+       end
+  
+       def each
+               yield record_get until @stream.eof?
+               self # not to have a messy return value
+       end
+end
+
+
+__END__
diff --git a/code_ruby/Maasha/lib/bp_optparse.rb b/code_ruby/Maasha/lib/bp_optparse.rb
deleted file mode 100644 (file)
index 1946fda..0000000
+++ /dev/null
@@ -1,58 +0,0 @@
-require 'getoptlong'
-
-class BP_optparse
-       attr_accessor :options
-
-       def initialize( options = [] )
-               @options = options
-       end
-
-       # Method that adds default options to the option list.
-       def add_default_options
-               @options << { :long => 'help',       :short => '?', :type => :flag,  :mandatory => false, :default => nil, :allowed => nil, :disallowed => nil }
-               @options << { :long => 'stream_in',  :short => 'I', :type => :file!, :mandatory => false, :default => nil, :allowed => nil, :disallowed => nil }
-               @options << { :long => 'stream_out', :short => 'O', :type => :file,  :mandatory => false, :default => nil, :allowed => nil, :disallowed => nil }
-               @options << { :long => 'verbose',    :short => 'v', :type => :flag,  :mandatory => false, :default => nil, :allowed => nil, :disallowed => nil }
-       end
-
-       # Method to check if the option list contains duplicate long options.
-       def check_duplicate_long
-               hash = {}
-
-               @options.each do |opt|
-                       raise ArgumentError, "Duplicate long argument" if hash.include?( opt[ :long ] )
-
-                       hash[ opt[ :long ] ] = true
-               end
-       end
-
-       # Method to check if the option list contains duplicate short options.
-       def check_duplicate_short
-               hash = {}
-
-               @options.each do |opt|
-                       raise ArgumentError, "Duplicate short argument" if hash.include?( opt[ :short ] )
-
-                       hash[ opt[ :short ] ] = true
-               end
-       end
-
-       # Method to prepare the option list into the format of GetoptLong.
-       def compile_option_list
-               option_list = []
-
-               @options.each do |opt|
-                       if opt[ :type ] == :flag
-                               option_list << [ "--#{ opt[ :long ] }", "-#{ opt[ :short ] }", GetoptLong::NO_ARGUMENT ]
-                       else
-                               option_list << [ "--#{ opt[ :long ] }", "-#{ opt[ :short ] }", GetoptLong::REQUIRED_ARGUMENT ]
-                       end
-               end
-
-               option_list
-       end
-
-       def parse_options( option_list )
-               opts = GetoptLong.new()
-       end
-end