livingstyleguide 2.0.0.alpha.5 → 2.0.0.alpha.6
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/lib/livingstyleguide/document.rb +10 -7
- data/lib/livingstyleguide/filters/css.rb +3 -0
- data/lib/livingstyleguide/filters/data.rb +6 -1
- data/lib/livingstyleguide/filters/default.rb +6 -0
- data/lib/livingstyleguide/filters/{import.rb → import_and_use.rb} +22 -8
- data/lib/livingstyleguide/filters/layout.rb +33 -0
- data/lib/livingstyleguide/filters/style.rb +1 -1
- data/lib/livingstyleguide/filters.rb +3 -2
- data/lib/livingstyleguide/templates/layout.html.erb +1 -1
- data/lib/livingstyleguide/version.rb +1 -1
- metadata +19 -4
- data/lib/livingstyleguide/filters/html_head.rb +0 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 99011854cea04c29122a5e4014eca155e1972da2
|
4
|
+
data.tar.gz: 324abacc9ef03fa22b0fa570b8fee64f686c5312
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 201d20433e57bce205aa2fc8086678e49455b33c97fadacded15fc9538d8b2be1d24876c005bb671662cdb2918ad0bb0ee460ee7a06773c9e2bcba03e7312e67
|
7
|
+
data.tar.gz: 4c8f285365e917fd882f173c03827a195dc66df295a9f5051264c4b0368ba6c679beda37212dc16c96b291054110fd39f568c8f04aa27dcce344737586c64832
|
@@ -8,6 +8,7 @@ class LivingStyleGuide::Document < ::Tilt::Template
|
|
8
8
|
attr_accessor :source, :type, :filters, :template, :classes, :html
|
9
9
|
attr_accessor :css, :id, :locals
|
10
10
|
attr_accessor :title
|
11
|
+
attr_accessor :defaults
|
11
12
|
attr_reader :scope
|
12
13
|
|
13
14
|
%w(scss head header footer).each do |attr|
|
@@ -36,10 +37,10 @@ class LivingStyleGuide::Document < ::Tilt::Template
|
|
36
37
|
@scss = ''
|
37
38
|
@css = ''
|
38
39
|
@locals = {}
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
@
|
40
|
+
@defaults = { global: {} }
|
41
|
+
@head = ""
|
42
|
+
@header = ""
|
43
|
+
@footer = ""
|
43
44
|
end
|
44
45
|
|
45
46
|
def highlighted_source
|
@@ -64,13 +65,15 @@ class LivingStyleGuide::Document < ::Tilt::Template
|
|
64
65
|
|
65
66
|
def erb
|
66
67
|
@erb ||= parse_filters do |name, arguments, options, block|
|
67
|
-
|
68
|
+
options = %Q(document.defaults[:global].merge(document.defaults[:@#{name}] || {}).merge(#{options.inspect}))
|
69
|
+
"<%= #{name}(#{arguments.inspect}, #{options}, #{block.inspect}) %>\n"
|
68
70
|
end
|
69
71
|
end
|
70
72
|
|
71
73
|
def evaluate(scope, locals, &block)
|
72
74
|
@scope = scope
|
73
75
|
result = ERB.new(erb).result(@filters.get_binding)
|
76
|
+
@source = result
|
74
77
|
@html = render_html(result, locals)
|
75
78
|
@classes.unshift "livingstyleguide--#{@type}-example"
|
76
79
|
@classes.unshift "livingstyleguide--example"
|
@@ -170,7 +173,7 @@ class LivingStyleGuide::Document < ::Tilt::Template
|
|
170
173
|
def parse_filters
|
171
174
|
data.gsub('<%', '<%%').gsub(/\G(.*?)((```.+?```)|\Z)/m) do
|
172
175
|
content, code_block = $1, $2
|
173
|
-
content.gsub(/^@([\w\d_-]+)(?: ([^\n]*[^\{\n:]))?(?: *\{\n((?:.|\n)*?)\n\}
|
176
|
+
content.gsub(/^@([\w\d_-]+)(?: ([^\n]*[^\{\n:]))?(?: *\{\n((?:.|\n)*?)\n\}|((?:\n+ .*)+(?=\n|\Z))| *:\n((?:.|\n)*?)(?:\n\n|\Z))?/) do
|
174
177
|
name, arguments_string, block = $1, $2 || '', $3 || $4 || $5
|
175
178
|
options = {
|
176
179
|
block_type: $3 ? :braces : $4 ? :indented : $5 ? :block : :none
|
@@ -178,7 +181,7 @@ class LivingStyleGuide::Document < ::Tilt::Template
|
|
178
181
|
name = name.gsub('-', '_').to_sym
|
179
182
|
arguments = parse_arguments(arguments_string, options)
|
180
183
|
if options[:block_type] == :indented
|
181
|
-
block.gsub!(/\A(\s*)((?:.|\n)+)\Z/){ $2.gsub(/^#{$1}/, '') }
|
184
|
+
block.gsub!(/\A\n(\s*)((?:.|\n)+)\Z/){ $2.gsub(/^#{$1}/, '') }
|
182
185
|
end
|
183
186
|
yield name, arguments, options, block
|
184
187
|
end + code_block
|
@@ -7,6 +7,9 @@ LivingStyleGuide.add_filter :css, :scss do |arguments, options, source|
|
|
7
7
|
document.depend_on file
|
8
8
|
document.scss << %Q(@import "#{file}";\n)
|
9
9
|
else
|
10
|
+
if options[:preprocessor] == "sass"
|
11
|
+
source = Sass::Engine.new(source).to_tree.to_scss
|
12
|
+
end
|
10
13
|
document.scss << "##{document.id.gsub('/', '\\/')} {\n#{source}\n}\n"
|
11
14
|
end
|
12
15
|
nil
|
@@ -1,6 +1,11 @@
|
|
1
1
|
require 'json'
|
2
|
+
require 'yaml'
|
2
3
|
|
3
4
|
LivingStyleGuide.add_filter :data do |arguments, options, data|
|
4
|
-
|
5
|
+
if options[:format] == "yaml"
|
6
|
+
document.locals.merge! Psych.load("{#{data}}")
|
7
|
+
else
|
8
|
+
document.locals.merge! JSON.parse("{#{data}}")
|
9
|
+
end
|
5
10
|
nil
|
6
11
|
end
|
@@ -1,25 +1,39 @@
|
|
1
1
|
require 'tilt'
|
2
2
|
|
3
|
-
|
4
|
-
glob = arguments.first
|
5
|
-
if glob =~ /\.s[ac]ss$/
|
6
|
-
raise "Error: Please use `@css #{glob}` instead of `@import #{glob}` for importing Sass."
|
7
|
-
end
|
3
|
+
def map_files(glob, &block)
|
8
4
|
glob << '.lsg' unless glob =~ /\.(\w+|\*)$/
|
9
5
|
glob.gsub!(/[^\/]+$/, '{_,}\\0')
|
10
6
|
if document.file
|
11
7
|
glob = File.join(File.dirname(document.file), glob)
|
12
8
|
end
|
13
9
|
|
10
|
+
Dir.glob(glob).map do |file|
|
11
|
+
document.depend_on file
|
12
|
+
yield(file)
|
13
|
+
end.join
|
14
|
+
end
|
15
|
+
|
16
|
+
LivingStyleGuide.add_filter :import do |arguments, options, data|
|
17
|
+
glob = arguments.first
|
18
|
+
if glob =~ /\.s[ac]ss$/
|
19
|
+
raise "Error: Please use `@css #{glob}` instead of `@import #{glob}` for importing Sass."
|
20
|
+
end
|
21
|
+
|
14
22
|
if data
|
15
23
|
Kernel.require 'json'
|
16
24
|
data = JSON.parse("{#{data}}")
|
17
25
|
end
|
18
26
|
|
19
|
-
|
20
|
-
document.depend_on file
|
27
|
+
map_files glob do |file|
|
21
28
|
html = ::Tilt.new(file, livingstyleguide: document).render(document.scope, data)
|
22
29
|
html.gsub!("\n", "\n ")
|
23
30
|
"\n<div>\n#{html}\n</div>\n"
|
24
|
-
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
LivingStyleGuide.add_filter :use do |arguments, options, data|
|
35
|
+
glob = arguments.first
|
36
|
+
map_files glob do |file|
|
37
|
+
File.read(file)
|
38
|
+
end
|
25
39
|
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
LivingStyleGuide.add_filter :title do |arguments, options, block|
|
2
|
+
document.title = arguments.first
|
3
|
+
nil
|
4
|
+
end
|
5
|
+
|
6
|
+
{ :before => :head, :after => :footer }.each do |name, destination|
|
7
|
+
eval <<-RUBY
|
8
|
+
LivingStyleGuide.add_filter :javascript_#{name} do |arguments, options, block|
|
9
|
+
if src = arguments.first
|
10
|
+
document.#{destination} << %Q(<script src="\#{src}"></script>)
|
11
|
+
else
|
12
|
+
if options[:transpiler] == "coffee-script"
|
13
|
+
block = Tilt["coffee"].new{ block }.render
|
14
|
+
end
|
15
|
+
document.#{destination} << %Q(<script>\\n\#{block}\\n</script>)
|
16
|
+
end
|
17
|
+
nil
|
18
|
+
end
|
19
|
+
RUBY
|
20
|
+
end
|
21
|
+
|
22
|
+
%w(head header footer).each do |part|
|
23
|
+
eval <<-RUBY
|
24
|
+
LivingStyleGuide.add_filter :#{part} do |arguments, options, block|
|
25
|
+
if template = Tilt[options[:type]]
|
26
|
+
block = template.new{ block }.render
|
27
|
+
end
|
28
|
+
document.#{part} << block + "\n"
|
29
|
+
nil
|
30
|
+
end
|
31
|
+
RUBY
|
32
|
+
nil
|
33
|
+
end
|
@@ -17,7 +17,8 @@ class LivingStyleGuide::Filters
|
|
17
17
|
end
|
18
18
|
|
19
19
|
require 'livingstyleguide/filters/options'
|
20
|
-
require 'livingstyleguide/filters/
|
20
|
+
require 'livingstyleguide/filters/default'
|
21
|
+
require 'livingstyleguide/filters/import_and_use'
|
21
22
|
require 'livingstyleguide/filters/require'
|
22
23
|
require 'livingstyleguide/filters/full_width'
|
23
24
|
require 'livingstyleguide/filters/haml'
|
@@ -31,4 +32,4 @@ require 'livingstyleguide/filters/colors'
|
|
31
32
|
require 'livingstyleguide/filters/css'
|
32
33
|
require 'livingstyleguide/filters/style'
|
33
34
|
require 'livingstyleguide/filters/data'
|
34
|
-
require 'livingstyleguide/filters/
|
35
|
+
require 'livingstyleguide/filters/layout'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: livingstyleguide
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.0.alpha.
|
4
|
+
version: 2.0.0.alpha.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nico Hagenburger
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-05-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: minisyntax
|
@@ -122,6 +122,20 @@ dependencies:
|
|
122
122
|
- - ">="
|
123
123
|
- !ruby/object:Gem::Version
|
124
124
|
version: '0'
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: erubis
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - ">="
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '0'
|
132
|
+
type: :development
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - ">="
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: '0'
|
125
139
|
- !ruby/object:Gem::Dependency
|
126
140
|
name: heredoc_unindent
|
127
141
|
requirement: !ruby/object:Gem::Requirement
|
@@ -199,12 +213,13 @@ files:
|
|
199
213
|
- lib/livingstyleguide/filters/colors.rb
|
200
214
|
- lib/livingstyleguide/filters/css.rb
|
201
215
|
- lib/livingstyleguide/filters/data.rb
|
216
|
+
- lib/livingstyleguide/filters/default.rb
|
202
217
|
- lib/livingstyleguide/filters/font_example.rb
|
203
218
|
- lib/livingstyleguide/filters/full_width.rb
|
204
219
|
- lib/livingstyleguide/filters/haml.rb
|
205
|
-
- lib/livingstyleguide/filters/
|
206
|
-
- lib/livingstyleguide/filters/import.rb
|
220
|
+
- lib/livingstyleguide/filters/import_and_use.rb
|
207
221
|
- lib/livingstyleguide/filters/javascript.rb
|
222
|
+
- lib/livingstyleguide/filters/layout.rb
|
208
223
|
- lib/livingstyleguide/filters/markdown.rb
|
209
224
|
- lib/livingstyleguide/filters/options.rb
|
210
225
|
- lib/livingstyleguide/filters/require.rb
|