pieces 0.4.2 → 0.4.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/README.md +42 -5
- data/examples/boilerplate/app/assets/stylesheets/components/header.css +3 -0
- data/examples/boilerplate/app/assets/stylesheets/pieces.css +1 -0
- data/examples/boilerplate/app/views/layouts/pieces.html.erb +1 -1
- data/examples/original/Gemfile +4 -0
- data/examples/original/app/assets/stylesheets/pieces.css +3 -0
- data/examples/rails_app/app/assets/stylesheets/components/article_summary.scss +4 -0
- data/examples/rails_app/app/assets/stylesheets/components/branding.scss +3 -0
- data/examples/rails_app/app/assets/stylesheets/components/header.scss +3 -0
- data/examples/rails_app/app/views/application/_branding.html.erb +3 -0
- data/examples/rails_app/app/views/application/_footer.html.erb +7 -0
- data/examples/rails_app/app/views/application/_header.html.erb +1 -1
- data/examples/rails_app/app/views/articles/_summary.html.erb +9 -0
- data/examples/rails_app/app/views/layouts/pieces.html.erb +1 -1
- data/examples/rails_app/config/pieces.yml +16 -1
- data/lib/pieces/builder.rb +14 -13
- data/lib/pieces/cli.rb +2 -1
- data/lib/pieces/compilers/route_compiler.rb +17 -2
- data/lib/pieces/generator.rb +22 -34
- data/lib/pieces/listener.rb +27 -4
- data/lib/pieces/rails.rb +2 -1
- data/lib/pieces/server.rb +11 -2
- data/lib/pieces/tilt_extension.rb +0 -4
- data/lib/pieces/version.rb +1 -1
- data/lib/pieces.rb +0 -4
- data/pieces.gemspec +5 -4
- metadata +26 -5
- data/examples/rails_app/app/assets/stylesheets/components/header.css +0 -4
- data/lib/pieces/compilers/style_compiler.rb +0 -32
- data/lib/pieces/tilt/css.rb +0 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d8657ab3cd83d6002517cb3ea8781a3ecfe7358c
|
4
|
+
data.tar.gz: 782f43be0159d2f469ac79f5ce3876848ea2db4d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4a36a59748f1ae938ddbe218e9fc66eca662e41c553fb3b7e903ada89ea3a1a524a8524cd02fe2d3fce523dc3ab4df810c2b049d271f35784284fab07522435b
|
7
|
+
data.tar.gz: 7b9821b278c1b80e9ccac7bd93436b2e0f7a57e8bed64c9159ad9b61956163cc4ff1adb65d54a26dc4874095edebb92d32ffd40f970167f91b429689d32d9cff
|
data/.gitignore
CHANGED
data/README.md
CHANGED
@@ -15,7 +15,14 @@ into a static site or styleguide.
|
|
15
15
|
With Pieces, you define the view of your application with components. Even
|
16
16
|
your layout is just another component.
|
17
17
|
|
18
|
-
|
18
|
+
## Welcome early adopters
|
19
|
+
|
20
|
+
I'd really appreciate feedback so please do try Pieces out for your current
|
21
|
+
or next project. Obviously it's new and changing but I adhere very closely
|
22
|
+
to semantic versioning and your styleguide should be a safe place to try
|
23
|
+
new things. Thanks in advance, Luke.
|
24
|
+
|
25
|
+
## Installation
|
19
26
|
|
20
27
|
If installing Pieces into a rails app, add it to your Gemfile:
|
21
28
|
|
@@ -29,7 +36,7 @@ If building a standalone site, install globally:
|
|
29
36
|
gem install pieces
|
30
37
|
```
|
31
38
|
|
32
|
-
|
39
|
+
## Quick example
|
33
40
|
|
34
41
|
Let's start by defining some "pieces", or components, or views as they are
|
35
42
|
better known in the rails world. You'll notice Pieces looks for files in the
|
@@ -61,12 +68,23 @@ For example, `.article` should be defined like so.
|
|
61
68
|
|
62
69
|
You can use `.css`, `.scss`, `.sass` and `.less` with Pieces.
|
63
70
|
|
71
|
+
We also need to pull this stylesheet into main one for your styleguide.
|
72
|
+
|
73
|
+
**`app/assets/stylesheets/components/article.css`:**
|
74
|
+
|
75
|
+
```css
|
76
|
+
/*= require_tree ./components */
|
77
|
+
```
|
78
|
+
|
79
|
+
And a layout to pull it together.
|
80
|
+
|
64
81
|
**`app/views/layouts/pieces.html.erb`:**
|
65
82
|
|
66
83
|
``` erb
|
67
84
|
<html>
|
68
85
|
<head>
|
69
86
|
<title>{{title}}</title>
|
87
|
+
<link rel="stylesheet" src="/assets/pieces.css" />
|
70
88
|
</head>
|
71
89
|
<body>
|
72
90
|
<%= yield %>
|
@@ -114,7 +132,9 @@ bundle
|
|
114
132
|
bundle exec rails g pieces:rails:install
|
115
133
|
```
|
116
134
|
|
117
|
-
Edit your `config/pieces.yml` to demo some of your components.
|
135
|
+
Edit your `config/pieces.yml` to demo some of your components. Please see the
|
136
|
+
examples in this README as to how it should look. Detailed documentation coming
|
137
|
+
soon. Thanks for your patience!
|
118
138
|
|
119
139
|
Now boot up rails:
|
120
140
|
|
@@ -124,8 +144,25 @@ bundle exec rails s
|
|
124
144
|
|
125
145
|
And then visit [http://localhost:3000/styleguide](http://localhost:3000/styleguide)
|
126
146
|
|
127
|
-
|
128
|
-
|
147
|
+
To build a static version of your site:
|
148
|
+
|
149
|
+
```
|
150
|
+
bundle exec pieces build
|
151
|
+
```
|
152
|
+
|
153
|
+
This will build your styleguide into `build/`.
|
154
|
+
|
155
|
+
You can also run pieces server rather than rails for faster development:
|
156
|
+
|
157
|
+
```
|
158
|
+
bundle exec pieces s
|
159
|
+
```
|
160
|
+
|
161
|
+
And then visit [http://localhost:8080](http://localhost:8080)
|
162
|
+
|
163
|
+
### Do you use vagrant?
|
164
|
+
|
165
|
+
If you do you should update Pieces::Rails in your `config/routes.rb` as follows:
|
129
166
|
|
130
167
|
``` ruby
|
131
168
|
mount Pieces::Rails.new(force_polling: true).mount, at: '/styleguide' unless Rails.env.production?
|
@@ -0,0 +1 @@
|
|
1
|
+
/*= require_tree ./components */
|
@@ -6,4 +6,19 @@ index:
|
|
6
6
|
_pieces:
|
7
7
|
- layouts/pieces:
|
8
8
|
_pieces:
|
9
|
-
- _header:
|
9
|
+
- _header:
|
10
|
+
_pieces:
|
11
|
+
- _branding: {}
|
12
|
+
- articles/_summary:
|
13
|
+
article:
|
14
|
+
title: 'A standard artile summary'
|
15
|
+
excerpt: 'This summary does not deserve any special attention.'
|
16
|
+
- articles/_summary:
|
17
|
+
modifier: '--latest'
|
18
|
+
article:
|
19
|
+
title: 'Building systems with styleguides'
|
20
|
+
excerpt: 'PSDs or one off website builds are not quite a thing of the past but they certainly are not what all clients want these days.'
|
21
|
+
- _footer:
|
22
|
+
contact_links:
|
23
|
+
- ['Email', 'mailto:lukemorton.dev@gmail.com']
|
24
|
+
- ['Twitter', 'https://twitter.com/lukemorton']
|
data/lib/pieces/builder.rb
CHANGED
@@ -1,5 +1,9 @@
|
|
1
1
|
require 'ostruct'
|
2
2
|
require 'yaml'
|
3
|
+
require 'sprockets'
|
4
|
+
require 'pieces/compilers/route_compiler'
|
5
|
+
require 'pieces/server'
|
6
|
+
require 'pieces/tilt_extension'
|
3
7
|
|
4
8
|
module Pieces
|
5
9
|
class Builder
|
@@ -13,29 +17,26 @@ module Pieces
|
|
13
17
|
def initialize(config)
|
14
18
|
@path = config[:path]
|
15
19
|
@route_config ||= YAML.load_file("#{path}/config/pieces.yml")
|
16
|
-
require 'pieces/tilt_extension'
|
17
20
|
end
|
18
21
|
|
19
22
|
def build
|
20
|
-
save_files(
|
23
|
+
save_files(build_routes(build_styles))
|
21
24
|
end
|
22
25
|
|
23
|
-
|
24
|
-
save_files(_build_styles)
|
25
|
-
end
|
26
|
+
private
|
26
27
|
|
27
|
-
def
|
28
|
-
|
28
|
+
def env
|
29
|
+
@env ||= Server.new(path: path).sprockets_env
|
29
30
|
end
|
30
31
|
|
31
|
-
|
32
|
-
|
33
|
-
def _build_styles(files = {})
|
34
|
-
StyleCompiler.new(path: path).compile(files)
|
32
|
+
def build_styles(files = {})
|
33
|
+
files.merge('assets/pieces.css' => { type: 'css', contents: env['pieces.css'] })
|
35
34
|
end
|
36
35
|
|
37
|
-
def
|
38
|
-
route_compiler = RouteCompiler.new(path: path,
|
36
|
+
def build_routes(files = {})
|
37
|
+
route_compiler = RouteCompiler.new(path: path,
|
38
|
+
globals: route_config['_global'],
|
39
|
+
env: env)
|
39
40
|
|
40
41
|
routes.reduce(files) do |files, (name, route)|
|
41
42
|
route_compiler.compile(files, name, route)
|
data/lib/pieces/cli.rb
CHANGED
@@ -3,10 +3,12 @@ require 'ostruct'
|
|
3
3
|
module Pieces
|
4
4
|
class RouteCompiler
|
5
5
|
attr_reader :path
|
6
|
+
attr_reader :env
|
6
7
|
attr_reader :globals
|
7
8
|
|
8
9
|
def initialize(config)
|
9
10
|
@path = config[:path] || Dir.pwd
|
11
|
+
@env = config[:env]
|
10
12
|
@globals = config[:globals] || {}
|
11
13
|
end
|
12
14
|
|
@@ -36,6 +38,7 @@ module Pieces
|
|
36
38
|
|
37
39
|
def compile_piece(piece, data)
|
38
40
|
view_model = ViewModel.new(data['_global'].merge(data))
|
41
|
+
view_model.env = env
|
39
42
|
::Tilt.new(piece_path(piece)).render(view_model) { yield_pieces(data) }
|
40
43
|
end
|
41
44
|
|
@@ -46,14 +49,26 @@ module Pieces
|
|
46
49
|
end
|
47
50
|
|
48
51
|
class ViewModel < OpenStruct
|
49
|
-
|
52
|
+
attr_accessor :env
|
53
|
+
|
54
|
+
begin
|
55
|
+
require 'action_view'
|
50
56
|
include ActionView::Context
|
51
57
|
include ActionView::Helpers
|
58
|
+
rescue LoadError => e
|
52
59
|
end
|
53
60
|
|
54
61
|
def initialize(*)
|
55
62
|
super
|
56
|
-
_prepare_context if
|
63
|
+
_prepare_context if respond_to?(:_prepare_context)
|
64
|
+
end
|
65
|
+
|
66
|
+
def compute_asset_path(path, options = {})
|
67
|
+
if env.resolve!(path)
|
68
|
+
File.join('/assets', path)
|
69
|
+
else
|
70
|
+
super
|
71
|
+
end
|
57
72
|
end
|
58
73
|
end
|
59
74
|
end
|
data/lib/pieces/generator.rb
CHANGED
@@ -1,45 +1,33 @@
|
|
1
|
-
|
2
|
-
module Generator
|
3
|
-
extend self
|
4
|
-
|
5
|
-
def init(config = {})
|
6
|
-
path = config[:path] || Dir.pwd
|
7
|
-
FileUtils.mkdir_p(path)
|
1
|
+
require 'thor'
|
8
2
|
|
9
|
-
|
10
|
-
|
11
|
-
|
3
|
+
module Pieces
|
4
|
+
class Generator
|
5
|
+
def self.init(config = {})
|
6
|
+
new(config).init
|
7
|
+
end
|
12
8
|
|
13
|
-
|
14
|
-
|
15
|
-
|
9
|
+
def self.from_superclass(method, default)
|
10
|
+
default
|
11
|
+
end
|
16
12
|
|
17
|
-
|
18
|
-
|
19
|
-
end
|
13
|
+
include Thor::Actions
|
14
|
+
include Thor::Shell
|
20
15
|
|
21
|
-
|
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
|
16
|
+
source_root File.expand_path('../../../examples/boilerplate', __FILE__)
|
28
17
|
|
29
|
-
|
30
|
-
FileUtils.mkdir_p("#{path}/config")
|
31
|
-
FileUtils.cp("#{example_path}/config/pieces.yml", "#{path}/config/pieces.yml")
|
32
|
-
end
|
18
|
+
attr_reader :path, :options
|
33
19
|
|
34
|
-
|
35
|
-
|
36
|
-
|
20
|
+
def initialize(config = {})
|
21
|
+
@path = config[:path] || Dir.pwd
|
22
|
+
@options = {}
|
23
|
+
self.destination_root = config[:path]
|
37
24
|
end
|
38
25
|
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
26
|
+
def init
|
27
|
+
directory 'app/assets/stylesheets'
|
28
|
+
directory 'app/views'
|
29
|
+
copy_file 'config/pieces.yml'
|
30
|
+
copy_file 'Gemfile'
|
43
31
|
end
|
44
32
|
end
|
45
33
|
end
|
data/lib/pieces/listener.rb
CHANGED
@@ -12,10 +12,8 @@ module Pieces
|
|
12
12
|
end
|
13
13
|
|
14
14
|
def listen
|
15
|
-
Listen.to("#{path}/config/", "#{path}/app/", force_polling: force_polling) do
|
16
|
-
|
17
|
-
build_pieces
|
18
|
-
puts 'done.'
|
15
|
+
Listen.to("#{path}/config/", "#{path}/app/views", force_polling: force_polling) do
|
16
|
+
rebuild_pieces
|
19
17
|
end.tap(&:start)
|
20
18
|
end
|
21
19
|
|
@@ -23,6 +21,31 @@ module Pieces
|
|
23
21
|
|
24
22
|
def build_pieces
|
25
23
|
Pieces::Builder.new(path: path).send(build_method)
|
24
|
+
rescue => e
|
25
|
+
output_backtrace(e)
|
26
|
+
exit(1)
|
27
|
+
end
|
28
|
+
|
29
|
+
def rebuild_pieces
|
30
|
+
print "\n[pieces]: Rebuilding #{File.basename(path)}... "
|
31
|
+
Pieces::Builder.new(path: path).send(build_method)
|
32
|
+
puts 'done.'
|
33
|
+
rescue => e
|
34
|
+
puts 'an error occurred.'
|
35
|
+
puts ''
|
36
|
+
output_backtrace(e)
|
37
|
+
end
|
38
|
+
|
39
|
+
def output_backtrace(exception)
|
40
|
+
puts "[pieces]: Exception occured: #{exception.message}"
|
41
|
+
puts '[pieces]:'
|
42
|
+
|
43
|
+
if defined?(::Rails)
|
44
|
+
trace = ::Rails.backtrace_cleaner.clean(exception.backtrace)
|
45
|
+
puts trace.map { |line| "[pieces]: #{line}" }
|
46
|
+
else
|
47
|
+
puts exception.backtrace.map { |line| "[pieces]: #{line}" }
|
48
|
+
end
|
26
49
|
end
|
27
50
|
end
|
28
51
|
end
|
data/lib/pieces/rails.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'pieces/rails/railtie'
|
2
|
+
require 'pieces/server'
|
2
3
|
|
3
4
|
module Pieces
|
4
5
|
class Rails
|
@@ -10,7 +11,7 @@ module Pieces
|
|
10
11
|
end
|
11
12
|
|
12
13
|
def mount
|
13
|
-
Pieces::Listener.new(path: path,
|
14
|
+
Pieces::Listener.new(path: path, force_polling: force_polling).listen
|
14
15
|
Pieces::Server.new(path: path).app
|
15
16
|
end
|
16
17
|
end
|
data/lib/pieces/server.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
require 'rack'
|
2
2
|
require 'listen'
|
3
|
+
require 'sprockets'
|
3
4
|
|
4
5
|
module Pieces
|
5
6
|
class Server < Rack::Server
|
@@ -15,13 +16,21 @@ module Pieces
|
|
15
16
|
super
|
16
17
|
end
|
17
18
|
|
19
|
+
def sprockets_env
|
20
|
+
Sprockets::Environment.new.tap do |env|
|
21
|
+
env.append_path 'app/assets/javascripts'
|
22
|
+
env.append_path 'app/assets/stylesheets'
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
18
26
|
def app
|
19
|
-
|
27
|
+
urls = files_to_serve(path)
|
20
28
|
build_path = "#{path}/build"
|
21
29
|
|
22
30
|
Rack::Builder.app do
|
23
31
|
use Rack::Reloader
|
24
|
-
use Rack::Static, urls:
|
32
|
+
use Rack::Static, urls: urls, root: build_path, index: 'index.html'
|
33
|
+
map('/assets') { run sprockets_env } unless defined? ::Rails
|
25
34
|
run Proc.new { |env| [404, {}, ['Not found']] }
|
26
35
|
end
|
27
36
|
end
|
@@ -3,12 +3,8 @@ require 'tilt'
|
|
3
3
|
module Tilt
|
4
4
|
if respond_to?(:register_lazy)
|
5
5
|
register_lazy 'Pieces::Tilt::MustacheTemplate', 'pieces/tilt/mustache', 'mustache', 'ms'
|
6
|
-
register_lazy 'Pieces::Tilt::CssTemplate', 'pieces/tilt/css', 'css'
|
7
6
|
else # support tilt v1
|
8
7
|
require 'pieces/tilt/mustache'
|
9
8
|
register Pieces::Tilt::MustacheTemplate, 'mustache', 'ms'
|
10
|
-
|
11
|
-
require 'pieces/tilt/css'
|
12
|
-
register Pieces::Tilt::CssTemplate, 'css'
|
13
9
|
end
|
14
10
|
end
|
data/lib/pieces/version.rb
CHANGED
data/lib/pieces.rb
CHANGED
@@ -1,9 +1,5 @@
|
|
1
|
-
require 'pieces/compilers/route_compiler'
|
2
|
-
require 'pieces/compilers/style_compiler'
|
3
1
|
require 'pieces/builder'
|
4
|
-
require 'pieces/generator'
|
5
2
|
require 'pieces/listener'
|
6
|
-
require 'pieces/server'
|
7
3
|
require 'pieces/rails' if defined?(Rails)
|
8
4
|
require 'pieces/version'
|
9
5
|
|
data/pieces.gemspec
CHANGED
@@ -16,10 +16,11 @@ Gem::Specification.new do |spec|
|
|
16
16
|
spec.executables = ['pieces']
|
17
17
|
spec.require_paths = ['lib']
|
18
18
|
|
19
|
-
spec.add_dependency 'tilt'
|
20
|
-
spec.add_dependency 'thor'
|
21
|
-
spec.add_dependency 'rack'
|
22
|
-
spec.add_dependency 'listen'
|
19
|
+
spec.add_dependency 'tilt'
|
20
|
+
spec.add_dependency 'thor'
|
21
|
+
spec.add_dependency 'rack'
|
22
|
+
spec.add_dependency 'listen'
|
23
|
+
spec.add_dependency 'sprockets'
|
23
24
|
|
24
25
|
spec.add_development_dependency 'bundler'
|
25
26
|
spec.add_development_dependency 'codeclimate-test-reporter'
|
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.4.
|
4
|
+
version: 0.4.3
|
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-
|
11
|
+
date: 2015-08-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: tilt
|
@@ -66,6 +66,20 @@ dependencies:
|
|
66
66
|
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: sprockets
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
69
83
|
- !ruby/object:Gem::Dependency
|
70
84
|
name: bundler
|
71
85
|
requirement: !ruby/object:Gem::Requirement
|
@@ -170,10 +184,14 @@ files:
|
|
170
184
|
- bin/pieces
|
171
185
|
- examples/boilerplate/.gitignore
|
172
186
|
- examples/boilerplate/Gemfile
|
187
|
+
- examples/boilerplate/app/assets/stylesheets/components/header.css
|
188
|
+
- examples/boilerplate/app/assets/stylesheets/pieces.css
|
173
189
|
- examples/boilerplate/app/views/application/footer.html.erb
|
174
190
|
- examples/boilerplate/app/views/application/header.html.erb
|
175
191
|
- examples/boilerplate/app/views/layouts/pieces.html.erb
|
176
192
|
- examples/boilerplate/config/pieces.yml
|
193
|
+
- examples/original/Gemfile
|
194
|
+
- examples/original/app/assets/stylesheets/pieces.css
|
177
195
|
- examples/original/app/views/application/footer.html.mustache
|
178
196
|
- examples/original/app/views/application/header.html.erb
|
179
197
|
- examples/original/app/views/layouts/layout.html.mustache
|
@@ -187,7 +205,9 @@ files:
|
|
187
205
|
- examples/rails_app/app/assets/images/.keep
|
188
206
|
- examples/rails_app/app/assets/javascripts/application.js
|
189
207
|
- examples/rails_app/app/assets/stylesheets/application.css
|
190
|
-
- examples/rails_app/app/assets/stylesheets/components/
|
208
|
+
- examples/rails_app/app/assets/stylesheets/components/article_summary.scss
|
209
|
+
- examples/rails_app/app/assets/stylesheets/components/branding.scss
|
210
|
+
- examples/rails_app/app/assets/stylesheets/components/header.scss
|
191
211
|
- examples/rails_app/app/assets/stylesheets/pieces.css
|
192
212
|
- examples/rails_app/app/controllers/application_controller.rb
|
193
213
|
- examples/rails_app/app/controllers/concerns/.keep
|
@@ -195,7 +215,10 @@ files:
|
|
195
215
|
- examples/rails_app/app/mailers/.keep
|
196
216
|
- examples/rails_app/app/models/.keep
|
197
217
|
- examples/rails_app/app/models/concerns/.keep
|
218
|
+
- examples/rails_app/app/views/application/_branding.html.erb
|
219
|
+
- examples/rails_app/app/views/application/_footer.html.erb
|
198
220
|
- examples/rails_app/app/views/application/_header.html.erb
|
221
|
+
- examples/rails_app/app/views/articles/_summary.html.erb
|
199
222
|
- examples/rails_app/app/views/layouts/application.html.erb
|
200
223
|
- examples/rails_app/app/views/layouts/pieces.html.erb
|
201
224
|
- examples/rails_app/bin/bundle
|
@@ -236,14 +259,12 @@ files:
|
|
236
259
|
- lib/pieces/builder.rb
|
237
260
|
- lib/pieces/cli.rb
|
238
261
|
- lib/pieces/compilers/route_compiler.rb
|
239
|
-
- lib/pieces/compilers/style_compiler.rb
|
240
262
|
- lib/pieces/generator.rb
|
241
263
|
- lib/pieces/listener.rb
|
242
264
|
- lib/pieces/rails.rb
|
243
265
|
- lib/pieces/rails/install_generator.rb
|
244
266
|
- lib/pieces/rails/railtie.rb
|
245
267
|
- lib/pieces/server.rb
|
246
|
-
- lib/pieces/tilt/css.rb
|
247
268
|
- lib/pieces/tilt/mustache.rb
|
248
269
|
- lib/pieces/tilt_extension.rb
|
249
270
|
- lib/pieces/version.rb
|
@@ -1,32 +0,0 @@
|
|
1
|
-
module Pieces
|
2
|
-
class StyleCompiler
|
3
|
-
attr_reader :path
|
4
|
-
|
5
|
-
def initialize(config = {})
|
6
|
-
@path = config[:path] || Dir.pwd
|
7
|
-
end
|
8
|
-
|
9
|
-
def compile(files)
|
10
|
-
files.merge('compiled.css' => { contents: '', type: 'css' }).tap do |files|
|
11
|
-
files['compiled.css'][:contents] << yield_stylesheets('app/assets/stylesheets/components')
|
12
|
-
files['compiled.css'][:contents] << yield_stylesheets('app/views')
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
private
|
17
|
-
|
18
|
-
def yield_stylesheets(dir)
|
19
|
-
Dir["#{path}/#{dir}/**/*.{css,scss,sass,less}"].reduce('') do |contents, stylesheet|
|
20
|
-
contents << ::Tilt.new(stylesheet, sass_config).render
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
def sass_config
|
25
|
-
if defined? Compass
|
26
|
-
{ load_paths: Compass.sass_engine_options[:load_paths] }
|
27
|
-
else
|
28
|
-
{ load_paths: "#{path}/app/assets/stylesheets/" }
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|