livingstyleguide 0.5.2 → 0.6.0.alpha.0

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: 872caa9b33cafee4074b86d935c6028e28295ac9
4
- data.tar.gz: 3725fe734f6275c4965fb0fbcdd7044eaa2bd3e7
3
+ metadata.gz: 7ce8037b3c84517db3602995b10c72e30b3c3ca6
4
+ data.tar.gz: b7acd8ff3d54088613ed7274af01da497835256b
5
5
  SHA512:
6
- metadata.gz: 9bf32b2f6e03ac8f9b114bad6247b4f351aa6286ee87b1efe4fdf145abe3c37b27792dd34c414ec27b0bf9b1b39bc52394c448fac87f0d788a5b831fc6d73f29
7
- data.tar.gz: 6094aa84c7ea6ac883106c06721e4a8159c569ec95df5e557e995fcc4360ccfebc800cb258d8f231e3f811dca4abac6c60b596c2b1b340b070ccd2cb7f3fc207
6
+ metadata.gz: 18e3233b83e7645a1170de1bd28e824b2d96a0028b3ca2afc4fe32ead5527d8ccca0be533eafaa07e7362a174f091d0fbacecc54f11c874d2dae6ced6bf2cf07
7
+ data.tar.gz: 6831b4ff910cd4076116c03145fd305244aecc5375199f2b1556ebac641c3f5db95c2365762d2a6ae8816f33afbf382709c5d103a8e1b59d95dd2952cf6a257a
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib', 'livingstyleguide'))
4
+ require File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib', 'livingstyleguide', 'command_line_interface'))
5
+
6
+ LivingStyleGuide::CommandLineInterface.start(ARGV)
7
+
@@ -1,10 +1,27 @@
1
1
  require 'livingstyleguide/version'
2
+ require 'compass'
2
3
  require 'livingstyleguide/sass_extensions'
3
4
  require 'livingstyleguide/variables_importer'
5
+ require 'livingstyleguide/importer'
6
+ require 'livingstyleguide/renderer'
4
7
  require 'livingstyleguide/markdown_extensions'
5
- require 'sass/plugin'
8
+ require 'livingstyleguide/tilt_template'
6
9
 
7
10
  module LivingStyleGuide
11
+ @@markdown = nil
12
+
13
+ def self.reset
14
+ @@markdown = nil
15
+ end
16
+
17
+ def self.add_markdown(markdown)
18
+ (@@markdown ||= '') << markdown
19
+ end
20
+
21
+ def self.markdown
22
+ @@markdown
23
+ end
24
+
8
25
  end
9
26
 
10
27
  Compass.configuration.add_import_path LivingStyleGuide::VariablesImporter.new
@@ -12,3 +29,13 @@ Compass.configuration.add_import_path LivingStyleGuide::VariablesImporter.new
12
29
  base_directory = File.join(File.dirname(__FILE__), '..')
13
30
  Compass::Frameworks.register 'livingstyleguide', :path => base_directory
14
31
 
32
+ class Sass::Engine
33
+ include LivingStyleGuide::Renderer
34
+ end
35
+
36
+ class String
37
+ def blank?
38
+ self.nil? || self.empty?
39
+ end
40
+ end
41
+
@@ -0,0 +1,21 @@
1
+ require 'rubygems'
2
+ require 'bundler/setup'
3
+ require 'thor'
4
+ require 'tilt'
5
+
6
+ module LivingStyleGuide
7
+ class CommandLineInterface < Thor
8
+
9
+ desc 'compile filename', 'Compiles the living style guide to HTML.'
10
+ def compile(file)
11
+ Compass.add_project_configuration
12
+ html = Tilt.new(file).render
13
+ output_file = file.sub(/\.s[ac]ss\.lsg$/, '')
14
+ output_file.sub! /^#{Compass.configuration.sass_dir}/, Compass.configuration.css_dir
15
+ File.write output_file, html
16
+ puts "Successfully generated a living style guide at #{output_file}."
17
+ end
18
+
19
+ end
20
+ end
21
+
@@ -0,0 +1,18 @@
1
+ require 'sass-globbing'
2
+
3
+ class LivingStyleGuide::Importer < Sass::Globbing::Importer
4
+ def find_relative(name, base, options, absolute = false)
5
+ if name =~ /^(.+)\.s[ac]ss$|^(\*|[a-z0-9_\/-])+$/
6
+ path = File.expand_path(File.dirname(base))
7
+ file = "#{path}/#{name.sub(/\..+$/, '')}.md"
8
+ file.sub!(/(.*)\//, '\\1/_') unless file =~ /\/_/
9
+
10
+ if File.exist? file
11
+ LivingStyleGuide.add_markdown File.read(file)
12
+ end
13
+
14
+ super(name, base, options, absolute)
15
+ end
16
+ end
17
+ end
18
+
@@ -26,24 +26,12 @@ module LivingStyleGuide
26
26
 
27
27
  def evaluate(context, locals, &block)
28
28
  @context ||= context
29
-
30
- if @engine.renderer.respond_to? :middleman_app=
31
- @engine.renderer.middleman_app = @context
32
- end
33
29
  super
34
30
  end
31
+
35
32
  end
36
33
 
37
34
  class RedcarpetHTML < ::Redcarpet::Render::HTML
38
- attr_accessor :middleman_app
39
-
40
- def image(link, title, alt_text)
41
- middleman_app.image_tag(link, :title => title, :alt => alt_text)
42
- end
43
-
44
- def link(link, title, content)
45
- middleman_app.link_to(content, link, :title => title)
46
- end
47
35
 
48
36
  def header(text, header_level)
49
37
  id = %Q( id="#{::ActiveSupport::Inflector.parameterize(text, '-')}")
@@ -0,0 +1,15 @@
1
+ require 'erb'
2
+
3
+ module LivingStyleGuide::Renderer
4
+
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
10
+ LivingStyleGuide.reset
11
+ ERB.new(template).result(binding)
12
+ end
13
+
14
+ end
15
+
@@ -0,0 +1,35 @@
1
+ require 'tilt'
2
+ require 'erb'
3
+ require 'compass'
4
+
5
+ module ::Tilt
6
+ class LivingStyleGuideTemplate < Template
7
+ self.default_mime_type = 'text/html'
8
+
9
+ def prepare
10
+ end
11
+
12
+ def evaluate(scope, locals, &block)
13
+ engine = ::Sass::Engine.new(data, sass_options)
14
+ @output ||= engine.render_living_style_guide
15
+ end
16
+
17
+ private
18
+ def sass_options
19
+ options = Compass.configuration.to_sass_plugin_options
20
+ options[:template_location].each do |path, short|
21
+ options[:load_paths] << path
22
+ end
23
+ options[:filename] = eval_file
24
+ options[:line] = line
25
+ options[:syntax] = @file =~ /\.sass/ ? :sass : :scss
26
+ options[:importer] = LivingStyleGuide::Importer.instance
27
+ options
28
+ end
29
+ end
30
+
31
+ %w(sass.lsg scss.lsg).each do |ext|
32
+ register ext, LivingStyleGuideTemplate
33
+ end
34
+ end
35
+
@@ -20,6 +20,9 @@ module LivingStyleGuide
20
20
  nil
21
21
  end
22
22
 
23
+ def root
24
+ end
25
+
23
26
  def find_relative(uri, base, options)
24
27
  nil
25
28
  end
@@ -1,3 +1,3 @@
1
1
  module LivingStyleGuide
2
- VERSION = "0.5.2"
2
+ VERSION = "0.6.0.alpha.0"
3
3
  end
@@ -18,10 +18,13 @@ Gem::Specification.new do |gem|
18
18
  gem.require_paths = ["lib"]
19
19
 
20
20
  gem.add_dependency 'minisyntax'
21
- gem.add_dependency 'middleman', '~> 3'
22
21
  gem.add_dependency 'compass'
23
22
  gem.add_dependency 'sass'
23
+ gem.add_dependency 'sass-globbing'
24
24
  gem.add_dependency 'redcarpet'
25
+ gem.add_dependency 'tilt'
26
+ gem.add_dependency 'activesupport'
27
+ gem.add_dependency 'thor'
25
28
 
26
29
  gem.add_development_dependency 'rake'
27
30
  gem.add_development_dependency 'haml'
@@ -0,0 +1,23 @@
1
+ <!doctype html>
2
+ <html>
3
+
4
+ <head>
5
+ <meta charset="utf-8">
6
+ <meta content="IE=edge,chrome=1" http-equiv="X-UA-Compatible">
7
+ <meta content="The LivingStyleGuide Gem – http://livingstyleguide.org" name="generator">
8
+ <title>Living Style Guide</title>
9
+ <script>
10
+ // see: http://www.hagenburger.net/BLOG/Simple-HTML5-Fix-for-IE.html
11
+ for(var e,l='article aside footer header nav section time picture'.split(' ');e=l.pop();document.createElement(e));
12
+ </script>
13
+ <style>
14
+ <%= @css %>
15
+ </style>
16
+ </head>
17
+
18
+ <body class="livingstyleguide">
19
+ <%= @html %>
20
+ </body>
21
+
22
+ </html>
23
+
File without changes
@@ -0,0 +1,6 @@
1
+ # Buttons
2
+
3
+ ~~~ example
4
+ <button class="button">A button</button>
5
+ ~~~
6
+
@@ -0,0 +1,4 @@
1
+ .button {
2
+ background: red;
3
+ }
4
+
@@ -0,0 +1 @@
1
+ @import "modules/**";
@@ -0,0 +1,2 @@
1
+ @import "style";
2
+
@@ -38,7 +38,7 @@ class MarkdownTest < Test::Unit::TestCase
38
38
  <div class="livingstyleguide--example">
39
39
  <button class="button">Test</button>
40
40
  </div>
41
- <pre class="livingstyleguide--code-block"><code class="livingstyleguide--code"><em>%button</em>.button Test</code></pre>
41
+ <pre class="livingstyleguide--code-block"><code class="livingstyleguide--code"><em>%button</em><b>.button</b> Test</code></pre>
42
42
  HTML
43
43
  end
44
44
 
@@ -0,0 +1,13 @@
1
+ require 'test_helper'
2
+ require 'tilt'
3
+
4
+ class MarkdownTest < Test::Unit::TestCase
5
+
6
+ def test_standalone_project
7
+ html = Tilt.new('test/fixtures/standalone/styleguide.html.scss.lsg').render
8
+ assert_match %r(background: red), html
9
+ assert_match %r(<button class="button">), html
10
+ end
11
+
12
+ end
13
+
data/test/test_helper.rb CHANGED
@@ -3,3 +3,18 @@ require 'livingstyleguide'
3
3
  require 'test/unit'
4
4
 
5
5
  Compass.configuration.add_import_path File.join(%w(test fixtures stylesheets))
6
+
7
+ def parse_file(filename)
8
+ filename = File.join(File.dirname(__FILE__), 'fixtures', filename.split('/'))
9
+ syntax = filename[-4..-1].to_sym
10
+ syntax = :scss unless [:scss, :sass].include?(syntax)
11
+ options = {
12
+ :filename => filename,
13
+ :load_paths => [File.dirname(filename), LivingStyleGuide::Importer.instance],
14
+ :syntax => syntax,
15
+ :cache => false,
16
+ :read_cache => false
17
+ }
18
+ Sass::Engine.new(File.read(filename), options)
19
+ end
20
+
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.5.2
4
+ version: 0.6.0.alpha.0
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-11-04 00:00:00.000000000 Z
11
+ date: 2013-11-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: minisyntax
@@ -25,21 +25,21 @@ dependencies:
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
27
  - !ruby/object:Gem::Dependency
28
- name: middleman
28
+ name: compass
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ~>
31
+ - - '>='
32
32
  - !ruby/object:Gem::Version
33
- version: '3'
33
+ version: '0'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ~>
38
+ - - '>='
39
39
  - !ruby/object:Gem::Version
40
- version: '3'
40
+ version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
- name: compass
42
+ name: sass
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - '>='
@@ -53,7 +53,7 @@ dependencies:
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
55
  - !ruby/object:Gem::Dependency
56
- name: sass
56
+ name: sass-globbing
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
59
  - - '>='
@@ -80,6 +80,48 @@ dependencies:
80
80
  - - '>='
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: tilt
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - '>='
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - '>='
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: activesupport
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - '>='
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :runtime
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - '>='
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: thor
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - '>='
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :runtime
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - '>='
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
83
125
  - !ruby/object:Gem::Dependency
84
126
  name: rake
85
127
  requirement: !ruby/object:Gem::Requirement
@@ -111,7 +153,8 @@ dependencies:
111
153
  description: Living Style Guide
112
154
  email:
113
155
  - nico@hagenburger.net
114
- executables: []
156
+ executables:
157
+ - livingstyleguide
115
158
  extensions: []
116
159
  extra_rdoc_files: []
117
160
  files:
@@ -123,10 +166,15 @@ files:
123
166
  - README.md
124
167
  - Rakefile
125
168
  - assets/javascripts/livingstyleguide.js
169
+ - bin/livingstyleguide
126
170
  - lib/livingstyleguide.rb
171
+ - lib/livingstyleguide/command_line_interface.rb
172
+ - lib/livingstyleguide/importer.rb
127
173
  - lib/livingstyleguide/markdown_extensions.rb
174
+ - lib/livingstyleguide/renderer.rb
128
175
  - lib/livingstyleguide/sass_extensions.rb
129
176
  - lib/livingstyleguide/sass_extensions/functions.rb
177
+ - lib/livingstyleguide/tilt_template.rb
130
178
  - lib/livingstyleguide/variables_importer.rb
131
179
  - lib/livingstyleguide/variables_importer/content.erb
132
180
  - lib/livingstyleguide/version.rb
@@ -136,6 +184,7 @@ files:
136
184
  - stylesheets/livingstyleguide/_color-swatches.scss
137
185
  - stylesheets/livingstyleguide/_content.scss
138
186
  - stylesheets/livingstyleguide/_layout.scss
187
+ - templates/layouts/default.html.erb
139
188
  - test/fixtures/markdown/code-with-highlight-block.md
140
189
  - test/fixtures/markdown/code-with-highlight.md
141
190
  - test/fixtures/markdown/code.md
@@ -148,10 +197,16 @@ files:
148
197
  - test/fixtures/markdown/layout-example.md
149
198
  - test/fixtures/markdown/text.md
150
199
  - test/fixtures/markdown/variables.md
200
+ - test/fixtures/standalone/config.rb
201
+ - test/fixtures/standalone/modules/_buttons.md
202
+ - test/fixtures/standalone/modules/_buttons.scss
203
+ - test/fixtures/standalone/style.scss
204
+ - test/fixtures/standalone/styleguide.html.scss.lsg
151
205
  - test/fixtures/stylesheets/variables/_more-other-colors.sass
152
206
  - test/fixtures/stylesheets/variables/colors.scss
153
207
  - test/fixtures/stylesheets/variables/other-colors.sass
154
208
  - test/integration/markdown_test.rb
209
+ - test/integration/standalone_test.rb
155
210
  - test/integration/variables_test.rb
156
211
  - test/test_helper.rb
157
212
  - test/unit/sass_extensions_test.rb
@@ -169,9 +224,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
169
224
  version: '0'
170
225
  required_rubygems_version: !ruby/object:Gem::Requirement
171
226
  requirements:
172
- - - '>='
227
+ - - '>'
173
228
  - !ruby/object:Gem::Version
174
- version: '0'
229
+ version: 1.3.1
175
230
  requirements: []
176
231
  rubyforge_project:
177
232
  rubygems_version: 2.0.6
@@ -191,10 +246,16 @@ test_files:
191
246
  - test/fixtures/markdown/layout-example.md
192
247
  - test/fixtures/markdown/text.md
193
248
  - test/fixtures/markdown/variables.md
249
+ - test/fixtures/standalone/config.rb
250
+ - test/fixtures/standalone/modules/_buttons.md
251
+ - test/fixtures/standalone/modules/_buttons.scss
252
+ - test/fixtures/standalone/style.scss
253
+ - test/fixtures/standalone/styleguide.html.scss.lsg
194
254
  - test/fixtures/stylesheets/variables/_more-other-colors.sass
195
255
  - test/fixtures/stylesheets/variables/colors.scss
196
256
  - test/fixtures/stylesheets/variables/other-colors.sass
197
257
  - test/integration/markdown_test.rb
258
+ - test/integration/standalone_test.rb
198
259
  - test/integration/variables_test.rb
199
260
  - test/test_helper.rb
200
261
  - test/unit/sass_extensions_test.rb