style-guide 0.7.0 → 0.7.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,4 @@
1
+ require "tilt"
1
2
  require "nokogiri"
2
3
  require "github/markdown"
3
4
 
@@ -15,11 +16,11 @@ module StyleGuide
15
16
  end
16
17
 
17
18
  def title
18
- @title ||= File.basename(path, ".erb").titleize.strip
19
+ @title ||= File.basename(path, File.extname(path)).titleize.strip
19
20
  end
20
21
 
21
22
  def content
22
- @content ||= File.read(path)
23
+ rendered.gsub(/\</, "&lt;").gsub(/\>/, "&gt;").html_safe
23
24
  end
24
25
 
25
26
  def description
@@ -48,6 +49,10 @@ module StyleGuide
48
49
 
49
50
  private
50
51
 
52
+ def rendered
53
+ @rendered ||= Tilt.new(path).render
54
+ end
55
+
51
56
  def style_guide_scope
52
57
  [:style_guide, section.id.to_sym]
53
58
  end
@@ -59,7 +64,7 @@ module StyleGuide
59
64
  end
60
65
 
61
66
  def parsed
62
- @parsed ||= Nokogiri::HTML.parse(content)
67
+ @parsed ||= Nokogiri::HTML.parse(rendered)
63
68
  end
64
69
  end
65
70
  end
@@ -33,7 +33,7 @@ module StyleGuide
33
33
  private
34
34
 
35
35
  def partial_paths
36
- @partial_paths ||= Dir.glob(File.expand_path("_*.erb", path))
36
+ @partial_paths ||= Dir.glob(File.expand_path("_*", path))
37
37
  end
38
38
  end
39
39
  end
@@ -1,3 +1,3 @@
1
1
  module StyleGuide
2
- VERSION = "0.7.0"
2
+ VERSION = "0.7.2"
3
3
  end
@@ -46,7 +46,8 @@ describe StyleGuide::Partial do
46
46
  end
47
47
 
48
48
  describe "#content" do
49
- before { File.stub(:read => "reading is for chumps") }
49
+ let(:tilt) { double(:tilt, :render => "reading is for chumps") }
50
+ before { Tilt.stub(:new => tilt) }
50
51
 
51
52
  subject { partial.content }
52
53
 
@@ -87,8 +88,8 @@ describe StyleGuide::Partial do
87
88
 
88
89
  describe "#classes" do
89
90
  let(:content) { %(<div class="noseclip"><img class="earplug noseclip"></div>) }
90
-
91
- before { File.stub(:read => content) }
91
+ let(:tilt) { double(:tilt, :render => content) }
92
+ before { Tilt.stub(:new => tilt) }
92
93
 
93
94
  subject { partial.classes }
94
95
 
@@ -97,8 +98,8 @@ describe StyleGuide::Partial do
97
98
 
98
99
  describe "#ids" do
99
100
  let(:content) { %(<div id="stent"><img id="cholesterol"></div>) }
100
-
101
- before { File.stub(:read => content) }
101
+ let(:tilt) { double(:tilt, :render => content) }
102
+ before { Tilt.stub(:new => tilt) }
102
103
 
103
104
  subject { partial.ids }
104
105
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: style-guide
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.0
4
+ version: 0.7.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: