card_mask 0.1.0 → 0.2.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: 4ed4dbadf896614cc5f39eb7037ae69c578e8c5d
4
- data.tar.gz: 7d99d8e1ff8751dce2c7cc861da34214f70e48d2
3
+ metadata.gz: bd92972a8e2b707c0a013e5e22f2a349ca23fd22
4
+ data.tar.gz: e514b437bbd337a8edf4226c22168dceec3fe14f
5
5
  SHA512:
6
- metadata.gz: 2960869f53da5c116d2014e5c25c9797fc2427ee9991940b99ef3d5175e24c972ca32ac3db9b5cfc4cc223774965b8bb18f62af91ac82ecd03a8f8ec03951ce0
7
- data.tar.gz: 6bc43a6ee17b6004111e4a8c5aec6bffb2f3cbbe345263a16b5b85a99d9f77ccf75d2641a06c64ba68cefcdb0b2d2eaf866f3a2d416dcf384a038573cd27851c
6
+ metadata.gz: 128c38e18ae94541711db5d18ef09e8d30a3864dc7741f0cc7c6cf7aacd104ef47d378b81c05366e8c1e3dc98f8a1fe908ec26eb6ac1e47df53453e53dcd238f
7
+ data.tar.gz: 64d4478d6d3fb83f17457607a9886fc4b2294c58ea7edea587e850f35f7e382d1fb97b6655111f5babf2b248e896b7e7d8c946b30cc41bd833fb94c3169b4cbb
data/README.md CHANGED
@@ -1,6 +1,8 @@
1
1
  # CardMask
2
2
 
3
- CardMask is a simple `ViewHelper` wrapper that generates a mask for card numbers, perfect for the [Stripe API](https://stripe.com/docs/api).
3
+ [![Gem Version](https://badge.fury.io/rb/card_mask.svg)](https://badge.fury.io/rb/card_mask)
4
+
5
+ CardMask is a simple `ViewHelper` wrapper that generates a mask for card numbers, perfect for use with the [Stripe API](https://stripe.com/docs/api).
4
6
 
5
7
  Supported card types:
6
8
  - Visa
@@ -22,20 +24,28 @@ And then execute:
22
24
 
23
25
  $ bundle
24
26
 
25
- gfgfgfgOr install it yourself as:
27
+ Or install it yourself as:
26
28
 
27
29
  $ gem install card_mask
28
30
 
29
31
  ## Usage
30
32
 
33
+ ### TL;DR
34
+
31
35
  Something like this:
32
36
  ``` erb
33
- <%= card_mask("Visa", "9876") %>
37
+ <%= card_mask("Visa", "9876", id: "primary-card", class: "card-number") %>
34
38
  ```
35
39
  will generate something like this:
36
40
  ``` html
37
- <span>**** **** **** 9876</span>
41
+ <span id="primary-card" class="card-number">**** **** **** 9876</span>
42
+ ```
43
+
44
+ ### Syntax
45
+ ``` erb
46
+ <%= card_mask(card_type, last4, options = {}) %>
38
47
  ```
48
+ `card_type` values include: `Visa`, `American Express`, `MasterCard`, `Discover`, `JCB` and `Diners Club`.
39
49
 
40
50
  ## Development
41
51
 
@@ -51,4 +61,3 @@ Bug reports and pull requests are welcome on GitHub at https://github.com/slehma
51
61
  ## License
52
62
 
53
63
  The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
54
-
@@ -1,3 +1,3 @@
1
1
  module CardMask
2
- VERSION = "0.1.0"
2
+ VERSION = "0.2.0"
3
3
  end
@@ -1,16 +1,23 @@
1
1
  module CardMask
2
2
  module ViewHelpers
3
- def card_mask(card_type, last4)
4
- case card_type
3
+ def card_mask(card_type, last4, options = nil)
4
+
5
+ # options ||= {}
6
+ options = options.stringify_keys
7
+
8
+ output_string = case card_type
5
9
  when "Visa", "MasterCard", "Discover", "JCB"
6
- content_tag :span, "**** **** **** #{last4}"
10
+ "**** **** **** #{last4}"
7
11
  when "American Express"
8
- content_tag :span, "**** ****** *#{last4}"
12
+ "**** ****** *#{last4}"
9
13
  when "Diners Club"
10
- content_tag :span, "**** ****** #{last4}"
14
+ "**** ****** #{last4}"
11
15
  else
12
- content_tag :span, "#{card_type} ending in #{last4}"
16
+ "#{card_type} ending in #{last4}"
13
17
  end
18
+
19
+ # Generate final tag
20
+ content_tag(:span, output_string, options)
14
21
  end
15
22
  end
16
23
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: card_mask
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Simon Lehmann
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-04-17 00:00:00.000000000 Z
11
+ date: 2017-04-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler