Skip to content
This repository has been archived by the owner on Jan 11, 2024. It is now read-only.

Commit

Permalink
Application booting, seems to work for the most part
Browse files Browse the repository at this point in the history
  • Loading branch information
qrush committed Jul 17, 2010
1 parent 1da640c commit dccafbd
Show file tree
Hide file tree
Showing 196 changed files with 1,797 additions and 4,826 deletions.
31 changes: 17 additions & 14 deletions Gemfile
@@ -1,13 +1,15 @@
source :rubygems

gem "rails", "2.3.5"
gem "rack", "1.0.1"
gem "rails", "3.0.0.beta4"
gem "rack", "1.1.0"

gem "aws-s3", "0.6.2", :require => "aws/s3"
gem "clearance", "0.8.2"
gem "clearance", "0.9.0.rc1"
gem "ddollar-pacecar", "1.1.6", :require => "pacecar"
gem "delayed_job", "2.0.3"
gem "gchartrb", "0.8", :require => "google_chart"
gem "gravtastic", "2.1.3"
gem "high_voltage", "0.9.0"
gem "hoptoad_notifier", "2.2.0"
gem "json", "1.2.0"
gem "rack-maintenance", "0.3.0", :require => "rack/maintenance"
Expand All @@ -22,15 +24,16 @@ gem "pg", "0.8.0"
# gem "mysql", "2.8.1"

group :test do
gem "cucumber", "0.3.101"
gem "factory_girl", "1.2.3"
gem "fakeweb", "1.2.6"
gem "nokogiri", "1.4.1"
gem "rack-test", "0.5.0", :require => "rack/test"
gem "redgreen", "1.2.2"
gem "rr", "0.10.11"
gem "shoulda", "2.10.2"
gem "treetop", "1.4.3"
gem "webrat", "0.5.3"
gem "webmock", "0.7.3"
gem "cucumber-rails", "0.3.2"
gem "factory_girl_rails", "1.0"

gem "fakeweb", "1.2.6"
gem "nokogiri", "1.4.1"
gem "rack-test", "0.5.4", :require => "rack/test"
gem "redgreen", "1.2.2"
gem "rr", "0.10.11"
gem "shoulda", "2.11.0"
gem "treetop", "1.4.5"
gem "webrat", "0.5.3"
gem "webmock", "0.7.3"
end
8 changes: 2 additions & 6 deletions Rakefile
@@ -1,10 +1,6 @@
require(File.join(File.dirname(__FILE__), 'config', 'boot'))

require File.expand_path('../config/application', __FILE__)
require 'rake'
require 'rake/testtask'
require 'rake/rdoctask'

require 'tasks/rails'
Rails::Application.load_tasks

desc "Run all tests and features"
task :default => [:test, :cucumber]
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/api/v1/rubygems_controller.rb
Expand Up @@ -19,7 +19,7 @@ def show
end

def create
gemcutter = Gemcutter.new(current_user, request.body, request.host_with_port)
gemcutter = Pusher.new(current_user, request.body, request.host_with_port)
gemcutter.process
render :text => gemcutter.message, :status => gemcutter.code
end
Expand Down
3 changes: 2 additions & 1 deletion app/helpers/rubygems_helper.rb
Expand Up @@ -41,6 +41,7 @@ def clippy(text, bgcolor='#AADD44')
/>
</object>
EOF
html.html_safe
end

def subscribe_link(gem)
Expand Down Expand Up @@ -70,7 +71,7 @@ def unsubscribe_link(gem)
:style => gem.subscribers.find_by_id(current_user.try(:id)) ? 'display:inline-block' : 'display:none'
}) if signed_in?
end

def download_link(version)
link_to "Download", "/downloads/#{version.full_name}.gem", :id => :download
end
Expand Down
4 changes: 2 additions & 2 deletions app/models/dependency.rb
Expand Up @@ -8,8 +8,8 @@ class Dependency < ActiveRecord::Base
validates_presence_of :requirements
validates_inclusion_of :scope, :in => %w( development runtime )

named_scope :development, { :conditions => { :scope => 'development' }}
named_scope :runtime, { :conditions => { :scope => 'runtime' }}
scope :development, { :conditions => { :scope => 'development' }}
scope :runtime, { :conditions => { :scope => 'runtime' }}

attr_accessor :gem_dependency

Expand Down
2 changes: 1 addition & 1 deletion lib/gemcutter.rb → app/models/pusher.rb
@@ -1,4 +1,4 @@
class Gemcutter
class Pusher
if Rails.env.development? || Rails.env.test?
include Vault::FS
else
Expand Down
8 changes: 4 additions & 4 deletions app/models/rubygem.rb
Expand Up @@ -18,21 +18,21 @@ def latest
validates_presence_of :name
validates_uniqueness_of :name

named_scope :with_versions,
scope :with_versions,
:conditions => "rubygems.id IN (SELECT rubygem_id FROM versions where versions.indexed IS true)"

named_scope :with_one_version,
scope :with_one_version,
:select => 'rubygems.*',
:joins => :versions,
:group => column_names.map{ |name| "rubygems.#{name}" }.join(', '),
:having => 'COUNT(versions.id) = 1'

named_scope :name_is, lambda { |name| {
scope :name_is, lambda { |name| {
:conditions => ["name = ?", name.strip],
:limit => 1 }
}

named_scope :search, lambda { |query| {
scope :search, lambda { |query| {
:conditions => ["(upper(name) like upper(:query) or upper(versions.description) like upper(:query))",
{:query => "%#{query.strip}%"}],
:include => [:versions],
Expand Down
16 changes: 8 additions & 8 deletions app/models/version.rb
Expand Up @@ -8,25 +8,25 @@ class Version < ActiveRecord::Base

validates_format_of :number, :with => /\A#{Gem::Version::VERSION_PATTERN}\z/

named_scope :owned_by, lambda { |user|
scope :owned_by, lambda { |user|
{ :conditions => { :rubygem_id => user.rubygem_ids } }
}

named_scope :subscribed_to_by, lambda { |user|
scope :subscribed_to_by, lambda { |user|
{ :conditions => { :rubygem_id => user.subscribed_gem_ids },
:order => 'created_at desc' }
}

named_scope :with_associated, {
scope :with_associated, {
:conditions => ["versions.rubygem_id IN (SELECT versions.rubygem_id FROM versions GROUP BY versions.rubygem_id HAVING COUNT(versions.id) > 1)"],
:include => :rubygem,
:order => "versions.built_at desc"
}

named_scope :latest, { :conditions => { :latest => true }}
named_scope :with_deps, { :include => { :dependencies => :rubygem }}
named_scope :prerelease, { :conditions => { :prerelease => true }}
named_scope :release, { :conditions => { :prerelease => false }}
scope :latest, { :conditions => { :latest => true }}
scope :with_deps, { :include => { :dependencies => :rubygem }}
scope :prerelease, { :conditions => { :prerelease => true }}
scope :release, { :conditions => { :prerelease => false }}

before_save :update_prerelease
after_save :reorder_versions
Expand Down Expand Up @@ -71,7 +71,7 @@ def self.find_from_slug!(rubygem_id, slug)
end

def self.platforms
find(:all, :select => 'platform').map(&:platform).uniq
select('platform').map(&:platform).uniq
end

def platformed?
Expand Down
4 changes: 2 additions & 2 deletions app/models/web_hook.rb
Expand Up @@ -2,8 +2,8 @@ class WebHook < ActiveRecord::Base
belongs_to :user
belongs_to :rubygem

named_scope :global, :conditions => {:rubygem_id => nil}
named_scope :specific, :conditions => "rubygem_id is not null"
scope :global, :conditions => {:rubygem_id => nil}
scope :specific, :conditions => "rubygem_id is not null"

GLOBAL_PATTERN = '*'

Expand Down
60 changes: 28 additions & 32 deletions app/views/layouts/application.html.erb
Expand Up @@ -5,57 +5,53 @@
<link rel="shortcut icon" href="/favicon.ico" type="image/x-icon">
<link rel="fluid-icon" href="/apple-touch-icon.png"/>
<link rel="search" type="application/opensearchdescription+xml" title="<%=t :title %>" href="/opensearch.xml">
<%= stylesheet_link_tag "reset", "960", "screen", :cache => true %>
<%= stylesheet_link_tag "reset", "960", "screen", "humanmsg", :cache => true %>
<!--[if IE 7]>
<%= stylesheet_link_tag "ie7" %>
<![endif]-->
<%= render "layouts/feeds" %>
<title><%= page_title %></title>
</head>
<body>
<% flash.each do |name, msg| %>
<div id="flash_<%= name %>"><%= msg %></div>
<% end %>
<div class="container_12">
<div class="prefix_1 grid_4 header">
<h1><%= link_to t(:title), root_url, :title => "Home" %></h1>
</div>
<div class="grid_6 suffix_1 nav">
<div id="nav-cap">
<div id="nav">
<% if signed_in? %>
<div id="user-info">
<a href="<%= edit_profile_path %>">
<%= image_tag(current_user.gravatar_url(:size => 32), :id => "user_gravatar") %>
<span><%= truncate(current_user.name) %></span>
</a>
</div>
<ul id="signed_in">
<li id="all-gems"><%= link_to "all gems", rubygems_url %></li>
<li id="dashboard"><%= link_to "dashboard", dashboard_url %></li>
<li id="sign-out"><%= link_to "sign out", sign_out_path %></li>
</ul>
<% else %>
<ul id="signed_out">
<li id="all-gems"><%= link_to "all gems", rubygems_url %></li>
<li id="sign-in"><%= link_to "sign in", sign_in_path %></li>
<li id="sign-up"><%= link_to "sign up", sign_up_path %></li>
</ul>
<% end %>
<% if signed_in? %>
<a href="<%= profile_url%>">
<%= image_tag(current_user.gravatar_url(:size => 24), :id => "user_gravatar") %>
<span><%= truncate(current_user.name) %></span>
</a>
<ul>
<li><%= link_to "all gems", rubygems_url %></li>
<li><%= link_to "dashboard", dashboard_url %></li>
<li><%= link_to "logout", sign_out_path %></li>
</ul>
<% else %>
<ul id="signed_out">
<li><%= link_to "all gems", rubygems_url %></li>
<li><%= link_to "sign in", sign_in_path %></li>
<li><%= link_to "sign up", sign_up_path %></li>
</ul>
<% end %>
<%= form_tag search_url, :method => :get do %>
<div class="text_field">
<%= text_field_tag :query, params[:query] ? h(params[:query]) : "Search gems&hellip;" %>
</div>
</div>
<% form_tag search_url, :id => "main-search", :method => :get do %>
<%= text_field_tag :query, params[:query] ? h(params[:query]) : "Search gems&hellip;" %>
<%= submit_tag 'Search', :id => 'search_submit', :name => nil %>
<% end %>
</div>
<div class="prefix_1 grid_10 suffix_1 main">
<% flash.each do |name, msg| %>
<div id="flash_<%= name %>"><%= msg %></div>
<% end %>
<% if content_for?(:fold) %>
<div class="fold">
<%= yield :fold %>
</div>
<% end %>
<div class="info clearfix">
<div class="info">
<div class="title">
<% if @title %>
<h2><%= link_to @title, "" %></h2>
Expand All @@ -77,12 +73,12 @@
<%= link_to "Code", "http://github.com/rubygems/gemcutter" %>
<%= link_to "Discuss", "http://groups.google.com/group/gemcutter" %>
<%= link_to "Stats", statistics_url %>
<%= link_to "designed by #{image_tag('thoughtbot.png')}", "http://thoughtbot.com", :title => "Designed by Thoughtbot", :id => "thoughtbot" %>
<%= link_to "supported by #{image_tag('rubycentral.png')}", "http://rubycentral.org", :title => "Supported by Ruby Central", :id => "rubycentral" %>
<%= link_to "designed by #{image_tag('thoughtbot.png')}".html_safe, "http://thoughtbot.com", :title => "Designed by Thoughtbot", :id => "thoughtbot" %>
<%= link_to "supported by #{image_tag('rubycentral.png')}".html_safe, "http://rubycentral.org", :title => "Supported by Ruby Central", :id => "rubycentral" %>
</div>
</div>
</div>
<%= javascript_include_tag "jquery", "jquery.easing.1.3", "application", :cache => true %>
<%= javascript_include_tag "jquery", "jquery.easing.1.3", "humanmsg", "application", :cache => true %>
<script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
Expand Down
2 changes: 1 addition & 1 deletion app/views/rubygems/index.html.erb
Expand Up @@ -6,7 +6,7 @@
</ol>
</div>
<p class="entries">
<%= page_entries_info @gems, :entry_name => 'gem' %>
<%= page_entries_info(@gems, :entry_name => 'gem').html_safe %>
</p>
<div class="gems border">
<ol>
Expand Down
4 changes: 4 additions & 0 deletions config.ru
@@ -0,0 +1,4 @@
# This file is used by Rack-based servers to start the application.

require ::File.expand_path('../config/environment', __FILE__)
run Gemcutter::Application
15 changes: 15 additions & 0 deletions config/application.rb
@@ -0,0 +1,15 @@
require File.expand_path('../boot', __FILE__)

require 'rails/all'

Bundler.require(:default, Rails.env) if defined?(Bundler)

module Gemcutter
class Application < Rails::Application
config.time_zone = 'UTC'
config.action_mailer.delivery_method = :sendmail
config.load_paths << Rails.root.join('app', 'middleware')
config.encoding = "utf-8"
config.filter_parameters += [:password]
end
end

0 comments on commit dccafbd

Please sign in to comment.