working on storing files to Amazon’s S3 web service. Here’s what I’ve come up with so far:
1
2
3
4
5
6
7
8
9
10
11
12
| require 'aws/s3'
def aws_connect
@aws_connect ||= AWS::S3::Base.establish_connection!(
:access_key_id=>AWS_KEY,
:secret_access_key=>AWS_SECRET
)
end
def aws_upload(file,bucket=AWS_BUCKET)
aws_connect
AWS::S3::S3Object.store(file,open(file),bucket)
end |
then a:
Will upload the the file to the Amazon bucket. Pretty simple.
Posted: March 22nd, 2010 | Author: jay | Filed under: Code | Tags: amazon, aws, aws/s3, bucket, gem, ruby, s3, s3object, upload | No Comments »
Email is going to be used to activate an account, and I’m leaning towards using the Pony gem to simplify the creations and sending.
Here’s how simple Pony is:
1
| Pony.mail(:to => 'test@example.com', :from=>'test@example.com', :subject=>'spam', :body=>(erb :registration_email)) |
and here’s how you can test it with the pony-test gem:
1
2
3
4
5
6
7
8
9
10
| def test_valid_new_user_signup_should_create_email
count=all_email.count
create_user
assert_equal count+1, all_email.count
end
def test_signup_email_should_contain_activation_link
create_user
assert_match /http\:\/\//, current_email.body
end |
Don’t forget to nclude the Pony test helpers in your test class…
1
| include Pony::TestHelpers |
Posted: March 12th, 2010 | Author: jay | Filed under: Code | Tags: email, gem, pony, ruby, test | No Comments »