def bug_to_record(model, bug)
#      STDERR.puts "bug_to_record #{bug.inspect}"
      record = { }
      model.properties.each do |p|
	v = case p.name
      when :version, :target_milestone, :op_sys, :qa_contact then bug['internals', p.name]
      when :platform then bug['internals', 'rep_platform']
      when :creator then bug['internals', 'reporter_id']
      when :whiteboard then bug['internals', 'status_whiteboard']
	else
	  bug[p.name]
	end
#	STDERR.puts "#{v.inspect} -> #{p.inspect}"
	if v
	  case p
	  when DataMapper::Property::String then   v = v.to_s
	  when DataMapper::Property::Integer then  v = v.to_i
	  when DataMapper::Property::DateTime
#	    STDERR.puts "DateTime #{v.to_a.inspect}"
	    v = DateTime.civil(*v.to_a)
#	    STDERR.puts "DateTime #{v}"
	  else
	    raise "*** Unsupported property type #{p.inspect}"
	  end
	end
	record[p.name.to_s] = v
      end
      record
    end
def bug_to_record(model, bug)
#      STDERR.puts "bug_to_record #{bug.inspect}"
      record = { }
      model.properties.each do |p|
	v = case p.name
      when :version, :target_milestone, :op_sys, :qa_contact then bug['internals', p.name]
      when :platform then bug['internals', 'rep_platform']
      when :creator then bug['internals', 'reporter_id']
      when :whiteboard then bug['internals', 'status_whiteboard']
	else
	  bug[p.name]
	end
#	STDERR.puts "#{v.inspect} -> #{p.inspect}"
	if v
	  case p
	  when DataMapper::Property::String then   v = v.to_s
	  when DataMapper::Property::Integer then  v = v.to_i
	  when DataMapper::Property::DateTime
#	    STDERR.puts "DateTime #{v.to_a.inspect}"
	    v = DateTime.civil(*v.to_a)
#	    STDERR.puts "DateTime #{v}"
	  else
	    raise "*** Unsupported property type #{p.inspect}"
	  end
	end
	record[p.name.to_s] = v
      end
      record
    end
def

 Convert Bicho::Bug into record (as hash of key/value pairs)

 @return [Hash]
   A hash of all of the properties for a particular record

  assigned_to [String] The login name of a user that a bug is assigned to.
  component [String] The name of the Component that the bug is in.
  creation_time [DateTime] Searches for bugs that were created at this time or later. May not be an array.
  creator [String] The login name of the user who created the bug.
  id [Integer] The numeric id of the bug.
  last_change_time [DateTime] Searches for bugs that were modified at this time or later. May not be an array.
  limit [Integer] Limit the number of results returned to int records.
  offset [Integer] Used in conjunction with the limit argument, offset defines the starting position for the search. For example, given a search that would return 100 bugs, setting limit to 10 and offset to 10 would return bugs 11 through 20 from the set of 100.
  op_sys [String] The "Operating System" field of a bug.
  platform [String] The Platform (sometimes called "Hardware") field of a bug.
  priority [String] The Priority field on a bug.
  product [String] The name of the Product that the bug is in.
  creator [String] The login name of the user who reported the bug.
  resolution [String] The current resolution--only set if a bug is closed. You can find open bugs by searching for bugs with an empty resolution.
  severity [String] The Severity field on a bug.
  status [String] The current status of a bug (not including its resolution, if it has one, which is a separate field above).
  summary [String] Searches for substrings in the single-line Summary field on bugs. If you specify an array, then bugs whose summaries match any of the passed substrings will be returned.
  target_milestone [String] The Target Milestone field of a bug. Note that even if this Bugzilla does not have the Target Milestone field enabled, you can still search for bugs by Target Milestone. However, it is likely that in that case, most bugs will not have a Target Milestone set (it defaults to "---" when the field isn't enabled).
  qa_contact [String] The login name of the bug's QA Contact. Note that even if this Bugzilla does not have the QA Contact field enabled, you can still search for bugs by QA Contact (though it is likely that no bug will have a QA Contact set, if the field is disabled).
  url [String] The "URL" field of a bug.
  version [String] The Version field of a bug.
  whiteboard [String] Search the "Status Whiteboard" field on bugs for a substring. Works the same as the summary field described above, but searches the Status Whiteboard field.

 @api private