easy_contact 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/MIT-LICENSE +20 -0
- data/README.md +121 -0
- data/Rakefile +27 -0
- data/app/models/easy_contact/address.rb +2 -0
- data/app/models/easy_contact/email.rb +2 -0
- data/app/models/easy_contact/entry.rb +4 -0
- data/app/models/easy_contact/name.rb +2 -0
- data/app/models/easy_contact/phone.rb +2 -0
- data/app/models/easy_contact/website.rb +2 -0
- data/app/models/easy_contact.rb +8 -0
- data/config/routes.rb +2 -0
- data/lib/easy_contact/contactable.rb +39 -0
- data/lib/easy_contact/engine.rb +4 -0
- data/lib/easy_contact/version.rb +3 -0
- data/lib/easy_contact.rb +17 -0
- data/lib/generators/easy_contact/migration/migration_generator.rb +21 -0
- data/lib/generators/easy_contact/migration/templates/migration.rb +18 -0
- data/lib/tasks/easy_contact_tasks.rake +4 -0
- data.tar.gz.sig +0 -0
- metadata +122 -0
- metadata.gz.sig +0 -0
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright 2013 YOURNAME
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,121 @@
|
|
1
|
+
## EasyContact
|
2
|
+
|
3
|
+
This is a very simple contact system for Rails. Because it is so simple, you should fork and modify it for your own purpose.
|
4
|
+
|
5
|
+
This gem is used in my other projects, thus, it will be kept updated, albeit slowly.
|
6
|
+
|
7
|
+
## Install
|
8
|
+
|
9
|
+
rails generate easy_contact:migration
|
10
|
+
rake db:migrate
|
11
|
+
rake db:test:prepare
|
12
|
+
|
13
|
+
## Basic Usage
|
14
|
+
|
15
|
+
You need to define __acts_as_contactable__ in a contact model like this:
|
16
|
+
|
17
|
+
class User < ActiveRecord::Base
|
18
|
+
acts_as_contactable
|
19
|
+
end
|
20
|
+
|
21
|
+
You can manage contact information like this:
|
22
|
+
|
23
|
+
user.addresses
|
24
|
+
user.phones
|
25
|
+
|
26
|
+
## Entry
|
27
|
+
|
28
|
+
Each information is stored in an entry, no matter it is an address or a phone number. EasyContact use STI to create classes of address and phone. An entry contains these fields:
|
29
|
+
|
30
|
+
type: string
|
31
|
+
label: string
|
32
|
+
content: text
|
33
|
+
extra: string
|
34
|
+
addition: string
|
35
|
+
country: string
|
36
|
+
locale: string
|
37
|
+
primary: boolean
|
38
|
+
|
39
|
+
All of them are in string format. The **type** defines this entry an address or a phone number. The use of other fields depend on the type.
|
40
|
+
|
41
|
+
**country** is used in address and phone type. It is set as 2-letter abbreviation of country like US, UK.
|
42
|
+
|
43
|
+
**locale** set the language of this entry. A person might have English and Chinese name.
|
44
|
+
|
45
|
+
**primary** specify the main entry of a type, for example, the main address of a person.
|
46
|
+
|
47
|
+
### Name
|
48
|
+
|
49
|
+
It doesn't care the order of first and last name, or suffix and middle name. Just a string of the name this person use. Thus, it is your choice to put the name as 'John Doe' or 'Doe, John'.
|
50
|
+
|
51
|
+
Content: string of name
|
52
|
+
Label: 'fullname', 'nickname'
|
53
|
+
Extra: not in use
|
54
|
+
Addition: not in use
|
55
|
+
|
56
|
+
### Address
|
57
|
+
|
58
|
+
It is in a free form for address. Think the address in the name card.
|
59
|
+
|
60
|
+
Content: string of address
|
61
|
+
Label: 'home', 'office'
|
62
|
+
Extra: not in use
|
63
|
+
Addition: not in use
|
64
|
+
|
65
|
+
### Phone
|
66
|
+
|
67
|
+
It is in a free form of address. Thus, you can use 1-545-8342 or (545)8743. There is no need to put country code. The code can be derived from country field.
|
68
|
+
|
69
|
+
Content: string of phone number
|
70
|
+
Label: 'home', 'office'
|
71
|
+
Extra: not in use
|
72
|
+
Addition: not in use
|
73
|
+
|
74
|
+
### Employment
|
75
|
+
|
76
|
+
It is in a free form of employment
|
77
|
+
|
78
|
+
Content: string of employer (company, organization)
|
79
|
+
Label: no predefined
|
80
|
+
Extra: title of this employment
|
81
|
+
Addition: year during this employment in free form, ex. 1998-2001.
|
82
|
+
|
83
|
+
### Birthday
|
84
|
+
|
85
|
+
It is in seconds. Use __to_i__ to convert a date into seconds. Time zone is ignored. To avoid problem, always use UTC even if you are not born in UTC time zone.
|
86
|
+
|
87
|
+
Content: string in seconds
|
88
|
+
Label: no predefined
|
89
|
+
Extra: not in use
|
90
|
+
Addition: not in use
|
91
|
+
|
92
|
+
### Email
|
93
|
+
|
94
|
+
It is in a free form of email
|
95
|
+
|
96
|
+
Content: string of email
|
97
|
+
Label: no predefined
|
98
|
+
Extra: not in use
|
99
|
+
Addition: not in use
|
100
|
+
|
101
|
+
### Website
|
102
|
+
|
103
|
+
It is in a free form of website
|
104
|
+
|
105
|
+
Content: string of email
|
106
|
+
Label: no predefined
|
107
|
+
Extra: not in use
|
108
|
+
Addition: not in use
|
109
|
+
|
110
|
+
### Instant Messenger
|
111
|
+
|
112
|
+
It is in a free form of website
|
113
|
+
|
114
|
+
Content: string of instant messenger ID
|
115
|
+
Label: 'google talk', 'skype', 'yahoo', 'msn', 'jabber'
|
116
|
+
Extra: not in use
|
117
|
+
Addition: not in use
|
118
|
+
|
119
|
+
## License
|
120
|
+
|
121
|
+
MIT
|
data/Rakefile
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
#!/usr/bin/env rake
|
2
|
+
begin
|
3
|
+
require 'bundler/setup'
|
4
|
+
rescue LoadError
|
5
|
+
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
|
6
|
+
end
|
7
|
+
begin
|
8
|
+
require 'rdoc/task'
|
9
|
+
rescue LoadError
|
10
|
+
require 'rdoc/rdoc'
|
11
|
+
require 'rake/rdoctask'
|
12
|
+
RDoc::Task = Rake::RDocTask
|
13
|
+
end
|
14
|
+
|
15
|
+
RDoc::Task.new(:rdoc) do |rdoc|
|
16
|
+
rdoc.rdoc_dir = 'rdoc'
|
17
|
+
rdoc.title = 'EasyContact'
|
18
|
+
rdoc.options << '--line-numbers'
|
19
|
+
rdoc.rdoc_files.include('README.rdoc')
|
20
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
21
|
+
end
|
22
|
+
|
23
|
+
APP_RAKEFILE = File.expand_path("../spec/dummy/Rakefile", __FILE__)
|
24
|
+
load 'rails/tasks/engine.rake'
|
25
|
+
|
26
|
+
Bundler::GemHelper.install_tasks
|
27
|
+
|
data/config/routes.rb
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
module EasyContact
|
2
|
+
module Contactable
|
3
|
+
extend ActiveSupport::Concern
|
4
|
+
|
5
|
+
included do
|
6
|
+
has_many :entries, :dependent => :destroy,
|
7
|
+
:class_name => 'EasyContact::Entry',
|
8
|
+
:foreign_key => 'contactable_id'
|
9
|
+
has_many :names, :dependent => :destroy,
|
10
|
+
:class_name => 'EasyContact::Name',
|
11
|
+
:foreign_key => 'contactable_id'
|
12
|
+
has_many :addresses, :dependent => :destroy,
|
13
|
+
:class_name => 'EasyContact::Address',
|
14
|
+
:foreign_key => 'contactable_id'
|
15
|
+
has_many :phones, :dependent => :destroy,
|
16
|
+
:class_name => 'EasyContact::Phone',
|
17
|
+
:foreign_key => 'contactable_id'
|
18
|
+
has_many :emails, :dependent => :destroy,
|
19
|
+
:class_name => 'EasyContact::Email',
|
20
|
+
:foreign_key => 'contactable_id'
|
21
|
+
has_many :websites, :dependent => :destroy,
|
22
|
+
:class_name => 'EasyContact::Website',
|
23
|
+
:foreign_key => 'contactable_id'
|
24
|
+
|
25
|
+
accepts_nested_attributes_for :entries,
|
26
|
+
:names, :phones, :addresses, :emails, :websites,
|
27
|
+
:reject_if => :reject_entries,
|
28
|
+
:allow_destroy => true
|
29
|
+
end
|
30
|
+
|
31
|
+
module ClassMethods
|
32
|
+
end # end of class methods
|
33
|
+
|
34
|
+
def reject_entries(attributes)
|
35
|
+
attributes['content'].blank?
|
36
|
+
end
|
37
|
+
|
38
|
+
end
|
39
|
+
end
|
data/lib/easy_contact.rb
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
require "easy_contact/engine"
|
2
|
+
require "easy_contact/contactable"
|
3
|
+
|
4
|
+
module EasyContact
|
5
|
+
def self.table_name_prefix
|
6
|
+
'easy_contact_'
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
if defined?(ActiveRecord::Base)
|
11
|
+
class ActiveRecord::Base
|
12
|
+
def self.acts_as_contactable(options = {})
|
13
|
+
options.reverse_merge!({})
|
14
|
+
include EasyContact::Contactable
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'rails/generators'
|
2
|
+
require 'rails/generators/migration'
|
3
|
+
require 'rails/generators/active_record'
|
4
|
+
|
5
|
+
module EasyContact
|
6
|
+
class MigrationGenerator < Rails::Generators::Base
|
7
|
+
include Rails::Generators::Migration
|
8
|
+
|
9
|
+
desc 'add easy contact'
|
10
|
+
|
11
|
+
source_root File.expand_path('../templates', __FILE__)
|
12
|
+
|
13
|
+
def self.next_migration_number(path)
|
14
|
+
ActiveRecord::Generators::Base.next_migration_number(path)
|
15
|
+
end
|
16
|
+
|
17
|
+
def create_migration_file
|
18
|
+
migration_template 'migration.rb', 'db/migrate/easy_contact_migration'
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
class EasyContactMigration < ActiveRecord::Migration
|
2
|
+
def change
|
3
|
+
create_table :easy_contact_entries do |t|
|
4
|
+
t.string :type
|
5
|
+
t.string :label
|
6
|
+
t.text :content
|
7
|
+
t.string :addition
|
8
|
+
t.string :extra
|
9
|
+
t.string :country
|
10
|
+
t.string :locale
|
11
|
+
t.boolean :primary
|
12
|
+
t.references :contactable
|
13
|
+
|
14
|
+
t.timestamps
|
15
|
+
end
|
16
|
+
add_index :easy_contact_entries, :contactable_id
|
17
|
+
end
|
18
|
+
end
|
data.tar.gz.sig
ADDED
Binary file
|
metadata
ADDED
@@ -0,0 +1,122 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: easy_contact
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Yen-Ju Chen
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain:
|
12
|
+
- !binary |-
|
13
|
+
LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSURNRENDQWhpZ0F3SUJB
|
14
|
+
Z0lCQURBTkJna3Foa2lHOXcwQkFRVUZBREErTVJBd0RnWURWUVFEREFkNWFt
|
15
|
+
Tm8KWlc1NE1SVXdFd1lLQ1pJbWlaUHlMR1FCR1JZRloyMWhhV3d4RXpBUkJn
|
16
|
+
b0praWFKay9Jc1pBRVpGZ05qYjIwdwpIaGNOTVRNd01qQTNNREV5T0RJNFdo
|
17
|
+
Y05NVFF3TWpBM01ERXlPREk0V2pBK01SQXdEZ1lEVlFRRERBZDVhbU5vClpX
|
18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+
Ry9pSlM4NVB2MERXbkFUM2NsNzZNL3I0TStRSE91MzhWQU9KeQo2clVIV2lh
|
34
|
+
LzlJekFKWlo4UHRPUGkwSGtUd1pJdnBTNmpMRjZqZXEyd3IrUThuYVFaNlMv
|
35
|
+
Sm5hbEJlNm43ZExTCkxPRXAzV3dMYWZCWjlWdElRay92Z0IzUUp4b3I4WDRS
|
36
|
+
M0lBc1Z2QzJZa0d3SjA5cUZWM1dRV1daU1NYUkp5ajUKMER3VStLZlV0YTRI
|
37
|
+
V1JyK2psKzRrWWVpVUtnYW1kdjJwUTRWYUo4M1ZHQzNGSXBVazlUVUxDTTN2
|
38
|
+
NWlIYkRRdQpvWnNXQ1E9PQotLS0tLUVORCBDRVJUSUZJQ0FURS0tLS0tCg==
|
39
|
+
date: 2013-02-25 00:00:00.000000000 Z
|
40
|
+
dependencies:
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rails
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
none: false
|
45
|
+
requirements:
|
46
|
+
- - ~>
|
47
|
+
- !ruby/object:Gem::Version
|
48
|
+
version: 3.2.11
|
49
|
+
type: :runtime
|
50
|
+
prerelease: false
|
51
|
+
version_requirements: !ruby/object:Gem::Requirement
|
52
|
+
none: false
|
53
|
+
requirements:
|
54
|
+
- - ~>
|
55
|
+
- !ruby/object:Gem::Version
|
56
|
+
version: 3.2.11
|
57
|
+
- !ruby/object:Gem::Dependency
|
58
|
+
name: sqlite3
|
59
|
+
requirement: !ruby/object:Gem::Requirement
|
60
|
+
none: false
|
61
|
+
requirements:
|
62
|
+
- - ! '>='
|
63
|
+
- !ruby/object:Gem::Version
|
64
|
+
version: '0'
|
65
|
+
type: :development
|
66
|
+
prerelease: false
|
67
|
+
version_requirements: !ruby/object:Gem::Requirement
|
68
|
+
none: false
|
69
|
+
requirements:
|
70
|
+
- - ! '>='
|
71
|
+
- !ruby/object:Gem::Version
|
72
|
+
version: '0'
|
73
|
+
description: A very simple contact system for Rails
|
74
|
+
email:
|
75
|
+
- yjchenx@gmail.com
|
76
|
+
executables: []
|
77
|
+
extensions: []
|
78
|
+
extra_rdoc_files: []
|
79
|
+
files:
|
80
|
+
- app/models/easy_contact/address.rb
|
81
|
+
- app/models/easy_contact/email.rb
|
82
|
+
- app/models/easy_contact/entry.rb
|
83
|
+
- app/models/easy_contact/name.rb
|
84
|
+
- app/models/easy_contact/phone.rb
|
85
|
+
- app/models/easy_contact/website.rb
|
86
|
+
- app/models/easy_contact.rb
|
87
|
+
- config/routes.rb
|
88
|
+
- lib/easy_contact/contactable.rb
|
89
|
+
- lib/easy_contact/engine.rb
|
90
|
+
- lib/easy_contact/version.rb
|
91
|
+
- lib/easy_contact.rb
|
92
|
+
- lib/generators/easy_contact/migration/migration_generator.rb
|
93
|
+
- lib/generators/easy_contact/migration/templates/migration.rb
|
94
|
+
- lib/tasks/easy_contact_tasks.rake
|
95
|
+
- MIT-LICENSE
|
96
|
+
- Rakefile
|
97
|
+
- README.md
|
98
|
+
homepage: https://github.com/yjchen/easy_contact
|
99
|
+
licenses: []
|
100
|
+
post_install_message:
|
101
|
+
rdoc_options: []
|
102
|
+
require_paths:
|
103
|
+
- lib
|
104
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
105
|
+
none: false
|
106
|
+
requirements:
|
107
|
+
- - ! '>='
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: '0'
|
110
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
111
|
+
none: false
|
112
|
+
requirements:
|
113
|
+
- - ! '>='
|
114
|
+
- !ruby/object:Gem::Version
|
115
|
+
version: '0'
|
116
|
+
requirements: []
|
117
|
+
rubyforge_project:
|
118
|
+
rubygems_version: 1.8.25
|
119
|
+
signing_key:
|
120
|
+
specification_version: 3
|
121
|
+
summary: A very simple contact system for Rails
|
122
|
+
test_files: []
|
metadata.gz.sig
ADDED
Binary file
|