morse_contactable 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 89d7bf562e4d880da26fe6026ade18856886b565
4
+ data.tar.gz: 68d71aa237e32ce32f689e383932818e7637aa29
5
+ SHA512:
6
+ metadata.gz: 064835ce46932afaffa643992ad7e45300842940c3202e5f5d1bd07ce2366a16670fd6efbcdeb1b5b0e035b48b10efeeafc4c9a800d6a5b3daf9f5944b77e8cc
7
+ data.tar.gz: ccfa55ec000dba178701f2e91430a65b1d3194ead40fa1274a9bf9ffed1b8d50fe5ecfd7e25f91952728a556ec49110b8c3c23b0bee62e78c6f2ef56915650ef
data/.gitignore ADDED
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
data/.travis.yml ADDED
@@ -0,0 +1,3 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.2.0
@@ -0,0 +1,13 @@
1
+ # Contributor Code of Conduct
2
+
3
+ As contributors and maintainers of this project, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities.
4
+
5
+ We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, age, or religion.
6
+
7
+ Examples of unacceptable behavior by participants include the use of sexual language or imagery, derogatory comments or personal attacks, trolling, public or private harassment, insults, or other unprofessional conduct.
8
+
9
+ Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct. Project maintainers who do not follow the Code of Conduct may be removed from the project team.
10
+
11
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting one or more of the project maintainers.
12
+
13
+ This Code of Conduct is adapted from the [Contributor Covenant](http:contributor-covenant.org), version 1.0.0, available at [http://contributor-covenant.org/version/1/0/0/](http://contributor-covenant.org/version/1/0/0/)
data/Gemfile ADDED
@@ -0,0 +1,5 @@
1
+ source 'https://rubygems.org'
2
+
3
+
4
+ # Specify your gem's dependencies in morse_contactable.gemspec
5
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015 Terry S
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,39 @@
1
+ # MorseContactable
2
+
3
+ Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/morse_contactable`. To experiment with that code, run `bin/console` for an interactive prompt.
4
+
5
+ TODO: Delete this and the text above, and describe your gem
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'morse_contactable'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install morse_contactable
22
+
23
+ ## Usage
24
+
25
+ TODO: Write usage instructions here
26
+
27
+ ## Development
28
+
29
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `bin/console` for an interactive prompt that will allow you to experiment.
30
+
31
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release` to create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
32
+
33
+ ## Contributing
34
+
35
+ 1. Fork it ( https://github.com/[my-github-username]/morse_contactable/fork )
36
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
37
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
38
+ 4. Push to the branch (`git push origin my-new-feature`)
39
+ 5. Create a new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require 'rspec/core/rake_task'
3
+
4
+ RSpec::Core::RakeTask.new('spec')
5
+
6
+ task :default => :spec
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "morse_contactable"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start
data/bin/setup ADDED
@@ -0,0 +1,7 @@
1
+ #!/bin/bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+
5
+ bundle install
6
+
7
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,6 @@
1
+ require 'active_model'
2
+ require 'active_support/all'
3
+ require "morse_contactable/version"
4
+ require "morse_contactable/fields_validator"
5
+ require "morse_contactable/contactable"
6
+
@@ -0,0 +1,78 @@
1
+ module Contactable
2
+ VALIDATE_ADDRESSABLE = %w{address1 postcode}
3
+ VALIDATE_EMAILABLE = %w{email}
4
+ VALIDATE_PERSONABLE = ["firstname", "lastname"]
5
+ VALIDATE_PHONEABLE = %w{phone}
6
+ extend ActiveSupport::Concern
7
+ include FieldsValidator
8
+
9
+ def self.collect_attributes(klass,*_attrs)
10
+ _attrs.map { |rdf| klass.send(rdf.to_sym) }.compact
11
+ end
12
+
13
+ module Address
14
+ extend ActiveSupport::Concern
15
+ include FieldsValidator
16
+
17
+ REQUIRED_DATABASE_FIELDS = %w{address1 address2 address3 town county country postcode}
18
+
19
+ included do
20
+ validate_column_names(*REQUIRED_DATABASE_FIELDS)
21
+ load_required_attributes(*VALIDATE_ADDRESSABLE)
22
+ end
23
+ def contactable_address
24
+ Contactable.collect_attributes(self,*REQUIRED_DATABASE_FIELDS)
25
+ end
26
+ end
27
+
28
+ module Email
29
+ extend ActiveSupport::Concern
30
+ include FieldsValidator
31
+
32
+ REQUIRED_DATABASE_FIELDS = %w{email}
33
+
34
+ included do
35
+ validate_column_names(*REQUIRED_DATABASE_FIELDS)
36
+ load_required_attributes(*VALIDATE_EMAILABLE)
37
+ end
38
+ def contactable_email
39
+ Contactable.collect_attributes(self,*REQUIRED_DATABASE_FIELDS)
40
+ end
41
+ end
42
+
43
+ module Person
44
+ extend ActiveSupport::Concern
45
+ include FieldsValidator
46
+
47
+ REQUIRED_DATABASE_FIELDS = %w{firstname lastname}
48
+
49
+ included do
50
+ validate_column_names(*REQUIRED_DATABASE_FIELDS)
51
+ load_required_attributes(*VALIDATE_PERSONABLE)
52
+ end
53
+ def contactable_person
54
+ Contactable.collect_attributes(self,*REQUIRED_DATABASE_FIELDS)
55
+ end
56
+ end
57
+
58
+ module Phone
59
+ extend ActiveSupport::Concern
60
+ include FieldsValidator
61
+
62
+ REQUIRED_DATABASE_FIELDS = %w{phone mobile}
63
+
64
+ included do
65
+ validate_column_names(*REQUIRED_DATABASE_FIELDS)
66
+ load_required_attributes(*VALIDATE_PHONEABLE)
67
+ end
68
+ def contactable_phone
69
+ Contactable.collect_attributes(self,*REQUIRED_DATABASE_FIELDS)
70
+ end
71
+ end
72
+
73
+
74
+ include Address
75
+ include Email
76
+ include Person
77
+ include Phone
78
+ end
@@ -0,0 +1,25 @@
1
+ module FieldsValidator
2
+ ERROR = 'please ensure necessary fields are in place'
3
+
4
+ extend ActiveSupport::Concern
5
+ class_methods do
6
+ def validate_required_attributes
7
+ required_attributes.each do |a|
8
+ validates a.to_sym, presence: true
9
+ end
10
+ end
11
+ def load_required_attributes(*_attrs)
12
+ @required_attributes ||=[]
13
+ @required_attributes += _attrs
14
+ @required_attributes.uniq!
15
+ end
16
+
17
+ def required_attributes
18
+ @required_attributes
19
+ end
20
+
21
+ def validate_column_names(*_attrs)
22
+ _attrs.each { |rdf| raise "#{rdf} not included. #{ERROR}" unless column_names.include?(rdf)}
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,3 @@
1
+ module MorseContactable
2
+ VERSION = "0.1.2"
3
+ end
@@ -0,0 +1,32 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'morse_contactable/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "morse_contactable"
8
+ spec.version = MorseContactable::VERSION
9
+ spec.authors = ["Terry S","Fred McGroarty"]
10
+ spec.email = ["itsterry@gmail.com", 'freddymcgroarty@gmail.com']
11
+
12
+ if spec.respond_to?(:metadata)
13
+ #spec.metadata['allowed_push_host'] = "TODO: Set to 'http://mygemserver.com' to prevent pushes to rubygems.org, or delete to allow pushes to any server."
14
+ end
15
+
16
+ spec.summary = %q{ Module to easily include contact fields in ActiveRecord models }
17
+ spec.homepage = "https://github.com/morsedigital/morse_contactable"
18
+ spec.license = "MIT"
19
+
20
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
21
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
22
+ spec.require_paths = ["lib"]
23
+
24
+ spec.add_dependency "activemodel","~>4.2"
25
+ spec.add_dependency "activesupport","~>4.2"
26
+
27
+ spec.add_development_dependency "bundler", "~> 1.8"
28
+ spec.add_development_dependency "shoulda-matchers", "~> 2.8"
29
+ spec.add_development_dependency "rake", "~> 10.0"
30
+ spec.add_development_dependency "rspec", "~> 3.2"
31
+
32
+ end
metadata ADDED
@@ -0,0 +1,145 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: morse_contactable
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.2
5
+ platform: ruby
6
+ authors:
7
+ - Terry S
8
+ - Fred McGroarty
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2015-07-27 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: activemodel
16
+ requirement: !ruby/object:Gem::Requirement
17
+ requirements:
18
+ - - "~>"
19
+ - !ruby/object:Gem::Version
20
+ version: '4.2'
21
+ type: :runtime
22
+ prerelease: false
23
+ version_requirements: !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - "~>"
26
+ - !ruby/object:Gem::Version
27
+ version: '4.2'
28
+ - !ruby/object:Gem::Dependency
29
+ name: activesupport
30
+ requirement: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - "~>"
33
+ - !ruby/object:Gem::Version
34
+ version: '4.2'
35
+ type: :runtime
36
+ prerelease: false
37
+ version_requirements: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - "~>"
40
+ - !ruby/object:Gem::Version
41
+ version: '4.2'
42
+ - !ruby/object:Gem::Dependency
43
+ name: bundler
44
+ requirement: !ruby/object:Gem::Requirement
45
+ requirements:
46
+ - - "~>"
47
+ - !ruby/object:Gem::Version
48
+ version: '1.8'
49
+ type: :development
50
+ prerelease: false
51
+ version_requirements: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - "~>"
54
+ - !ruby/object:Gem::Version
55
+ version: '1.8'
56
+ - !ruby/object:Gem::Dependency
57
+ name: shoulda-matchers
58
+ requirement: !ruby/object:Gem::Requirement
59
+ requirements:
60
+ - - "~>"
61
+ - !ruby/object:Gem::Version
62
+ version: '2.8'
63
+ type: :development
64
+ prerelease: false
65
+ version_requirements: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - "~>"
68
+ - !ruby/object:Gem::Version
69
+ version: '2.8'
70
+ - !ruby/object:Gem::Dependency
71
+ name: rake
72
+ requirement: !ruby/object:Gem::Requirement
73
+ requirements:
74
+ - - "~>"
75
+ - !ruby/object:Gem::Version
76
+ version: '10.0'
77
+ type: :development
78
+ prerelease: false
79
+ version_requirements: !ruby/object:Gem::Requirement
80
+ requirements:
81
+ - - "~>"
82
+ - !ruby/object:Gem::Version
83
+ version: '10.0'
84
+ - !ruby/object:Gem::Dependency
85
+ name: rspec
86
+ requirement: !ruby/object:Gem::Requirement
87
+ requirements:
88
+ - - "~>"
89
+ - !ruby/object:Gem::Version
90
+ version: '3.2'
91
+ type: :development
92
+ prerelease: false
93
+ version_requirements: !ruby/object:Gem::Requirement
94
+ requirements:
95
+ - - "~>"
96
+ - !ruby/object:Gem::Version
97
+ version: '3.2'
98
+ description:
99
+ email:
100
+ - itsterry@gmail.com
101
+ - freddymcgroarty@gmail.com
102
+ executables: []
103
+ extensions: []
104
+ extra_rdoc_files: []
105
+ files:
106
+ - ".gitignore"
107
+ - ".rspec"
108
+ - ".travis.yml"
109
+ - CODE_OF_CONDUCT.md
110
+ - Gemfile
111
+ - LICENSE.txt
112
+ - README.md
113
+ - Rakefile
114
+ - bin/console
115
+ - bin/setup
116
+ - lib/morse_contactable.rb
117
+ - lib/morse_contactable/contactable.rb
118
+ - lib/morse_contactable/fields_validator.rb
119
+ - lib/morse_contactable/version.rb
120
+ - morse_contactable.gemspec
121
+ homepage: https://github.com/morsedigital/morse_contactable
122
+ licenses:
123
+ - MIT
124
+ metadata: {}
125
+ post_install_message:
126
+ rdoc_options: []
127
+ require_paths:
128
+ - lib
129
+ required_ruby_version: !ruby/object:Gem::Requirement
130
+ requirements:
131
+ - - ">="
132
+ - !ruby/object:Gem::Version
133
+ version: '0'
134
+ required_rubygems_version: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - ">="
137
+ - !ruby/object:Gem::Version
138
+ version: '0'
139
+ requirements: []
140
+ rubyforge_project:
141
+ rubygems_version: 2.4.5
142
+ signing_key:
143
+ specification_version: 4
144
+ summary: Module to easily include contact fields in ActiveRecord models
145
+ test_files: []