livingstyleguide 0.6.0.alpha.1 → 0.6.0.alpha.2

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: 9d11d94de9e3e3effd2978cf825fa788d8b1c580
4
- data.tar.gz: 1c229b285f7e026f7eec53f85c039d561740ee85
3
+ metadata.gz: c33ece860e06225991997ea016a1bb63296bcc80
4
+ data.tar.gz: 5ce8ad16bad308ed0b874b27e7e2dd8de467f55f
5
5
  SHA512:
6
- metadata.gz: 995f18281ce94a1eb31f3b711025cc104d3fa4faf8fb23e01443ca57f4069bbea6a63d755315413705e06a5d204dfcec8934791c126f3fe661db8577016fa473
7
- data.tar.gz: 95cd6a320e6055b2ef931c2d56f388fbb0f173b596fc57a59df264b3c0271f28b542c4b9bddbf66a6bd8bd6b71f29792c19254cbfaf52769aa055fe20df0dfda
6
+ metadata.gz: 473fcd6e4a359e8f3246113a8b5c832408b1dde659038d55444c4fdf82da4d3cd32fc1943dc02b03a92885683a2d75e19b5328f0bd873add7c0dbb22c0e7077f
7
+ data.tar.gz: de49cd6ffa45fd89f67d9e8c2f396237ba92f9091b352ee9eae3587e3e2ed57d86b7c6423385919f65d0311ee680ec4a9cd8d375974557865bfbe37f103d660e
data/CHANGELOG.md CHANGED
@@ -32,3 +32,8 @@
32
32
  * Removed globbing
33
33
  * Set .html.lsg as default file extension
34
34
 
35
+ ## 0.6.0.alpha.2
36
+
37
+ * Better support for load paths in Rails
38
+ * Fix for colors
39
+
@@ -3,12 +3,33 @@ require 'erb'
3
3
  module LivingStyleGuide::Renderer
4
4
 
5
5
  def render_living_style_guide
6
- @css = self.render
7
- template = File.read(File.join(File.dirname(__FILE__), '..', '..', 'templates', 'layouts', 'default.html.erb'))
8
- markdown = LivingStyleGuide.markdown || ""
9
- @html = LivingStyleGuide::RedcarpetTemplate.new{ markdown }.render
6
+ data = Class.new do
7
+ attr_accessor :css, :html, :title, :head, :header, :footer
8
+ include ERB::Util
9
+ def get_binding; binding end
10
+ end.new
11
+ data.css = self.render
12
+ markdown = LivingStyleGuide.markdown || ''
13
+ data.html = LivingStyleGuide::RedcarpetTemplate.new{ markdown }.render
14
+ data.title = @options[:living_style_guide][:title]
15
+
16
+ head = (@options[:living_style_guide][:javascript_before] || []).map do |src|
17
+ %Q(<script src="#{src}"></script>)
18
+ end
19
+ data.head = head.join("\n")
20
+
21
+ header = [@options[:living_style_guide][:header]]
22
+ data.header = header.join("\n")
23
+
24
+ footer = [@options[:living_style_guide][:footer]]
25
+ footer << (@options[:living_style_guide][:javascript_after] || []).map do |src|
26
+ %Q(<script src="#{src}"></script>)
27
+ end
28
+ data.footer = footer.join("\n")
29
+
10
30
  LivingStyleGuide.reset
11
- ERB.new(template).result(binding)
31
+ template = File.read(File.join(File.dirname(__FILE__), '..', '..', 'templates', 'layouts', 'default.html.erb'))
32
+ ERB.new(template).result(data.get_binding)
12
33
  end
13
34
 
14
35
  end
@@ -1,6 +1,7 @@
1
1
  require 'tilt'
2
2
  require 'erb'
3
3
  require 'compass'
4
+ require 'yaml'
4
5
 
5
6
  module ::Tilt
6
7
  class LivingStyleGuideTemplate < Template
@@ -10,26 +11,59 @@ module ::Tilt
10
11
  end
11
12
 
12
13
  def evaluate(scope, locals, &block)
13
- engine = ::Sass::Engine.new(data, sass_options)
14
- engine.render_living_style_guide
14
+ parse_options(data)
15
+ generate_sass
16
+ render_living_style_guide
15
17
  end
16
18
 
17
19
  private
18
20
  def sass_options
19
21
  options = Compass.configuration.to_sass_plugin_options
22
+ if defined?(Rails)
23
+ options[:load_paths] = options[:load_paths] | Rails.application.config.assets.paths
24
+ end
20
25
  options[:template_location].each do |path, short|
21
26
  options[:load_paths] << ::LivingStyleGuide::Importer.new(path)
22
27
  end
23
- options[:filename] = eval_file
24
- options[:line] = line
25
- options[:syntax] = detect_syntax
26
- options[:importer] = LivingStyleGuide::Importer.new('.')
28
+ options[:filename] = eval_file
29
+ options[:line] = line
30
+ options[:syntax] = @options[:syntax]
31
+ options[:importer] = LivingStyleGuide::Importer.new('.')
32
+ options[:living_style_guide] = @options
27
33
  options
28
34
  end
29
35
 
30
36
  private
31
- def detect_syntax
32
- data =~ %r(^//\s*@syntax\s*:\s*sass\s*$) ? :sass : :scss
37
+ def parse_options(data)
38
+ @options = YAML.load(data)
39
+ @options.keys.each do |key|
40
+ @options[key.gsub('-', '_').to_sym] = @options.delete(key)
41
+ end
42
+ @options[:syntax] = @options.has_key?(:styleguide_sass) ? :sass : :scss
43
+ end
44
+
45
+ private
46
+ def generate_sass
47
+ @sass = [
48
+ %Q(@import "#{@options[:source]}"),
49
+ style_variables,
50
+ %Q(@import "livingstyleguide"),
51
+ @options[:styleguide_sass] || @options[:styleguide_scss]
52
+ ].flatten.join(@options[:syntax] == :sass ? "\n" : ';')
53
+ end
54
+
55
+ private
56
+ def style_variables
57
+ return unless @options.has_key?(:style)
58
+ @options[:style].map do |key, value|
59
+ "$livingstyleguide--#{key}: #{value}"
60
+ end
61
+ end
62
+
63
+ private
64
+ def render_living_style_guide
65
+ engine = ::Sass::Engine.new(@sass, sass_options)
66
+ engine.render_living_style_guide
33
67
  end
34
68
  end
35
69
 
@@ -1,3 +1,3 @@
1
1
  module LivingStyleGuide
2
- VERSION = "0.6.0.alpha.1"
2
+ VERSION = "0.6.0.alpha.2"
3
3
  end
@@ -2,6 +2,7 @@
2
2
  .livingstyleguide--code-block,
3
3
  .livingstyleguide--unordered-list,
4
4
  .livingstyleguide--ordered-list {
5
+ color: $livingstyleguide--color;
5
6
  display: block;
6
7
  font-family: $livingstyleguide--base-font;
7
8
  font-size: $livingstyleguide--base-font-size;
@@ -24,6 +25,7 @@
24
25
  .livingstyleguide--headline,
25
26
  .livingstyleguide--sub-headline,
26
27
  .livingstyleguide--sub-sub-headline {
28
+ color: $livingstyleguide--color;
27
29
  display: block;
28
30
  font-family: $livingstyleguide--headline-font;
29
31
  font-size: $livingstyleguide--headline-font-size;
@@ -1,5 +1,4 @@
1
1
  .livingstyleguide {
2
2
  background: $livingstyleguide--background-color;
3
- color: $livingstyleguide--color;
4
3
  display: block;
5
4
  }
@@ -5,7 +5,7 @@
5
5
  <meta charset="utf-8">
6
6
  <meta content="IE=edge,chrome=1" http-equiv="X-UA-Compatible">
7
7
  <meta content="The LivingStyleGuide Gem – http://livingstyleguide.org" name="generator">
8
- <title>Living Style Guide</title>
8
+ <title><%= h(@title) %></title>
9
9
  <script>
10
10
  // see: http://www.hagenburger.net/BLOG/Simple-HTML5-Fix-for-IE.html
11
11
  for(var e,l='article aside footer header nav section time picture'.split(' ');e=l.pop();document.createElement(e));
@@ -13,10 +13,13 @@ for(var e,l='article aside footer header nav section time picture'.split(' ');e=
13
13
  <style>
14
14
  <%= @css %>
15
15
  </style>
16
+ <%= @head %>
16
17
  </head>
17
18
 
18
19
  <body class="livingstyleguide">
20
+ <%= @header %>
19
21
  <%= @html %>
22
+ <%= @footer %>
20
23
  </body>
21
24
 
22
25
  </html>
@@ -1,2 +1,5 @@
1
+ $my-base-color: green;
2
+
3
+ @import "compass";
1
4
  @import "modules/buttons";
2
5
 
@@ -0,0 +1,7 @@
1
+ source: "style.scss"
2
+ title: "My Nice & Beautiful Living Style Guide"
3
+ header: |
4
+ <h1>Super Style Guide</h1>
5
+ footer: |
6
+ <p>Made by me</p>
7
+
@@ -0,0 +1,8 @@
1
+ source: "style.scss"
2
+ title: "My Nice & Beautiful Living Style Guide"
3
+ javascript-before:
4
+ - modernizr.js
5
+ javascript-after:
6
+ - http://code.jquery.com/jquery-2.0.3.js
7
+ - application.js
8
+
@@ -0,0 +1,6 @@
1
+ source: "style.scss"
2
+ title: "My Nice & Beautiful Living Style Guide"
3
+ styleguide-sass: |
4
+ #test
5
+ color: green
6
+
@@ -0,0 +1,7 @@
1
+ source: "style.scss"
2
+ title: "My Nice & Beautiful Living Style Guide"
3
+ styleguide-scss: |
4
+ #test {
5
+ color: red;
6
+ }
7
+
@@ -0,0 +1,7 @@
1
+ source: "style.scss"
2
+ title: "My Nice & Beautiful Living Style Guide"
3
+ style:
4
+ color: red
5
+ border-radius: 3px
6
+ code-color: darken($my-base-color, 10%)
7
+
@@ -1,4 +1,3 @@
1
- @import "compass";
2
- @import "style";
3
- @import "livingstyleguide";
1
+ source: "style.scss"
2
+ title: "My Nice & Beautiful Living Style Guide"
4
3
 
@@ -4,9 +4,44 @@ require 'tilt'
4
4
  class MarkdownTest < Test::Unit::TestCase
5
5
 
6
6
  def test_standalone_project
7
- html = Tilt.new('test/fixtures/standalone/styleguide.html.lsg').render
7
+ html = render('test/fixtures/standalone/styleguide.html.lsg')
8
8
  assert_match %r(background: red), html
9
9
  assert_match %r(<button class="button">), html
10
+ assert_match %r(<title>My Nice &amp; Beautiful Living Style Guide</title>), html
11
+ end
12
+
13
+ def test_custom_styles
14
+ html = render('test/fixtures/standalone/styleguide-with-style.html.lsg')
15
+ assert_match %r(.livingstyleguide--ordered-list { color: red;), html
16
+ assert_match %r(border-radius: 3px), html
17
+ assert_match %r(em { color: green;), html
18
+ end
19
+
20
+ def test_javascript_includes
21
+ html = render('test/fixtures/standalone/styleguide-with-javascript.html.lsg')
22
+ assert_match %r(<script src="modernizr.js"></script>.*</head>), html
23
+ assert_match %r(<script src="http://code.jquery.com/jquery-2.0.3.js"></script> <script src="application.js"></script> </body>), html
24
+ end
25
+
26
+ def test_additional_scss_code
27
+ html = render('test/fixtures/standalone/styleguide-with-scss.html.lsg')
28
+ assert_match %r(#test { color: red; }), html
29
+ end
30
+
31
+ def test_additional_sass_code
32
+ html = render('test/fixtures/standalone/styleguide-with-sass.html.lsg')
33
+ assert_match %r(#test { color: green; }), html
34
+ end
35
+
36
+ def test_header_footer
37
+ html = render('test/fixtures/standalone/styleguide-with-header-footer.html.lsg')
38
+ assert_match %r(<h1>Super Style Guide</h1>), html
39
+ assert_match %r(<p>Made by me</p>), html
40
+ end
41
+
42
+ private
43
+ def render(file)
44
+ Tilt.new(file).render.gsub(/\s+/, ' ')
10
45
  end
11
46
 
12
47
  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: 0.6.0.alpha.1
4
+ version: 0.6.0.alpha.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nico Hagenburger
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-12-06 00:00:00.000000000 Z
11
+ date: 2014-01-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: minisyntax
@@ -190,6 +190,11 @@ files:
190
190
  - test/fixtures/standalone/modules/_buttons.md
191
191
  - test/fixtures/standalone/modules/_buttons.scss
192
192
  - test/fixtures/standalone/style.scss
193
+ - test/fixtures/standalone/styleguide-with-header-footer.html.lsg
194
+ - test/fixtures/standalone/styleguide-with-javascript.html.lsg
195
+ - test/fixtures/standalone/styleguide-with-sass.html.lsg
196
+ - test/fixtures/standalone/styleguide-with-scss.html.lsg
197
+ - test/fixtures/standalone/styleguide-with-style.html.lsg
193
198
  - test/fixtures/standalone/styleguide.html.lsg
194
199
  - test/fixtures/stylesheets/variables/_more-other-colors.sass
195
200
  - test/fixtures/stylesheets/variables/colors.scss
@@ -239,6 +244,11 @@ test_files:
239
244
  - test/fixtures/standalone/modules/_buttons.md
240
245
  - test/fixtures/standalone/modules/_buttons.scss
241
246
  - test/fixtures/standalone/style.scss
247
+ - test/fixtures/standalone/styleguide-with-header-footer.html.lsg
248
+ - test/fixtures/standalone/styleguide-with-javascript.html.lsg
249
+ - test/fixtures/standalone/styleguide-with-sass.html.lsg
250
+ - test/fixtures/standalone/styleguide-with-scss.html.lsg
251
+ - test/fixtures/standalone/styleguide-with-style.html.lsg
242
252
  - test/fixtures/standalone/styleguide.html.lsg
243
253
  - test/fixtures/stylesheets/variables/_more-other-colors.sass
244
254
  - test/fixtures/stylesheets/variables/colors.scss