jekyll-liquid-plus 1.0.1 → 1.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- NGI3NmEwZTU2NGMxNzMyMTQ4ODljZWZhYjhkMDk5MDliOTIwNTEwYQ==
4
+ MmRkMmM1YTBiYTM5MTFkZTM0MTY4ODVlM2ZhMjQwOTFjZDc5NDQ5Mg==
5
5
  data.tar.gz: !binary |-
6
- YzNlMDg3ZGIwNTQ0MDMzYTNhOTk3ZjA5NGJhOTEzZDgzYmI1MmIxZA==
6
+ NmI4NjljOTRkMmEyYzA4OTc1NGQzODhmZjk3Y2YwZmMyNzczZTlhOA==
7
7
  !binary "U0hBNTEy":
8
8
  metadata.gz: !binary |-
9
- OGZmZjM5NTQwZTFiN2UzYTEyMTJhMDM3YTMxNDM5YmJiYTE4OGM0NTQxMThk
10
- ZTY3NWI4MTkxYjM4NTg0ZWRjODgzMjU5YzllMDhjZTAxNmEyNjAwNGI3YmEx
11
- MTMzMjg4NDEzYzQ3ZDYyM2Y2ZjhmYTFhMWM5MWIwNDM0YzJhYzQ=
9
+ ZDk4NGJmYTZhOGNhNGI2ZTc3MGZmNDUwZjdlNmUzZjEzNGU3MGY3ZmI3ZDc2
10
+ NmI3ZTI1MmI3YmRkMWNlM2Q5ZmI2YjllYjEyNDM0NTZmOWYxZjFjMDVmYTll
11
+ MGUzYmY1M2VhN2E1YzUxNGFjODI5MThmZmQ5NjcxYzc3YzQzNzk=
12
12
  data.tar.gz: !binary |-
13
- Y2NhNTMxMTdmYzEyMmRmM2MwZDU5ZGEzNTQ4MzkwOWEzMzhhOWMyMWQ4MDlm
14
- ODZiMGE2Y2Q2MzhlOGM3NTQyODY3MGU0Mjc0NGI3NDYzZGQ5MTA3MzQ5ZWZk
15
- ZjNmNGJjMjZlNTVmOWUxZjM1YzIzMWZhNjA4NzMwYzQyNmExNjg=
13
+ ODYzMTFjMjdkNDU0YzhkMmUxOWVjZTEwOTE0OGI3YjFlMDcwYTliNTU0MjM2
14
+ N2RhZmIwZDgxNDA5MDVhMTIzMmFmN2M0ODU3YzhiN2M5NWE5ZDA5MjIxYTAy
15
+ OTVkNjRlZjdjZmFlZjA0Y2IwMWYyZDJiNjdjZjQ5OTVkYmNlZjM=
@@ -1,5 +1,8 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.0.2 (2013-11-03)
4
+ - Speed improvement: Now caching file path existence to reduce disk checks.
5
+
3
6
  ## 1.0.1 (2013-10-22)
4
7
  - Fixed var access issues #2, #3
5
8
 
@@ -5,6 +5,7 @@ $:.unshift File.dirname(__FILE__)
5
5
  $LOAD_PATH.unshift(File.dirname(__FILE__))
6
6
 
7
7
  module LiquidPlus
8
+ autoload :Cache, 'jekyll-liquid-plus/helpers/cache'
8
9
  autoload :IncludeTag, 'jekyll-liquid-plus/tags/include'
9
10
  autoload :WrapTag, 'jekyll-liquid-plus/tags/wrap'
10
11
  autoload :RenderTag, 'jekyll-liquid-plus/tags/render'
@@ -0,0 +1,8 @@
1
+ module LiquidPlus
2
+ class Cache
3
+ def self.exists(path)
4
+ @exists ||= {}
5
+ @exists[path] ||= File.exist? path
6
+ end
7
+ end
8
+ end
@@ -44,7 +44,7 @@ module LiquidPlus
44
44
  files = get_paths(files, context)
45
45
  files.each_with_index do |f, i|
46
46
  file = path ? File.join(path, f) : f
47
- if File.exist? expand(file, context)
47
+ if exists(file, context)
48
48
  return f
49
49
  # If "file.html || none" is passed, fail gracefully
50
50
  elsif i == files.size - 1
@@ -53,6 +53,11 @@ module LiquidPlus
53
53
  end
54
54
  end
55
55
 
56
+ def exists(file, context)
57
+ path = expand(file, context)
58
+ Cache.exists(path)
59
+ end
60
+
56
61
  # Read file paths from context variables if necessary
57
62
  #
58
63
  # Input:
@@ -79,7 +79,7 @@ module LiquidPlus
79
79
  def render(context)
80
80
  parse_markup
81
81
  path = get_path(context)
82
- if path and File.exist? path
82
+ if path and Cache.exists(path)
83
83
 
84
84
  Dir.chdir(File.dirname(path)) do
85
85
  content = path.read
@@ -1,3 +1,3 @@
1
1
  module LiquidPlus
2
- VERSION = "1.0.1"
2
+ VERSION = "1.0.2"
3
3
  end
@@ -0,0 +1 @@
1
+ {% include file.html %}
@@ -7,6 +7,7 @@ layout: nil
7
7
 
8
8
  ## Simple include
9
9
  file.html → {% include file.html %}
10
+ file.html → {% include file3.html %}
10
11
 
11
12
  ## File name stored in variable name
12
13
  file.html → {% include file %}
@@ -7,6 +7,7 @@ layout: nil
7
7
 
8
8
  ## Simple include
9
9
  file.html → {% render f/file.html %}
10
+ file.html → {% render _includes/file3.html %}
10
11
 
11
12
  ## File name stored in variable name
12
13
  file.html → {% render file %}
@@ -35,7 +35,7 @@ def test(path)
35
35
  end
36
36
  end
37
37
 
38
- `bundle exec jekyll build --trace`
38
+ `rm -rf _site/; bundle exec jekyll build --trace`
39
39
 
40
40
  # Test include
41
41
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jekyll-liquid-plus
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brandon Mathis
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-10-22 00:00:00.000000000 Z
11
+ date: 2013-11-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: jekyll
@@ -82,6 +82,7 @@ files:
82
82
  - Rakefile
83
83
  - jekyll-liquid-plus.gemspec
84
84
  - lib/jekyll-liquid-plus.rb
85
+ - lib/jekyll-liquid-plus/helpers/cache.rb
85
86
  - lib/jekyll-liquid-plus/helpers/conditional.rb
86
87
  - lib/jekyll-liquid-plus/helpers/include.rb
87
88
  - lib/jekyll-liquid-plus/helpers/path.rb
@@ -97,6 +98,7 @@ files:
97
98
  - test/source/.gitignore
98
99
  - test/source/_includes/file.html
99
100
  - test/source/_includes/file2.html
101
+ - test/source/_includes/file3.html
100
102
  - test/source/_layouts/default.html
101
103
  - test/source/_plugins/liquid-plus.rb
102
104
  - test/source/assign.html