about summary refs log tree commit homepage
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2011-11-02 22:33:01 +0000
committerEric Wong <normalperson@yhbt.net>2011-11-02 22:42:53 +0000
commit443d7bdf4c1fb3b950cd05ffb475aef12d50c4b6 (patch)
tree9bca156997a281dff95e75600bc7dd91eb9e1a5c
parent909a2ae12d11593d59fccf30b7c2143cc9f441ab (diff)
downloadmogilefs-client-443d7bdf4c1fb3b950cd05ffb475aef12d50c4b6.tar.gz
-rw-r--r--lib/mogilefs/bigfile.rb50
-rw-r--r--test/test_bigfile.rb2
2 files changed, 24 insertions, 28 deletions
diff --git a/lib/mogilefs/bigfile.rb b/lib/mogilefs/bigfile.rb
index 1be36a5..1f9d0ba 100644
--- a/lib/mogilefs/bigfile.rb
+++ b/lib/mogilefs/bigfile.rb
@@ -12,7 +12,7 @@ module MogileFS::Bigfile
 
   # returns a big_info hash if successful
   def bigfile_stat(key)
-    parse_info(get_file_data(key))
+    bigfile_parse_info(get_file_data(key))
   end
 
   # returns total bytes written and the big_info hash if successful, raises an
@@ -51,34 +51,30 @@ module MogileFS::Bigfile
     [ total, info ]
   end
 
-  private
-
-    include MogileFS::Util
-
-    ##
-    # parses the contents of a _big_info: string or IO object
-    def parse_info(info = '')
-      rv = { :parts => [] }
-      info.each_line do |line|
-        line.chomp!
-        case line
-        when /^(des|type|filename)\s+(.+)$/
-          rv[$1.to_sym] = $2
-        when /^compressed\s+([01])$/
-          rv[:compressed] = ($1 == '1')
-        when /^(chunks|size)\s+(\d+)$/
-          rv[$1.to_sym] = $2.to_i
-        when /^part\s+(\d+)\s+bytes=(\d+)\s+md5=(.+)\s+paths:\s+(.+)$/
-          rv[:parts][$1.to_i] = {
-            :bytes => $2.to_i,
-            :md5 => $3.downcase,
-            :paths => $4.split(/\s*,\s*/),
-          }
-        end
+  ##
+  # parses the contents of a _big_info: string or IO object
+  def bigfile_parse_info(info) # :nodoc:
+    rv = { :parts => [] }
+    info.each_line do |line|
+      line.chomp!
+      case line
+      when /^(des|type|filename)\s+(.+)$/
+        rv[$1.to_sym] = $2
+      when /^compressed\s+([01])$/
+        rv[:compressed] = ($1 == '1')
+      when /^(chunks|size)\s+(\d+)$/
+        rv[$1.to_sym] = $2.to_i
+      when /^part\s+(\d+)\s+bytes=(\d+)\s+md5=(.+)\s+paths:\s+(.+)$/
+        rv[:parts][$1.to_i] = {
+          :bytes => $2.to_i,
+          :md5 => $3.downcase,
+          :paths => $4.split(/\s*,\s*/),
+        }
       end
-
-      rv
     end
+
+    rv
+  end
 end
 require "mogilefs/bigfile/filter"
 
diff --git a/test/test_bigfile.rb b/test/test_bigfile.rb
index c99b878..8cf4624 100644
--- a/test/test_bigfile.rb
+++ b/test/test_bigfile.rb
@@ -41,7 +41,7 @@ size 18
 part 1 bytes=12 md5=d3b4d15c294b24d9f853e26095dfe3d0 paths: http://foo1:7500/dev2/0/000/144/0000144411.fid, http://foo2:7500/dev1/0/000/144/0000144411.fid
 part 2 bytes=6 md5=d3b4d15c294b24d9f853e26095dfe3d0 paths: http://foo4:7500/dev2/0/000/144/0000144411.fid, http://foo3:7500/dev1/0/000/144/0000144411.fid
 EOS
-    i = parse_info(s)
+    i = bigfile_parse_info(s)
     assert_equal expect, i
   end