pieces 0.3.3 → 0.3.5

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: e1f7dc061f6f697acee3c861621544b165d2a2a8
4
- data.tar.gz: a936fc1074f2aaa27e64e009b68be133a29fc63f
3
+ metadata.gz: cf95f21e65d0bf4fd7ca923670baf2a893c5d14d
4
+ data.tar.gz: 8d0e716fa17ee6ac4fb54a605fbb9114fdca7c99
5
5
  SHA512:
6
- metadata.gz: 9349d82313f51c7d57bbccd08d9522d52a51a54de5cde1c147f44be3e837c8fefbfcf99f9c767364ea37f6ff2cf24f9e49469b91b0efc268b3bd5fe8773a131b
7
- data.tar.gz: cf3270f620c425d55eca0b8040ba1f284c5da156fbd73360cb406dee74be9447dd74443878863e593fb0b4f1f3f2084463b43cc6f45ec5514aafaa55aafe2fd4
6
+ metadata.gz: a672697f08f2f7f3aa9c32f8741452058b346902175c1889f8142862efa0da12268b0a1908a4c0e53edae3be9659d1b4c1f0c0f4e6b76ed93a3f5a92a62f2835
7
+ data.tar.gz: db08a20f9635229d07baea336469dd3fc04c6279c5f48121fe8a3ec28b0d3efb16c7bb6f11b3fb1d3a38155f83f210d65ed1cb09aeb0b88ffd68ae851b960136
@@ -16,6 +16,7 @@ module Pieces
16
16
  end
17
17
 
18
18
  def build
19
+ require 'pieces/tilt_extension'
19
20
  save_files(build_files)
20
21
  end
21
22
 
@@ -34,7 +34,7 @@ module Pieces
34
34
 
35
35
  def compile_piece(piece, data)
36
36
  view_model = OpenStruct.new(data['_global'].merge(data))
37
- Tilt.new(piece_path(piece)).render(view_model) { yield_pieces(data) }
37
+ ::Tilt.new(piece_path(piece)).render(view_model) { yield_pieces(data) }
38
38
  end
39
39
 
40
40
  def yield_pieces(data)
@@ -9,7 +9,7 @@ module Pieces
9
9
  def compile(files)
10
10
  files.merge('compiled.css' => { contents: '', type: 'css' }).tap do |files|
11
11
  Dir["#{path}/app/views/*/*.{css,scss,sass,less}"].each do |file|
12
- files['compiled.css'][:contents] << Tilt.new(file).render
12
+ files['compiled.css'][:contents] << ::Tilt.new(file).render
13
13
  end
14
14
  end
15
15
  end
@@ -6,8 +6,29 @@ module Pieces
6
6
  path = config[:path] || Dir.pwd
7
7
  FileUtils.mkdir_p(path)
8
8
 
9
- Dir["#{example_path}/{config,app}"].each do |dir|
10
- FileUtils.cp_r(dir, path) unless Dir.exist?("#{path}/#{File.basename(dir)}")
9
+ if Dir.exist?("#{path}/app/views")
10
+ FileUtils.mkdir_p("#{path}/app/views/application")
11
+ FileUtils.mkdir_p("#{path}/app/views/layouts")
12
+
13
+ unless File.exist?("#{path}/app/views/layouts/pieces.html.erb")
14
+ FileUtils.cp("#{example_path}/app/views/layouts/pieces.html.erb", "#{path}/app/views/layouts")
15
+ end
16
+
17
+ unless File.exist?("#{path}/app/views/application/header.html.erb")
18
+ FileUtils.cp("#{example_path}/app/views/application/header.html.erb", "#{path}/app/views/application")
19
+ end
20
+
21
+ unless File.exist?("#{path}/app/views/application/footer.html.erb")
22
+ FileUtils.cp("#{example_path}/app/views/application/footer.html.erb", "#{path}/app/views/application")
23
+ end
24
+ else
25
+ FileUtils.mkdir_p("#{path}/app/")
26
+ FileUtils.cp_r("#{example_path}/app/views", "#{path}/app/views")
27
+ end
28
+
29
+ unless File.exist?("#{path}/config/pieces.yml")
30
+ FileUtils.mkdir_p("#{path}/config")
31
+ FileUtils.cp("#{example_path}/config/pieces.yml", "#{path}/config/pieces.yml")
11
32
  end
12
33
 
13
34
  unless File.exist?("#{path}/Gemfile")
@@ -0,0 +1,8 @@
1
+ require 'tilt/plain'
2
+
3
+ module Pieces
4
+ module Tilt
5
+ class CssTemplate < ::Tilt::PlainTemplate
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,30 @@
1
+ module Pieces
2
+ module Tilt
3
+ class MustacheTemplate < ::Tilt::Template
4
+ def initialize_engine; end
5
+
6
+ def prepare; end
7
+
8
+ def evaluate(scope, locals, &block)
9
+ require 'mustache'
10
+ Mustache.render(data, with_block(view_model(scope, locals), &block))
11
+ end
12
+
13
+ private
14
+
15
+ def view_model(scope, locals)
16
+ if scope.is_a?(Hash)
17
+ locals.merge(scope)
18
+ elsif scope.respond_to?(:to_h)
19
+ locals.merge(scope.to_h)
20
+ else
21
+ locals
22
+ end
23
+ end
24
+
25
+ def with_block(view_model, &block)
26
+ view_model.merge(:yield => block.nil? ? '' : block.call)
27
+ end
28
+ end
29
+ end
30
+ end
@@ -4,13 +4,11 @@ module Tilt
4
4
  if respond_to?(:register_lazy)
5
5
  register_lazy :MustacheTemplate, 'tilt/mustache', 'mustache', 'ms'
6
6
  register_lazy :CssTemplate, 'tilt/css', 'css'
7
- elsif defined?(Rails)
8
- # Register these yourself
9
7
  else # support tilt v1
10
- require 'tilt/mustache'
11
- register MustacheTemplate, 'mustache', 'ms'
8
+ require 'pieces/tilt/mustache'
9
+ register Tilt::MustacheTemplate, 'mustache', 'ms'
12
10
 
13
- require 'tilt/css'
14
- register CssTemplate, 'css'
11
+ require 'pieces/tilt/css'
12
+ register Tilt::CssTemplate, 'css'
15
13
  end
16
14
  end
@@ -1,3 +1,3 @@
1
1
  module Pieces
2
- VERSION = '0.3.3'
2
+ VERSION = '0.3.5'
3
3
  end
data/lib/pieces.rb CHANGED
@@ -5,7 +5,6 @@ require 'pieces/generator'
5
5
  require 'pieces/listener'
6
6
  require 'pieces/server'
7
7
  require 'pieces/rails'
8
- require 'pieces/tilt_extension'
9
8
  require 'pieces/version'
10
9
 
11
10
  module Pieces
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pieces
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.3
4
+ version: 0.3.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Luke Morton
@@ -238,10 +238,10 @@ files:
238
238
  - lib/pieces/listener.rb
239
239
  - lib/pieces/rails.rb
240
240
  - lib/pieces/server.rb
241
+ - lib/pieces/tilt/css.rb
242
+ - lib/pieces/tilt/mustache.rb
241
243
  - lib/pieces/tilt_extension.rb
242
244
  - lib/pieces/version.rb
243
- - lib/tilt/css.rb
244
- - lib/tilt/mustache.rb
245
245
  - pieces.gemspec
246
246
  homepage: https://github.com/drpheltright/pieces
247
247
  licenses:
data/lib/tilt/css.rb DELETED
@@ -1,6 +0,0 @@
1
- require 'tilt/plain'
2
-
3
- module Tilt
4
- class CssTemplate < PlainTemplate
5
- end
6
- end
data/lib/tilt/mustache.rb DELETED
@@ -1,29 +0,0 @@
1
- require 'mustache'
2
-
3
- module Tilt
4
- class MustacheTemplate < Template
5
- def initialize_engine; end
6
-
7
- def prepare; end
8
-
9
- def evaluate(scope, locals, &block)
10
- Mustache.render(data, with_block(view_model(scope, locals), &block))
11
- end
12
-
13
- private
14
-
15
- def view_model(scope, locals)
16
- if scope.is_a?(Hash)
17
- locals.merge(scope)
18
- elsif scope.respond_to?(:to_h)
19
- locals.merge(scope.to_h)
20
- else
21
- locals
22
- end
23
- end
24
-
25
- def with_block(view_model, &block)
26
- view_model.merge(:yield => block.nil? ? '' : block.call)
27
- end
28
- end
29
- end