munge 0.7.1 → 0.8.0

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: 7fa33dfb3bfa3c6040f2b72dd3a5f382d52f1805
4
- data.tar.gz: 7c053502ee9c5bf4f7571d80ae40ba5c87731c40
3
+ metadata.gz: 8c59629c86e087e24ffd0f4c0c6541050b7d1263
4
+ data.tar.gz: 760d8f97c8a011e8499cbaa10c39b2e3c125a8b5
5
5
  SHA512:
6
- metadata.gz: 8d3061ee4abaf367192b0afde561b912f0dee607b867bed033ce02baaaa58a69805f205a49aeb084d016581de59399f7a591fa26d48f8d74153d3dca11c98ad8
7
- data.tar.gz: 5c2842c9a228b1a283fa587160eb5ad80e8ee97d716984675e9f7eacfd906f2e7022ebca728cedd7ff6a43271e03dfde447f5655fd250cffccec09d4e185775c
6
+ metadata.gz: 3270e943cf0f1f25f2797e7b8b37d690645ba2a7fb3b54706c467d167c2caeecb34e49d48b2835b900ddfbc866e86305edeb2d2d1537d06d54e59941654b489b
7
+ data.tar.gz: 24191c1b2fbb9cacfcb171839af26f596832a048ec7a08fba4b78540e402e5a94ab6ed5c8f9b49216f67a73147d81c7e4a11268a78035c5e7fdac0c7cf42cee8
data/README.md CHANGED
@@ -80,11 +80,10 @@ posts_for_index =
80
80
  .sort_by { |item| item.route }
81
81
  .reverse
82
82
 
83
- app.create("blog/index.html.erb", "", posts: posts_for_index) do |item|
84
- item.route = "blog" # sets output file to "/blog/index.html"
85
- item.layout = "list"
86
- item.transform
87
- end
83
+ app.create("blog/index.html.erb", "", posts: posts_for_index)
84
+ .each { |item| item.route = "blog" }
85
+ .each { |item| item.layout = "list" }
86
+ .each { |item| item.transform }
88
87
  ```
89
88
 
90
89
 
@@ -22,8 +22,8 @@ module Munge
22
22
 
23
23
  def create(*args)
24
24
  item = build_virtual_item(*args)
25
- yield item if block_given?
26
25
  @system.items.push(item)
26
+ [item]
27
27
  end
28
28
 
29
29
  def vomit(component_name)
@@ -5,19 +5,21 @@ module Munge
5
5
  content = content_override || item.content
6
6
  renderers = tilt_renderer_list(item, engines)
7
7
  mdata = merged_data(item.frontmatter, data, self_item: item)
8
+ item_path = item.relpath
8
9
 
9
- render_string(content, data: mdata, engines: renderers)
10
+ render_string(content, data: mdata, engines: renderers, template_name: item_path)
10
11
  end
11
12
 
12
13
  def layout(item_or_string, data: {}, &block)
13
14
  layout_item = resolve_layout(item_or_string)
14
15
  renderers = tilt_renderer_list(layout_item, nil)
15
16
  mdata = merged_data(layout_item.frontmatter, data, self_layout: layout_item)
17
+ layout_path = "(layout) #{layout_item.relpath}"
16
18
 
17
- render_string(layout_item.content, data: mdata, engines: renderers, &block)
19
+ render_string(layout_item.content, data: mdata, engines: renderers, template_name: layout_path, &block)
18
20
  end
19
21
 
20
- def render_string(content, data: {}, engines: [], &block)
22
+ def render_string(content, data: {}, engines: [], template_name: nil, &block)
21
23
  inner =
22
24
  if block_given?
23
25
  capture(&block)
@@ -26,7 +28,7 @@ module Munge
26
28
  output =
27
29
  engines
28
30
  .inject(content) do |memo, engine|
29
- template = engine.new { memo }
31
+ template = engine.new(template_name) { memo }
30
32
 
31
33
  if inner
32
34
  template.render(self, data) { inner }
@@ -16,6 +16,9 @@ module Munge
16
16
  @app = Munge::Application.new(system)
17
17
 
18
18
  import(rules_path)
19
+
20
+ @app.items.each(&:freeze)
21
+ @app.items.freeze
19
22
  end
20
23
 
21
24
  def config_path
@@ -82,6 +82,12 @@ module Munge
82
82
  @transforms.push([transformer, args])
83
83
  end
84
84
 
85
+ def freeze
86
+ freeze_all_instance_variables
87
+
88
+ super
89
+ end
90
+
85
91
  private
86
92
 
87
93
  def generate_regex(pattern_list)
@@ -94,5 +100,11 @@ module Munge
94
100
  .sub(%r{^/+}, "")
95
101
  .sub(%r{/+$}, "")
96
102
  end
103
+
104
+ def freeze_all_instance_variables
105
+ instance_variables.each do |ivar|
106
+ instance_variable_get(ivar).freeze
107
+ end
108
+ end
97
109
  end
98
110
  end
@@ -45,6 +45,12 @@ module Munge
45
45
  found_item
46
46
  end
47
47
 
48
+ def freeze
49
+ @items.freeze
50
+
51
+ super
52
+ end
53
+
48
54
  private
49
55
 
50
56
  def prune_args(args)
@@ -32,7 +32,7 @@ module Munge
32
32
 
33
33
  def route_mapper(item, method_name, initial_route = nil)
34
34
  if !item.route && !initial_route
35
- raise "item has no route"
35
+ raise "item `#{item.relpath}` has no route"
36
36
  end
37
37
 
38
38
  itemish = Itemish.new(item, @alterant)
@@ -1,3 +1,3 @@
1
1
  module Munge
2
- VERSION = "0.7.1".freeze
2
+ VERSION = "0.8.0".freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: munge
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.1
4
+ version: 0.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Zach Ahn
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-03-26 00:00:00.000000000 Z
11
+ date: 2016-04-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -192,7 +192,7 @@ dependencies:
192
192
  - - "~>"
193
193
  - !ruby/object:Gem::Version
194
194
  version: '3.4'
195
- description: Documentation for this release is located in https://github.com/zachahn/munge/blob/v0.7.1/README.md
195
+ description: Documentation for this release is located in https://github.com/zachahn/munge/blob/v0.8.0/README.md
196
196
  email:
197
197
  - zach.ahn@gmail.com
198
198
  executables: