alexander_graham_bell 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Guardfile +5 -0
- data/README.md +19 -12
- data/alexander_graham_bell.gemspec +5 -3
- data/lib/alexander_graham_bell/version.rb +1 -1
- data/lib/alexander_graham_bell.rb +12 -1
- metadata +37 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 926ea95a3d2aa6a163c4729f2ef82e2241418f51
|
4
|
+
data.tar.gz: 0afff154f9914785920404eb76b68bcefa1babc3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 40a0a7deec8b03e8c8753f2f66fb459db27b13c4be6e10dd610fbbf9f39df68083f0e14fc01b79b689a1b3d2bf7993e628f8d64d4140a859b2b22e6d57aeea92
|
7
|
+
data.tar.gz: 003fb7a06ee93637b00c932dd7c16d6a56a4b862b191a81eea472841a4729d20cafee4a9f5f22dbb664ca2f8a332e58f850631b4be705f0204028a19c9d100d2
|
data/Guardfile
ADDED
data/README.md
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
[![Build Status](https://circleci.com/gh/appfolio/alexander_graham_bell.svg?style=svg)](https://circleci.com/gh/appfolio/alexander_graham_bell.svg?style=svg)
|
2
|
+
|
1
3
|
# AlexanderGrahamBell
|
2
4
|
|
3
5
|
Phone number parser and tel link creator.
|
@@ -14,25 +16,30 @@ gem install alexander_graham_bell
|
|
14
16
|
* Ruby 2.2.3 or higher
|
15
17
|
|
16
18
|
## Examples
|
17
|
-
|
19
|
+
#### Generate a tel link
|
18
20
|
```ruby
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
puts AlexanderGrahamBell.tel_link('
|
25
|
-
#<a href=\"tel
|
21
|
+
puts AlexanderGrahamBell.tel_link('1-800-555-1234')
|
22
|
+
# <a href=\"tel:18005551234\">1-800-555-1234</a>
|
23
|
+
```
|
24
|
+
#### Generate a tel link with an extension
|
25
|
+
```ruby
|
26
|
+
puts AlexanderGrahamBell.tel_link('1-800-555-1234ext5')
|
27
|
+
#<a href=\"tel:18005551234;isub=5\">1-800-555-1234ext5</a>
|
28
|
+
```
|
29
|
+
#### Get the href contents
|
30
|
+
```ruby
|
31
|
+
puts AlexanderGrahamBell.tel_href('1-800-555-1234')
|
32
|
+
# tel:18005551234
|
26
33
|
```
|
27
|
-
|
34
|
+
#### For use with rails
|
28
35
|
```ruby
|
29
|
-
# If you're using rails and you want to html escape everything wrap it in your own module or class.
|
36
|
+
# If you're using rails and you want to html escape everything, wrap it in your own module or class.
|
30
37
|
|
31
|
-
module
|
38
|
+
module MyTelLinkGenerator
|
32
39
|
def self.build(phone_number)
|
33
40
|
AlexanderGrahamBell.tel_link(phone_number).html_safe
|
34
41
|
end
|
35
42
|
end
|
36
43
|
|
37
|
-
|
44
|
+
MyTelLinkGenerator.build('+18052234567ext5')
|
38
45
|
```
|
@@ -9,7 +9,7 @@ Gem::Specification.new do |spec|
|
|
9
9
|
spec.authors = ["Scott Speidel","Michael Jewell"]
|
10
10
|
spec.email = ["scottspeidel@gmail.com", "michaeljewell9911@gmail.com"]
|
11
11
|
|
12
|
-
spec.summary =
|
12
|
+
spec.summary = "Phone number parser and tel link creator."
|
13
13
|
spec.homepage = "https://github.com/appfolio/alexander-graham-bell"
|
14
14
|
spec.license = "MIT"
|
15
15
|
|
@@ -18,7 +18,9 @@ Gem::Specification.new do |spec|
|
|
18
18
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
19
19
|
spec.require_paths = ["lib"]
|
20
20
|
|
21
|
-
spec.add_development_dependency "bundler", "~> 1.
|
22
|
-
spec.add_development_dependency "rake"
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.9"
|
22
|
+
spec.add_development_dependency "rake"
|
23
23
|
spec.add_development_dependency "minitest", "~> 5.0"
|
24
|
+
spec.add_development_dependency "guard"
|
25
|
+
spec.add_development_dependency "guard-minitest"
|
24
26
|
end
|
@@ -6,13 +6,24 @@ module AlexanderGrahamBell
|
|
6
6
|
class << self
|
7
7
|
def tel_link(phone_number, escaper = ERB::Util.method(:h))
|
8
8
|
phone = Phone.new(phone_number)
|
9
|
-
escaped_phone_number =
|
9
|
+
escaped_phone_number = escape_phone_number(phone_number, escaper)
|
10
10
|
return escaped_phone_number unless phone.valid?
|
11
11
|
"<a href=\"tel:#{phone.number}#{isub(phone)}\">#{escaped_phone_number}</a>"
|
12
12
|
end
|
13
13
|
|
14
|
+
def tel_href(phone_number)
|
15
|
+
phone = Phone.new(phone_number)
|
16
|
+
escaped_phone_number = escape_phone_number(phone_number)
|
17
|
+
return "tel:#{escaped_phone_number}" unless phone.valid?
|
18
|
+
"tel:#{phone.number}#{isub(phone)}"
|
19
|
+
end
|
20
|
+
|
14
21
|
private
|
15
22
|
|
23
|
+
def escape_phone_number(phone_number, escaper = ERB::Util.method(:h))
|
24
|
+
escaper ? escaper.call(phone_number) : phone_number
|
25
|
+
end
|
26
|
+
|
16
27
|
def isub(phone)
|
17
28
|
";isub=#{phone.extension}" unless phone.extension.nil?
|
18
29
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: alexander_graham_bell
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Scott Speidel
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: exe
|
11
11
|
cert_chain: []
|
12
|
-
date: 2016-03-
|
12
|
+
date: 2016-03-11 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|
@@ -17,28 +17,28 @@ dependencies:
|
|
17
17
|
requirements:
|
18
18
|
- - "~>"
|
19
19
|
- !ruby/object:Gem::Version
|
20
|
-
version: '1.
|
20
|
+
version: '1.9'
|
21
21
|
type: :development
|
22
22
|
prerelease: false
|
23
23
|
version_requirements: !ruby/object:Gem::Requirement
|
24
24
|
requirements:
|
25
25
|
- - "~>"
|
26
26
|
- !ruby/object:Gem::Version
|
27
|
-
version: '1.
|
27
|
+
version: '1.9'
|
28
28
|
- !ruby/object:Gem::Dependency
|
29
29
|
name: rake
|
30
30
|
requirement: !ruby/object:Gem::Requirement
|
31
31
|
requirements:
|
32
|
-
- - "
|
32
|
+
- - ">="
|
33
33
|
- !ruby/object:Gem::Version
|
34
|
-
version: '
|
34
|
+
version: '0'
|
35
35
|
type: :development
|
36
36
|
prerelease: false
|
37
37
|
version_requirements: !ruby/object:Gem::Requirement
|
38
38
|
requirements:
|
39
|
-
- - "
|
39
|
+
- - ">="
|
40
40
|
- !ruby/object:Gem::Version
|
41
|
-
version: '
|
41
|
+
version: '0'
|
42
42
|
- !ruby/object:Gem::Dependency
|
43
43
|
name: minitest
|
44
44
|
requirement: !ruby/object:Gem::Requirement
|
@@ -53,6 +53,34 @@ dependencies:
|
|
53
53
|
- - "~>"
|
54
54
|
- !ruby/object:Gem::Version
|
55
55
|
version: '5.0'
|
56
|
+
- !ruby/object:Gem::Dependency
|
57
|
+
name: guard
|
58
|
+
requirement: !ruby/object:Gem::Requirement
|
59
|
+
requirements:
|
60
|
+
- - ">="
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: '0'
|
63
|
+
type: :development
|
64
|
+
prerelease: false
|
65
|
+
version_requirements: !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - ">="
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0'
|
70
|
+
- !ruby/object:Gem::Dependency
|
71
|
+
name: guard-minitest
|
72
|
+
requirement: !ruby/object:Gem::Requirement
|
73
|
+
requirements:
|
74
|
+
- - ">="
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: '0'
|
77
|
+
type: :development
|
78
|
+
prerelease: false
|
79
|
+
version_requirements: !ruby/object:Gem::Requirement
|
80
|
+
requirements:
|
81
|
+
- - ">="
|
82
|
+
- !ruby/object:Gem::Version
|
83
|
+
version: '0'
|
56
84
|
description:
|
57
85
|
email:
|
58
86
|
- scottspeidel@gmail.com
|
@@ -64,6 +92,7 @@ files:
|
|
64
92
|
- ".gitignore"
|
65
93
|
- ".travis.yml"
|
66
94
|
- Gemfile
|
95
|
+
- Guardfile
|
67
96
|
- LICENSE.txt
|
68
97
|
- README.md
|
69
98
|
- Rakefile
|