This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ApplicationController < ActionController | |
def wiki | |
@wiki ||= if (current_user.admin?) | |
AdminWiki.new | |
else | |
ReadonlyWiki.new | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace :cron | |
task :validate_models => [:environment] do | |
UseCases::ValidatesPostsAndComments.new.run | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace :cron | |
task :validate_models => [:environment] do | |
[Post, Comment].each do |klass| | |
klass.all.each do |obj| | |
ErrorMailer.report_errors('me@example.com', obj) unless obj.valid? | |
end | |
end | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class PublishesPosts < Struct.new(:post_id, :ui) | |
def run | |
Blog.lookup_post(post_id, self) | |
end | |
def post_found(post) | |
post.publish | |
ui.post_published(post) | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class PublishesPosts < Struct.new(:post_id, :ui) | |
def run | |
Blog.lookup_post(post_id, PublishesAPost.new(ui)) | |
end | |
end | |
class PublishesAPost < Struct.new(:ui) | |
def post_found(post) | |
post.publish | |
ui.post_published(post) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class PublishesPosts < Struct.new(:post_id, :ui) | |
def run | |
Blog.lookup_post(post_id) do |result| | |
result.success => lambda {|post| post.publish; ui.post_published(post) }, | |
result.failure => lambda {|post_id| ui.no_such_post(post_id) }) | |
end | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class PublishesPosts < Struct.new(:post_id, :ui) | |
def run | |
Blog.lookup_post(post_id, | |
:success => lambda {|post| post.publish; ui.post_published(post) }, | |
:failure => lambda {|post_id| ui.no_such_post(post_id) }) | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Post = Class.new # Just a placeholder to make the tests run | |
class PublishesPosts < Struct.new(:post_id, :ui) | |
def run | |
post = Post.find_by_id(post_id) | |
if post | |
post.publish | |
ui.post_published(post) | |
else |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ ls -l /home/kevin/.rvm/gems/ruby-1.9.3-p194@global/bin | |
total 16 | |
-rwxr-xr-x 1 kevin kevin 395 Jun 18 20:49 bundle | |
-rwxr-xr-x 1 kevin kevin 384 Jun 18 20:49 rake | |
-rwxr-xr-x 1 kevin kevin 444 Jun 18 20:49 rubygems-bundler-uninstaller | |
-rwxrwxr-x 1 kevin kevin 296 Jun 18 19:56 ruby_noexec_wrapper |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ uname -a | |
Linux kr-laptop 3.2.0-25-generic #40-Ubuntu SMP Wed May 23 20:30:51 UTC 2012 x86_64 x86_64 x86_64 GNU/Linux | |
$ rvm implode | |
# and edit .bashrc to remove RVM stuff there | |
# No RVM packages installed, no RVM gem, no other RVM config files found | |
$ curl -L https://get.rvm.io | bash -s stable | |
#... | |
rvm 1.14.2 (stable) by Wayne E. Seguin <wayneeseguin@gmail.com>, Michal Papis <mpapis@gmail.com> [https://rvm.io/] | |
$ . /home/kevin/.rvm/scripts/rvm |