tel_to_helper 0.0.3 → 0.1.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: df774c317792d5b97eeaf802f5508a682b8b2e8b
4
- data.tar.gz: bd5974bde5eaf89d4c0e948a0c92317e13414887
3
+ metadata.gz: 3abc4e1b0955b001ddbed298df3dc1a8c06a15e6
4
+ data.tar.gz: 0e022cd15a79a3c10b80bedc901566edb0e97ec8
5
5
  SHA512:
6
- metadata.gz: b2d858708e996852a8db8cd395ec4e0b4c8274a5e9e1153203325bf50452e115199b8940c2f1e9cf5e06cbf2b950dd2100a1033bc80e35e02e8b369e8ab64981
7
- data.tar.gz: 8abfe3ea52d0bebd9c458eb4d85e8d88067a31dcf92c4135e816f3eb46872d957a2a721e3a252951b6d007cdaba514587cb1d8e6c28f4ca86e35953d02822cd3
6
+ metadata.gz: a81128e11caac76d0a705730677043ab5ee8d2066a4c0c4a68a73e430b265ead0da317f767ea7a637edd9767fbb43caaaa53a23ea9c303eb4fc1b2a9f9e106dd
7
+ data.tar.gz: 0d1ddfb4ec08a245cccf18e4256cc73ffbcd1de059611b7ca01d91654c35678a62a18b1d629c894b4b40064f62bd2a555d971dbe7567b01a7280d649ff246ccf
data/README.md CHANGED
@@ -19,29 +19,29 @@ gem 'tel_to_helper'
19
19
 
20
20
  ## Usage
21
21
 
22
+ The parameters is almost the same as `link_to` except pass phone number to `options`.
23
+
22
24
  ```ruby
23
- tel_to(number, name = nil, link_to_options = nil)
25
+ tel_to(name = nil, options = nil, html_options = nil, &block)
24
26
  ```
25
27
 
26
28
  ## Examples
27
29
 
28
30
  ```ruby
29
- = tel_to '400-881-6609'
30
- # <a href="tel:400-881-6609">400-881-6609</a>
31
+ tel_to '000-000-0000'
32
+ # => <a href="tel:000-000-0000">000-000-0000</a>
31
33
  ```
34
+
32
35
  ```ruby
33
- = tel_to '400-881-6609', 'ihaveu.com Customer Service'
34
- # <a href="tel:400-881-6609">ihaveu.com Customer Service</a>
36
+ tel_to 'My phone number', '000-000-0000'
37
+ # => <a href="tel:000-000-0000">My phone number</a>
35
38
  ```
39
+
36
40
  ```ruby
37
- = tel_to '400-881-6609', 'ihaveu.com Customer Service', target: '_blank'
38
- # <a href="tel:400-881-6609" target="_blank">ihaveu.com Customer Service</a>
41
+ tel_to '000-000-0000', 'My phone number', target: '_blank'
42
+ # => <a href="tel:000-000-0000" target="_blank">My phone number</a>
39
43
  ```
40
44
 
41
- ## Credits
42
-
43
- * swordray @[ihaveu](http://www.ihaveu.com/home) @[shuhai](http://tw.shuhai.org/) @[leaf](http://leaf.iacger.com)
44
-
45
45
  ## License
46
46
 
47
- Copyright © 2014 Jianqiu Xiao <swordray@gmail.com> under The [MIT License](http://opensource.org/licenses/MIT).
47
+ Copyright © 2016 Jianqiu Xiao <swordray@gmail.com> under The [MIT License](http://opensource.org/licenses/MIT).
@@ -4,11 +4,17 @@ module ActionView
4
4
  module Helpers
5
5
  # = Action View Telephone Link Helper
6
6
  module TelToHelper
7
- # Creates a telephone link tag of the given +number+ and +name+. If +nil+
8
- # is passed as the +name+ the value of the link itself will become the
9
- # +number+. +options+ and +html_options+ will be same as +link_to.
10
- def tel_to(number, name = nil, link_to_options = nil)
11
- link_to(h(name || number), "tel:#{h(number)}", link_to_options) if number.present?
7
+ # Creates a telephone link tag of the given +name+ and +number+. If +nil+
8
+ # is passed as the +number+ the value of the link itself will become the
9
+ # +number+. +html_options+ will be same as +link_to+.
10
+ def tel_to(name = nil, options = nil, html_options = nil, &block)
11
+ number = block_given? ? name : (options || name)
12
+ return if number.blank?
13
+ if block_given?
14
+ link_to("tel:#{number}", options, html_options, &block)
15
+ else
16
+ link_to(name, "tel:#{number}", html_options, &block)
17
+ end
12
18
  end
13
19
  end
14
20
  end
@@ -1,3 +1,3 @@
1
1
  module TelToHelper #:nodoc:
2
- VERSION = '0.0.3'
2
+ VERSION = '0.1.0'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tel_to_helper
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jianqiu Xiao
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-03-18 00:00:00.000000000 Z
11
+ date: 2016-02-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -61,7 +61,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
61
61
  version: '0'
62
62
  requirements: []
63
63
  rubyforge_project:
64
- rubygems_version: 2.2.2
64
+ rubygems_version: 2.4.8
65
65
  signing_key:
66
66
  specification_version: 4
67
67
  summary: Telephone Link Tag Helper