safe_email_name 0.0.1 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/safe_email_name.rb +11 -3
  3. metadata +31 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4e954d8f4e2464865b184b457bbb018a6f2bbb51
4
- data.tar.gz: 25f5dae5153a06116a805a8a4ec1ba45708fd596
3
+ metadata.gz: 8449421bd0e8953ac466e5d995bfc686a2d91633
4
+ data.tar.gz: 76e240b38be65f76a9decc88ca078919efb24a98
5
5
  SHA512:
6
- metadata.gz: 84a8a609a53412b69cac9caf1ee63083d3c00bc1c15c3d42ee5924264e4e15f790dba36deb0fed80c2744b8b26022ef67df55515a886701ca2d910ea50561ec5
7
- data.tar.gz: 7c85a6ba3c75ada84f2dc0d959f0ab97cbbec1cd4016dff3bb3ed2077a8af82676cd8c55df6896ac4e5e53604bfad703649716c97303f090ddcb4dda29450495
6
+ metadata.gz: 2874582d7000cda7fe59b68f4d444a95e5d9cea56b743a825370a2ac58de32baffe79184f557ca327efd12334e598db081bc10457b8c286af999fea1c37c79ad
7
+ data.tar.gz: 19bbebb2b64e0ab8ee497a8be500f084c6dc26d54403feefce9cd8429d3d10e845de641b48230f81467c8b3042399497487f554e3d0c85d48b33b3bac177561a
@@ -1,9 +1,17 @@
1
+ require 'active_support'
2
+ require 'active_support/core_ext/object/blank'
3
+ require 'active_support/core_ext/string/filters' # squish
4
+
1
5
  module SafeEmailName
2
6
  def safe_email_name(name, email)
3
- escaped_chars = /"<>/
7
+ escaped_chars = /["<>]/
4
8
  email = email.gsub(escaped_chars, '')
5
- name = name.gsub(escaped_chars, '')
6
- "#{name} <#{email}>"
9
+ name = name.gsub(escaped_chars, '').squish
10
+ if name.blank?
11
+ email
12
+ else
13
+ "#{name} <#{email}>"
14
+ end
7
15
  end
8
16
 
9
17
  # Make method available as a class method as well.
metadata CHANGED
@@ -1,15 +1,43 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: safe_email_name
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sunny Ripert
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-11-25 00:00:00.000000000 Z
12
- dependencies: []
11
+ date: 2016-08-03 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: activesupport
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rspec
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
13
41
  description: Escape the name in To and From fields in emails
14
42
  email:
15
43
  - sunny@kisskissbankbank.com