jekyll-email-protect 1.0.1 → 1.0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1d273a3c3ef11a835e9c6c770f06f81c249f665f
4
- data.tar.gz: 14cb77041dc95e53c7cf295b4490f0bf2c790a09
3
+ metadata.gz: 6ab0fa5d76b825e289fd358b8605ab0346b7f8e9
4
+ data.tar.gz: 52afe5cafc58ddb1ac4b8d156e8c95562b35ec14
5
5
  SHA512:
6
- metadata.gz: 0e8f95d5593a7e33e1394f18c984f7adaa7a6e86e124ed78394433aee209f0115618cbbdcd35f43ecc8a4ed000cd55492ba32c544de42265ed14f9f228833ef6
7
- data.tar.gz: afa24eb781878a66dac1d1099007cb5620a36ecfad3fa933f7e6fed553cb02cd260298550ea467311fe7e24b6cb0379a31794cb0609eaf970710adf23f280c9e
6
+ metadata.gz: 2c44c99a8cf5e9d00b922c3d0645df3e0a579f3c4417d0c7d5f64e44e576f917410b47fc5223d66d45265dca87974bbd6f0ef4ff93785912189b6fad593f5d89
7
+ data.tar.gz: 4b0530049c23f1be1eaa671751fd64c11f051cd5401623d617747e031cd2040dc5415268e7a2b237d903bf1c029609f26b112c19f78b5d3e3879b07aff88cd83
@@ -1,19 +1,7 @@
1
- module JekyllEmailProtect
2
- module EmailProtectionFilter
3
-
4
- # Percent-encode alphanumeric characters of an email address
5
- def encode_email(input)
6
- input.to_s.chars.inject("") do |result, char|
7
- if char =~ /\p{Alnum}/
8
- char.bytes.inject(result) do |result, byte|
9
- result << '%%%02X' % byte
10
- end
11
- else
12
- result << char
13
- end
14
- end
15
- end
1
+ module Jekyll
2
+ module EmailProtect
3
+ autoload :VERSION, 'jekyll/email-protect/version.rb'
16
4
  end
17
5
  end
18
6
 
19
- Liquid::Template.register_filter(JekyllEmailProtect::EmailProtectionFilter)
7
+ require 'jekyll/email-protect.rb'
@@ -0,0 +1,21 @@
1
+ module Jekyll
2
+ module EmailProtect
3
+ module EmailProtectionFilter
4
+
5
+ # Percent-encode alphanumeric characters of an email address
6
+ def encode_email(input)
7
+ input.to_s.chars.inject("") do |result, char|
8
+ if char =~ /\p{Alnum}/
9
+ char.bytes.inject(result) do |result, byte|
10
+ result << '%%%02X' % byte
11
+ end
12
+ else
13
+ result << char
14
+ end
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
20
+
21
+ Liquid::Template.register_filter(Jekyll::EmailProtect::EmailProtectionFilter)
@@ -0,0 +1,5 @@
1
+ module Jekyll
2
+ module EmailProtect
3
+ VERSION = '1.0.3'
4
+ end
5
+ end
@@ -1,10 +1,8 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe(JekyllEmailProtect::EmailProtectionFilter) do
3
+ describe(Jekyll::EmailProtect::EmailProtectionFilter) do
4
4
  let(:output) do
5
- doc = doc_with_content(content)
6
- doc.content = content
7
- doc.output = Jekyll::Renderer.new(doc.site, doc).run
5
+ render_liquid(content, {'email' => email})
8
6
  end
9
7
 
10
8
  context "simple example address" do
@@ -12,7 +10,7 @@ describe(JekyllEmailProtect::EmailProtectionFilter) do
12
10
  let(:content) { "{{ '#{email}' | encode_email }}" }
13
11
 
14
12
  it "produces the correct percent-encoded email" do
15
- expect(output).to match(/%65%78%61%6D%70%6C%65@%65%78%61%6D%70%6C%65\.%63%6F%6D/)
13
+ expect(output).to eq("%65%78%61%6D%70%6C%65@%65%78%61%6D%70%6C%65.%63%6F%6D")
16
14
  end
17
15
  end
18
16
 
@@ -21,7 +19,7 @@ describe(JekyllEmailProtect::EmailProtectionFilter) do
21
19
  let(:content) { "{{ '#{email}' | encode_email }}" }
22
20
 
23
21
  it "produces the correct percent-encoded email" do
24
- expect(output).to match(/%65%78%61%6D%70%6C%65\-%70%65%72%73%6F%6E\+%73%70%61%6D@%65%78%61%6D%70%6C%65\.%63%6F%6D/)
22
+ expect(output).to eq("%65%78%61%6D%70%6C%65-%70%65%72%73%6F%6E+%73%70%61%6D@%65%78%61%6D%70%6C%65.%63%6F%6D")
25
23
  end
26
24
  end
27
25
  end
data/spec/spec_helper.rb CHANGED
@@ -1,42 +1,15 @@
1
1
  TEST_DIR = File.dirname(__FILE__)
2
- TMP_DIR = File.expand_path("../tmp", TEST_DIR)
3
2
 
4
3
  require 'jekyll'
5
4
  require File.expand_path("../lib/jekyll-email-protect.rb", TEST_DIR)
6
- Jekyll.logger.log_level = :error
7
- STDERR.reopen(test(?e, '/dev/null') ? '/dev/null' : 'NUL:')
8
5
 
9
6
  RSpec.configure do |config|
10
7
  config.run_all_when_everything_filtered = true
11
8
  config.filter_run :focus
12
9
  config.order = 'random'
13
10
 
14
- def tmp_dir(*files)
15
- File.join(TMP_DIR, *files)
16
- end
17
-
18
- def source_dir(*files)
19
- tmp_dir('source', *files)
20
- end
21
-
22
- def dest_dir(*files)
23
- tmp_dir('dest', *files)
24
- end
25
-
26
- def doc_with_content(content, opts = {})
27
- my_site = site
28
- Jekyll::Document.new(source_dir('_test/doc.md'), {site: my_site, collection: collection(my_site)})
29
- end
30
-
31
- def collection(site, label = 'test')
32
- Jekyll::Collection.new(site, label)
33
- end
34
-
35
- def site(opts = {})
36
- conf = Jekyll::Utils.deep_merge_hashes(Jekyll::Configuration::DEFAULTS, opts.merge({
37
- "source" => source_dir,
38
- "destination" => dest_dir
39
- }))
40
- Jekyll::Site.new(conf)
11
+ def render_liquid(content, variables)
12
+ template = Liquid::Template.parse(content)
13
+ template.render(variables)
41
14
  end
42
15
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jekyll-email-protect
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Vincent Wochnik
@@ -59,6 +59,8 @@ executables: []
59
59
  extensions: []
60
60
  extra_rdoc_files: []
61
61
  files:
62
+ - lib/jekyll/email-protect/version.rb
63
+ - lib/jekyll/email-protect.rb
62
64
  - lib/jekyll-email-protect.rb
63
65
  - README.md
64
66
  - LICENSE.md