pieces 0.3.8 → 0.3.9

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 779a56877fe797937693d618c05ea9f5528be171
4
- data.tar.gz: 6af7698feea41519da8cbe0311fdaf67d5c70096
3
+ metadata.gz: a6ee4dda30033a5731985268919bbd5287513269
4
+ data.tar.gz: baa91e4fc63e49afc2cf83ce0999742fc2382372
5
5
  SHA512:
6
- metadata.gz: 9add60074936b9675f114efa17c68dfea9f7de8e8ca3500f743deb9d6e201c989ec4b04a2af71bdfc488431e7d22d8117b3269e397f1dab39cf262e1809377cf
7
- data.tar.gz: 8cfd9ea75a80b2270edbcc47614dd7e9ba7c2c3d653a7a181d666d1aa6deb98f4470244bb08b5064a30ac90a3acc6489735e731e14ec6bcb715f1322b366aea2
6
+ metadata.gz: 9a8af9f673d72d5582d42ebd203830b36e1eae705af39675c9997fb56fb32beb959f5c6b90c7c8badb157ac06046154a17318fa156026a77558ee3abe8bf6fec
7
+ data.tar.gz: 17c49ca65c2ce7f228a99ac3d5b7543cf179138d7e56a9166c3d1cc90ed8caebe4815230ae3ada7fdb766b939132288ba34a4a7c0282a55736d9f7704b369f7c
data/README.md CHANGED
@@ -131,6 +131,14 @@ bundle exec rails s
131
131
 
132
132
  And then visit [http://localhost:3000/styleguide](http://localhost:3000/styleguide)
133
133
 
134
+ Alternatively you can run your styleguide without rails:
135
+
136
+ ```
137
+ bundle exec pieces s
138
+ ```
139
+
140
+ And then visit [http://localhost:8080](http://localhost:8080)
141
+
134
142
  ## Create new static site
135
143
 
136
144
  To create a new static site with pieces:
@@ -1,3 +1,5 @@
1
+ require 'ostruct'
2
+
1
3
  module Pieces
2
4
  class RouteCompiler
3
5
  attr_reader :path
@@ -33,7 +35,7 @@ module Pieces
33
35
  end
34
36
 
35
37
  def compile_piece(piece, data)
36
- view_model = OpenStruct.new(data['_global'].merge(data))
38
+ view_model = ViewModel.new(data['_global'].merge(data))
37
39
  ::Tilt.new(piece_path(piece)).render(view_model) { yield_pieces(data) }
38
40
  end
39
41
 
@@ -42,5 +44,17 @@ module Pieces
42
44
  contents << compile_piece(piece, data)
43
45
  end
44
46
  end
47
+
48
+ class ViewModel < OpenStruct
49
+ if defined?(ActionView)
50
+ include ActionView::Context
51
+ include ActionView::Helpers
52
+ end
53
+
54
+ def initialize(*)
55
+ super
56
+ _prepare_context if defined?(ActionView)
57
+ end
58
+ end
45
59
  end
46
60
  end
@@ -8,13 +8,16 @@ module Pieces
8
8
 
9
9
  def compile(files)
10
10
  files.merge('compiled.css' => { contents: '', type: 'css' }).tap do |files|
11
- Dir["#{path}/app/assets/stylesheets/components/**/*.{css,scss,sass,less}"].each do |file|
12
- files['compiled.css'][:contents] << ::Tilt.new(file).render
13
- end
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
14
17
 
15
- Dir["#{path}/app/views/**/*.{css,scss,sass,less}"].each do |file|
16
- files['compiled.css'][:contents] << ::Tilt.new(file).render
17
- end
18
+ def yield_stylesheets(dir)
19
+ Dir["#{path}/#{dir}/**/*.{css,scss,sass,less}"].reduce('') do |contents, stylesheet|
20
+ contents << ::Tilt.new(stylesheet).render
18
21
  end
19
22
  end
20
23
  end
@@ -1,3 +1,3 @@
1
1
  module Pieces
2
- VERSION = '0.3.8'
2
+ VERSION = '0.3.9'
3
3
  end
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.8
4
+ version: 0.3.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Luke Morton