jekyll-issue-mentions 0.1.2 → 0.1.4

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/jekyll-issue-mentions.rb +15 -13
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f469605292cf788e8ef582f7f274360d5e2b1aee
4
- data.tar.gz: b6e23375b0f5891c8d620e568f5ce901d837052f
3
+ metadata.gz: 014068c1a07d6b50e0ca713430d7fd9a05ade586
4
+ data.tar.gz: 5a33ca964326c54e6bf0ff1c070c9748d01d49aa
5
5
  SHA512:
6
- metadata.gz: 0e2bf76d5557b114b4bed00733576cbd42884403967034a366188cce8007a60fc5cd648a3138477e03bed5d264910d337ef58ec96c4baed19c1da1526016bc99
7
- data.tar.gz: 02a0bafbd602684d14a5bc3c790c772c95ccbf0bbd82fe3e8897ea066d748847b4d92f25e156733863ce1f4b7fe771b4ff9ce90f2e1fd01ec188557cb1132d64
6
+ metadata.gz: a012d075ec6ed451efea9ee239a0be1789f0c8c996df0e91a57ff48c900cb8507ba982e0f3edeba13777e91f975bd4669b3366cbda81c6a092984096a9d4fb74
7
+ data.tar.gz: ff3cea62ecde9726d8eccde9d518428f72930f104b492fb9572b95f77a69bf789fc0ca599019991d8fdd23b4089ff7bc5f11179d9af9ce5263bca13fdbbc90c8
@@ -5,9 +5,11 @@ require 'issue_mention_filter'
5
5
  module Jekyll
6
6
  class IssueMentions < Jekyll::Generator
7
7
  safe true
8
+ attr_reader :base_url, :issueid_pattern
8
9
 
9
10
  def initialize(config = Hash.new)
10
- @filter = HTML::Pipeline::IssueMentionFilter.new(nil, {:base_url => base_url(config['jekyll-issue-mentions']) })
11
+ validate_config!(config)
12
+ @filter = HTML::Pipeline::IssueMentionFilter.new(nil, base_url: base_url, issueid_pattern: issueid_pattern)
11
13
  end
12
14
 
13
15
  def generate(site)
@@ -25,22 +27,22 @@ module Jekyll
25
27
  page.html? || page.url.end_with?('/')
26
28
  end
27
29
 
28
- def base_url(configs)
30
+ private
31
+ def validate_config!(configs)
32
+ configs = configs['jekyll-issue-mentions']
33
+ base_url = issueid_pattern = nil
29
34
  case configs
30
- when nil, NilClass
31
- raise ArgumentError.new("Your jekyll-issue-mentions config has to configured.")
32
35
  when String
33
- configs.to_s
36
+ base_url = configs
34
37
  when Hash
35
- base_url = configs['base_url']
36
- if base_url.nil?
37
- raise ArgumentError.new("Your jekyll-issue-mentions is missing base_url configuration.")
38
- else
39
- base_url
40
- end
41
- else
42
- raise ArgumentError.new("Your jekyll-issue-mentions config has to either be a string or a hash! It's a #{configs.class} right now.")
38
+ base_url, issueid_pattern = configs['base_url'], configs['issueid_pattern']
39
+ issueid_pattern = /#{issueid_pattern}/ if issueid_pattern.is_a?(String)
43
40
  end
41
+ error_prefix = "jekyll-issue-mentions"
42
+ raise ArgumentError.new("#{error_prefix}.base_url is missing/empty") if (base_url.nil? || base_url.empty?)
43
+ raise ArgumentError.new("#{error_prefix}.issueid_pattern is invalid") if (!issueid_pattern.nil? && !issueid_pattern.is_a?(Regexp))
44
+
45
+ @base_url, @issueid_pattern = base_url, issueid_pattern
44
46
  end
45
47
  end
46
48
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jekyll-issue-mentions
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Harish Shetty
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-03-25 00:00:00.000000000 Z
11
+ date: 2015-03-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: jekyll