has_emails 0.3.0 → 0.3.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,6 +1,12 @@
1
1
  == master
2
2
 
3
- == 0.3.0
3
+ == 0.3.1 / 2010-03-07
4
+
5
+ * Add a generator for db migration
6
+ * Release gems via rake-gemcutter instead of rubyforge
7
+ * By default, sort emails newest first
8
+
9
+ == 0.3.0 / 2009-04-19
4
10
 
5
11
  * Add compatibility with has_messages 0.4.0 / Rails 2.3
6
12
 
data/LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2006-2009 Aaron Pfeifer
1
+ Copyright (c) 2006-2010 Aaron Pfeifer
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining
4
4
  a copy of this software and associated documentation files (the
@@ -37,6 +37,17 @@ of these features.
37
37
 
38
38
  == Usage
39
39
 
40
+ === Installation
41
+
42
+ +has_emails+ requires an additional database table to work. You can generate
43
+ a migration for this tables like so:
44
+
45
+ script/generate has_emails
46
+
47
+ Then simply migrate your database:
48
+
49
+ rake db:migrate
50
+
40
51
  === Creating new emails
41
52
 
42
53
  Emails should usually still be created using ActionMailer. However, instead of
data/Rakefile CHANGED
@@ -1,15 +1,17 @@
1
+ require 'rubygems'
2
+ require 'rake'
1
3
  require 'rake/testtask'
2
4
  require 'rake/rdoctask'
3
5
  require 'rake/gempackagetask'
4
- require 'rake/contrib/sshpublisher'
5
6
 
6
7
  spec = Gem::Specification.new do |s|
7
8
  s.name = 'has_emails'
8
- s.version = '0.3.0'
9
+ s.version = '0.3.1'
9
10
  s.platform = Gem::Platform::RUBY
10
- s.summary = 'Demonstrates a reference implementation for sending emails with logging and asynchronous support.'
11
+ s.summary = 'Demonstrates a reference implementation for sending emails with logging and asynchronous support in ActiveRecord'
12
+ s.description = s.summary
11
13
 
12
- s.files = FileList['{app,db,lib,test}/**/*'] + %w(CHANGELOG.rdoc init.rb LICENSE Rakefile README.rdoc) - FileList['test/app_root/{log,log/*,script,script/*}']
14
+ s.files = FileList['{app,generators,lib,test}/**/*'] + %w(CHANGELOG.rdoc init.rb LICENSE Rakefile README.rdoc) - FileList['test/app_root/{log,log/*,script,script/*}']
13
15
  s.require_path = 'lib'
14
16
  s.has_rdoc = true
15
17
  s.test_files = Dir['test/**/*_test.rb']
@@ -54,20 +56,27 @@ Rake::RDocTask.new(:rdoc) do |rdoc|
54
56
  rdoc.options << '--line-numbers' << '--inline-source'
55
57
  rdoc.rdoc_files.include('README.rdoc', 'CHANGELOG.rdoc', 'LICENSE', 'lib/**/*.rb', 'app/**/*.rb')
56
58
  end
57
-
59
+
60
+ desc 'Generate a gemspec file.'
61
+ task :gemspec do
62
+ File.open("#{spec.name}.gemspec", 'w') do |f|
63
+ f.write spec.to_ruby
64
+ end
65
+ end
66
+
58
67
  Rake::GemPackageTask.new(spec) do |p|
59
68
  p.gem_spec = spec
60
- p.need_tar = true
61
- p.need_zip = true
62
69
  end
63
70
 
64
71
  desc 'Publish the beta gem.'
65
72
  task :pgem => [:package] do
73
+ require 'rake/contrib/sshpublisher'
66
74
  Rake::SshFilePublisher.new('aaron@pluginaweek.org', '/home/aaron/gems.pluginaweek.org/public/gems', 'pkg', "#{spec.name}-#{spec.version}.gem").upload
67
75
  end
68
76
 
69
77
  desc 'Publish the API documentation.'
70
78
  task :pdoc => [:rdoc] do
79
+ require 'rake/contrib/sshpublisher'
71
80
  Rake::SshDirPublisher.new('aaron@pluginaweek.org', "/home/aaron/api.pluginaweek.org/public/#{spec.name}", 'rdoc').upload
72
81
  end
73
82
 
@@ -76,15 +85,8 @@ task :publish => [:pgem, :pdoc, :release]
76
85
 
77
86
  desc 'Publish the release files to RubyForge.'
78
87
  task :release => [:gem, :package] do
79
- require 'rubyforge'
80
-
81
- ruby_forge = RubyForge.new.configure
82
- ruby_forge.login
88
+ require 'rake/gemcutter'
83
89
 
84
- %w(gem tgz zip).each do |ext|
85
- file = "pkg/#{spec.name}-#{spec.version}.#{ext}"
86
- puts "Releasing #{File.basename(file)}..."
87
-
88
- ruby_forge.add_release(spec.rubyforge_project, spec.name, spec.version, file)
89
- end
90
+ Rake::Gemcutter::Tasks.new(spec)
91
+ Rake::Task['gem:push'].invoke
90
92
  end
@@ -0,0 +1,5 @@
1
+ Usage:
2
+
3
+ script/generate has_emails
4
+
5
+ This will create migrations that will add the proper tables to store emails.
@@ -0,0 +1,7 @@
1
+ class HasEmailsGenerator < Rails::Generator::Base
2
+ def manifest
3
+ record do |m|
4
+ m.migration_template '001_create_email_addresses.rb', 'db/migrate', :migration_file_name => 'create_email_addresses'
5
+ end
6
+ end
7
+ end
@@ -28,13 +28,13 @@ module HasEmails
28
28
  :as => :sender,
29
29
  :class_name => 'Email',
30
30
  :conditions => {:hidden_at => nil},
31
- :order => 'messages.created_at ASC'
31
+ :order => 'messages.created_at DESC'
32
32
  has_many :received_emails,
33
33
  :as => :receiver,
34
34
  :class_name => 'MessageRecipient',
35
35
  :include => :message,
36
36
  :conditions => ['message_recipients.hidden_at IS NULL AND messages.state = ?', 'sent'],
37
- :order => 'messages.created_at ASC'
37
+ :order => 'messages.created_at DESC'
38
38
 
39
39
  include HasEmails::InstanceMethods
40
40
  end
@@ -1,12 +1,12 @@
1
1
  class MigrateHasMessagesToVersion2 < ActiveRecord::Migration
2
2
  def self.up
3
- ActiveRecord::Migrator.new(:up, "#{directory}/db/migrate", 0).migrations.each do |migration|
3
+ ActiveRecord::Migrator.new(:up, "#{directory}/generators/has_messages/templates", 0).migrations.each do |migration|
4
4
  migration.migrate(:up)
5
5
  end
6
6
  end
7
7
 
8
8
  def self.down
9
- ActiveRecord::Migrator.new(:up, "#{directory}/db/migrate", 0).migrations.each do |migration|
9
+ ActiveRecord::Migrator.new(:down, "#{directory}/generators/has_messages/templates", 0).migrations.each do |migration|
10
10
  migration.migrate(:down)
11
11
  end
12
12
  end
@@ -1,12 +1,12 @@
1
1
  class MigrateHasEmailsToVersion1 < ActiveRecord::Migration
2
2
  def self.up
3
- ActiveRecord::Migrator.new(:up, "#{Rails.root}/../../db/migrate", 0).migrations.each do |migration|
3
+ ActiveRecord::Migrator.new(:up, "#{Rails.root}/../../generators/has_emails/templates", 0).migrations.each do |migration|
4
4
  migration.migrate(:up)
5
5
  end
6
6
  end
7
7
 
8
8
  def self.down
9
- ActiveRecord::Migrator.new(:up, "#{Rails.root}/../../db/migrate", 0).migrations.each do |migration|
9
+ ActiveRecord::Migrator.new(:down, "#{Rails.root}/../../generators/has_emails/templates", 0).migrations.each do |migration|
10
10
  migration.migrate(:down)
11
11
  end
12
12
  end
@@ -37,7 +37,8 @@ module Factory
37
37
  attributes[:sender] = create_user unless attributes.include?(:sender)
38
38
  attributes.reverse_merge!(
39
39
  :subject => 'New features',
40
- :body => 'Lots of new things to talk about... come to the meeting tonight to find out!'
40
+ :body => 'Lots of new things to talk about... come to the meeting tonight to find out!',
41
+ :created_at => Time.current + Email.count
41
42
  )
42
43
  end
43
44
 
@@ -50,11 +50,11 @@ class EmailAddressWithUnsentEmails < ActiveSupport::TestCase
50
50
  end
51
51
 
52
52
  def test_should_have_unsent_emails
53
- assert_equal [@first_draft, @second_draft], @email_address.unsent_emails
53
+ assert_equal [@second_draft, @first_draft], @email_address.unsent_emails
54
54
  end
55
55
 
56
56
  def test_should_include_unsent_emails_in_emails
57
- assert_equal [@sent_email, @first_draft, @second_draft], @email_address.emails
57
+ assert_equal [@second_draft, @first_draft, @sent_email], @email_address.emails
58
58
  end
59
59
  end
60
60
 
@@ -72,11 +72,11 @@ class EmailAddressWithSentEmails < ActiveSupport::TestCase
72
72
  end
73
73
 
74
74
  def test_should_have_sent_emails
75
- assert_equal [@first_sent_email, @second_sent_email], @email_address.sent_emails
75
+ assert_equal [@second_sent_email, @first_sent_email], @email_address.sent_emails
76
76
  end
77
77
 
78
78
  def test_should_include_sent_emails_in_emails
79
- assert_equal [@draft, @first_sent_email, @second_sent_email], @email_address.emails
79
+ assert_equal [@second_sent_email, @first_sent_email, @draft], @email_address.emails
80
80
  end
81
81
  end
82
82
 
@@ -95,7 +95,7 @@ class EmailAddressWithReceivedEmails < ActiveSupport::TestCase
95
95
  end
96
96
 
97
97
  def test_should_have_received_emails
98
- assert_equal [@first_sent_email, @second_sent_email], @email_address.received_emails.map(&:message)
98
+ assert_equal [@second_sent_email, @first_sent_email], @email_address.received_emails.map(&:message)
99
99
  end
100
100
  end
101
101
 
@@ -122,7 +122,7 @@ class EmailAddressWithHiddenEmailsTest < ActiveSupport::TestCase
122
122
  end
123
123
 
124
124
  def test_should_not_include_hidden_emails_in_emails
125
- assert_equal [@unsent_email, @sent_email], @email_address.emails
125
+ assert_equal [@sent_email, @unsent_email], @email_address.emails
126
126
  end
127
127
 
128
128
  def test_should_not_include_hidden_emails_in_unsent_emails
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: has_emails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Aaron Pfeifer
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-04-19 00:00:00 -04:00
12
+ date: 2010-03-07 00:00:00 -05:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -32,7 +32,7 @@ dependencies:
32
32
  - !ruby/object:Gem::Version
33
33
  version: 0.0.2
34
34
  version:
35
- description:
35
+ description: Demonstrates a reference implementation for sending emails with logging and asynchronous support in ActiveRecord
36
36
  email: aaron@pluginaweek.org
37
37
  executables: []
38
38
 
@@ -41,34 +41,23 @@ extensions: []
41
41
  extra_rdoc_files: []
42
42
 
43
43
  files:
44
- - app/models
45
- - app/models/email.rb
46
44
  - app/models/email_address.rb
47
- - db/migrate
48
- - db/migrate/001_create_email_addresses.rb
45
+ - app/models/email.rb
46
+ - generators/has_emails/USAGE
47
+ - generators/has_emails/has_emails_generator.rb
48
+ - generators/has_emails/templates/001_create_email_addresses.rb
49
49
  - lib/has_emails.rb
50
- - lib/has_emails
51
- - lib/has_emails/extensions
52
50
  - lib/has_emails/extensions/action_mailer.rb
53
- - test/factory.rb
54
- - test/test_helper.rb
55
- - test/functional
56
- - test/functional/has_emails_test.rb
57
- - test/unit
58
- - test/unit/action_mailer_test.rb
59
- - test/unit/email_test.rb
60
51
  - test/unit/email_address_test.rb
61
- - test/app_root
62
- - test/app_root/db
63
- - test/app_root/db/migrate
64
- - test/app_root/db/migrate/002_migrate_has_emails_to_version_1.rb
52
+ - test/unit/email_test.rb
53
+ - test/unit/action_mailer_test.rb
54
+ - test/app_root/vendor/plugins/plugin_tracker/init.rb
65
55
  - test/app_root/db/migrate/001_migrate_has_messages_to_version_2.rb
66
- - test/app_root/config
56
+ - test/app_root/db/migrate/002_migrate_has_emails_to_version_1.rb
67
57
  - test/app_root/config/environment.rb
68
- - test/app_root/vendor
69
- - test/app_root/vendor/plugins
70
- - test/app_root/vendor/plugins/plugin_tracker
71
- - test/app_root/vendor/plugins/plugin_tracker/init.rb
58
+ - test/test_helper.rb
59
+ - test/factory.rb
60
+ - test/functional/has_emails_test.rb
72
61
  - CHANGELOG.rdoc
73
62
  - init.rb
74
63
  - LICENSE
@@ -76,6 +65,8 @@ files:
76
65
  - README.rdoc
77
66
  has_rdoc: true
78
67
  homepage: http://www.pluginaweek.org
68
+ licenses: []
69
+
79
70
  post_install_message:
80
71
  rdoc_options: []
81
72
 
@@ -96,12 +87,12 @@ required_rubygems_version: !ruby/object:Gem::Requirement
96
87
  requirements: []
97
88
 
98
89
  rubyforge_project: pluginaweek
99
- rubygems_version: 1.3.1
90
+ rubygems_version: 1.3.5
100
91
  signing_key:
101
- specification_version: 2
102
- summary: Demonstrates a reference implementation for sending emails with logging and asynchronous support.
92
+ specification_version: 3
93
+ summary: Demonstrates a reference implementation for sending emails with logging and asynchronous support in ActiveRecord
103
94
  test_files:
104
- - test/functional/has_emails_test.rb
105
- - test/unit/action_mailer_test.rb
106
- - test/unit/email_test.rb
107
95
  - test/unit/email_address_test.rb
96
+ - test/unit/email_test.rb
97
+ - test/unit/action_mailer_test.rb
98
+ - test/functional/has_emails_test.rb