pieces 0.2.1 → 0.2.2

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: 0b51682b37d7d66fcb1ca1d9b4c771b183891d7b
4
- data.tar.gz: 76d48e3faa29e687c112bbada03c820d76909203
3
+ metadata.gz: 64cbce7a11d487d3cd6ba5b28592c05777238d69
4
+ data.tar.gz: 7372e016548ffafb26cccfa147c9b929079fcd13
5
5
  SHA512:
6
- metadata.gz: b6e6b397790bcf4d07933b206d137bc69657626115229b1525b3015eb694341855e79f050606dae413a155948d21aa22d846e10041328481812295f4c69cc78e
7
- data.tar.gz: f4f78c2ee4db24950ce27f59f68706111fcf4a2632bb8450e201d3bee5ba6b2b14ff8bb55c4f1a7009f275b1716e4596cea60b0bde06e9553e747663d2bc43c4
6
+ metadata.gz: bd1f4366fdb91cbea5628c12b8516c278d627414c55cef67dd6df71c4ac49c5447a35cd0222ce0dae28237aabfa4ba6b749d3d6a6f428c727762e7deb6e141f9
7
+ data.tar.gz: 64f235649c1c8b096f11f0d642183e05645a7a0c7022d70fc6c94fa52bcb8c0ec92426920e12f90745a63953aa8ccb3dd360fc7f3122f958f80043b1729ea8fa
data/README.md CHANGED
@@ -121,6 +121,10 @@ The child pieces will be rendered in order and passed into the parent
121
121
  </html>
122
122
  ```
123
123
 
124
+ ## More Examples
125
+
126
+ For more examples please see: https://github.com/drpheltright/pieces/tree/master/example
127
+
124
128
  ## Contributing
125
129
 
126
130
  1. Fork it ( https://github.com/drpheltright/pieces/fork )
@@ -0,0 +1,3 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gem 'pieces'
@@ -0,0 +1,10 @@
1
+ _global:
2
+ title: 'Your Site'
3
+ footer: 'Hey'
4
+
5
+ index:
6
+ _pieces:
7
+ - layouts/application:
8
+ _pieces:
9
+ - header: {}
10
+ - footer: {}
@@ -0,0 +1,3 @@
1
+ <footer>
2
+ <%= footer %>
3
+ </footer>
@@ -0,0 +1,3 @@
1
+ <header>
2
+ <%= title %>
3
+ </header>
@@ -0,0 +1,11 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title><%= title %></title>
5
+ <link rel="stylesheet" href="compiled.css" />
6
+ </head>
7
+
8
+ <body>
9
+ <%= yield %>
10
+ </body>
11
+ </html>
File without changes
@@ -1,3 +1,4 @@
1
+ require 'ostruct'
1
2
  require 'yaml'
2
3
 
3
4
  module Pieces
@@ -37,7 +38,8 @@ module Pieces
37
38
  end
38
39
 
39
40
  files["#{name}.html"] = { contents: '', type: 'html' } unless files.has_key?("#{name}.html")
40
- content = Tilt.new(piece_path(piece)).render(data['_global'].merge(data)) { yield_route_pieces(data) }
41
+ view_model = OpenStruct.new(data['_global'].merge(data))
42
+ content = Tilt.new(piece_path(piece)).render(view_model) { yield_route_pieces(data) }
41
43
  files["#{name}.html"][:contents] << content
42
44
 
43
45
  files
@@ -54,7 +56,8 @@ module Pieces
54
56
  parent_data['_pieces'].reduce('') do |content, piece|
55
57
  piece, data = piece.keys.first, piece.values.first
56
58
  data['_global'] = (parent_data['_global'] || {}).merge(data['_global'] || {})
57
- content << Tilt.new(piece_path(piece)).render(data['_global'].merge(data)) { yield_route_pieces(data) }
59
+ view_model = OpenStruct.new(data['_global'].merge(data))
60
+ content << Tilt.new(piece_path(piece)).render(view_model) { yield_route_pieces(data) }
58
61
  end
59
62
  end
60
63
 
@@ -6,12 +6,14 @@ module Pieces
6
6
  Dir["#{example_path}/{config,layouts,pieces}"].each do |dir|
7
7
  FileUtils.cp_r(dir, config[:path])
8
8
  end
9
+
10
+ FileUtils.cp("#{example_path}/Gemfile", "#{config[:path]}/Gemfile")
9
11
  end
10
12
 
11
13
  private
12
14
 
13
15
  def example_path
14
- File.dirname(__FILE__) + '/../../example'
16
+ File.dirname(__FILE__) + '/../../examples/boilerplate'
15
17
  end
16
18
  end
17
19
  end
@@ -1,3 +1,3 @@
1
1
  module Pieces
2
- VERSION = '0.2.1'
2
+ VERSION = '0.2.2'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pieces
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Luke Morton
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-08-05 00:00:00.000000000 Z
11
+ date: 2015-08-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: tilt
@@ -112,13 +112,18 @@ files:
112
112
  - README.md
113
113
  - Rakefile
114
114
  - bin/pieces
115
- - example/config/routes.yml
116
- - example/pieces/application/footer.html.mustache
117
- - example/pieces/application/header.html.erb
118
- - example/pieces/layouts/layout.html.mustache
119
- - example/pieces/posts/post.css
120
- - example/pieces/posts/post.html.mustache
121
- - example/pieces/posts/posts.html.erb
115
+ - examples/boilerplate/Gemfile
116
+ - examples/boilerplate/config/routes.yml
117
+ - examples/boilerplate/pieces/application/footer.html.erb
118
+ - examples/boilerplate/pieces/application/header.html.erb
119
+ - examples/boilerplate/pieces/layouts/application.html.erb
120
+ - examples/original/config/routes.yml
121
+ - examples/original/pieces/application/footer.html.mustache
122
+ - examples/original/pieces/application/header.html.erb
123
+ - examples/original/pieces/layouts/layout.html.mustache
124
+ - examples/original/pieces/posts/post.css
125
+ - examples/original/pieces/posts/post.html.mustache
126
+ - examples/original/pieces/posts/posts.html.erb
122
127
  - lib/pieces.rb
123
128
  - lib/pieces/builder.rb
124
129
  - lib/pieces/generator.rb