isotope_contacts 0.1.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.
Files changed (74) hide show
  1. data/MIT-LICENSE +20 -0
  2. data/README.md +37 -0
  3. data/Rakefile +39 -0
  4. data/app/assets/javascripts/isotope_contacts/application.js +9 -0
  5. data/app/assets/stylesheets/isotope_contacts/application.css +7 -0
  6. data/app/assets/stylesheets/isotope_contacts/screen.css.scss +24 -0
  7. data/app/controllers/isotope_contacts/application_controller.rb +4 -0
  8. data/app/controllers/isotope_contacts/contacts_controller.rb +53 -0
  9. data/app/controllers/isotope_contacts/emails_controller.rb +51 -0
  10. data/app/controllers/isotope_contacts/phone_numbers_controller.rb +51 -0
  11. data/app/models/isotope_contacts/contact.rb +15 -0
  12. data/app/models/isotope_contacts/email.rb +11 -0
  13. data/app/models/isotope_contacts/phone_number.rb +11 -0
  14. data/app/views/isotope_contacts/contacts/_form.html.haml +7 -0
  15. data/app/views/isotope_contacts/contacts/edit.html.haml +2 -0
  16. data/app/views/isotope_contacts/contacts/index.html.haml +13 -0
  17. data/app/views/isotope_contacts/contacts/new.html.haml +2 -0
  18. data/app/views/isotope_contacts/contacts/show.html.haml +40 -0
  19. data/app/views/isotope_contacts/emails/_form.html.haml +7 -0
  20. data/app/views/isotope_contacts/emails/edit.html.haml +2 -0
  21. data/app/views/isotope_contacts/emails/new.html.haml +2 -0
  22. data/app/views/isotope_contacts/phone_numbers/_form.html.haml +7 -0
  23. data/app/views/isotope_contacts/phone_numbers/edit.html.haml +2 -0
  24. data/app/views/isotope_contacts/phone_numbers/new.html.haml +2 -0
  25. data/app/views/layouts/isotope_contacts/application.html.haml +21 -0
  26. data/config/routes.rb +7 -0
  27. data/db/migrate/20120106173507_create_contacts.rb +8 -0
  28. data/db/migrate/20120106210546_create_phone_numbers.rb +9 -0
  29. data/db/migrate/20120106213612_create_emails.rb +9 -0
  30. data/lib/isotope_contacts.rb +10 -0
  31. data/lib/isotope_contacts/engine.rb +5 -0
  32. data/lib/isotope_contacts/version.rb +3 -0
  33. data/lib/tasks/isotope_contacts_tasks.rake +4 -0
  34. data/test/dummy/Rakefile +7 -0
  35. data/test/dummy/app/assets/javascripts/application.js +9 -0
  36. data/test/dummy/app/assets/stylesheets/application.css +7 -0
  37. data/test/dummy/app/controllers/application_controller.rb +3 -0
  38. data/test/dummy/app/helpers/application_helper.rb +2 -0
  39. data/test/dummy/app/views/layouts/application.html.erb +14 -0
  40. data/test/dummy/config.ru +4 -0
  41. data/test/dummy/config/application.rb +45 -0
  42. data/test/dummy/config/boot.rb +10 -0
  43. data/test/dummy/config/database.yml +25 -0
  44. data/test/dummy/config/environment.rb +5 -0
  45. data/test/dummy/config/environments/development.rb +30 -0
  46. data/test/dummy/config/environments/production.rb +60 -0
  47. data/test/dummy/config/environments/test.rb +39 -0
  48. data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
  49. data/test/dummy/config/initializers/inflections.rb +10 -0
  50. data/test/dummy/config/initializers/mime_types.rb +5 -0
  51. data/test/dummy/config/initializers/secret_token.rb +7 -0
  52. data/test/dummy/config/initializers/session_store.rb +8 -0
  53. data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
  54. data/test/dummy/config/locales/en.yml +5 -0
  55. data/test/dummy/config/routes.rb +3 -0
  56. data/test/dummy/db/development.sqlite3 +0 -0
  57. data/test/dummy/db/schema.rb +33 -0
  58. data/test/dummy/db/test.sqlite3 +0 -0
  59. data/test/dummy/log/development.log +31 -0
  60. data/test/dummy/log/test.log +275 -0
  61. data/test/dummy/public/404.html +26 -0
  62. data/test/dummy/public/422.html +26 -0
  63. data/test/dummy/public/500.html +26 -0
  64. data/test/dummy/public/favicon.ico +0 -0
  65. data/test/dummy/script/rails +6 -0
  66. data/test/integration/isotope_contacts/contacts_test.rb +56 -0
  67. data/test/integration/isotope_contacts/emails_test.rb +29 -0
  68. data/test/integration/isotope_contacts/phone_numbers_test.rb +29 -0
  69. data/test/isotope_contacts_test.rb +7 -0
  70. data/test/minitest_helper.rb +37 -0
  71. data/test/support/factories.rb +16 -0
  72. data/test/unit/isotope_contacts/contact_test.rb +26 -0
  73. data/test/unit/isotope_contacts/phone_number_test.rb +31 -0
  74. metadata +296 -0
@@ -0,0 +1,20 @@
1
+ Copyright 2012 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.
@@ -0,0 +1,37 @@
1
+ # IsotopeContacts
2
+ IsotopeContacts is a gem providing a rails engine for contact management.
3
+
4
+ It is compatible with Rails 3.1+
5
+
6
+ ## Demo site
7
+ [See it in action here.](http://isotope-contacts-demo.heroku.com)
8
+
9
+ ## Screenshots
10
+ Here are some screenshots of what it looks like:
11
+
12
+ ![Contact Listing](https://raw.github.com/isotope11/isotope_contacts/master/doc/contacts_listing.png)
13
+
14
+
15
+ ![Contact Show](https://raw.github.com/isotope11/isotope_contacts/master/doc/contact_show.png)
16
+
17
+ ## Installation
18
+ You can install it by adding the following to your Gemfile:
19
+
20
+ gem 'isotope_contacts', :git => 'http://github.com/isotope11/isotope_contacts.git'
21
+
22
+ Then in your config/routes.rb:
23
+
24
+ mount IsotopeContacts::Engine => "/isotope_contacts"
25
+
26
+ Then just fire up your app and visit `/isotope_contacts`
27
+
28
+ ## Developing on IsotopeContacts
29
+ IsotopeContacts is implemented as a Rails engine and its tests are run in the context
30
+ of a dummy Rails app. The process for getting the tests to run is similar to setting up a regular rails app:
31
+
32
+ bundle exec rake -f test/dummy/Rakefile db:drop db:create db:migrate db:test:prepare
33
+
34
+ Once this setup has been done, IsotopeContacts's specs can be run by executing this command:
35
+
36
+ bundle exec rake test
37
+
@@ -0,0 +1,39 @@
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 = 'IsotopeContacts'
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("../test/dummy/Rakefile", __FILE__)
24
+ load 'rails/tasks/engine.rake'
25
+
26
+
27
+ Bundler::GemHelper.install_tasks
28
+
29
+ require 'rake/testtask'
30
+
31
+ Rake::TestTask.new(:test) do |t|
32
+ t.libs << 'lib'
33
+ t.libs << 'test'
34
+ t.pattern = 'test/**/*_test.rb'
35
+ t.verbose = false
36
+ end
37
+
38
+
39
+ task :default => :test
@@ -0,0 +1,9 @@
1
+ // This is a manifest file that'll be compiled into including all the files listed below.
2
+ // Add new JavaScript/Coffee code in separate files in this directory and they'll automatically
3
+ // be included in the compiled file accessible from http://example.com/assets/application.js
4
+ // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
5
+ // the compiled file.
6
+ //
7
+ //= require jquery
8
+ //= require jquery_ujs
9
+ //= require_tree .
@@ -0,0 +1,7 @@
1
+ /*
2
+ * This is a manifest file that'll automatically include all the stylesheets available in this directory
3
+ * and any sub-directories. You're free to add application-wide styles to this file and they'll appear at
4
+ * the top of the compiled file, but it's generally better to create a new file per style scope.
5
+ *= require_self
6
+ *= require_tree .
7
+ */
@@ -0,0 +1,24 @@
1
+ @import 'bootstrap';
2
+
3
+ body{
4
+ padding-top: 60px;
5
+ }
6
+
7
+ .contact-module{
8
+ .contact{
9
+ h2{
10
+ display: inline-block;
11
+ }
12
+ a{
13
+ position: relative;
14
+ top: -4px;
15
+ margin-left: 10px;
16
+ }
17
+ }
18
+ }
19
+
20
+ .object-actions{
21
+ form{
22
+ display: inline-block;
23
+ }
24
+ }
@@ -0,0 +1,4 @@
1
+ module IsotopeContacts
2
+ class ApplicationController < ActionController::Base
3
+ end
4
+ end
@@ -0,0 +1,53 @@
1
+ module IsotopeContacts
2
+ class ContactsController < ApplicationController
3
+ def index
4
+ @search = ::IsotopeContacts::Contact.search(params[:search])
5
+ @contacts = @search.all
6
+ end
7
+
8
+ def new
9
+ @contact = ::IsotopeContacts::Contact.new(params[:contact])
10
+ end
11
+
12
+ def show
13
+ @contact = ::IsotopeContacts::Contact.find(params[:id])
14
+ end
15
+
16
+ def create
17
+ @contact = ::IsotopeContacts::Contact.new(params[:contact])
18
+ if @contact.save
19
+ flash[:notice] = "Contact created successfully."
20
+ redirect_to contact_path(@contact)
21
+ else
22
+ flash.now[:notice] = "There was a problem creating the contact."
23
+ render :new
24
+ end
25
+ end
26
+
27
+ def edit
28
+ @contact = ::IsotopeContacts::Contact.find(params[:id])
29
+ end
30
+
31
+ def update
32
+ @contact = ::IsotopeContacts::Contact.find(params[:id])
33
+ if @contact.update_attributes(params[:contact])
34
+ flash[:notice] = "Contact was updated successfully."
35
+ redirect_to contact_path(@contact)
36
+ else
37
+ flash.now[:error] = "There was a problem updating the contact."
38
+ render :edit
39
+ end
40
+ end
41
+
42
+ def destroy
43
+ @contact = ::IsotopeContacts::Contact.find(params[:id])
44
+ if @contact.destroy
45
+ flash[:notice] = "Contact was deleted successfully."
46
+ redirect_to contacts_path
47
+ else
48
+ flash[:error] = "There was a problem deleting the contact"
49
+ redirect_to contacts_path
50
+ end
51
+ end
52
+ end
53
+ end
@@ -0,0 +1,51 @@
1
+ module IsotopeContacts
2
+ class EmailsController < ApplicationController
3
+ before_filter :load_contact
4
+
5
+ def new
6
+ @email = @contact.emails.new(params[:email])
7
+ end
8
+
9
+ def create
10
+ @email = @contact.emails.new(params[:email])
11
+ if @email.save
12
+ flash[:notice] = "Email created successfully."
13
+ redirect_to contact_path(@contact)
14
+ else
15
+ flash.now[:notice] = "There was a problem creating the email."
16
+ render :new
17
+ end
18
+ end
19
+
20
+ def edit
21
+ @email = @contact.emails.find(params[:id])
22
+ end
23
+
24
+ def update
25
+ @email = @contact.emails.find(params[:id])
26
+ if @email.update_attributes(params[:email])
27
+ flash[:notice] = "Email updated successfully."
28
+ redirect_to contact_path(@contact)
29
+ else
30
+ flash.now[:notice] = "There was a problem updating the email."
31
+ render :edit
32
+ end
33
+ end
34
+
35
+ def destroy
36
+ @email = @contact.emails.find(params[:id])
37
+ if @email.destroy
38
+ flash[:notice] = "Email was deleted successfully."
39
+ redirect_to contact_path(@contact)
40
+ else
41
+ flash.now[:error] = "There was a problem deleting the email"
42
+ redirect_to contact_path(@contact)
43
+ end
44
+ end
45
+
46
+ protected
47
+ def load_contact
48
+ @contact = IsotopeContacts::Contact.find(params[:contact_id])
49
+ end
50
+ end
51
+ end
@@ -0,0 +1,51 @@
1
+ module IsotopeContacts
2
+ class PhoneNumbersController < ApplicationController
3
+ before_filter :load_contact
4
+
5
+ def new
6
+ @phone_number = @contact.phone_numbers.new(params[:phone_number])
7
+ end
8
+
9
+ def create
10
+ @phone_number = @contact.phone_numbers.new(params[:phone_number])
11
+ if @phone_number.save
12
+ flash[:notice] = "Phone Number created successfully."
13
+ redirect_to contact_path(@contact)
14
+ else
15
+ flash.now[:notice] = "There was a problem creating the phone number."
16
+ render :new
17
+ end
18
+ end
19
+
20
+ def edit
21
+ @phone_number = @contact.phone_numbers.find(params[:id])
22
+ end
23
+
24
+ def update
25
+ @phone_number = @contact.phone_numbers.find(params[:id])
26
+ if @phone_number.update_attributes(params[:phone_number])
27
+ flash[:notice] = "Phone Number updated successfully."
28
+ redirect_to contact_path(@contact)
29
+ else
30
+ flash.now[:notice] = "There was a problem updating the phone number."
31
+ render :edit
32
+ end
33
+ end
34
+
35
+ def destroy
36
+ @phone_number = @contact.phone_numbers.find(params[:id])
37
+ if @phone_number.destroy
38
+ flash[:notice] = "Phone Number was deleted successfully."
39
+ redirect_to contact_path(@contact)
40
+ else
41
+ flash.now[:error] = "There was a problem deleting the phone number"
42
+ redirect_to contact_path(@contact)
43
+ end
44
+ end
45
+
46
+ protected
47
+ def load_contact
48
+ @contact = IsotopeContacts::Contact.find(params[:contact_id])
49
+ end
50
+ end
51
+ end
@@ -0,0 +1,15 @@
1
+ module IsotopeContacts
2
+ class Contact < ActiveRecord::Base
3
+ validates_presence_of :first_name
4
+ has_many :phone_numbers
5
+ has_many :emails
6
+
7
+ def full_name
8
+ [first_name, last_name].join(" ")
9
+ end
10
+
11
+ def to_s
12
+ full_name
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,11 @@
1
+ module IsotopeContacts
2
+ class Email < ::ActiveRecord::Base
3
+ validates_presence_of :email
4
+ validates_presence_of :name
5
+ belongs_to :contact
6
+
7
+ def to_s
8
+ "#{name}: #{email}"
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,11 @@
1
+ module IsotopeContacts
2
+ class PhoneNumber < ::ActiveRecord::Base
3
+ validates_presence_of :number
4
+ validates_presence_of :name
5
+ belongs_to :contact
6
+
7
+ def to_s
8
+ "#{name}: #{number}"
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,7 @@
1
+ = semantic_form_for contact do |f|
2
+ = f.semantic_errors
3
+ = f.inputs do
4
+ = f.input :first_name
5
+ = f.input :last_name
6
+ = f.buttons do
7
+ = f.commit_button button_html: { class: 'btn primary' }
@@ -0,0 +1,2 @@
1
+ .contact-form-module
2
+ = render partial: 'form', locals: { contact: @contact }
@@ -0,0 +1,13 @@
1
+ .contacts-module
2
+ %table.zebra-striped
3
+ %thead
4
+ %tr
5
+ %th Name
6
+ %th Actions
7
+ %tbody
8
+ - @contacts.each do |contact|
9
+ %tr
10
+ %td= link_to contact, contact_path(contact)
11
+ %td.object-actions
12
+ = link_to "Edit", edit_contact_path(contact), class: 'btn'
13
+ = button_to "Delete", contact_path(contact), method: :delete, class: 'btn danger'
@@ -0,0 +1,2 @@
1
+ .contact-form-module
2
+ = render partial: 'form', locals: { contact: @contact }
@@ -0,0 +1,40 @@
1
+ .contact-module
2
+ .contact
3
+ %h2= @contact
4
+ = link_to "Edit", edit_contact_path(@contact), rel: 'edit-contact', class: 'btn primary'
5
+ %hr
6
+ .phone_numbers
7
+ %h5 Phone Numbers
8
+ %table.zebra-striped
9
+ %thead
10
+ %tr
11
+ %th Name
12
+ %th Number
13
+ %th Actions
14
+ %tbody
15
+ - @contact.phone_numbers.each do |phone_number|
16
+ %tr
17
+ %td= phone_number.name
18
+ %td= phone_number.number
19
+ %td.object-actions
20
+ = link_to "Edit", edit_contact_phone_number_path(@contact, phone_number), rel: 'edit-phone-number', class: 'btn'
21
+ = button_to "Delete", contact_phone_number_path(@contact, phone_number), rel: 'edit-phone-number', class: 'btn danger', method: :delete
22
+ = link_to "Add Phone Number", new_contact_phone_number_path(@contact), rel: 'add-phone-number', class: 'btn'
23
+ %hr
24
+ .emails
25
+ %h5 Emails
26
+ %table.zebra-striped
27
+ %thead
28
+ %tr
29
+ %th Name
30
+ %th Email
31
+ %th Actions
32
+ %tbody
33
+ - @contact.emails.each do |email|
34
+ %tr
35
+ %td= email.name
36
+ %td= email.email
37
+ %td.object-actions
38
+ = link_to "Edit", edit_contact_email_path(@contact, email), rel: 'edit-email', class: 'btn'
39
+ = button_to "Delete", contact_email_path(@contact, email), rel: 'edit-email', class: 'btn danger', method: :delete
40
+ = link_to "Add Email Address", new_contact_email_path(@contact), rel: 'add-email-address', class: 'btn'
@@ -0,0 +1,7 @@
1
+ = semantic_form_for [email.contact, email] do |f|
2
+ = f.semantic_errors
3
+ = f.inputs do
4
+ = f.input :name, hint: 'e.g Home, Office, etc.'
5
+ = f.input :email, hint: 'e.g. john@doe.com'
6
+ = f.buttons do
7
+ = f.commit_button button_html: { class: 'btn primary' }
@@ -0,0 +1,2 @@
1
+ .email-form-module
2
+ = render partial: 'form', locals: { email: @email }
@@ -0,0 +1,2 @@
1
+ .email-form-module
2
+ = render partial: 'form', locals: { email: @email }
@@ -0,0 +1,7 @@
1
+ = semantic_form_for [phone_number.contact, phone_number] do |f|
2
+ = f.semantic_errors
3
+ = f.inputs do
4
+ = f.input :name, hint: 'e.g Home, Office, etc.'
5
+ = f.input :number, hint: 'e.g. 2055551212'
6
+ = f.buttons do
7
+ = f.commit_button button_html: { class: 'btn primary' }