contact_sync 1.4.6 → 1.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Rakefile +24 -22
- data/lib/contact_sync.rb +0 -1
- data/lib/contact_sync/engine.rb +7 -0
- data/lib/contact_sync/syncable.rb +10 -0
- data/lib/contact_sync/version.rb +1 -1
- data/lib/generators/install_contact_sync/templates/contact.rb +0 -64
- data/lib/generators/install_contact_sync/templates/phone.rb +18 -8
- data/{test → spec}/dummy/README.rdoc +0 -0
- data/{test → spec}/dummy/Rakefile +0 -0
- data/{test → spec}/dummy/app/assets/javascripts/application.js +0 -0
- data/{test → spec}/dummy/app/assets/stylesheets/application.css +0 -0
- data/{test → spec}/dummy/app/controllers/application_controller.rb +0 -0
- data/{test → spec}/dummy/app/helpers/application_helper.rb +0 -0
- data/spec/dummy/app/models/address.rb +5 -0
- data/spec/dummy/app/models/contact.rb +10 -0
- data/spec/dummy/app/models/email.rb +14 -0
- data/spec/dummy/app/models/phone.rb +41 -0
- data/spec/dummy/app/models/routes.rb +9 -0
- data/spec/dummy/app/models/user.rb +4 -0
- data/spec/dummy/app/views/layouts/application.html.erb +14 -0
- data/{test → spec}/dummy/bin/bundle +0 -0
- data/{test → spec}/dummy/bin/rails +0 -0
- data/{test → spec}/dummy/bin/rake +0 -0
- data/{test → spec}/dummy/bin/setup +0 -0
- data/{test → spec}/dummy/config.ru +0 -0
- data/{test → spec}/dummy/config/application.rb +13 -3
- data/{test → spec}/dummy/config/boot.rb +0 -0
- data/{test → spec}/dummy/config/database.yml +0 -0
- data/{test → spec}/dummy/config/environment.rb +0 -0
- data/{test → spec}/dummy/config/environments/development.rb +0 -0
- data/{test → spec}/dummy/config/environments/production.rb +0 -0
- data/{test → spec}/dummy/config/environments/test.rb +0 -0
- data/{test → spec}/dummy/config/initializers/assets.rb +0 -0
- data/{test → spec}/dummy/config/initializers/backtrace_silencers.rb +0 -0
- data/{test → spec}/dummy/config/initializers/cookies_serializer.rb +0 -0
- data/{test → spec}/dummy/config/initializers/filter_parameter_logging.rb +0 -0
- data/{test → spec}/dummy/config/initializers/inflections.rb +0 -0
- data/{test → spec}/dummy/config/initializers/mime_types.rb +0 -0
- data/spec/dummy/config/initializers/session_store.rb +3 -0
- data/{test → spec}/dummy/config/initializers/wrap_parameters.rb +0 -0
- data/{test → spec}/dummy/config/locales/en.yml +0 -0
- data/{test → spec}/dummy/config/routes.rb +0 -0
- data/{test → spec}/dummy/config/secrets.yml +3 -3
- data/spec/dummy/db/development.sqlite3 +0 -0
- data/spec/dummy/db/migrate/20150520065844_create_contact_sync_schema.rb +70 -0
- data/spec/dummy/db/migrate/20150529072537_remove_device_id_from_contacts.rb +7 -0
- data/spec/dummy/db/schema.rb +74 -0
- data/spec/dummy/db/test.sqlite3 +0 -0
- data/spec/dummy/log/development.log +186 -0
- data/spec/dummy/log/test.log +386 -0
- data/{test → spec}/dummy/public/404.html +0 -0
- data/{test → spec}/dummy/public/422.html +0 -0
- data/{test → spec}/dummy/public/500.html +0 -0
- data/{test → spec}/dummy/public/favicon.ico +0 -0
- data/spec/factories/contact_factory.rb +18 -0
- data/spec/factories/user_factory.rb +7 -0
- data/spec/rails_helper.rb +82 -0
- data/spec/spec_helper.rb +92 -0
- data/spec/string_phone_spec.rb +15 -0
- metadata +152 -82
- data/test/con_sync_test.rb +0 -7
- data/test/dummy/config/initializers/session_store.rb +0 -3
- data/test/dummy/db/schema.rb +0 -17
- data/test/integration/navigation_test.rb +0 -10
- data/test/lib/generators/con_sync/install_con_sync_generator_test.rb +0 -16
- data/test/test_helper.rb +0 -20
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2929c9d455765385b5821e644c0ffab4dffeca62
|
4
|
+
data.tar.gz: 8148f5288906d279c7111e5f708a16494cc6fc25
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 24c507f52f602d35f982cff0ffa2354e22e497b445c148fdaf24141009f510f56044e27ef2466589775418ef9f8599ad854c0d5c3511b531a8421b253e718629
|
7
|
+
data.tar.gz: c077c847af5039e6d04d949ecdd6331169f356bf5af5cc22933b8e3e40eb4c6cbc9348dbb22b719665afc683ba30d08f587b227c7145ae0bd5cefbe831670368
|
data/Rakefile
CHANGED
@@ -1,37 +1,39 @@
|
|
1
|
+
#!/usr/bin/env rake
|
1
2
|
begin
|
2
3
|
require 'bundler/setup'
|
3
4
|
rescue LoadError
|
4
5
|
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
|
5
6
|
end
|
6
|
-
|
7
|
-
require 'rdoc/task'
|
8
|
-
|
9
|
-
RDoc::Task.new(:rdoc) do |rdoc|
|
10
|
-
rdoc.rdoc_dir = 'rdoc'
|
11
|
-
rdoc.title = 'ContactSync'
|
12
|
-
rdoc.options << '--line-numbers'
|
13
|
-
rdoc.rdoc_files.include('README.rdoc')
|
14
|
-
rdoc.rdoc_files.include('lib/**/*.rb')
|
15
|
-
end
|
16
|
-
|
17
|
-
APP_RAKEFILE = File.expand_path("../test/dummy/Rakefile", __FILE__)
|
7
|
+
APP_RAKEFILE = File.expand_path("../spec/dummy/Rakefile", __FILE__)
|
18
8
|
load 'rails/tasks/engine.rake'
|
19
9
|
|
20
10
|
|
21
|
-
|
22
|
-
|
11
|
+
Bundler::GemHelper.install_tasks
|
12
|
+
Dir[File.join(File.dirname(__FILE__), 'tasks/**/*.rake')].each {|f| load f }
|
13
|
+
require 'bundler/gem_tasks'
|
23
14
|
|
15
|
+
require 'rspec/core'
|
16
|
+
require 'rspec/core/rake_task'
|
24
17
|
|
25
|
-
|
18
|
+
load 'rails/tasks/statistics.rake' #what is this?
|
26
19
|
|
27
|
-
|
20
|
+
desc "Run all specs in spec directory (excluding plugin specs)"
|
21
|
+
RSpec::Core::RakeTask.new(:spec => 'app:db:test:prepare')
|
22
|
+
task :default => :spec
|
28
23
|
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
t.verbose = false
|
24
|
+
# Default directory to look in is `/specs`
|
25
|
+
# Run with `rake spec`
|
26
|
+
RSpec::Core::RakeTask.new(:spec) do |task|
|
27
|
+
task.rspec_opts = ['--color', '--format', 'documentation']
|
34
28
|
end
|
35
29
|
|
30
|
+
task :default => :spec
|
36
31
|
|
37
|
-
task
|
32
|
+
require 'rdoc/task'
|
33
|
+
RDoc::Task.new(:rdoc) do |rdoc|
|
34
|
+
rdoc.rdoc_dir = 'rdoc'
|
35
|
+
rdoc.title = 'ContactSync'
|
36
|
+
rdoc.options << '--line-numbers'
|
37
|
+
rdoc.rdoc_files.include('README.rdoc')
|
38
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
39
|
+
end
|
data/lib/contact_sync.rb
CHANGED
data/lib/contact_sync/engine.rb
CHANGED
@@ -1,5 +1,12 @@
|
|
1
1
|
module ContactSync
|
2
2
|
class Engine < ::Rails::Engine
|
3
3
|
isolate_namespace ContactSync
|
4
|
+
|
5
|
+
config.generators do |g|
|
6
|
+
g.test_framework :rspec
|
7
|
+
g.fixture_replacement :factory_girl, :dir => 'spec/factories'
|
8
|
+
g.assets false
|
9
|
+
g.helper false
|
10
|
+
end
|
4
11
|
end
|
5
12
|
end
|
@@ -68,6 +68,16 @@ module ContactSync
|
|
68
68
|
modified_contacts.each do |con|
|
69
69
|
theContact = self.contacts.find_by_record_id(con[:record_id])
|
70
70
|
if ! theContact.blank?
|
71
|
+
#lets create phone_numbers that have been added in this contact.
|
72
|
+
phones = con[:phones]
|
73
|
+
phones.each do |ph|
|
74
|
+
found_phone = theContact.phones.where(encrypted_number: ph[:number].extract_country_code[-1].encrypt(:symmetric)).limit(1).first
|
75
|
+
if !found_phone
|
76
|
+
theContact.phones.create(phone_params(ph))
|
77
|
+
else
|
78
|
+
puts 'modified phone_number is already present. Ignoring situation.'
|
79
|
+
end
|
80
|
+
end
|
71
81
|
if !theContact.update_attributes(contact_params(con))
|
72
82
|
result[:modified][:failed] << theContact.record_id
|
73
83
|
else
|
data/lib/contact_sync/version.rb
CHANGED
@@ -2,73 +2,9 @@ class Contact < ActiveRecord::Base
|
|
2
2
|
|
3
3
|
has_many :phones, dependent: :delete_all
|
4
4
|
has_many :emails, :dependent => :delete_all
|
5
|
-
# has_many :addresses, :dependent => :delete_all
|
6
|
-
# has_many :instant_messengers, :dependent => :delete_all
|
7
|
-
# has_many :social_profiles, :dependent => :delete_all
|
8
5
|
|
9
6
|
belongs_to :user
|
10
7
|
validates_presence_of :user
|
11
8
|
validates :record_id, presence: true, numericality: {:greater_than => 0}
|
12
9
|
|
13
|
-
# def jsonNotation
|
14
|
-
#
|
15
|
-
# phonesJSON = Array.new
|
16
|
-
# self.phones.each do |aPhone|
|
17
|
-
# hh =
|
18
|
-
# {
|
19
|
-
# lable: aPhone.label,
|
20
|
-
# phone_number: aPhone.number
|
21
|
-
# }
|
22
|
-
# phonesJSON << hh
|
23
|
-
# end
|
24
|
-
#
|
25
|
-
# emailsJSON = Array.new
|
26
|
-
#
|
27
|
-
# self.emails.each do |anEmail|
|
28
|
-
# hh = {
|
29
|
-
# label: anEmail.label,
|
30
|
-
# email: anEmail.email
|
31
|
-
# }
|
32
|
-
# emailsJSON << hh
|
33
|
-
# end
|
34
|
-
#
|
35
|
-
# profilesJSON = Array.new
|
36
|
-
# self.social_profiles.each do |aProfile|
|
37
|
-
# hh = {
|
38
|
-
# label: aProfile.label,
|
39
|
-
# username: aProfile.username
|
40
|
-
# }
|
41
|
-
# profilesJSON << hh
|
42
|
-
# end
|
43
|
-
#
|
44
|
-
# messengersJSON = Array.new
|
45
|
-
# self.instant_messengers.each do |aMessenger|
|
46
|
-
# hh = {
|
47
|
-
# label: aMessenger.label,
|
48
|
-
# username: aMessenger.username
|
49
|
-
# }
|
50
|
-
# messengersJSON << hh
|
51
|
-
# end
|
52
|
-
#
|
53
|
-
# contact = {
|
54
|
-
# first_name: first_name,
|
55
|
-
# middle_name: middle_name,
|
56
|
-
# last_name: last_name,
|
57
|
-
# composite_name: composite_name,
|
58
|
-
# prefix: prefix,
|
59
|
-
# suffix: suffix,
|
60
|
-
# nickname: nickname,
|
61
|
-
# job_title: job_title,
|
62
|
-
# department: department,
|
63
|
-
# birthdate: birthdate,
|
64
|
-
# note: note,
|
65
|
-
# creation_date: creation_date,
|
66
|
-
# modification_date: modification_date,
|
67
|
-
# phones: phonesJSON,
|
68
|
-
# emails: emailsJSON,
|
69
|
-
# social_profiles: profilesJSON,
|
70
|
-
# instant_messengers: messengersJSON
|
71
|
-
# }
|
72
|
-
# return contact
|
73
|
-
# end
|
74
10
|
end
|
@@ -1,20 +1,14 @@
|
|
1
1
|
class Phone < ActiveRecord::Base
|
2
2
|
attr_accessor :number
|
3
3
|
belongs_to :contact
|
4
|
+
validate :check_validity
|
4
5
|
|
5
6
|
def number
|
6
7
|
return self.encrypted_number.try(:decrypt,:symmetric) || ""
|
7
8
|
end
|
8
9
|
|
9
|
-
def complete_phone_number
|
10
|
-
if self.cc_prefix.blank?
|
11
|
-
"0#{self.number}"
|
12
|
-
else
|
13
|
-
"+#{self.cc_prefix}#{self.number}"
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
10
|
def number=(string)
|
11
|
+
puts "Phone Number Received: #{string}"
|
18
12
|
self.cc_prefix, num = string.extract_country_code
|
19
13
|
if num.blank? or num.length < 4
|
20
14
|
self.errors[:phone_number] << "Phone number is not valid"
|
@@ -24,8 +18,24 @@ class Phone < ActiveRecord::Base
|
|
24
18
|
self.encrypted_number
|
25
19
|
end
|
26
20
|
|
21
|
+
def complete_phone_number
|
22
|
+
if self.cc_prefix.blank?
|
23
|
+
"00#{self.phone_number}"
|
24
|
+
elsif self.cc_prefix == "0"
|
25
|
+
"#{self.cc_prefix}#{self.phone_number}"
|
26
|
+
else
|
27
|
+
"+#{self.cc_prefix}#{self.phone_number}"
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
27
31
|
def save_with_format!
|
28
32
|
save_with_format
|
29
33
|
save
|
30
34
|
end
|
35
|
+
private
|
36
|
+
def check_validity
|
37
|
+
if encrypted_number.blank? or number.size < 5
|
38
|
+
errors[:number] << "Phone number is invalid"
|
39
|
+
end
|
40
|
+
end
|
31
41
|
end
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
@@ -0,0 +1,41 @@
|
|
1
|
+
class Phone < ActiveRecord::Base
|
2
|
+
attr_accessor :number
|
3
|
+
belongs_to :contact
|
4
|
+
validate :check_validity
|
5
|
+
|
6
|
+
def number
|
7
|
+
return self.encrypted_number.try(:decrypt,:symmetric) || ""
|
8
|
+
end
|
9
|
+
|
10
|
+
def number=(string)
|
11
|
+
puts "Phone Number Received: #{string}"
|
12
|
+
self.cc_prefix, num = string.extract_country_code
|
13
|
+
if num.blank? or num.length < 4
|
14
|
+
self.errors[:phone_number] << "Phone number is not valid"
|
15
|
+
return
|
16
|
+
end
|
17
|
+
self.encrypted_number = num.encrypt(:symmetric)
|
18
|
+
self.encrypted_number
|
19
|
+
end
|
20
|
+
|
21
|
+
def complete_phone_number
|
22
|
+
if self.cc_prefix.blank?
|
23
|
+
"00#{self.phone_number}"
|
24
|
+
elsif self.cc_prefix == "0"
|
25
|
+
"#{self.cc_prefix}#{self.phone_number}"
|
26
|
+
else
|
27
|
+
"+#{self.cc_prefix}#{self.phone_number}"
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
def save_with_format!
|
32
|
+
save_with_format
|
33
|
+
save
|
34
|
+
end
|
35
|
+
private
|
36
|
+
def check_validity
|
37
|
+
if encrypted_number.blank? or number.size < 5
|
38
|
+
errors[:number] << "Phone number is invalid"
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>TestApp</title>
|
5
|
+
<%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => true %>
|
6
|
+
<%= javascript_include_tag 'application', 'data-turbolinks-track' => true %>
|
7
|
+
<%= csrf_meta_tags %>
|
8
|
+
</head>
|
9
|
+
<body>
|
10
|
+
|
11
|
+
<%= yield %>
|
12
|
+
|
13
|
+
</body>
|
14
|
+
</html>
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
@@ -1,11 +1,17 @@
|
|
1
1
|
require File.expand_path('../boot', __FILE__)
|
2
2
|
|
3
|
-
|
3
|
+
# Pick the frameworks you want:
|
4
|
+
require "active_record/railtie"
|
5
|
+
require "action_controller/railtie"
|
6
|
+
require "action_mailer/railtie"
|
7
|
+
require "action_view/railtie"
|
8
|
+
require "sprockets/railtie"
|
9
|
+
# require "rails/test_unit/railtie"
|
4
10
|
|
5
11
|
Bundler.require(*Rails.groups)
|
6
12
|
require "contact_sync"
|
7
13
|
|
8
|
-
module
|
14
|
+
module TestApp
|
9
15
|
class Application < Rails::Application
|
10
16
|
# Settings in config/environments/* take precedence over those specified here.
|
11
17
|
# Application configuration should go into files in config/initializers
|
@@ -21,6 +27,10 @@ module Dummy
|
|
21
27
|
|
22
28
|
# Do not swallow errors in after_commit/after_rollback callbacks.
|
23
29
|
config.active_record.raise_in_transactional_callbacks = true
|
30
|
+
|
31
|
+
|
32
|
+
EncryptedStrings::SymmetricCipher.default_algorithm = 'aes-256-cbc'
|
33
|
+
EncryptedStrings::SymmetricCipher.default_password = 'dkljf84fklj09wfkj09rj0cnwjer09c2u3hf9w8nfiojesdpsfpcndsfjs'
|
34
|
+
|
24
35
|
end
|
25
36
|
end
|
26
|
-
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
@@ -11,12 +11,12 @@
|
|
11
11
|
# if you're sharing your code publicly.
|
12
12
|
|
13
13
|
development:
|
14
|
-
secret_key_base:
|
14
|
+
secret_key_base: d55e5b24d007be0f96e6bd46ef59dc022b1244e86a424ba85430009d77be0aa97bc77c0284b69012bba89a781cebba1be8dcf72c514376206d6b9760e5e4a7f2
|
15
15
|
|
16
16
|
test:
|
17
|
-
secret_key_base:
|
17
|
+
secret_key_base: 725a51723ba99807a2b6474d8c7f8cc5b753a7f3ca3f2e678a37592d2ac6d3bfe8e3e779104c45bb03075fcfa4a484aaafc94121bae81258c772a16a0858e2aa
|
18
18
|
|
19
19
|
# Do not keep production secrets in the repository,
|
20
20
|
# instead read values from the environment.
|
21
21
|
production:
|
22
|
-
secret_key_base:
|
22
|
+
secret_key_base: 725a51723ba99807a2b6474d8c7f8cc5b753a7f3ca3f2e678a37592d2ac6d3bfe8e3e779104c45bb03075fcfa4a484aaafc94121bae81258c772a16a0858e2dd
|