morse_contactable 0.1.2 → 1.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 89d7bf562e4d880da26fe6026ade18856886b565
4
- data.tar.gz: 68d71aa237e32ce32f689e383932818e7637aa29
3
+ metadata.gz: 618732b3c9422f647d9d8c69b7e6847173a80199
4
+ data.tar.gz: b71d5c4b7639b1547324566559c422a237426a94
5
5
  SHA512:
6
- metadata.gz: 064835ce46932afaffa643992ad7e45300842940c3202e5f5d1bd07ce2366a16670fd6efbcdeb1b5b0e035b48b10efeeafc4c9a800d6a5b3daf9f5944b77e8cc
7
- data.tar.gz: ccfa55ec000dba178701f2e91430a65b1d3194ead40fa1274a9bf9ffed1b8d50fe5ecfd7e25f91952728a556ec49110b8c3c23b0bee62e78c6f2ef56915650ef
6
+ metadata.gz: 575c40e903337d86d9d16cbae1aec61f6514cbb93b114307b6b224d1e207ea1147aa37e561cbebc624b1351245673943ce7946e0d332e3e2bb6e18d38aab4b29
7
+ data.tar.gz: 43e0026f540f56f4f18b91967a69e6ce0b2d48adf87df43e84a1a3bac0fe8cbd41b8c660239a3c1864074bd87e3caacf75c68f93be51761b334aabdd4ee46f4c
data/.DS_Store ADDED
Binary file
data/Gemfile CHANGED
@@ -1,5 +1,4 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
-
4
3
  # Specify your gem's dependencies in morse_contactable.gemspec
5
4
  gemspec
data/LICENSE.txt CHANGED
@@ -1,6 +1,6 @@
1
1
  The MIT License (MIT)
2
2
 
3
- Copyright (c) 2015 Terry S
3
+ Copyright (c) 2015 fredmcgroarty
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
data/README.md CHANGED
@@ -26,14 +26,16 @@ TODO: Write usage instructions here
26
26
 
27
27
  ## Development
28
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.
29
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
30
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).
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`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
32
32
 
33
33
  ## Contributing
34
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
35
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/morse_contactable.
36
+
37
+
38
+ ## License
39
+
40
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
41
+
data/Rakefile CHANGED
@@ -1,6 +1,6 @@
1
1
  require "bundler/gem_tasks"
2
- require 'rspec/core/rake_task'
2
+ require "rspec/core/rake_task"
3
3
 
4
- RSpec::Core::RakeTask.new('spec')
4
+ RSpec::Core::RakeTask.new(:spec)
5
5
 
6
6
  task :default => :spec
data/bin/console CHANGED
File without changes
data/bin/setup CHANGED
File without changes
@@ -0,0 +1,55 @@
1
+ module Addressable
2
+ extend ActiveSupport::Concern
3
+ include FieldsValidator
4
+
5
+ included do
6
+ validate_required_attributes
7
+ end
8
+
9
+ class_methods do
10
+ def required_attributes
11
+ result=defined?(super) ? super : []
12
+ result+=required_addressable_attributes
13
+ end
14
+
15
+ def required_database_fields
16
+ result=defined?(super) ? super : []
17
+ result+=[:address1, :address2, :address3, :town, :county, :country, :postcode]
18
+ end
19
+
20
+ def required_addressable_attributes
21
+ [:address1,:postcode]
22
+ end
23
+ end
24
+
25
+ public
26
+
27
+ def city
28
+ town
29
+ end
30
+
31
+ def city=(thing)
32
+ self.town = thing
33
+ end
34
+
35
+ def state
36
+ county
37
+ end
38
+
39
+ def state=(thing)
40
+ self.county = thing
41
+ end
42
+
43
+ def zipcode
44
+ postcode
45
+ end
46
+
47
+ def zipcode=(thing)
48
+ self.postcode = thing
49
+ end
50
+
51
+ private
52
+
53
+
54
+ end
55
+
data/lib/emailable.rb ADDED
@@ -0,0 +1,31 @@
1
+ module Emailable
2
+ extend ActiveSupport::Concern
3
+ include FieldsValidator
4
+
5
+ included do
6
+ validate_required_attributes
7
+ end
8
+
9
+ class_methods do
10
+ def required_attributes
11
+ result=defined?(super) ? super : []
12
+ result+=required_emailable_attributes
13
+ end
14
+
15
+ def required_database_fields
16
+ result=defined?(super) ? super : []
17
+ result+=[:email]
18
+ end
19
+
20
+ def required_emailable_attributes
21
+ [:email]
22
+ end
23
+ end
24
+
25
+ public
26
+
27
+ private
28
+
29
+
30
+ end
31
+
@@ -1,3 +1,3 @@
1
1
  module MorseContactable
2
- VERSION = "0.1.2"
2
+ VERSION = "1.0.2"
3
3
  end
@@ -1,6 +1,10 @@
1
+ require "morse_contactable/version"
1
2
  require 'active_model'
2
3
  require 'active_support/all'
3
- require "morse_contactable/version"
4
- require "morse_contactable/fields_validator"
5
- require "morse_contactable/contactable"
6
-
4
+ require 'morse_fields_validator'
5
+ require "addressable"
6
+ require "emailable"
7
+ require "phoneable"
8
+ module MorseContactable
9
+ # Your code goes here...
10
+ end
data/lib/phoneable.rb ADDED
@@ -0,0 +1,35 @@
1
+ module Phoneable
2
+ extend ActiveSupport::Concern
3
+ include FieldsValidator
4
+
5
+ included do
6
+ validate_required_attributes
7
+ end
8
+
9
+ class_methods do
10
+ def required_attributes
11
+ result=defined?(super) ? super : []
12
+ result+=required_phoneable_attributes
13
+ end
14
+
15
+ def required_database_fields
16
+ result=defined?(super) ? super : []
17
+ result+=[:phone, :mobile]
18
+ end
19
+
20
+ def required_phoneable_attributes
21
+ [:phone]
22
+ end
23
+ end
24
+
25
+ public
26
+
27
+ def landline
28
+ phone
29
+ end
30
+
31
+ private
32
+
33
+
34
+ end
35
+
Binary file
@@ -6,14 +6,10 @@ require 'morse_contactable/version'
6
6
  Gem::Specification.new do |spec|
7
7
  spec.name = "morse_contactable"
8
8
  spec.version = MorseContactable::VERSION
9
- spec.authors = ["Terry S","Fred McGroarty"]
10
- spec.email = ["itsterry@gmail.com", 'freddymcgroarty@gmail.com']
9
+ spec.authors = ["fredmcgroarty"]
10
+ spec.email = ["mcfremac@icloud.com"]
11
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 }
12
+ spec.summary = %q{Module to allow easy contact functions in ActiveRecord models}
17
13
  spec.homepage = "https://github.com/morsedigital/morse_contactable"
18
14
  spec.license = "MIT"
19
15
 
@@ -21,12 +17,13 @@ Gem::Specification.new do |spec|
21
17
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
22
18
  spec.require_paths = ["lib"]
23
19
 
24
- spec.add_dependency "activemodel","~>4.2"
25
- spec.add_dependency "activesupport","~>4.2"
20
+ spec.add_dependency "morse_fields_validator","~>1.0"
26
21
 
27
22
  spec.add_development_dependency "bundler", "~> 1.8"
23
+ spec.add_development_dependency "coveralls", "~> 0.8"
24
+ spec.add_development_dependency "guard-rspec", "~> 4.5"
25
+ spec.add_development_dependency "rb-fsevent", "~> 0.9"
28
26
  spec.add_development_dependency "shoulda-matchers", "~> 2.8"
29
27
  spec.add_development_dependency "rake", "~> 10.0"
30
28
  spec.add_development_dependency "rspec", "~> 3.2"
31
-
32
29
  end
metadata CHANGED
@@ -1,58 +1,85 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: morse_contactable
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 1.0.2
5
5
  platform: ruby
6
6
  authors:
7
- - Terry S
8
- - Fred McGroarty
7
+ - fredmcgroarty
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2015-07-27 00:00:00.000000000 Z
11
+ date: 2015-08-06 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
- name: activemodel
14
+ name: morse_fields_validator
16
15
  requirement: !ruby/object:Gem::Requirement
17
16
  requirements:
18
17
  - - "~>"
19
18
  - !ruby/object:Gem::Version
20
- version: '4.2'
19
+ version: '1.0'
21
20
  type: :runtime
22
21
  prerelease: false
23
22
  version_requirements: !ruby/object:Gem::Requirement
24
23
  requirements:
25
24
  - - "~>"
26
25
  - !ruby/object:Gem::Version
27
- version: '4.2'
26
+ version: '1.0'
28
27
  - !ruby/object:Gem::Dependency
29
- name: activesupport
28
+ name: bundler
30
29
  requirement: !ruby/object:Gem::Requirement
31
30
  requirements:
32
31
  - - "~>"
33
32
  - !ruby/object:Gem::Version
34
- version: '4.2'
35
- type: :runtime
33
+ version: '1.8'
34
+ type: :development
36
35
  prerelease: false
37
36
  version_requirements: !ruby/object:Gem::Requirement
38
37
  requirements:
39
38
  - - "~>"
40
39
  - !ruby/object:Gem::Version
41
- version: '4.2'
40
+ version: '1.8'
42
41
  - !ruby/object:Gem::Dependency
43
- name: bundler
42
+ name: coveralls
44
43
  requirement: !ruby/object:Gem::Requirement
45
44
  requirements:
46
45
  - - "~>"
47
46
  - !ruby/object:Gem::Version
48
- version: '1.8'
47
+ version: '0.8'
49
48
  type: :development
50
49
  prerelease: false
51
50
  version_requirements: !ruby/object:Gem::Requirement
52
51
  requirements:
53
52
  - - "~>"
54
53
  - !ruby/object:Gem::Version
55
- version: '1.8'
54
+ version: '0.8'
55
+ - !ruby/object:Gem::Dependency
56
+ name: guard-rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '4.5'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '4.5'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rb-fsevent
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '0.9'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '0.9'
56
83
  - !ruby/object:Gem::Dependency
57
84
  name: shoulda-matchers
58
85
  requirement: !ruby/object:Gem::Requirement
@@ -97,26 +124,27 @@ dependencies:
97
124
  version: '3.2'
98
125
  description:
99
126
  email:
100
- - itsterry@gmail.com
101
- - freddymcgroarty@gmail.com
127
+ - mcfremac@icloud.com
102
128
  executables: []
103
129
  extensions: []
104
130
  extra_rdoc_files: []
105
131
  files:
132
+ - ".DS_Store"
106
133
  - ".gitignore"
107
134
  - ".rspec"
108
135
  - ".travis.yml"
109
- - CODE_OF_CONDUCT.md
110
136
  - Gemfile
111
137
  - LICENSE.txt
112
138
  - README.md
113
139
  - Rakefile
114
140
  - bin/console
115
141
  - bin/setup
142
+ - lib/addressable.rb
143
+ - lib/emailable.rb
116
144
  - lib/morse_contactable.rb
117
- - lib/morse_contactable/contactable.rb
118
- - lib/morse_contactable/fields_validator.rb
119
145
  - lib/morse_contactable/version.rb
146
+ - lib/phoneable.rb
147
+ - morse_contactable-1.0.1.gem
120
148
  - morse_contactable.gemspec
121
149
  homepage: https://github.com/morsedigital/morse_contactable
122
150
  licenses:
@@ -138,8 +166,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
138
166
  version: '0'
139
167
  requirements: []
140
168
  rubyforge_project:
141
- rubygems_version: 2.4.5
169
+ rubygems_version: 2.4.8
142
170
  signing_key:
143
171
  specification_version: 4
144
- summary: Module to easily include contact fields in ActiveRecord models
172
+ summary: Module to allow easy contact functions in ActiveRecord models
145
173
  test_files: []
data/CODE_OF_CONDUCT.md DELETED
@@ -1,13 +0,0 @@
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/)
@@ -1,78 +0,0 @@
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
@@ -1,25 +0,0 @@
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