[25804] users/jberry/mpwa

source_changes at macosforge.org source_changes at macosforge.org
Sat Jun 2 13:04:34 PDT 2007


Revision: 25804
          http://trac.macosforge.org/projects/macports/changeset/25804
Author:   jberry at macports.org
Date:     2007-06-02 13:04:33 -0700 (Sat, 02 Jun 2007)

Log Message:
-----------
mpwa: remove obsolete port_pkg_file model, view, and controller

Removed Paths:
-------------
    users/jberry/mpwa/app/controllers/port_pkg_file_controller.rb
    users/jberry/mpwa/app/helpers/port_pkg_file_helper.rb
    users/jberry/mpwa/app/models/port_pkg_file.rb
    users/jberry/mpwa/app/views/port_pkg_file/
    users/jberry/mpwa/test/fixtures/port_pkg_files.yml
    users/jberry/mpwa/test/functional/port_pkg_file_controller_test.rb
    users/jberry/mpwa/test/unit/port_pkg_file_test.rb

Deleted: users/jberry/mpwa/app/controllers/port_pkg_file_controller.rb
===================================================================
--- users/jberry/mpwa/app/controllers/port_pkg_file_controller.rb	2007-06-02 20:00:40 UTC (rev 25803)
+++ users/jberry/mpwa/app/controllers/port_pkg_file_controller.rb	2007-06-02 20:04:33 UTC (rev 25804)
@@ -1,65 +0,0 @@
-class PortPkgFileController < ApplicationController
-  def index
-    list
-    render :action => 'list'
-  end
-
-  # GETs should be safe (see http://www.w3.org/2001/tag/doc/whenToUseGet.html)
-  verify :method => :post, :only => [ :destroy, :create, :update ],
-         :redirect_to => { :action => :list }
-
-  def list
-    @port_pkg_file_pages, @port_pkg_files = paginate :port_pkg_files, :per_page => 10
-  end
-
-  def show
-    @port_pkg_file = PortPkgFile.find(params[:id])
-  end
-
-  def new
-    @port_pkg_file = PortPkgFile.new
-  end
-
-  def create
-    @port_pkg_file = PortPkgFile.new(params[:port_pkg_file])
-    if @port_pkg_file.save
-      flash[:notice] = 'PortPkgFile was successfully created.'
-      redirect_to :action => 'list'
-    else
-      render :action => 'new'
-    end
-  end
-
-  def edit
-    @port_pkg_file = PortPkgFile.find(params[:id])
-  end
-
-  def update
-    @port_pkg_file = PortPkgFile.find(params[:id])
-    if @port_pkg_file.update_attributes(params[:port_pkg_file])
-      flash[:notice] = 'PortPkgFile was successfully updated.'
-      redirect_to :action => 'show', :id => @port_pkg_file
-    else
-      render :action => 'edit'
-    end
-  end
-
-  def destroy
-    PortPkgFile.find(params[:id]).destroy
-    redirect_to :action => 'list'
-  end
-  
-  def emit
-    file = PortPkgFile.find(params[:id])
-    send_data file.data, :filename => file.file_path, :type => file.mime_type, :disposition => 'inline'
-
-    # Bump download counts for the file, and for the portpkg too if the file is a portpkg.
-    file.increment! 'download_count'
-    if (file.file_path == "portpkg.portpkg")
-      file.port_pkg.increment! 'download_count'
-    end
-  end
-  
-  private :create, :edit, :update, :destroy
-  
-end

Deleted: users/jberry/mpwa/app/helpers/port_pkg_file_helper.rb
===================================================================
--- users/jberry/mpwa/app/helpers/port_pkg_file_helper.rb	2007-06-02 20:00:40 UTC (rev 25803)
+++ users/jberry/mpwa/app/helpers/port_pkg_file_helper.rb	2007-06-02 20:04:33 UTC (rev 25804)
@@ -1,2 +0,0 @@
-module PortPkgFileHelper
-end

Deleted: users/jberry/mpwa/app/models/port_pkg_file.rb
===================================================================
--- users/jberry/mpwa/app/models/port_pkg_file.rb	2007-06-02 20:00:40 UTC (rev 25803)
+++ users/jberry/mpwa/app/models/port_pkg_file.rb	2007-06-02 20:04:33 UTC (rev 25804)
@@ -1,101 +0,0 @@
-require 'stringio'
-
-require 'file_blob'
-require 'mpwa-conf'
-
-class PortPkgFileException < RuntimeError
-end
-
-class PortPkgFile < ActiveRecord::Base
-    belongs_to :port_pkg
-    before_destroy { |f| FileBlob.delete_all "port_pkg_file_id = #{f.id}" }
-    #has_many :file_blob -- we don't use this association to avoid keeping many blobs in memory
-    
-    def PortPkgFile.from_path(port_pkg, path, path_root = nil, options = {})
-        port_pkg_file = PortPkgFile.new(:port_pkg => port_pkg)
-        return port_pkg_file.read_from_path(path, path_root, options)
-    end
-    
-    def PortPkgFile.mimetype_from_path(path)
-        mimetype = /^([^;]+)(;\w*(.*))?/.match(`#{MPWA::FILETOOL} --mime --brief #{path}`)[1]
-    end
-
-    def read_from_path(path, path_root = nil, options = {})
-        mimetype = options[:mimetype] || PortPkgFile.mimetype_from_path(path)
-        reported_path = options[:filename] || path_root.nil? ?
-            path.to_s : Pathname.new(path).relative_path_from(path_root).to_s
-            
-        File.open(path, "r") { |f| read_from_file(f, :path => reported_path, :mimetype => mimetype) }
-        return self
-    end
-    
-    def read_from_file(file, options = {})
-        # Save file meta information
-        self.file_path = options[:path]
-        self.length = 0
-        self.mime_type = options[:mimetype] || 'application/octet-stream'
-        
-        # Save so that we get a primary id for the blob associations
-        self.save
-        
-        # Create digesters for our digests
-        md5 = Digest::MD5.new
-        sha256 = Digest::SHA256.new
-        
-        # Read the file, creating blobs of data as we go
-        buf = ''
-        length = 0
-        seq = 0
-        while (file.read(MPWA::MAX_BLOB_SIZE, buf))
-            # Update the digests
-            md5.update buf
-            sha256.update buf
-            
-            # Create a new bob
-            blob = FileBlob.create(:port_pkg_file => self, :data => buf, :sequence => seq)
-
-            length += buf.length
-            seq += 1
-        end
-        
-        # Finish up
-        self.md5 = md5.hexdigest
-        self.sha256 = sha256.hexdigest
-        self.length = length
-    
-        self.save
-        return self  
-    end
-    
-    def write_to_file(file)
-        # Create a digester so that we can verify the digest
-        digest = Digest::MD5.new
-
-        # Page in the blobs, writing to file as we go
-        length = 0
-        seq = 0
-        while (length < self.length)
-            blob = FileBlob.find(:first, :conditions => "port_pkg_file_id=#{self.id} and sequence=#{seq}")
-            raise PortPkgFileException, "port_pkg_file missing segment" if !blob
-            
-            buf = blob.data
-            digest.update buf
-            
-            file.write(buf)
-            length += buf.length
-            
-            seq += 1
-        end
-        
-        # Verify the digest
-        raise PortPkgFileException, "digest mismatch while reading port_pkg_file #{self.id}" if digest.hexdigest != self.md5
-    end
-    
-    def data()
-        StringIO.open("rw") do |f|
-            write_to_file(f)
-            f.string
-        end
-    end
-    
-end

Deleted: users/jberry/mpwa/test/fixtures/port_pkg_files.yml
===================================================================
--- users/jberry/mpwa/test/fixtures/port_pkg_files.yml	2007-06-02 20:00:40 UTC (rev 25803)
+++ users/jberry/mpwa/test/fixtures/port_pkg_files.yml	2007-06-02 20:04:33 UTC (rev 25804)
@@ -1,5 +0,0 @@
-# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html
-one:
-  id: 1
-two:
-  id: 2

Deleted: users/jberry/mpwa/test/functional/port_pkg_file_controller_test.rb
===================================================================
--- users/jberry/mpwa/test/functional/port_pkg_file_controller_test.rb	2007-06-02 20:00:40 UTC (rev 25803)
+++ users/jberry/mpwa/test/functional/port_pkg_file_controller_test.rb	2007-06-02 20:04:33 UTC (rev 25804)
@@ -1,92 +0,0 @@
-require File.dirname(__FILE__) + '/../test_helper'
-require 'port_pkg_file_controller'
-
-# Re-raise errors caught by the controller.
-class PortPkgFileController; def rescue_action(e) raise e end; end
-
-class PortPkgFileControllerTest < Test::Unit::TestCase
-  fixtures :port_pkg_files
-
-  def setup
-    @controller = PortPkgFileController.new
-    @request    = ActionController::TestRequest.new
-    @response   = ActionController::TestResponse.new
-
-    @first_id = port_pkg_files(:first).id
-  end
-
-  def test_index
-    get :index
-    assert_response :success
-    assert_template 'list'
-  end
-
-  def test_list
-    get :list
-
-    assert_response :success
-    assert_template 'list'
-
-    assert_not_nil assigns(:port_pkg_files)
-  end
-
-  def test_show
-    get :show, :id => @first_id
-
-    assert_response :success
-    assert_template 'show'
-
-    assert_not_nil assigns(:port_pkg_file)
-    assert assigns(:port_pkg_file).valid?
-  end
-
-  def test_new
-    get :new
-
-    assert_response :success
-    assert_template 'new'
-
-    assert_not_nil assigns(:port_pkg_file)
-  end
-
-  def test_create
-    num_port_pkg_files = PortPkgFile.count
-
-    post :create, :port_pkg_file => {}
-
-    assert_response :redirect
-    assert_redirected_to :action => 'list'
-
-    assert_equal num_port_pkg_files + 1, PortPkgFile.count
-  end
-
-  def test_edit
-    get :edit, :id => @first_id
-
-    assert_response :success
-    assert_template 'edit'
-
-    assert_not_nil assigns(:port_pkg_file)
-    assert assigns(:port_pkg_file).valid?
-  end
-
-  def test_update
-    post :update, :id => @first_id
-    assert_response :redirect
-    assert_redirected_to :action => 'show', :id => @first_id
-  end
-
-  def test_destroy
-    assert_nothing_raised {
-      PortPkgFile.find(@first_id)
-    }
-
-    post :destroy, :id => @first_id
-    assert_response :redirect
-    assert_redirected_to :action => 'list'
-
-    assert_raise(ActiveRecord::RecordNotFound) {
-      PortPkgFile.find(@first_id)
-    }
-  end
-end

Deleted: users/jberry/mpwa/test/unit/port_pkg_file_test.rb
===================================================================
--- users/jberry/mpwa/test/unit/port_pkg_file_test.rb	2007-06-02 20:00:40 UTC (rev 25803)
+++ users/jberry/mpwa/test/unit/port_pkg_file_test.rb	2007-06-02 20:04:33 UTC (rev 25804)
@@ -1,10 +0,0 @@
-require File.dirname(__FILE__) + '/../test_helper'
-
-class PortPkgFileTest < Test::Unit::TestCase
-  fixtures :port_pkg_files
-
-  # Replace this with your real tests.
-  def test_truth
-    assert true
-  end
-end

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.macosforge.org/pipermail/macports-changes/attachments/20070602/a95c87f3/attachment.html


More information about the macports-changes mailing list