Skip to content

Commit

Permalink
Starting on some cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
qrush committed Oct 18, 2009
1 parent e344ac3 commit f12a306
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 20 deletions.
32 changes: 15 additions & 17 deletions app/models/rubygem.rb
@@ -1,21 +1,21 @@
class Rubygem < ActiveRecord::Base
include Pacecar

has_many :owners, :through => :ownerships, :source => :user
has_many :ownerships, :dependent => :destroy
has_many :owners, :through => :ownerships, :source => :user
has_many :ownerships, :dependent => :destroy
has_many :subscribers, :through => :subscriptions, :source => :user
has_many :subscriptions
has_many :versions, :dependent => :destroy do
has_many :versions, :dependent => :destroy do
def latest
self.find(:first)
end
end
has_one :linkset, :dependent => :destroy

validates_presence_of :name
validates_presence_of :name
validates_uniqueness_of :name

named_scope :with_versions, :conditions => ["versions_count > 0"]
named_scope :with_versions, :conditions => ["versions_count > 0"]
named_scope :with_one_version, :conditions => ["versions_count = 1"]

named_scope :search, lambda { |query| {
Expand All @@ -26,8 +26,7 @@ def latest
}

serialize_with_options do
only :name, :downloads, :rubyforge_project
methods :version, :authors, :info
methods :version, :authors, :info, :name, :downloads, :rubyforge_project
end

def validate
Expand Down Expand Up @@ -74,9 +73,9 @@ def to_param
name
end

def to_yaml
public_api_info.to_yaml
end
#def to_yaml
# public_api_info.to_yaml
#end

def with_downloads
"#{name} (#{downloads})"
Expand Down Expand Up @@ -117,15 +116,15 @@ def update_attributes_from_gem_specification!(version, spec)
end

def version
versions.current.number
versions.latest.number
end

def authors
versions.current.authors
versions.latest.authors
end

def info
versions.current.info
versions.latest.info
end

def reorder_versions
Expand All @@ -147,10 +146,9 @@ def find_or_initialize_version_from_spec(spec)
def public_api_info
{:name => name,
:downloads => downloads,
:version => versions.current.number,
:authors => versions.current.authors,
:info => versions.current.info,
:version => versions.latest.number,
:authors => versions.latest.authors,
:info => versions.latest.info,
:rubyforge_project => rubyforge_project }
end

end
6 changes: 3 additions & 3 deletions app/models/version.rb
Expand Up @@ -62,9 +62,9 @@ def to_title
"#{rubygem.name} (#{to_s})"
end

def to_yaml
public_api_info.to_yaml
end
#def to_yaml
# public_api_info.to_yaml
#end

def to_slug
param = number.dup
Expand Down

0 comments on commit f12a306

Please sign in to comment.