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

Hi! I cleaned up your code for you! #1

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 33 additions & 33 deletions CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@

# runs the one statement 10 times
script/benchmarker 10 'Person.expensive_method(10)'

# pits the two statements against each other with 50 runs each
script/benchmarker 50 'Person.expensive_method(10)' 'Person.cheap_method(10)'

Expand Down Expand Up @@ -227,18 +227,18 @@
* Changed .htaccess to allow dispatch.* to be called from a sub-directory as part of the push with Action Pack to make Rails work on non-vhost setups #826 [Nicholas Seckar/Tobias Luetke]

* Added script/runner which can be used to run code inside the environment by eval'ing the first parameter. Examples:

./script/runner 'ReminderService.deliver'
./script/runner 'Mailer.receive(STDIN.read)'

This makes it easier to do CRON and postfix scripts without actually making a script just to trigger 1 line of code.

* Fixed webrick_server cookie handling to allow multiple cookes to be set at once #800, #813 [[email protected]]

* Fixed the Rakefile's interaction with postgresql to:

1. Use PGPASSWORD and PGHOST in the environment to fix prompting for
passwords when connecting to a remote db and local socket connections.
1. Use PGPASSWORD and PGHOST in the environment to fix prompting for
passwords when connecting to a remote db and local socket connections.
2. Add a '-x' flag to pg_dump which stops it dumping privileges #807 [rasputnik]
3. Quote the user name and use template0 when dumping so the functions doesn't get dumped too #855 [pburleson]
4. Use the port if available #875 [madrobby]
Expand Down Expand Up @@ -301,10 +301,10 @@

Controller: components/list/items_controller.rb
(holds a List::ItemsController class with uses_component_template_root called)

Model : components/list/item.rb
(namespace is still shared, so an Item model in app/models will take precedence)

Views : components/list/items/show.rhtml


Expand Down Expand Up @@ -397,11 +397,11 @@

* Fixed dependency management to happen in a unified fashion for Active Record and Action Pack using the new Dependencies module. This means that
the environment options needs to change from:

Before in development.rb:
ActionController::Base.reload_dependencies = true  
ActiveRecord::Base.reload_associations     = true

Now in development.rb:
Dependencies.mechanism = :load

Expand Down Expand Up @@ -455,41 +455,41 @@

* Added breakpoint support through the script/breakpointer client. This means that you can break out of execution at any point in
the code, investigate and change the model, AND then resume execution! Example:

class WeblogController < ActionController::Base
def index
@posts = Post.find_all
breakpoint "Breaking out from the list"
end
end
So the controller will accept the action, run the first line, then present you with a IRB prompt in the breakpointer window.

So the controller will accept the action, run the first line, then present you with a IRB prompt in the breakpointer window.
Here you can do things like:

Executing breakpoint "Breaking out from the list" at .../webrick_server.rb:16 in 'breakpoint'

>> @posts.inspect
=> "[#<Post:0x14a6be8 @attributes={\"title\"=>nil, \"body\"=>nil, \"id\"=>\"1\"}>,
=> "[#<Post:0x14a6be8 @attributes={\"title\"=>nil, \"body\"=>nil, \"id\"=>\"1\"}>,
#<Post:0x14a6620 @attributes={\"title\"=>\"Rails you know!\", \"body\"=>\"Only ten..\", \"id\"=>\"2\"}>]"
>> @posts.first.title = "hello from a breakpoint"
=> "hello from a breakpoint"

...and even better is that you can examine how your runtime objects actually work:

>> f = @posts.first
>> f = @posts.first
=> #<Post:0x13630c4 @attributes={"title"=>nil, "body"=>nil, "id"=>"1"}>
>> f.
Display all 152 possibilities? (y or n)

Finally, when you're ready to resume execution, you press CTRL-D

* Changed environments to be configurable through an environment variable. By default, the environment is "development", but you
can change that and set your own by configuring the Apache vhost with a string like (mod_env must be available on the server):

SetEnv RAILS_ENV production

...if you're using WEBrick, you can pick the environment to use with the command-line parameters -e/--environment, like this:

ruby public/dispatcher.servlet -e production

* Added a new default environment called "development", which leaves the production environment to be tuned exclusively for that.
Expand All @@ -504,11 +504,11 @@

app/controllers/account_controller.rb # URL: /account/
app/controllers/admin/account_controller.rb # URL: /admin/account/

NOTE: You need to update your public/.htaccess with the new rules to pick it up

* Added reloading for associations and dependencies under cached environments like FastCGI and mod_ruby. This makes it possible to use
those environments for development. This is turned on by default, but can be turned off with
* Added reloading for associations and dependencies under cached environments like FastCGI and mod_ruby. This makes it possible to use
those environments for development. This is turned on by default, but can be turned off with
ActiveRecord::Base.reload_associations = false and ActionController::Base.reload_dependencies = false in production environments.

* Added support for sub-directories in app/models. So now you can have something like Basecamp with:
Expand All @@ -517,7 +517,7 @@
app/models/project
app/models/participants
app/models/settings

It's poor man's namespacing, but only for file-system organization. You still require files just like before.
Nothing changes inside the files themselves.

Expand All @@ -537,7 +537,7 @@
@david.projects << @new_project
breakpoint "Let's have a closer look at @david"
end

You need to install dev-utils yourself for this to work ("gem install dev-util").

* Added shared generator behavior so future upgrades should be possible without manually copying over files [Jeremy Kemper]
Expand Down Expand Up @@ -596,7 +596,7 @@

*0.7.0*

* Added an optional second argument to the new_model script that allows the programmer to specify the table name,
* Added an optional second argument to the new_model script that allows the programmer to specify the table name,
which will used to generate a custom table_name method in the model and will also be used in the creation of fixtures.
[Kevin Radloff]

Expand All @@ -610,8 +610,8 @@

* create_fixtures in both the functional and unit test helper now turns off the log during fixture generation
and can generate more than one fixture at a time. Which makes it possible for assignments like:
@people, @projects, @project_access, @companies, @accounts =

@people, @projects, @project_access, @companies, @accounts =
create_fixtures "people", "projects", "project_access", "companies", "accounts"

* Upgraded to Action Pack 0.8.5 (locally-scoped variables, partials, advanced send_file)
Expand All @@ -623,7 +623,7 @@

* No longer specifies a template for rdoc, so it'll use whatever is default (you can change it in the rakefile)

* The new_model generator will now use the same rules for plural wordings as Active Record
* The new_model generator will now use the same rules for plural wordings as Active Record
(so Category will give categories, not categorys) [Kevin Radloff]

* dispatch.fcgi now sets FCGI_PURE_RUBY to true to ensure that it's the Ruby version that's loaded [danp]
Expand All @@ -649,13 +649,13 @@

* Added environments that can be included from any script to get the full Active Record and Action Controller
context running. This can be used by maintenance scripts or to interact with the model through IRB. Example:

require 'config/environments/production'

for account in Account.find_all
account.recalculate_interests
end

A short migration script for an account model that had it's interest calculation strategy changed.

* Accessing the index of a controller with "/weblog" will now redirect to "/weblog/" (only on Apache, not WEBrick)
Expand All @@ -678,7 +678,7 @@

* Added lib in root as a place to store app specific libraries

* Added lib and vendor to load_path, so anything store within can be loaded directly.
* Added lib and vendor to load_path, so anything store within can be loaded directly.
Hence lib/redcloth.rb can be loaded with require "redcloth"

* Upgraded to Action Pack 0.7.8 (lots of fixes)
Expand All @@ -692,7 +692,7 @@

* Updated the generated template stubs to valid XHTML files

* Ensure that controllers generated are capitalized, so "new_controller TodoLists"
* Ensure that controllers generated are capitalized, so "new_controller TodoLists"
gives the same as "new_controller Todolists" and "new_controller todolists".


Expand Down
12 changes: 6 additions & 6 deletions README
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
Cat Herder (source code to pdxruby.org)

This application was written way back in late 2005 at a group hackfest hosted
This application was written way back in late 2005 at a group hackfest hosted
by the Portland Ruby Brigade. We wanted a way to propose and RSVP for events
without requiring any particular person or group to manage a calendar for
everyone else.
without requiring any particular person or group to manage a calendar for
everyone else.

Anyone can register for an account, propose an event, and sign up to attend
Anyone can register for an account, propose an event, and sign up to attend
other people's events. There is also some basic support for aggregation of
members' RSS feeds, and feedback from event participants, but the primary use
of the system is still as a simple event calendar.

The file doc/TODO contains a few miscellaneous items we've thought about
The file doc/TODO contains a few miscellaneous items we've thought about
changing over the years, but overall this whole codebase is probably of more
interest as a historical oddity than as a useful application for other people
to use. It uses a mish-mash of APIs, coding styles, and tests contributed by
about a dozen different maintainers over the last three years, and certainly
about a dozen different maintainers over the last three years, and certainly
shows its age when compared to a shiny new legacy-free Rails 2 application.
2 changes: 1 addition & 1 deletion app/controllers/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def authenticate
def authenticated?
session[:member] && Member.find(session[:member].id)
end

# check to see if the currently authenticated member is
# the member with the given id
def member_is_this_member?(id)
Expand Down
28 changes: 14 additions & 14 deletions app/models/event.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,60 +20,60 @@ class Event < ActiveRecord::Base
validates_each :status do |rec,attr|
rec.errors.add attr, 'that status is not one I know about' unless EVENT_STATUS.has_value? rec.send(attr)
end

# make sure the start time is in the future (unless it is already past)
validates_each :starts_at do |rec, attr|
unless rec.ends_at.nil? || rec.ends_at < Time.now
rec.errors.add attr, 'must be later than now' if rec.starts_at && rec.starts_at < Time.now
end
end

# make sure the end time is later than the start time (i.e. interval is positive)
validates_each :ends_at do |rec, attr|
rec.errors.add attr, 'must be later than start time' if rec.starts_at && rec.ends_at && rec.ends_at < rec.starts_at
end

def cancelled?
self.status == EVENT_STATUS[:canceled]
end

def cancel!
self.status = EVENT_STATUS[:canceled]
end

def active?
self.status == EVENT_STATUS[:active]
end

def active!
self.status = EVENT_STATUS[:active]
end

def has_participant(member)
self.participants.map {|p| p.member }.member?(member)
end

def started?
self.starts_at < Time.now
end

def ended?
self.ends_at < Time.now
end

def feedbacks
self.participants.map {|p| p.feedbacks }.flatten
end

def unclaimed?
nil == self.member
end

def Event.find_upcoming(limit=10)
find(:all, :limit => limit, :order => 'starts_at desc',
find(:all, :limit => limit, :order => 'starts_at desc',
:conditions => ['starts_at > ? and status = ?', Time.now, EVENT_STATUS[:active]])
end

def Event.find_recent(limit=10)
find(:all, :limit => limit, :order => 'ends_at desc')
find(:all, :limit => limit, :order => 'ends_at desc',
Expand Down
18 changes: 9 additions & 9 deletions app/models/mail_bot.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
class MailBot < ActionMailer::Base
SITE_FROM_ADDRESS = '[email protected]'
SUBJECT_PREFIX = '[pdxruby] '

helper ActionView::Helpers::UrlHelper

# New user signup message
def signup_message(ctrl, member)
self.site_headers(member, "Account signup")
Expand All @@ -21,43 +21,43 @@ def feedback_message(ctrl, event)
self.site_headers(event.member, "Feedback added for event #{event.name}")
@body = { :controller => ctrl, :event => event }
end

# Notify all event participants of changes to event details
def change_message(ctrl, event)
rcpt = event.participants.map {|p| p.member}
self.site_headers(rcpt, "Event #{event.name} details changed")
@body = { :controller => ctrl, :event => event }
end

# Notify all event participants of event cancellation
def cancel_message(ctrl, event)
rcpt = event.participants.map {|p| p.member}
self.site_headers(rcpt, "Event #{event.name} has been cancelled")
@body = { :controller => ctrl, :event => event }
end

# Notify event owner of RSVP for their event
def rsvp_message(ctrl, participant)
event = participant.event
self.site_headers(event.member, "New participant signup for event #{event.name}")
@body = { :controller => ctrl, :participant => participant }
end

# Notify event owner of new feedback
def feedback_message(ctrl, feedback)
event = feedback.participant.event
self.site_headers(event.member, "New feedback for event #{event.name}")
@body = { :controller => ctrl, :feedback => feedback }
end
# the deliver_new_event_message method should be called seperately for

# the deliver_new_event_message method should be called seperately for
# each site member (i.e., within a Member.find(:all) { ... } block) to
# avoid exposing all member email addresses
def new_event_message(ctrl, member, event)
self.site_headers(member, "New event created")
@body = { :controller => ctrl, :event => event, :member => member }
end

def site_headers(rcpt, subj)
@recipients = rcpt.respond_to?(:map) ? rcpt.map {|m| m.email } : rcpt.email
@from = SITE_FROM_ADDRESS
Expand Down
Loading