contactable 0.1.0 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (110) hide show
  1. data/CHANGELOG +2 -0
  2. data/Manifest +94 -14
  3. data/README.rdoc +27 -1
  4. data/Rakefile +1 -1
  5. data/app/controllers/addresses_controller.rb +3 -0
  6. data/app/controllers/cities_controller.rb +16 -0
  7. data/app/controllers/contact_field_actions.rb +60 -0
  8. data/app/controllers/divisions_controller.rb +17 -0
  9. data/app/controllers/emails_controller.rb +3 -0
  10. data/app/controllers/identifications_controller.rb +3 -0
  11. data/app/controllers/instant_messengers_controller.rb +3 -0
  12. data/app/controllers/phones_controller.rb +3 -0
  13. data/app/controllers/websites_controller.rb +3 -0
  14. data/app/helpers/contactable_helper.rb +46 -0
  15. data/app/models/address.rb +96 -0
  16. data/app/models/address_type.rb +5 -0
  17. data/app/models/city.rb +21 -0
  18. data/app/models/country.rb +8 -0
  19. data/app/models/division.rb +26 -0
  20. data/{generators/contactable/templates → app}/models/email.rb +0 -0
  21. data/app/models/email_type.rb +5 -0
  22. data/app/models/identification.rb +7 -0
  23. data/app/models/identification_type.rb +5 -0
  24. data/{generators/contactable/templates → app}/models/instant_messenger.rb +0 -0
  25. data/{generators/contactable/templates → app}/models/instant_messenger_protocol.rb +2 -2
  26. data/{generators/contactable/templates → app}/models/instant_messenger_type.rb +3 -3
  27. data/{generators/contactable/templates → app}/models/phone.rb +0 -0
  28. data/app/models/phone_type.rb +5 -0
  29. data/{generators/contactable/templates → app}/models/province.rb +0 -0
  30. data/{generators/contactable/templates → app}/models/website.rb +0 -0
  31. data/app/models/website_type.rb +5 -0
  32. data/app/views/addresses/_address.html.erb +31 -0
  33. data/app/views/cities/index.html.erb +6 -0
  34. data/app/views/contactable/_contactable.html.erb +11 -0
  35. data/app/views/contactable/_contactable_field.html.erb +8 -0
  36. data/app/views/contactable/_fields.html.erb +49 -0
  37. data/app/views/divisions/index.html.erb +9 -0
  38. data/app/views/emails/_email.html.erb +2 -0
  39. data/app/views/identifications/_identification.html.erb +2 -0
  40. data/app/views/instant_messengers/_instant_messenger.html.erb +3 -0
  41. data/app/views/phones/_phone.html.erb +2 -0
  42. data/app/views/websites/_website.html.erb +2 -0
  43. data/config/contactable_routes.rb +4 -0
  44. data/contactable.gemspec +5 -5
  45. data/generators/contactable/USAGE +1 -10
  46. data/generators/contactable/contactable_generator.rb +35 -32
  47. data/generators/contactable/lib/insert_commands.rb +33 -0
  48. data/generators/contactable/templates/README +12 -0
  49. data/generators/contactable/templates/migrations/create_contactable_related_tables.rb +153 -26
  50. data/generators/contactable_views/USAGE +1 -0
  51. data/generators/contactable_views/contactable_views_generator.rb +24 -0
  52. data/generators/contactable_views/templates/views/formtastic/addresses/_address.html.erb +31 -0
  53. data/generators/contactable_views/templates/views/formtastic/cities/index.html.erb +6 -0
  54. data/generators/contactable_views/templates/views/formtastic/contactable/_contactable.html.erb +11 -0
  55. data/generators/contactable_views/templates/views/formtastic/contactable/_contactable_field.html.erb +8 -0
  56. data/generators/contactable_views/templates/views/formtastic/contactable/_fields.html.erb +49 -0
  57. data/generators/contactable_views/templates/views/formtastic/divisions/index.html.erb +9 -0
  58. data/generators/contactable_views/templates/views/formtastic/emails/_email.html.erb +2 -0
  59. data/generators/contactable_views/templates/views/formtastic/identifications/_identification.html.erb +2 -0
  60. data/generators/contactable_views/templates/views/formtastic/instant_messengers/_instant_messenger.html.erb +3 -0
  61. data/generators/contactable_views/templates/views/formtastic/phones/_phone.html.erb +2 -0
  62. data/generators/contactable_views/templates/views/formtastic/websites/_website.html.erb +2 -0
  63. data/generators/contactable_views/templates/views/jintastic/addresses/_address.html.erb +31 -0
  64. data/generators/contactable_views/templates/views/jintastic/addresses/_form.html.erb +9 -0
  65. data/generators/contactable_views/templates/views/jintastic/addresses/create.js.rjs +3 -0
  66. data/generators/contactable_views/templates/views/jintastic/addresses/destroy.js.rjs +3 -0
  67. data/generators/contactable_views/templates/views/jintastic/addresses/update.js.rjs +3 -0
  68. data/generators/contactable_views/templates/views/jintastic/cities/index.html.erb +6 -0
  69. data/generators/contactable_views/templates/views/jintastic/contactable/_birthday.html.erb +1 -0
  70. data/generators/contactable_views/templates/views/jintastic/contactable/_contactable.html.erb +16 -0
  71. data/generators/contactable_views/templates/views/jintastic/contactable/_contactable_field.html.erb +14 -0
  72. data/generators/contactable_views/templates/views/jintastic/contactable/_fields.html.erb +49 -0
  73. data/generators/contactable_views/templates/views/jintastic/contactable/_name.html.erb +3 -0
  74. data/generators/contactable_views/templates/views/jintastic/divisions/index.html.erb +9 -0
  75. data/generators/contactable_views/templates/views/jintastic/emails/_email.html.erb +2 -0
  76. data/generators/contactable_views/templates/views/jintastic/emails/_form.html.erb +9 -0
  77. data/generators/contactable_views/templates/views/jintastic/emails/create.js.rjs +3 -0
  78. data/generators/contactable_views/templates/views/jintastic/emails/destroy.js.rjs +3 -0
  79. data/generators/contactable_views/templates/views/jintastic/emails/update.js.rjs +3 -0
  80. data/generators/contactable_views/templates/views/jintastic/identifications/_form.html.erb +9 -0
  81. data/generators/contactable_views/templates/views/jintastic/identifications/_identification.html.erb +2 -0
  82. data/generators/contactable_views/templates/views/jintastic/identifications/create.js.rjs +3 -0
  83. data/generators/contactable_views/templates/views/jintastic/identifications/destroy.js.rjs +3 -0
  84. data/generators/contactable_views/templates/views/jintastic/identifications/update.js.rjs +3 -0
  85. data/generators/contactable_views/templates/views/jintastic/instant_messengers/_form.html.erb +9 -0
  86. data/generators/contactable_views/templates/views/jintastic/instant_messengers/_instant_messenger.html.erb +3 -0
  87. data/generators/contactable_views/templates/views/jintastic/instant_messengers/create.js.rjs +3 -0
  88. data/generators/contactable_views/templates/views/jintastic/instant_messengers/destroy.js.rjs +3 -0
  89. data/generators/contactable_views/templates/views/jintastic/instant_messengers/update.js.rjs +3 -0
  90. data/generators/contactable_views/templates/views/jintastic/phones/_form.html.erb +9 -0
  91. data/generators/contactable_views/templates/views/jintastic/phones/_phone.html.erb +2 -0
  92. data/generators/contactable_views/templates/views/jintastic/phones/create.js.rjs +3 -0
  93. data/generators/contactable_views/templates/views/jintastic/phones/destroy.js.rjs +3 -0
  94. data/generators/contactable_views/templates/views/jintastic/phones/update.js.rjs +3 -0
  95. data/generators/contactable_views/templates/views/jintastic/websites/_form.html.erb +9 -0
  96. data/generators/contactable_views/templates/views/jintastic/websites/_website.html.erb +2 -0
  97. data/generators/contactable_views/templates/views/jintastic/websites/create.js.rjs +3 -0
  98. data/generators/contactable_views/templates/views/jintastic/websites/destroy.js.rjs +3 -0
  99. data/generators/contactable_views/templates/views/jintastic/websites/update.js.rjs +3 -0
  100. data/lib/contactable.rb +6 -2
  101. data/lib/contactable/extensions/routes.rb +22 -0
  102. data/rails/init.rb +1 -0
  103. metadata +109 -19
  104. data/generators/contactable/templates/models/address.rb +0 -33
  105. data/generators/contactable/templates/models/address_type.rb +0 -5
  106. data/generators/contactable/templates/models/city.rb +0 -4
  107. data/generators/contactable/templates/models/country.rb +0 -4
  108. data/generators/contactable/templates/models/email_type.rb +0 -5
  109. data/generators/contactable/templates/models/phone_type.rb +0 -5
  110. data/generators/contactable/templates/models/website_type.rb +0 -5
@@ -0,0 +1,3 @@
1
+ page << "$('.multi.phones').replaceWith('#{escape_javascript render :partial => 'contactable/contactable_field', :locals => {:contactable => @contactable, :field_name => 'phone'}}');"
2
+
3
+ page << show_messages(flash)
@@ -0,0 +1,3 @@
1
+ page << "$('##{@field_dom_id}').remove();"
2
+
3
+ page << show_messages(flash)
@@ -0,0 +1,3 @@
1
+ page << "$('.multi.phones').replaceWith('#{escape_javascript render :partial => 'contactable/contactable_field', :locals => {:contactable => @contactable, :field_name => 'phone'}}');"
2
+
3
+ page << show_messages(flash)
@@ -0,0 +1,9 @@
1
+ <% semantic_remote_form_for [website.owner, website] do |f| %>
2
+ <% f.inputs do %>
3
+ <%= render :partial => 'websites/website', :locals => {:f => f} %>
4
+ <% end %>
5
+ <% f.buttons do %>
6
+ <%= f.commit_button %>
7
+ <li><%= link_to_function t('actions.cancel'), "$('#new_website_form').hide();$('#new_website').reset();$('#new_website_link').show()" %></li>
8
+ <% end %>
9
+ <% end %>
@@ -0,0 +1,2 @@
1
+ <%= f.input :address %>
2
+ <%= f.input :type %>
@@ -0,0 +1,3 @@
1
+ page << "$('.multi.websites').replaceWith('#{escape_javascript render :partial => 'contactable/contactable_field', :locals => {:contactable => @contactable, :field_name => 'website'}}');"
2
+
3
+ page << show_messages(flash)
@@ -0,0 +1,3 @@
1
+ page << "$('##{@field_dom_id}').remove();"
2
+
3
+ page << show_messages(flash)
@@ -0,0 +1,3 @@
1
+ page << "$('.multi.websites').replaceWith('#{escape_javascript render :partial => 'contactable/contactable_field', :locals => {:contactable => @contactable, :field_name => 'website'}}');"
2
+
3
+ page << show_messages(flash)
@@ -62,6 +62,7 @@ module Contactable
62
62
  has_many :instant_messengers, :as => :owner
63
63
  has_many :phones, :as => :owner
64
64
  has_many :websites, :as => :owner
65
+ has_many :identifications, :as => :owner
65
66
 
66
67
  accepts_nested_attributes_for :addresses,
67
68
  :reject_if => proc { |attributes| attributes['address'].blank? }, :allow_destroy => true
@@ -73,12 +74,15 @@ module Contactable
73
74
  :reject_if => proc { |attributes| attributes['number'].blank? }, :allow_destroy => true
74
75
  accepts_nested_attributes_for :websites,
75
76
  :reject_if => proc { |attributes| attributes['address'].blank? }, :allow_destroy => true
77
+ accepts_nested_attributes_for :identifications,
78
+ :reject_if => proc { |attributes| attributes['address'].blank? }, :allow_destroy => true
76
79
  EOV
77
80
  end
78
-
79
81
  end
80
82
  end
81
83
 
82
84
  class ActiveRecord::Base
83
85
  include Contactable
84
- end
86
+ end
87
+
88
+ require 'contactable/extensions/routes'
@@ -0,0 +1,22 @@
1
+ if defined?(ActionController::Routing::RouteSet)
2
+ class ActionController::Routing::RouteSet
3
+ def load_routes_with_contactable!
4
+ lib_path = File.dirname(__FILE__)
5
+ contactable_routes = File.join(lib_path, *%w[.. .. .. config contactable_routes.rb])
6
+ unless configuration_files.include?(contactable_routes)
7
+ add_configuration_file(contactable_routes)
8
+ end
9
+ load_routes_without_contactable!
10
+ end
11
+
12
+ alias_method_chain :load_routes!, :contactable
13
+ end
14
+ end
15
+
16
+ module ActionController::Resources
17
+ def contactable_resources(*entities, &block)
18
+ options = entities.extract_options!
19
+ resources(:phones, :addresses, :emails, :websites, :instant_messengers, :identifications, options.dup, &block)
20
+ end
21
+ end
22
+
@@ -0,0 +1 @@
1
+ require 'contactable'
metadata CHANGED
@@ -1,7 +1,12 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: contactable
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ prerelease: false
5
+ segments:
6
+ - 1
7
+ - 0
8
+ - 1
9
+ version: 1.0.1
5
10
  platform: ruby
6
11
  authors:
7
12
  - Luis Perichon
@@ -9,7 +14,7 @@ autorequire:
9
14
  bindir: bin
10
15
  cert_chain: []
11
16
 
12
- date: 2009-11-18 00:00:00 -03:00
17
+ date: 2010-03-29 00:00:00 -03:00
13
18
  default_executable:
14
19
  dependencies: []
15
20
 
@@ -20,32 +25,114 @@ executables: []
20
25
  extensions: []
21
26
 
22
27
  extra_rdoc_files:
28
+ - CHANGELOG
23
29
  - LICENSE
24
30
  - README.rdoc
25
31
  - lib/contactable.rb
32
+ - lib/contactable/extensions/routes.rb
26
33
  files:
34
+ - CHANGELOG
27
35
  - LICENSE
28
36
  - Manifest
29
37
  - README.rdoc
30
38
  - Rakefile
39
+ - app/controllers/addresses_controller.rb
40
+ - app/controllers/cities_controller.rb
41
+ - app/controllers/contact_field_actions.rb
42
+ - app/controllers/divisions_controller.rb
43
+ - app/controllers/emails_controller.rb
44
+ - app/controllers/identifications_controller.rb
45
+ - app/controllers/instant_messengers_controller.rb
46
+ - app/controllers/phones_controller.rb
47
+ - app/controllers/websites_controller.rb
48
+ - app/helpers/contactable_helper.rb
49
+ - app/models/address.rb
50
+ - app/models/address_type.rb
51
+ - app/models/city.rb
52
+ - app/models/country.rb
53
+ - app/models/division.rb
54
+ - app/models/email.rb
55
+ - app/models/email_type.rb
56
+ - app/models/identification.rb
57
+ - app/models/identification_type.rb
58
+ - app/models/instant_messenger.rb
59
+ - app/models/instant_messenger_protocol.rb
60
+ - app/models/instant_messenger_type.rb
61
+ - app/models/phone.rb
62
+ - app/models/phone_type.rb
63
+ - app/models/province.rb
64
+ - app/models/website.rb
65
+ - app/models/website_type.rb
66
+ - app/views/addresses/_address.html.erb
67
+ - app/views/cities/index.html.erb
68
+ - app/views/contactable/_contactable.html.erb
69
+ - app/views/contactable/_contactable_field.html.erb
70
+ - app/views/contactable/_fields.html.erb
71
+ - app/views/divisions/index.html.erb
72
+ - app/views/emails/_email.html.erb
73
+ - app/views/identifications/_identification.html.erb
74
+ - app/views/instant_messengers/_instant_messenger.html.erb
75
+ - app/views/phones/_phone.html.erb
76
+ - app/views/websites/_website.html.erb
77
+ - config/contactable_routes.rb
31
78
  - generators/contactable/USAGE
32
79
  - generators/contactable/contactable_generator.rb
80
+ - generators/contactable/lib/insert_commands.rb
81
+ - generators/contactable/templates/README
33
82
  - generators/contactable/templates/migrations/create_contactable_related_tables.rb
34
- - generators/contactable/templates/models/address.rb
35
- - generators/contactable/templates/models/address_type.rb
36
- - generators/contactable/templates/models/city.rb
37
- - generators/contactable/templates/models/country.rb
38
- - generators/contactable/templates/models/email.rb
39
- - generators/contactable/templates/models/email_type.rb
40
- - generators/contactable/templates/models/instant_messenger.rb
41
- - generators/contactable/templates/models/instant_messenger_protocol.rb
42
- - generators/contactable/templates/models/instant_messenger_type.rb
43
- - generators/contactable/templates/models/phone.rb
44
- - generators/contactable/templates/models/phone_type.rb
45
- - generators/contactable/templates/models/province.rb
46
- - generators/contactable/templates/models/website.rb
47
- - generators/contactable/templates/models/website_type.rb
83
+ - generators/contactable_views/USAGE
84
+ - generators/contactable_views/contactable_views_generator.rb
85
+ - generators/contactable_views/templates/views/formtastic/addresses/_address.html.erb
86
+ - generators/contactable_views/templates/views/formtastic/cities/index.html.erb
87
+ - generators/contactable_views/templates/views/formtastic/contactable/_contactable.html.erb
88
+ - generators/contactable_views/templates/views/formtastic/contactable/_contactable_field.html.erb
89
+ - generators/contactable_views/templates/views/formtastic/contactable/_fields.html.erb
90
+ - generators/contactable_views/templates/views/formtastic/divisions/index.html.erb
91
+ - generators/contactable_views/templates/views/formtastic/emails/_email.html.erb
92
+ - generators/contactable_views/templates/views/formtastic/identifications/_identification.html.erb
93
+ - generators/contactable_views/templates/views/formtastic/instant_messengers/_instant_messenger.html.erb
94
+ - generators/contactable_views/templates/views/formtastic/phones/_phone.html.erb
95
+ - generators/contactable_views/templates/views/formtastic/websites/_website.html.erb
96
+ - generators/contactable_views/templates/views/jintastic/addresses/_address.html.erb
97
+ - generators/contactable_views/templates/views/jintastic/addresses/_form.html.erb
98
+ - generators/contactable_views/templates/views/jintastic/addresses/create.js.rjs
99
+ - generators/contactable_views/templates/views/jintastic/addresses/destroy.js.rjs
100
+ - generators/contactable_views/templates/views/jintastic/addresses/update.js.rjs
101
+ - generators/contactable_views/templates/views/jintastic/cities/index.html.erb
102
+ - generators/contactable_views/templates/views/jintastic/contactable/_birthday.html.erb
103
+ - generators/contactable_views/templates/views/jintastic/contactable/_contactable.html.erb
104
+ - generators/contactable_views/templates/views/jintastic/contactable/_contactable_field.html.erb
105
+ - generators/contactable_views/templates/views/jintastic/contactable/_fields.html.erb
106
+ - generators/contactable_views/templates/views/jintastic/contactable/_name.html.erb
107
+ - generators/contactable_views/templates/views/jintastic/divisions/index.html.erb
108
+ - generators/contactable_views/templates/views/jintastic/emails/_email.html.erb
109
+ - generators/contactable_views/templates/views/jintastic/emails/_form.html.erb
110
+ - generators/contactable_views/templates/views/jintastic/emails/create.js.rjs
111
+ - generators/contactable_views/templates/views/jintastic/emails/destroy.js.rjs
112
+ - generators/contactable_views/templates/views/jintastic/emails/update.js.rjs
113
+ - generators/contactable_views/templates/views/jintastic/identifications/_form.html.erb
114
+ - generators/contactable_views/templates/views/jintastic/identifications/_identification.html.erb
115
+ - generators/contactable_views/templates/views/jintastic/identifications/create.js.rjs
116
+ - generators/contactable_views/templates/views/jintastic/identifications/destroy.js.rjs
117
+ - generators/contactable_views/templates/views/jintastic/identifications/update.js.rjs
118
+ - generators/contactable_views/templates/views/jintastic/instant_messengers/_form.html.erb
119
+ - generators/contactable_views/templates/views/jintastic/instant_messengers/_instant_messenger.html.erb
120
+ - generators/contactable_views/templates/views/jintastic/instant_messengers/create.js.rjs
121
+ - generators/contactable_views/templates/views/jintastic/instant_messengers/destroy.js.rjs
122
+ - generators/contactable_views/templates/views/jintastic/instant_messengers/update.js.rjs
123
+ - generators/contactable_views/templates/views/jintastic/phones/_form.html.erb
124
+ - generators/contactable_views/templates/views/jintastic/phones/_phone.html.erb
125
+ - generators/contactable_views/templates/views/jintastic/phones/create.js.rjs
126
+ - generators/contactable_views/templates/views/jintastic/phones/destroy.js.rjs
127
+ - generators/contactable_views/templates/views/jintastic/phones/update.js.rjs
128
+ - generators/contactable_views/templates/views/jintastic/websites/_form.html.erb
129
+ - generators/contactable_views/templates/views/jintastic/websites/_website.html.erb
130
+ - generators/contactable_views/templates/views/jintastic/websites/create.js.rjs
131
+ - generators/contactable_views/templates/views/jintastic/websites/destroy.js.rjs
132
+ - generators/contactable_views/templates/views/jintastic/websites/update.js.rjs
48
133
  - lib/contactable.rb
134
+ - lib/contactable/extensions/routes.rb
135
+ - rails/init.rb
49
136
  - test/contactable_test.rb
50
137
  - contactable.gemspec
51
138
  has_rdoc: true
@@ -66,18 +153,21 @@ required_ruby_version: !ruby/object:Gem::Requirement
66
153
  requirements:
67
154
  - - ">="
68
155
  - !ruby/object:Gem::Version
156
+ segments:
157
+ - 0
69
158
  version: "0"
70
- version:
71
159
  required_rubygems_version: !ruby/object:Gem::Requirement
72
160
  requirements:
73
161
  - - ">="
74
162
  - !ruby/object:Gem::Version
163
+ segments:
164
+ - 1
165
+ - 2
75
166
  version: "1.2"
76
- version:
77
167
  requirements: []
78
168
 
79
169
  rubyforge_project: contactable
80
- rubygems_version: 1.3.5
170
+ rubygems_version: 1.3.6
81
171
  signing_key:
82
172
  specification_version: 3
83
173
  summary: Adds contact information to an active record model
@@ -1,33 +0,0 @@
1
- class Address < ActiveRecord::Base
2
-
3
- belongs_to :owner, :polymorphic => true
4
- belongs_to :type, :class_name => 'AddressType'
5
- belongs_to :city
6
- belongs_to :country
7
- belongs_to :province
8
-
9
- def city_name
10
- city.name if city
11
- end
12
-
13
- def city_name=(name)
14
- self.city = City.find_or_create_by_name(name.to_s.titleize) unless name.blank?
15
- end
16
-
17
- def province_name
18
- province.name if province
19
- end
20
-
21
- def province_name=(name)
22
- self.province = Province.find_or_create_by_name(name.to_s.titleize) unless name.blank?
23
- end
24
-
25
- def country_name
26
- country.name if country
27
- end
28
-
29
- def country_name=(name)
30
- self.country = Country.find_or_create_by_name(name.to_s.titleize) unless name.blank?
31
- end
32
-
33
- end
@@ -1,5 +0,0 @@
1
- class AddressType < ActiveRecord::Base
2
-
3
- validates_presence_of :description
4
-
5
- end
@@ -1,4 +0,0 @@
1
- class City < ActiveRecord::Base
2
- belongs_to :province
3
- validates_presence_of :name, :province
4
- end
@@ -1,4 +0,0 @@
1
- class Country < ActiveRecord::Base
2
- has_many :provinces
3
- validates_presence_of :name
4
- end
@@ -1,5 +0,0 @@
1
- class EmailType < ActiveRecord::Base
2
-
3
- validates_presence_of :description
4
-
5
- end
@@ -1,5 +0,0 @@
1
- class PhoneType < ActiveRecord::Base
2
-
3
- validates_presence_of :description
4
-
5
- end
@@ -1,5 +0,0 @@
1
- class WebsiteType < ActiveRecord::Base
2
-
3
- validates_presence_of :description
4
-
5
- end