Commits

Erik Hetzner committed 854ea04

add more rdoc

Comments (0)

Files changed (5)

 require 'rake/testtask'
+require 'rake/rdoctask'
 
 require 'bundler'
 include Rake::DSL
   t.pattern = 'test/**/test_*.rb'
   t.verbose = true
 end
+
+Rake::RDocTask.new do |rd|
+#  rd.main = "README.rdoc"
+  rd.rdoc_files.include("lib/**/*.rb")
+end

lib/mrt/ingest/client.rb

 module Mrt
   module Ingest
 
+    # A client for ingesting objects into a Merritt.
     class Client
       def initialize(base_uri, username=nil, password=nil)
         @base_uri = base_uri
         @username = username
         @password = password
       end
-      
+
+      # Send a request to the client.
+      def ingest(ingest_req)
+        return Response.new(mk_rest_request(ingest_req).execute())
+      end
+
+      # :nodoc:
       def mk_rest_request(ingest_req)
         args = { 
           :method   => :post,
         return RestClient::Request.new(args)
       end
 
-      def ingest(ingest_req)
-        return Response.new(mk_rest_request(ingest_req).execute())
-      end
     end
   end
 end

lib/mrt/ingest/iobject.rb

 
 module Mrt
   module Ingest
-    class Component
+    # Represents a component of an object to ingest. Either a #URI or a
+    # #File.
+    class Component # :nodoc:
       def initialize(server, where, options)
         @name = options[:name]
         @digest = options[:digest]
       end
     end
     
-    # An object ready for ingest into Merritt.
+    # An object prepared for ingest into Merritt.
     class IObject
       
-      attr_accessor :primary_identifier, :local_identifier, :erc, :erc_file
+      attr_accessor :primary_identifier, :local_identifier, :erc
 
+      # Options can have the keys :primary_identifier,
+      # :local_identifier, :server, or :erc. :erc can be a #File, #Uri
+      # or a #Hash of metadata. :server is a #OneTimeServer.
       def initialize(options={})
         @primary_identifier = options[:primary_identifier]
         @local_identifier = options[:local_identifier]
         @server = options[:server] || Mrt::Ingest::OneTimeServer.new
       end
       
+      # Add a component to the object. where can be either a #URI or a
+      # #File. Options is a hash whose keys may be :name, :digest,
+      # :mime_type, or :size. If :digest is supplied, it must be a
+      # subclass of Mrt::Ingest::MessageDigest::Base. If where is a
+      # #File, it will be hosted on an embedded web server.
       def add_component(where, options={})
         @components.push(Component.new(@server, where, options))
       end
               :primary_identifier => @primary_identifier)
       end
 
-      def start_server
+      def start_server # :nodoc:
         return @server.start_server()
       end
 
-      def join_server
+      def join_server # :nodoc:
         return @server.join_server()
       end
 
-      def stop_server
+      def stop_server # :nodoc:
         return @server.stop_server()
       end
         
-      def mk_manifest(manifest, erc_component)
+      def mk_manifest(manifest, erc_component) # :nodoc:
         manifest.write("#%checkm_0.7\n")
         manifest.write("#%profile http://uc3.cdlib.org/registry/ingest/manifest/mrt-ingest-manifest\n")
         manifest.write("#%prefix | mrt: | http://uc3.cdlib.org/ontology/mom#\n")
         manifest.write("#%EOF\n")
       end
       
+      # Begin an ingest on the given client, with a profile and
+      # submitter.
       def start_ingest(client, profile, submitter)
         request = mk_request(profile, submitter)
         start_server
         return @response
       end
 
+      # Wait for the ingest of this object to finish.
       def finish_ingest
+        # XXX Right now we only join the hosting server; in the future
+        # we will check the status via the ingest server.
         join_server
       end
     end

lib/mrt/ingest/message_digest.rb

 module Mrt
   module Ingest
     module MessageDigest
-      class Base
-        attr_reader :value
-        def initialize(value)
+      class Base # :nodoc:
+        attr_reader :value, :type
+        def initialize(value, type)
           @value = value
+          @type  = type
         end
       end
       
+      # Represents a SHA256 digest suitable for a Checkm manifest.
       class SHA256 < Base
-        def type
-          return "sha-256"
+        def initialize(value)
+          super(value, "sha-256")
         end
       end
 
+      # Represents an MD5 digest suitable for a Checkm manifest.
       class MD5 < Base
-        def type
-          return "md5"
+        def initialize(value)
+          super(value, "md5")
         end
         
+        # Generate a digest from a file.
         def self.from_file(file)
           digest = Digest::MD5.new
           File.open(file.path, 'r') do |f|
         end
       end
 
+      # Represents a SHA1 digest suitable for a Checkm manifest.
       class SHA1 < Base
-        def type
-          return "sha-1"
+        def initialize(value)
+          super(value, "sha1")
         end
       end
     end
   end
 end
-

lib/mrt/ingest/request.rb

     class RequestException < Exception
     end
 
+    # Represents a request to be sent to an ingest server.
     class Request
       attr_accessor :creator, :date, :local_identifier,
                     :primary_identifier, :profile, :note, :submitter,
                     :title, :type
 
+      # Options is a hash; required are :profile, :submitter, :type.
+      # May also include :creator, :date, :digest, :file, :filename,
+      # :local_identifier, :primary_identifier, :note, :title.
       def initialize(options)
         @creator = options[:creator]
         @date = options[:date]
         end
       end
       
+      # Returns a hash of arguments suitable for sending to a server.
       def mk_args
         return {
           'creator'           => @creator,
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.