alexander_graham_bell 0.1.0 → 0.1.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.
- checksums.yaml +4 -4
- data/README.md +38 -1
- data/lib/alexander_graham_bell.rb +11 -9
- data/lib/alexander_graham_bell/version.rb +1 -1
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d35fca9242c8482807144626721bbfe784cd271a
|
4
|
+
data.tar.gz: f217ec7dd145a12aa231e4d2c80b87307e4096bb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f2048efbeac23c2881feec4758564bcf6ec84729b38920f32c14f3d0f2b850c0c5fb8265da05bcc65bc666440cbc1dd6c450e2e104053f73ceba962e3c8c0094
|
7
|
+
data.tar.gz: 35a4beea8c093ded131097b1432ee3d9007aa1cbdddb4f723913d81ad66f0c3f066852c4da7aa0ec48174b0ecd1f2fe0c59ce02799386fbe7450d270648c7e7d
|
data/README.md
CHANGED
@@ -1 +1,38 @@
|
|
1
|
-
#
|
1
|
+
# AlexanderGrahamBell
|
2
|
+
|
3
|
+
Phone number parser and tel link creator.
|
4
|
+
|
5
|
+
## Install
|
6
|
+
|
7
|
+
```
|
8
|
+
gem install alexander_graham_bell
|
9
|
+
```
|
10
|
+
|
11
|
+
|
12
|
+
## Requirements
|
13
|
+
|
14
|
+
* Ruby 2.2.3 or higher
|
15
|
+
|
16
|
+
## Examples
|
17
|
+
|
18
|
+
```ruby
|
19
|
+
# Use the class methods to generate a tel link
|
20
|
+
puts AlexanderGrahamBell.tel_link('1-800-275-2273')
|
21
|
+
# <a href=\"tel:18002752273\">1-800-275-2273</a>
|
22
|
+
|
23
|
+
# Extensions
|
24
|
+
puts AlexanderGrahamBell.tel_link('+18052234567ext5')
|
25
|
+
#<a href=\"tel:+18052234567;isub=5\">+18052234567ext5</a>
|
26
|
+
```
|
27
|
+
###rails
|
28
|
+
```ruby
|
29
|
+
# If you're using rails and you want to html escape everything wrap it in your own module or class.
|
30
|
+
|
31
|
+
module MyLinkGenerator
|
32
|
+
def self.build(phone_number)
|
33
|
+
AlexanderGrahamBell.tel_link(phone_number).html_safe
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
|
38
|
+
```
|
@@ -3,16 +3,18 @@ require 'alexander_graham_bell/version'
|
|
3
3
|
require 'alexander_graham_bell/phone'
|
4
4
|
|
5
5
|
module AlexanderGrahamBell
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
6
|
+
class << self
|
7
|
+
def tel_link(phone_number, escaper = ERB::Util.method(:h))
|
8
|
+
phone = Phone.new(phone_number)
|
9
|
+
escaped_phone_number = escaper ? escaper.call(phone_number) : phone_number
|
10
|
+
return escaped_phone_number unless phone.valid?
|
11
|
+
"<a href=\"tel:#{phone.number}#{isub(phone)}\">#{escaped_phone_number}</a>"
|
12
|
+
end
|
12
13
|
|
13
|
-
|
14
|
+
private
|
14
15
|
|
15
|
-
|
16
|
-
|
16
|
+
def isub(phone)
|
17
|
+
";isub=#{phone.extension}" unless phone.extension.nil?
|
18
|
+
end
|
17
19
|
end
|
18
20
|
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.1
|
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-08 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|
@@ -93,8 +93,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
93
93
|
version: '0'
|
94
94
|
requirements: []
|
95
95
|
rubyforge_project:
|
96
|
-
rubygems_version: 2.4.
|
96
|
+
rubygems_version: 2.4.5.1
|
97
97
|
signing_key:
|
98
98
|
specification_version: 4
|
99
99
|
summary: Phone number parser and tel link creator.
|
100
100
|
test_files: []
|
101
|
+
has_rdoc:
|