has_many_emails 0.2.16 → 0.3.1

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ gem 'attribute_normalizer'
2
+ #gem "rfc-822" # Validate emails
3
+ gem 'validate_email'
4
+
data/README.rdoc CHANGED
@@ -5,22 +5,26 @@ Add multiply emails to the +User+ model without changing the +email+ attribute b
5
5
  == Installation
6
6
 
7
7
 
8
- 1. Install the plugin
8
+ Install the plugin
9
9
 
10
10
  $ rails plugin install http://..
11
11
 
12
- 2. Add to you +User+ class:
12
+ Add to you +User+ class:
13
13
 
14
14
  class User < ActiveRecord::Base
15
15
  ...
16
16
  has_many_emails
17
17
  ...
18
18
 
19
- 3. Generate migration:
20
-
19
+ Generate the migration:
20
+
21
21
  $ rails generate has_many_emails
22
-
23
- 4. Migrate.
22
+
23
+ Or add new schema email's convertaion for User and Contact models:
24
+
25
+ $ rails generate has_many_emails -m User,Contact
26
+
27
+ Migrate.
24
28
 
25
29
  $ rake db:migrate
26
30
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.16
1
+ 0.3.1
@@ -1,75 +1,77 @@
1
1
  # Generated by jeweler
2
2
  # DO NOT EDIT THIS FILE DIRECTLY
3
- # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
4
  # -*- encoding: utf-8 -*-
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{has_many_emails}
8
- s.version = "0.2.16"
8
+ s.version = "0.3.1"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Danil Pismenny"]
12
- s.date = %q{2010-10-20}
12
+ s.date = %q{2011-02-23}
13
13
  s.description = %q{Add multiply emails features to models like User without changing common behaviour of the email attribute}
14
14
  s.email = %q{danil@orionet.ru}
15
15
  s.extra_rdoc_files = [
16
16
  "README.rdoc"
17
17
  ]
18
18
  s.files = [
19
- ".gitignore",
20
- "MIT-LICENSE",
21
- "README.rdoc",
22
- "Rakefile",
23
- "VERSION",
24
- "has_many_emails.gemspec",
25
- "init.rb",
26
- "install.rb",
27
- "lib/generators/USAGE",
28
- "lib/generators/has_many_emails_generator.rb",
29
- "lib/generators/templates/create_email_address.rb",
30
- "lib/has_many_emails.rb",
31
- "lib/has_many_emails/class_methods.rb",
32
- "lib/has_many_emails/email_address.rb",
33
- "lib/has_many_emails/instance_methods.rb",
34
- "spec/db/create_db.rb",
35
- "spec/db/database.yml",
36
- "spec/db/models/user.rb",
37
- "spec/models/email_spec.rb",
38
- "spec/models/exampels_spec.rb",
39
- "spec/models/user_emails_spec.rb",
40
- "spec/models/user_spec.rb",
41
- "spec/spec_helper.rb",
42
- "test/helper.rb",
43
- "test/test_has_many_emails.rb"
19
+ "Gemfile",
20
+ "MIT-LICENSE",
21
+ "README.rdoc",
22
+ "Rakefile",
23
+ "VERSION",
24
+ "has_many_emails.gemspec",
25
+ "init.rb",
26
+ "install.rb",
27
+ "lib/generators/USAGE",
28
+ "lib/generators/has_many_emails_generator.rb",
29
+ "lib/generators/templates/create_email_address.rb",
30
+ "lib/has_many_emails.rb",
31
+ "lib/has_many_emails/class_methods.rb",
32
+ "lib/has_many_emails/email_address.rb",
33
+ "lib/has_many_emails/instance_methods.rb",
34
+ "spec/db/create_db.rb",
35
+ "spec/db/database.yml",
36
+ "spec/db/models/user.rb",
37
+ "spec/models/email_spec.rb",
38
+ "spec/models/exampels_spec.rb",
39
+ "spec/models/user_emails_spec.rb",
40
+ "spec/models/user_spec.rb",
41
+ "spec/spec_helper.rb",
42
+ "test/helper.rb",
43
+ "test/test_has_many_emails.rb"
44
44
  ]
45
45
  s.homepage = %q{http://github.com/dapi/has_many_emails}
46
- s.rdoc_options = ["--charset=UTF-8"]
47
46
  s.require_paths = ["lib"]
48
- s.rubygems_version = %q{1.3.7}
47
+ s.rubygems_version = %q{1.5.0}
49
48
  s.summary = %q{Add multiply emails features to models like User without changing common behaviour of the email attribute}
50
49
  s.test_files = [
50
+ "spec/db/create_db.rb",
51
+ "spec/db/models/user.rb",
52
+ "spec/models/email_spec.rb",
51
53
  "spec/models/exampels_spec.rb",
52
- "spec/models/user_emails_spec.rb",
53
- "spec/models/email_spec.rb",
54
- "spec/models/user_spec.rb",
55
- "spec/db/models/user.rb",
56
- "spec/db/create_db.rb",
57
- "spec/spec_helper.rb",
58
- "test/helper.rb",
59
- "test/test_has_many_emails.rb"
54
+ "spec/models/user_emails_spec.rb",
55
+ "spec/models/user_spec.rb",
56
+ "spec/spec_helper.rb",
57
+ "test/helper.rb",
58
+ "test/test_has_many_emails.rb"
60
59
  ]
61
60
 
62
61
  if s.respond_to? :specification_version then
63
- current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
64
62
  s.specification_version = 3
65
63
 
66
64
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
65
+ s.add_runtime_dependency(%q<attribute_normalizer>, [">= 0"])
66
+ s.add_runtime_dependency(%q<validate_email>, [">= 0"])
67
67
  s.add_runtime_dependency(%q<attribute_normalizer>, [">= 0"])
68
68
  s.add_runtime_dependency(%q<validate_email>, [">= 0"])
69
69
  s.add_development_dependency(%q<validate_email>, [">= 0"])
70
70
  s.add_development_dependency(%q<activerecord>, [">= 0"])
71
71
  s.add_development_dependency(%q<remarkable_activerecord>, [">= 0"])
72
72
  else
73
+ s.add_dependency(%q<attribute_normalizer>, [">= 0"])
74
+ s.add_dependency(%q<validate_email>, [">= 0"])
73
75
  s.add_dependency(%q<attribute_normalizer>, [">= 0"])
74
76
  s.add_dependency(%q<validate_email>, [">= 0"])
75
77
  s.add_dependency(%q<validate_email>, [">= 0"])
@@ -77,6 +79,8 @@ Gem::Specification.new do |s|
77
79
  s.add_dependency(%q<remarkable_activerecord>, [">= 0"])
78
80
  end
79
81
  else
82
+ s.add_dependency(%q<attribute_normalizer>, [">= 0"])
83
+ s.add_dependency(%q<validate_email>, [">= 0"])
80
84
  s.add_dependency(%q<attribute_normalizer>, [">= 0"])
81
85
  s.add_dependency(%q<validate_email>, [">= 0"])
82
86
  s.add_dependency(%q<validate_email>, [">= 0"])
@@ -2,22 +2,23 @@ class <%= migration_name %> < ActiveRecord::Migration
2
2
 
3
3
  def self.up
4
4
  create_table :<%= email_address_table_name %> do |t|
5
- t.integer :user_id, :null => false
5
+ t.integer :owner_id, :null => false
6
+ t.string :owner_type, :null => false
6
7
  t.string :email, :null => false
7
8
  # t.boolean :is_main, :null => false, :default=>false
8
9
 
9
10
  t.timestamps
10
11
  end
11
12
 
12
- add_index :<%= email_address_table_name %>, [:user_id, :email], :unique=>true
13
+ add_index :<%= email_address_table_name %>, [:owner_id, :owner_type, :email], :unique=>true
13
14
  add_index :<%= email_address_table_name %>, :email
14
15
 
15
16
 
16
17
  <% models_with_emails.each do |model| %>
17
18
  if <%= model %>.column_names.include? 'email'
18
19
  raise "PROBLEM! <%= model %> does not have 'has_many_emails'. Insert it before usage." unless <%= model %>.respond_to? :has_many_emails
19
- <%= model %>.all.each do |user|
20
- user.add_email user.attributes['email']
20
+ <%= model %>.all.each do |owner|
21
+ ower.add_email owner.attributes['email']
21
22
  end
22
23
  end
23
24
  <% end %>
@@ -4,7 +4,7 @@ module HasManyEmails
4
4
  module ClassMethods
5
5
 
6
6
  def find_by_email( email )
7
- address = HasManyEmails::EmailAddress.find_by_email( email.downcase ) and address.user
7
+ address = HasManyEmails::EmailAddress.find_by_email( email.downcase ) and address.owner
8
8
  end
9
9
 
10
10
  end
@@ -1,6 +1,6 @@
1
1
  # -*- coding: utf-8 -*-
2
2
  class HasManyEmails::EmailAddress < ActiveRecord::Base
3
- belongs_to :user
3
+ belongs_to :owner, :polymorphic => true
4
4
 
5
5
  normalize_attributes :email
6
6
 
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: has_many_emails
3
3
  version: !ruby/object:Gem::Version
4
- hash: 55
5
- prerelease: false
4
+ hash: 17
5
+ prerelease:
6
6
  segments:
7
7
  - 0
8
- - 2
9
- - 16
10
- version: 0.2.16
8
+ - 3
9
+ - 1
10
+ version: 0.3.1
11
11
  platform: ruby
12
12
  authors:
13
13
  - Danil Pismenny
@@ -15,13 +15,12 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-10-20 00:00:00 +04:00
18
+ date: 2011-02-23 00:00:00 +03:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
22
22
  name: attribute_normalizer
23
- prerelease: false
24
- requirement: &id001 !ruby/object:Gem::Requirement
23
+ version_requirements: &id001 !ruby/object:Gem::Requirement
25
24
  none: false
26
25
  requirements:
27
26
  - - ">="
@@ -30,12 +29,26 @@ dependencies:
30
29
  segments:
31
30
  - 0
32
31
  version: "0"
32
+ prerelease: false
33
33
  type: :runtime
34
- version_requirements: *id001
34
+ requirement: *id001
35
35
  - !ruby/object:Gem::Dependency
36
36
  name: validate_email
37
+ version_requirements: &id002 !ruby/object:Gem::Requirement
38
+ none: false
39
+ requirements:
40
+ - - ">="
41
+ - !ruby/object:Gem::Version
42
+ hash: 3
43
+ segments:
44
+ - 0
45
+ version: "0"
37
46
  prerelease: false
38
- requirement: &id002 !ruby/object:Gem::Requirement
47
+ type: :runtime
48
+ requirement: *id002
49
+ - !ruby/object:Gem::Dependency
50
+ name: attribute_normalizer
51
+ version_requirements: &id003 !ruby/object:Gem::Requirement
39
52
  none: false
40
53
  requirements:
41
54
  - - ">="
@@ -44,12 +57,26 @@ dependencies:
44
57
  segments:
45
58
  - 0
46
59
  version: "0"
60
+ prerelease: false
47
61
  type: :runtime
48
- version_requirements: *id002
62
+ requirement: *id003
49
63
  - !ruby/object:Gem::Dependency
50
64
  name: validate_email
65
+ version_requirements: &id004 !ruby/object:Gem::Requirement
66
+ none: false
67
+ requirements:
68
+ - - ">="
69
+ - !ruby/object:Gem::Version
70
+ hash: 3
71
+ segments:
72
+ - 0
73
+ version: "0"
51
74
  prerelease: false
52
- requirement: &id003 !ruby/object:Gem::Requirement
75
+ type: :runtime
76
+ requirement: *id004
77
+ - !ruby/object:Gem::Dependency
78
+ name: validate_email
79
+ version_requirements: &id005 !ruby/object:Gem::Requirement
53
80
  none: false
54
81
  requirements:
55
82
  - - ">="
@@ -58,12 +85,12 @@ dependencies:
58
85
  segments:
59
86
  - 0
60
87
  version: "0"
88
+ prerelease: false
61
89
  type: :development
62
- version_requirements: *id003
90
+ requirement: *id005
63
91
  - !ruby/object:Gem::Dependency
64
92
  name: activerecord
65
- prerelease: false
66
- requirement: &id004 !ruby/object:Gem::Requirement
93
+ version_requirements: &id006 !ruby/object:Gem::Requirement
67
94
  none: false
68
95
  requirements:
69
96
  - - ">="
@@ -72,12 +99,12 @@ dependencies:
72
99
  segments:
73
100
  - 0
74
101
  version: "0"
102
+ prerelease: false
75
103
  type: :development
76
- version_requirements: *id004
104
+ requirement: *id006
77
105
  - !ruby/object:Gem::Dependency
78
106
  name: remarkable_activerecord
79
- prerelease: false
80
- requirement: &id005 !ruby/object:Gem::Requirement
107
+ version_requirements: &id007 !ruby/object:Gem::Requirement
81
108
  none: false
82
109
  requirements:
83
110
  - - ">="
@@ -86,8 +113,9 @@ dependencies:
86
113
  segments:
87
114
  - 0
88
115
  version: "0"
116
+ prerelease: false
89
117
  type: :development
90
- version_requirements: *id005
118
+ requirement: *id007
91
119
  description: Add multiply emails features to models like User without changing common behaviour of the email attribute
92
120
  email: danil@orionet.ru
93
121
  executables: []
@@ -97,7 +125,7 @@ extensions: []
97
125
  extra_rdoc_files:
98
126
  - README.rdoc
99
127
  files:
100
- - .gitignore
128
+ - Gemfile
101
129
  - MIT-LICENSE
102
130
  - README.rdoc
103
131
  - Rakefile
@@ -127,8 +155,8 @@ homepage: http://github.com/dapi/has_many_emails
127
155
  licenses: []
128
156
 
129
157
  post_install_message:
130
- rdoc_options:
131
- - --charset=UTF-8
158
+ rdoc_options: []
159
+
132
160
  require_paths:
133
161
  - lib
134
162
  required_ruby_version: !ruby/object:Gem::Requirement
@@ -152,17 +180,17 @@ required_rubygems_version: !ruby/object:Gem::Requirement
152
180
  requirements: []
153
181
 
154
182
  rubyforge_project:
155
- rubygems_version: 1.3.7
183
+ rubygems_version: 1.5.0
156
184
  signing_key:
157
185
  specification_version: 3
158
186
  summary: Add multiply emails features to models like User without changing common behaviour of the email attribute
159
187
  test_files:
188
+ - spec/db/create_db.rb
189
+ - spec/db/models/user.rb
190
+ - spec/models/email_spec.rb
160
191
  - spec/models/exampels_spec.rb
161
192
  - spec/models/user_emails_spec.rb
162
- - spec/models/email_spec.rb
163
193
  - spec/models/user_spec.rb
164
- - spec/db/models/user.rb
165
- - spec/db/create_db.rb
166
194
  - spec/spec_helper.rb
167
195
  - test/helper.rb
168
196
  - test/test_has_many_emails.rb
data/.gitignore DELETED
@@ -1,4 +0,0 @@
1
- spec/db/has_many_emails.sqlite3.db
2
- /spec/db/log/test.log
3
- pkg
4
- spec/debug.log