acts-as-contactable 0.1.10

Sign up to get free protection for your applications and to get access to all the features.
Files changed (37) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +11 -0
  3. data/.rspec +1 -0
  4. data/.rubocop.yml +121 -0
  5. data/Gemfile +17 -0
  6. data/Gemfile.lock +172 -0
  7. data/MIT-LICENSE +20 -0
  8. data/README.md +28 -0
  9. data/Rakefile +21 -0
  10. data/acts_as_contactable.gemspec +32 -0
  11. data/app/assets/config/acts_as_contactable_manifest.js +0 -0
  12. data/app/assets/images/acts_as_contactable/.keep +0 -0
  13. data/app/assets/javascripts/acts_as_contactable/.keep +0 -0
  14. data/app/assets/stylesheets/acts_as_contactable/.keep +0 -0
  15. data/app/controllers/.keep +0 -0
  16. data/app/helpers/.keep +0 -0
  17. data/app/mailers/.keep +0 -0
  18. data/app/models/.keep +0 -0
  19. data/app/views/.keep +0 -0
  20. data/bin/rails +26 -0
  21. data/config/routes.rb +4 -0
  22. data/lib/acts_as_contactable/address.rb +7 -0
  23. data/lib/acts_as_contactable/contactable.rb +12 -0
  24. data/lib/acts_as_contactable/engine.rb +6 -0
  25. data/lib/acts_as_contactable/extenders/contactable.rb +26 -0
  26. data/lib/acts_as_contactable/version.rb +5 -0
  27. data/lib/acts_as_contactable.rb +14 -0
  28. data/lib/generators/acts_as_contactable/migration/migration_generator.rb +43 -0
  29. data/lib/generators/acts_as_contactable/migration/templates/active_record/address_migration.erb +24 -0
  30. data/lib/tasks/acts_as_contactable_tasks.rake +6 -0
  31. data/spec/contactable_spec.rb +17 -0
  32. data/spec/factories/contactable.rb +4 -0
  33. data/spec/generators/active_record_generator_spec.rb +13 -0
  34. data/spec/shared_example/contactable_model.rb +2 -0
  35. data/spec/shared_examples/support/factory_bot.rb +7 -0
  36. data/spec/spec_helper.rb +46 -0
  37. metadata +190 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 122bea2a2348a4b4d34b1348a894f6594d5ac0e1279e753b737b07333749154f
4
+ data.tar.gz: a36f135b695a971c146204f410bdc8f498fc5019d5fb99d03bc991d1c5b752f2
5
+ SHA512:
6
+ metadata.gz: '09a262fc96415fdc5da0cd39a320181c38ea491205ea370aff6d1ccca5a6508e5911976e68689230061e295a1970365aa43654e0ae04fc89b2f820945e6df27a'
7
+ data.tar.gz: '0998412d73a946a818f77c5405fe3c00b83b7c34c9acb577eea744d8c06f5675cd8cc8eed9440ecfd2606d2bd4811482233e8b484bbf46c45a8abb70a0e977f0'
data/.gitignore ADDED
@@ -0,0 +1,11 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /gemfiles/*.gemfile.lock
5
+ /_yardoc/
6
+ /coverage/
7
+ /doc/
8
+ /pkg/
9
+ /spec/reports/
10
+ /tmp/
11
+ *.gem
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --require spec_helper
data/.rubocop.yml ADDED
@@ -0,0 +1,121 @@
1
+ AllCops:
2
+ TargetRubyVersion: 2.2
3
+ # RuboCop has a bunch of cops enabled by default. This setting tells RuboCop
4
+ # to ignore them, so only the ones explicitly set in this file are enabled.
5
+ DisabledByDefault: true
6
+
7
+ # Prefer &&/|| over and/or.
8
+ Style/AndOr:
9
+ Enabled: true
10
+
11
+ # Do not use braces for hash literals when they are the last argument of a
12
+ # method call.
13
+ Style/BracesAroundHashParameters:
14
+ Enabled: true
15
+ EnforcedStyle: context_dependent
16
+
17
+ # Align `when` with `case`.
18
+ Layout/CaseIndentation:
19
+ Enabled: true
20
+
21
+ # Align comments with method definitions.
22
+ Layout/CommentIndentation:
23
+ Enabled: true
24
+
25
+ Layout/EmptyLineAfterMagicComment:
26
+ Enabled: true
27
+
28
+ # In a regular class definition, no empty lines around the body.
29
+ Layout/EmptyLinesAroundClassBody:
30
+ Enabled: true
31
+
32
+ # In a regular method definition, no empty lines around the body.
33
+ Layout/EmptyLinesAroundMethodBody:
34
+ Enabled: true
35
+
36
+ # In a regular module definition, no empty lines around the body.
37
+ Layout/EmptyLinesAroundModuleBody:
38
+ Enabled: true
39
+
40
+ Layout/FirstParameterIndentation:
41
+ Enabled: true
42
+
43
+ # Use Ruby >= 1.9 syntax for hashes. Prefer { a: :b } over { :a => :b }.
44
+ Style/HashSyntax:
45
+ Enabled: true
46
+
47
+ # Two spaces, no tabs (for indentation).
48
+ Layout/IndentationWidth:
49
+ Enabled: true
50
+
51
+ Layout/SpaceAfterColon:
52
+ Enabled: true
53
+
54
+ Layout/SpaceAfterComma:
55
+ Enabled: true
56
+
57
+ Layout/SpaceAroundEqualsInParameterDefault:
58
+ Enabled: true
59
+
60
+ Layout/SpaceAroundKeyword:
61
+ Enabled: true
62
+
63
+ Layout/SpaceAroundOperators:
64
+ Enabled: true
65
+
66
+ Layout/SpaceBeforeFirstArg:
67
+ Enabled: true
68
+
69
+ # Defining a method with parameters needs parentheses.
70
+ Style/MethodDefParentheses:
71
+ Enabled: true
72
+
73
+ Style/FrozenStringLiteralComment:
74
+ Enabled: true
75
+ EnforcedStyle: always
76
+
77
+ # Use `foo {}` not `foo{}`.
78
+ Layout/SpaceBeforeBlockBraces:
79
+ Enabled: true
80
+
81
+ # Use `foo { bar }` not `foo {bar}`.
82
+ Layout/SpaceInsideBlockBraces:
83
+ Enabled: true
84
+
85
+ # Use `{ a: 1 }` not `{a:1}`.
86
+ Layout/SpaceInsideHashLiteralBraces:
87
+ Enabled: true
88
+
89
+ Layout/SpaceInsideParens:
90
+ Enabled: true
91
+
92
+ # Check quotes usage according to lint rule below.
93
+ Style/StringLiterals:
94
+ Enabled: true
95
+ EnforcedStyle: single_quotes
96
+
97
+ # Detect hard tabs, no hard tabs.
98
+ Layout/Tab:
99
+ Enabled: true
100
+
101
+ # Blank lines should not have any spaces.
102
+ Layout/TrailingBlankLines:
103
+ Enabled: true
104
+
105
+ # No trailing whitespace.
106
+ Layout/TrailingWhitespace:
107
+ Enabled: true
108
+
109
+ # Use quotes for string literals when they are enough.
110
+ Style/UnneededPercentQ:
111
+ Enabled: true
112
+
113
+ # Align `end` with the matching keyword or starting expression except for
114
+ # assignments, where it should be aligned with the LHS.
115
+ Lint/EndAlignment:
116
+ Enabled: true
117
+ EnforcedStyleAlignWith: variable
118
+
119
+ # Use my_method(my_arg) not my_method( my_arg ) or my_method my_arg.
120
+ Layout/RequireParentheses:
121
+ Enabled: true
data/Gemfile ADDED
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ source 'https://rubygems.org'
4
+ git_source(:github) { |repo| "https://github.com/#{repo}.git" }
5
+
6
+ # Declare your gem's dependencies in acts_as_contactable.gemspec.
7
+ # Bundler will treat runtime dependencies like base dependencies, and
8
+ # development dependencies will be added by default to the :development group.
9
+ gemspec
10
+
11
+ # Declare any dependencies that are still in development here instead of in
12
+ # your gemspec. These might include edge Rails or gems from your path or
13
+ # Git. Remember to move these dependencies to your gemspec before releasing
14
+ # your gem to rubygems.org.
15
+
16
+ # To use a debugger
17
+ # gem 'byebug', group: [:development, :test]
data/Gemfile.lock ADDED
@@ -0,0 +1,172 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ acts-as-contactable (0.1.10)
5
+ rails (~> 5.2.1)
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ actioncable (5.2.1)
11
+ actionpack (= 5.2.1)
12
+ nio4r (~> 2.0)
13
+ websocket-driver (>= 0.6.1)
14
+ actionmailer (5.2.1)
15
+ actionpack (= 5.2.1)
16
+ actionview (= 5.2.1)
17
+ activejob (= 5.2.1)
18
+ mail (~> 2.5, >= 2.5.4)
19
+ rails-dom-testing (~> 2.0)
20
+ actionpack (5.2.1)
21
+ actionview (= 5.2.1)
22
+ activesupport (= 5.2.1)
23
+ rack (~> 2.0)
24
+ rack-test (>= 0.6.3)
25
+ rails-dom-testing (~> 2.0)
26
+ rails-html-sanitizer (~> 1.0, >= 1.0.2)
27
+ actionview (5.2.1)
28
+ activesupport (= 5.2.1)
29
+ builder (~> 3.1)
30
+ erubi (~> 1.4)
31
+ rails-dom-testing (~> 2.0)
32
+ rails-html-sanitizer (~> 1.0, >= 1.0.3)
33
+ activejob (5.2.1)
34
+ activesupport (= 5.2.1)
35
+ globalid (>= 0.3.6)
36
+ activemodel (5.2.1)
37
+ activesupport (= 5.2.1)
38
+ activerecord (5.2.1)
39
+ activemodel (= 5.2.1)
40
+ activesupport (= 5.2.1)
41
+ arel (>= 9.0)
42
+ activestorage (5.2.1)
43
+ actionpack (= 5.2.1)
44
+ activerecord (= 5.2.1)
45
+ marcel (~> 0.3.1)
46
+ activesupport (5.2.1)
47
+ concurrent-ruby (~> 1.0, >= 1.0.2)
48
+ i18n (>= 0.7, < 2)
49
+ minitest (~> 5.1)
50
+ tzinfo (~> 1.1)
51
+ arel (9.0.0)
52
+ ast (2.4.0)
53
+ builder (3.2.3)
54
+ bump (0.6.0)
55
+ concurrent-ruby (1.0.5)
56
+ crass (1.0.4)
57
+ diff-lcs (1.3)
58
+ docile (1.1.5)
59
+ erubi (1.7.1)
60
+ factory_bot (4.11.0)
61
+ activesupport (>= 3.0.0)
62
+ globalid (0.4.1)
63
+ activesupport (>= 4.2.0)
64
+ i18n (1.1.0)
65
+ concurrent-ruby (~> 1.0)
66
+ json (2.1.0)
67
+ loofah (2.2.2)
68
+ crass (~> 1.0.2)
69
+ nokogiri (>= 1.5.9)
70
+ mail (2.7.0)
71
+ mini_mime (>= 0.1.1)
72
+ marcel (0.3.2)
73
+ mimemagic (~> 0.3.2)
74
+ method_source (0.9.0)
75
+ mimemagic (0.3.2)
76
+ mini_mime (1.0.1)
77
+ mini_portile2 (2.3.0)
78
+ minitest (5.11.3)
79
+ nio4r (2.3.1)
80
+ nokogiri (1.8.4)
81
+ mini_portile2 (~> 2.3.0)
82
+ parallel (1.12.1)
83
+ parser (2.5.1.2)
84
+ ast (~> 2.4.0)
85
+ powerpack (0.1.2)
86
+ rack (2.0.5)
87
+ rack-test (1.1.0)
88
+ rack (>= 1.0, < 3)
89
+ rails (5.2.1)
90
+ actioncable (= 5.2.1)
91
+ actionmailer (= 5.2.1)
92
+ actionpack (= 5.2.1)
93
+ actionview (= 5.2.1)
94
+ activejob (= 5.2.1)
95
+ activemodel (= 5.2.1)
96
+ activerecord (= 5.2.1)
97
+ activestorage (= 5.2.1)
98
+ activesupport (= 5.2.1)
99
+ bundler (>= 1.3.0)
100
+ railties (= 5.2.1)
101
+ sprockets-rails (>= 2.0.0)
102
+ rails-dom-testing (2.0.3)
103
+ activesupport (>= 4.2.0)
104
+ nokogiri (>= 1.6)
105
+ rails-html-sanitizer (1.0.4)
106
+ loofah (~> 2.2, >= 2.2.2)
107
+ railties (5.2.1)
108
+ actionpack (= 5.2.1)
109
+ activesupport (= 5.2.1)
110
+ method_source
111
+ rake (>= 0.8.7)
112
+ thor (>= 0.19.0, < 2.0)
113
+ rainbow (2.2.2)
114
+ rake
115
+ rake (12.3.1)
116
+ rspec (3.8.0)
117
+ rspec-core (~> 3.8.0)
118
+ rspec-expectations (~> 3.8.0)
119
+ rspec-mocks (~> 3.8.0)
120
+ rspec-core (3.8.0)
121
+ rspec-support (~> 3.8.0)
122
+ rspec-expectations (3.8.1)
123
+ diff-lcs (>= 1.2.0, < 2.0)
124
+ rspec-support (~> 3.8.0)
125
+ rspec-mocks (3.8.0)
126
+ diff-lcs (>= 1.2.0, < 2.0)
127
+ rspec-support (~> 3.8.0)
128
+ rspec-support (3.8.0)
129
+ rubocop (0.49.1)
130
+ parallel (~> 1.10)
131
+ parser (>= 2.3.3.1, < 3.0)
132
+ powerpack (~> 0.1)
133
+ rainbow (>= 1.99.1, < 3.0)
134
+ ruby-progressbar (~> 1.7)
135
+ unicode-display_width (~> 1.0, >= 1.0.1)
136
+ ruby-progressbar (1.10.0)
137
+ simplecov (0.15.1)
138
+ docile (~> 1.1.0)
139
+ json (>= 1.8, < 3)
140
+ simplecov-html (~> 0.10.0)
141
+ simplecov-html (0.10.2)
142
+ sprockets (3.7.2)
143
+ concurrent-ruby (~> 1.0)
144
+ rack (> 1, < 3)
145
+ sprockets-rails (3.2.1)
146
+ actionpack (>= 4.0)
147
+ activesupport (>= 4.0)
148
+ sprockets (>= 3.0.0)
149
+ sqlite3 (1.3.13)
150
+ thor (0.20.0)
151
+ thread_safe (0.3.6)
152
+ tzinfo (1.2.5)
153
+ thread_safe (~> 0.1)
154
+ unicode-display_width (1.4.0)
155
+ websocket-driver (0.7.0)
156
+ websocket-extensions (>= 0.1.0)
157
+ websocket-extensions (0.1.3)
158
+
159
+ PLATFORMS
160
+ ruby
161
+
162
+ DEPENDENCIES
163
+ acts-as-contactable!
164
+ bump (~> 0.5, >= 0.5.3)
165
+ factory_bot (~> 4.8)
166
+ rspec (~> 3.6)
167
+ rubocop (~> 0.49.1)
168
+ simplecov (~> 0.15.0)
169
+ sqlite3 (~> 1.3)
170
+
171
+ BUNDLED WITH
172
+ 1.16.1
data/MIT-LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright 2018 Nora Alvarado
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,28 @@
1
+ # ActsAsContactable
2
+ Short description and motivation.
3
+
4
+ ## Usage
5
+ How to use my plugin.
6
+
7
+ ## Installation
8
+ Add this line to your application's Gemfile:
9
+
10
+ ```ruby
11
+ gem 'acts-as-contactable'
12
+ ```
13
+
14
+ And then execute:
15
+ ```bash
16
+ $ bundle
17
+ ```
18
+
19
+ Or install it yourself as:
20
+ ```bash
21
+ $ gem install acts_as_contactable
22
+ ```
23
+
24
+ ## Contributing
25
+ Contribution directions go here.
26
+
27
+ ## License
28
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+
3
+ begin
4
+ require 'bundler/setup'
5
+ rescue LoadError
6
+ puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
7
+ end
8
+
9
+ require 'rdoc/task'
10
+
11
+ RDoc::Task.new(:rdoc) do |rdoc|
12
+ rdoc.rdoc_dir = 'rdoc'
13
+ rdoc.title = 'ActsAsContactable'
14
+ rdoc.options << '--line-numbers'
15
+ rdoc.rdoc_files.include('README.md')
16
+ rdoc.rdoc_files.include('lib/**/*.rb')
17
+ end
18
+
19
+ load 'rails/tasks/statistics.rake'
20
+
21
+ require 'bundler/gem_tasks'
@@ -0,0 +1,32 @@
1
+ # frozen_string_literal: true
2
+
3
+ $LOAD_PATH.push File.expand_path('lib', __dir__)
4
+
5
+ # Maintain your gem's version:
6
+ require 'acts_as_contactable/version'
7
+
8
+ # Describe your gem and declare its dependencies:
9
+ Gem::Specification.new do |s|
10
+ s.name = 'acts-as-contactable'
11
+ s.version = ActsAsContactable::VERSION
12
+ s.authors = ['Nora Alvarado']
13
+ s.email = ['noragmora@gmail.com']
14
+ s.homepage = 'https://github.com/aromaron/acts_as_contactable.git'
15
+ s.summary = 'TBD'
16
+ s.description = 'TBD'
17
+ s.license = 'MIT'
18
+
19
+ s.files = `git ls-files`.split("\n")
20
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
21
+ s.executables = `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) }
22
+ s.require_paths = ['lib']
23
+
24
+ s.add_dependency "rails", "~> 5.2.1"
25
+
26
+ s.add_development_dependency 'bump', '~> 0.5', '>= 0.5.3'
27
+ s.add_development_dependency 'factory_bot', '~> 4.8'
28
+ s.add_development_dependency 'rspec', '~> 3.6'
29
+ s.add_development_dependency 'rubocop', '~> 0.49.1'
30
+ s.add_development_dependency 'simplecov', '~> 0.15.0'
31
+ s.add_development_dependency 'sqlite3', '~> 1.3'
32
+ end
File without changes
File without changes
File without changes
File without changes
File without changes
data/app/helpers/.keep ADDED
File without changes
data/app/mailers/.keep ADDED
File without changes
data/app/models/.keep ADDED
File without changes
data/app/views/.keep ADDED
File without changes
data/bin/rails ADDED
@@ -0,0 +1,26 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ # This command will automatically be run when you run "rails" with Rails gems
5
+ # installed from the root of your application.
6
+
7
+ ENGINE_ROOT = File.expand_path('..', __dir__)
8
+ ENGINE_PATH = File.expand_path('../lib/acts_as_contactable/engine', __dir__)
9
+
10
+ # Set up gems listed in the Gemfile.
11
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__)
12
+ require 'bundler/setup' if File.exist?(ENV['BUNDLE_GEMFILE'])
13
+
14
+ require 'rails'
15
+ # Pick the frameworks you want:
16
+ require 'active_model/railtie'
17
+ require 'active_job/railtie'
18
+ require 'active_record/railtie'
19
+ require 'active_storage/engine'
20
+ require 'action_controller/railtie'
21
+ require 'action_mailer/railtie'
22
+ require 'action_view/railtie'
23
+ require 'action_cable/engine'
24
+ require 'sprockets/railtie'
25
+ # require "rails/test_unit/railtie"
26
+ require 'rails/engine/commands'
data/config/routes.rb ADDED
@@ -0,0 +1,4 @@
1
+ # frozen_string_literal: true
2
+
3
+ Rails.application.routes.draw do
4
+ end
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ActsAsContactable
4
+ class Address < ActiveRecord::Base
5
+ belongs_to :addressable, polymorphic: true
6
+ end
7
+ end
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ActsAsContactable
4
+ module Contactable
5
+ def self.included(base)
6
+ base.class_eval do
7
+ has_many :addresses, class_name: 'ActsAsContactable::Address',
8
+ as: :addressable, dependent: :destroy
9
+ end
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,6 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ActsAsContactable
4
+ class Engine < ::Rails::Engine
5
+ end
6
+ end
@@ -0,0 +1,26 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ActsAsContactable
4
+ module Extenders
5
+ module Contactable
6
+ def contactable?
7
+ false
8
+ end
9
+
10
+ def acts_as_contactable(_args = {})
11
+ require 'acts_as_contactable/contactable'
12
+ include ActsAsContactable::Contactable
13
+
14
+ define_method :acts_as_contactable_options do
15
+ self.class.instance_variable_get('@acts_as_contactable_options')
16
+ end
17
+
18
+ class_eval do
19
+ def self.contactable?
20
+ true
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ActsAsContactable
4
+ VERSION = '0.1.10'.freeze
5
+ end
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'acts_as_contactable/engine'
4
+ require 'active_support/inflector'
5
+
6
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
7
+
8
+ module ActsAsContactable
9
+ if defined?(ActiveRecord::Base)
10
+ require 'acts_as_contactable/extenders/contactable'
11
+ require 'acts_as_contactable/address'
12
+ ActiveRecord::Base.extend ActsAsContactable::Extenders::Contactable
13
+ end
14
+ end
@@ -0,0 +1,43 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'rails/generators/migration'
4
+
5
+ module ActsAsContactable
6
+ class MigrationGenerator < Rails::Generators::Base
7
+ include Rails::Generators::Migration
8
+
9
+ desc 'Generates migration for contactable (address table)'
10
+
11
+ def self.orm
12
+ Rails::Generators.options[:rails][:orm]
13
+ end
14
+
15
+ def self.source_root
16
+ File.join(File.dirname(__FILE__), 'templates', (orm.to_s unless orm.class.eql?(String)))
17
+ end
18
+
19
+ def self.orm_has_migration?
20
+ [:active_record].include? orm
21
+ end
22
+
23
+ def self.next_migration_number(_path)
24
+ Time.now.utc.strftime('%Y%m%d%H%M%S')
25
+ end
26
+
27
+ def create_migration_file
28
+ if self.class.orm_has_migration?
29
+ migration_template 'address_migration.erb', 'db/migrate/acts_as_contactable_address_migration.rb', migration_version: migration_version
30
+ end
31
+ end
32
+
33
+ private
34
+
35
+ def migration_version
36
+ '[4.2]' if rails5?
37
+ end
38
+
39
+ def rails5?
40
+ Rails.version.start_with? '5'
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,24 @@
1
+ class ActsAsContactableAddressMigration < ActiveRecord::Migration<%= migration_version %>
2
+ def self.up
3
+ create_table :addresses do |t|
4
+
5
+ t.references :addressable, :polymorphic => true
6
+
7
+ t.string :name
8
+ t.string :street
9
+ t.string :street2
10
+ t.string :city
11
+ t.string :state
12
+ t.string :zip
13
+ t.boolean :primary
14
+
15
+ t.timestamps
16
+ end
17
+
18
+ add_index :addresses, [:addressable_id, :addressable_type]
19
+ end
20
+
21
+ def self.down
22
+ drop_table :addresses
23
+ end
24
+ end
@@ -0,0 +1,6 @@
1
+ # frozen_string_literal: true
2
+
3
+ # desc "Explaining what the task does"
4
+ # task :acts_as_contactable do
5
+ # # Task goes here
6
+ # end
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "spec_helper"
4
+
5
+ describe ActsAsContactable::Contactable do
6
+ it "should not be contactable" do
7
+ expect(NotContactable).not_to be_contactable
8
+ end
9
+
10
+ it "should be contactable" do
11
+ expect(Contactable).to be_contactable
12
+ end
13
+
14
+ it_behaves_like "a contactable_model" do
15
+ let (:contactable) { create(:contactable, name: "a contactable model") }
16
+ end
17
+ end
@@ -0,0 +1,4 @@
1
+ FactoryBot.define do
2
+ factory :contactable do
3
+ end
4
+ end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "acts_as_contactable"
4
+ require "spec_helper"
5
+
6
+ require "rails/generators"
7
+ require "generators/acts_as_contactable/migration/migration_generator"
8
+
9
+ module ActsAsContactable
10
+ describe MigrationGenerator do
11
+ pending
12
+ end
13
+ end
@@ -0,0 +1,2 @@
1
+ shared_examples "a contactable_model" do
2
+ end
@@ -0,0 +1,7 @@
1
+ RSpec.configure do |config|
2
+ config.include FactoryBot::Syntax::Methods
3
+
4
+ config.before(:suite) do
5
+ FactoryBot.find_definitions
6
+ end
7
+ end
@@ -0,0 +1,46 @@
1
+ # frozen_string_literal: true
2
+
3
+ $LOAD_PATH << File.join(File.dirname(__FILE__), "..", "lib")
4
+ require 'rails/engine'
5
+ require 'active_record'
6
+ require "acts_as_contactable"
7
+ require "sqlite3"
8
+ require "simplecov"
9
+ require "factory_bot"
10
+
11
+ Dir["./spec/shared_example/**/*.rb"].sort.each { |f| require f }
12
+ Dir["./spec/support/**/*.rb"].sort.each { |f| require f }
13
+
14
+ SimpleCov.start
15
+
16
+ ActiveRecord::Base.establish_connection(adapter: "sqlite3", database: ":memory:")
17
+
18
+ ActiveRecord::Schema.define(version: 1) do
19
+ create_table :addresses do |t|
20
+ t.references :addressable, polymorphic: true
21
+
22
+ t.string :name
23
+ t.string :street
24
+ t.string :street2
25
+ t.string :city
26
+ t.string :state
27
+ t.string :zip
28
+ t.boolean :primary
29
+
30
+ t.timestamps
31
+ end
32
+
33
+ add_index :addresses, [:addressable_id, :addressable_type]
34
+
35
+ create_table :addressables do |t|
36
+ t.string :name
37
+ end
38
+ end
39
+
40
+ class Contactable < ActiveRecord::Base
41
+ acts_as_contactable
42
+ validates_presence_of :name
43
+ end
44
+
45
+ class NotContactable < ActiveRecord::Base
46
+ end
metadata ADDED
@@ -0,0 +1,190 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: acts-as-contactable
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.10
5
+ platform: ruby
6
+ authors:
7
+ - Nora Alvarado
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2018-09-07 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rails
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 5.2.1
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 5.2.1
27
+ - !ruby/object:Gem::Dependency
28
+ name: bump
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '0.5'
34
+ - - ">="
35
+ - !ruby/object:Gem::Version
36
+ version: 0.5.3
37
+ type: :development
38
+ prerelease: false
39
+ version_requirements: !ruby/object:Gem::Requirement
40
+ requirements:
41
+ - - "~>"
42
+ - !ruby/object:Gem::Version
43
+ version: '0.5'
44
+ - - ">="
45
+ - !ruby/object:Gem::Version
46
+ version: 0.5.3
47
+ - !ruby/object:Gem::Dependency
48
+ name: factory_bot
49
+ requirement: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - "~>"
52
+ - !ruby/object:Gem::Version
53
+ version: '4.8'
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - "~>"
59
+ - !ruby/object:Gem::Version
60
+ version: '4.8'
61
+ - !ruby/object:Gem::Dependency
62
+ name: rspec
63
+ requirement: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - "~>"
66
+ - !ruby/object:Gem::Version
67
+ version: '3.6'
68
+ type: :development
69
+ prerelease: false
70
+ version_requirements: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - "~>"
73
+ - !ruby/object:Gem::Version
74
+ version: '3.6'
75
+ - !ruby/object:Gem::Dependency
76
+ name: rubocop
77
+ requirement: !ruby/object:Gem::Requirement
78
+ requirements:
79
+ - - "~>"
80
+ - !ruby/object:Gem::Version
81
+ version: 0.49.1
82
+ type: :development
83
+ prerelease: false
84
+ version_requirements: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - "~>"
87
+ - !ruby/object:Gem::Version
88
+ version: 0.49.1
89
+ - !ruby/object:Gem::Dependency
90
+ name: simplecov
91
+ requirement: !ruby/object:Gem::Requirement
92
+ requirements:
93
+ - - "~>"
94
+ - !ruby/object:Gem::Version
95
+ version: 0.15.0
96
+ type: :development
97
+ prerelease: false
98
+ version_requirements: !ruby/object:Gem::Requirement
99
+ requirements:
100
+ - - "~>"
101
+ - !ruby/object:Gem::Version
102
+ version: 0.15.0
103
+ - !ruby/object:Gem::Dependency
104
+ name: sqlite3
105
+ requirement: !ruby/object:Gem::Requirement
106
+ requirements:
107
+ - - "~>"
108
+ - !ruby/object:Gem::Version
109
+ version: '1.3'
110
+ type: :development
111
+ prerelease: false
112
+ version_requirements: !ruby/object:Gem::Requirement
113
+ requirements:
114
+ - - "~>"
115
+ - !ruby/object:Gem::Version
116
+ version: '1.3'
117
+ description: TBD
118
+ email:
119
+ - noragmora@gmail.com
120
+ executables:
121
+ - rails
122
+ extensions: []
123
+ extra_rdoc_files: []
124
+ files:
125
+ - ".gitignore"
126
+ - ".rspec"
127
+ - ".rubocop.yml"
128
+ - Gemfile
129
+ - Gemfile.lock
130
+ - MIT-LICENSE
131
+ - README.md
132
+ - Rakefile
133
+ - acts_as_contactable.gemspec
134
+ - app/assets/config/acts_as_contactable_manifest.js
135
+ - app/assets/images/acts_as_contactable/.keep
136
+ - app/assets/javascripts/acts_as_contactable/.keep
137
+ - app/assets/stylesheets/acts_as_contactable/.keep
138
+ - app/controllers/.keep
139
+ - app/helpers/.keep
140
+ - app/mailers/.keep
141
+ - app/models/.keep
142
+ - app/views/.keep
143
+ - bin/rails
144
+ - config/routes.rb
145
+ - lib/acts_as_contactable.rb
146
+ - lib/acts_as_contactable/address.rb
147
+ - lib/acts_as_contactable/contactable.rb
148
+ - lib/acts_as_contactable/engine.rb
149
+ - lib/acts_as_contactable/extenders/contactable.rb
150
+ - lib/acts_as_contactable/version.rb
151
+ - lib/generators/acts_as_contactable/migration/migration_generator.rb
152
+ - lib/generators/acts_as_contactable/migration/templates/active_record/address_migration.erb
153
+ - lib/tasks/acts_as_contactable_tasks.rake
154
+ - spec/contactable_spec.rb
155
+ - spec/factories/contactable.rb
156
+ - spec/generators/active_record_generator_spec.rb
157
+ - spec/shared_example/contactable_model.rb
158
+ - spec/shared_examples/support/factory_bot.rb
159
+ - spec/spec_helper.rb
160
+ homepage: https://github.com/aromaron/acts_as_contactable.git
161
+ licenses:
162
+ - MIT
163
+ metadata: {}
164
+ post_install_message:
165
+ rdoc_options: []
166
+ require_paths:
167
+ - lib
168
+ required_ruby_version: !ruby/object:Gem::Requirement
169
+ requirements:
170
+ - - ">="
171
+ - !ruby/object:Gem::Version
172
+ version: '0'
173
+ required_rubygems_version: !ruby/object:Gem::Requirement
174
+ requirements:
175
+ - - ">="
176
+ - !ruby/object:Gem::Version
177
+ version: '0'
178
+ requirements: []
179
+ rubyforge_project:
180
+ rubygems_version: 2.7.6
181
+ signing_key:
182
+ specification_version: 4
183
+ summary: TBD
184
+ test_files:
185
+ - spec/contactable_spec.rb
186
+ - spec/factories/contactable.rb
187
+ - spec/generators/active_record_generator_spec.rb
188
+ - spec/shared_example/contactable_model.rb
189
+ - spec/shared_examples/support/factory_bot.rb
190
+ - spec/spec_helper.rb