livingstyleguide 2.0.0.alpha.6 → 2.0.0.alpha.7

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: 99011854cea04c29122a5e4014eca155e1972da2
4
- data.tar.gz: 324abacc9ef03fa22b0fa570b8fee64f686c5312
3
+ metadata.gz: 438f69eb3ec2f4eb23b292b249efdb90c1717626
4
+ data.tar.gz: c756e5fde9db9cca59a375b44476f75f81ca71d3
5
5
  SHA512:
6
- metadata.gz: 201d20433e57bce205aa2fc8086678e49455b33c97fadacded15fc9538d8b2be1d24876c005bb671662cdb2918ad0bb0ee460ee7a06773c9e2bcba03e7312e67
7
- data.tar.gz: 4c8f285365e917fd882f173c03827a195dc66df295a9f5051264c4b0368ba6c679beda37212dc16c96b291054110fd39f568c8f04aa27dcce344737586c64832
6
+ metadata.gz: faf35f680b14f27dd18da04a9700a8bce0ff8fe3397a08f1c5cd38372b1c0a3630b4937e193b5a2eab9dfd8ca4fefd0c81728fd31e0155957438a64f814b8e92
7
+ data.tar.gz: eb1c5979afdcfd392e66bd0f220106d86911e66c2ea0e7d963b63a26434c005a84f37486682d9b752bbbe1ce86c412d7a15a6b7cc7d9e1dd962ae38221f7b177
@@ -8,10 +8,10 @@ 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
+ attr_accessor :syntax
12
12
  attr_reader :scope
13
13
 
14
- %w(scss head header footer).each do |attr|
14
+ %w(scss head header footer defaults).each do |attr|
15
15
  define_method attr do
16
16
  if options.has_key?(:livingstyleguide)
17
17
  options[:livingstyleguide].send(attr)
@@ -48,8 +48,9 @@ class LivingStyleGuide::Document < ::Tilt::Template
48
48
  if type == :plain
49
49
  without_highlights
50
50
  else
51
- without_highlights = ERB::Util.h(without_highlights) if type == :html
52
- ::MiniSyntax.highlight(without_highlights, type)
51
+ @syntax ||= type
52
+ without_highlights = ERB::Util.h(without_highlights) if @syntax == :html
53
+ ::MiniSyntax.highlight(without_highlights, @syntax || type)
53
54
  end
54
55
  end.gsub("\n", "<br>")
55
56
  end
@@ -95,7 +96,10 @@ class LivingStyleGuide::Document < ::Tilt::Template
95
96
  require "tilt/#{template_name}"
96
97
  rescue LoadError
97
98
  end
98
- engine.new{ remove_highlights(result) }.render(@scope, @locals.merge(locals))
99
+ template = engine.new{ remove_highlights(result) }
100
+ (@locals.is_a?(Array) ? @locals : [@locals]).map do |current_locals|
101
+ template.render(@scope || Object.new, current_locals.merge(locals))
102
+ end.join("\n")
99
103
  elsif @type == :escaped
100
104
  ERB::Util.h(remove_highlights(result))
101
105
  else
@@ -249,7 +253,7 @@ class LivingStyleGuide::Document < ::Tilt::Template
249
253
  sass_options[:load_paths] << path
250
254
  end
251
255
  end
252
- scss_template.new(file, sass_options){ scss }.render(@scope)
256
+ scss_template.new(file, sass_options){ scss }.render(@scope || Object.new)
253
257
  end
254
258
  end
255
259
 
@@ -3,9 +3,17 @@ require 'yaml'
3
3
 
4
4
  LivingStyleGuide.add_filter :data do |arguments, options, data|
5
5
  if options[:format] == "yaml"
6
- document.locals.merge! Psych.load("{#{data}}")
6
+ data = Psych.load(data)
7
7
  else
8
- document.locals.merge! JSON.parse("{#{data}}")
8
+ data = "{#{data}}" unless data.strip =~ /^[\[\{]/
9
+ data = JSON.parse(data)
10
+ end
11
+ if data.is_a?(Array)
12
+ document.locals = [] unless document.locals.is_a?(Array)
13
+ document.locals.push(*data)
14
+ else
15
+ document.locals = {} unless document.locals.is_a?(Hash)
16
+ document.locals.merge! data
9
17
  end
10
18
  nil
11
19
  end
@@ -0,0 +1,4 @@
1
+ LivingStyleGuide.add_filter :syntax do |arguments, options, block|
2
+ document.syntax = arguments.first.to_sym
3
+ nil
4
+ end
@@ -33,3 +33,4 @@ require 'livingstyleguide/filters/css'
33
33
  require 'livingstyleguide/filters/style'
34
34
  require 'livingstyleguide/filters/data'
35
35
  require 'livingstyleguide/filters/layout'
36
+ require 'livingstyleguide/filters/syntax'
@@ -1,3 +1,3 @@
1
1
  module LivingStyleGuide
2
- VERSION = '2.0.0.alpha.6'
2
+ VERSION = '2.0.0.alpha.7'
3
3
  end
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.6
4
+ version: 2.0.0.alpha.7
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-05-02 00:00:00.000000000 Z
11
+ date: 2015-05-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: minisyntax
@@ -224,6 +224,7 @@ files:
224
224
  - lib/livingstyleguide/filters/options.rb
225
225
  - lib/livingstyleguide/filters/require.rb
226
226
  - lib/livingstyleguide/filters/style.rb
227
+ - lib/livingstyleguide/filters/syntax.rb
227
228
  - lib/livingstyleguide/filters/type.rb
228
229
  - lib/livingstyleguide/integration.rb
229
230
  - lib/livingstyleguide/integration/compass.rb
@@ -265,7 +266,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
265
266
  version: 1.3.1
266
267
  requirements: []
267
268
  rubyforge_project:
268
- rubygems_version: 2.2.2
269
+ rubygems_version: 2.4.5
269
270
  signing_key:
270
271
  specification_version: 4
271
272
  summary: Generate beautiful front-end style guides