pinpoint 0.0.1

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.
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2012 Jeff Felchner
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,4 @@
1
+ pinpoint
2
+ ========
3
+
4
+ (Un)conventional Address Composition for Ruby (and Rails)
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
data/lib/pinpoint.rb ADDED
@@ -0,0 +1,5 @@
1
+ require 'pinpoint/version'
2
+ require 'pinpoint/addressable'
3
+
4
+ module Pinpoint
5
+ end
@@ -0,0 +1,51 @@
1
+ module Addressable
2
+ module ClassMethods
3
+ def address(name)
4
+ instance_eval <<-VALIDATIONIZATION
5
+ validates :#{name}_street_and_premises,
6
+ :presence => {
7
+ :if => :#{name}_incomplete? },
8
+ :length => {
9
+ :maximum => 255 }
10
+
11
+ validates :#{name}_city,
12
+ :presence => {
13
+ :if => :#{name}_incomplete? },
14
+ :length => {
15
+ :maximum => 60 }
16
+
17
+ validates :#{name}_state_or_province,
18
+ :presence => {
19
+ :if => :#{name}_incomplete? },
20
+ :inclusion => {
21
+ :in => US_STATES,
22
+ :allow_blank => true }
23
+
24
+ validates :#{name}_postal_code,
25
+ :presence => {
26
+ :if => :#{name}_incomplete? },
27
+ :format => {
28
+ :with => Chirrpy::FORMATS[:zip_code],
29
+ :allow_blank => true }
30
+ VALIDATIONIZATION
31
+
32
+ define_method :"#{name}_address?" do
33
+ send(:"#{name}_street_and_premises?") &&
34
+ send(:"#{name}_city?") &&
35
+ send(:"#{name}_state_or_province?") &&
36
+ send(:"#{name}_postal_code?")
37
+ end
38
+
39
+ define_method :"#{name}_incomplete?" do
40
+ send(:"#{name}_street_and_premises?") ||
41
+ send(:"#{name}_city?") ||
42
+ send(:"#{name}_state_or_province?") ||
43
+ send(:"#{name}_postal_code?")
44
+ end
45
+ end
46
+ end
47
+
48
+ def self.included(base)
49
+ base.extend ClassMethods
50
+ end
51
+ end
@@ -0,0 +1,3 @@
1
+ module Pinpoint
2
+ VERSION = "0.0.1"
3
+ end
metadata ADDED
@@ -0,0 +1,55 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: pinpoint
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - jfelchner
9
+ - m5rk
10
+ autorequire:
11
+ bindir: bin
12
+ cert_chain: []
13
+ date: 2012-10-02 00:00:00.000000000 Z
14
+ dependencies: []
15
+ description: Handling common address logic (currently only for US addresses but international
16
+ is planned.
17
+ email: support@chirrpy.com
18
+ executables: []
19
+ extensions: []
20
+ extra_rdoc_files:
21
+ - README.md
22
+ - LICENSE
23
+ files:
24
+ - lib/pinpoint/addressable.rb
25
+ - lib/pinpoint/version.rb
26
+ - lib/pinpoint.rb
27
+ - Rakefile
28
+ - README.md
29
+ - LICENSE
30
+ homepage: https://github.com/chirrpy/pinpoint
31
+ licenses: []
32
+ post_install_message:
33
+ rdoc_options:
34
+ - --charset = UTF-8
35
+ require_paths:
36
+ - lib
37
+ required_ruby_version: !ruby/object:Gem::Requirement
38
+ none: false
39
+ requirements:
40
+ - - ! '>='
41
+ - !ruby/object:Gem::Version
42
+ version: '0'
43
+ required_rubygems_version: !ruby/object:Gem::Requirement
44
+ none: false
45
+ requirements:
46
+ - - ! '>='
47
+ - !ruby/object:Gem::Version
48
+ version: '0'
49
+ requirements: []
50
+ rubyforge_project: pinpoint
51
+ rubygems_version: 1.8.24
52
+ signing_key:
53
+ specification_version: 3
54
+ summary: (Un)conventional Address Composition for Ruby (and Rails)
55
+ test_files: []