glorify 0.4.0 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 4bf0a54bba1e47a0081dd95144f656d566221c9e
4
+ data.tar.gz: 9e0dbbc0c880d892984c0e06f16a4801fef815fd
5
+ SHA512:
6
+ metadata.gz: 834a04db94613c71fc15cf7867983c98ca06cdca451b7fc6e2431303ea7bd44baefc14b27cb904840c285c120d45c643933a310cac50a313c432804ec34bca5c
7
+ data.tar.gz: 36b0e8d07c4d7dac87dae67e6e49e3930ea7aacc92a1b02bedab4191c128ccb6da14b2995440672f531c1da496878265d3a133753a9c93c2accd803e5bc74179
@@ -61,8 +61,8 @@ module Sinatra
61
61
  #
62
62
  # For modular applications you must add <code>register
63
63
  # Sinatra::Helpers</code> to your application.
64
- def glorify text
65
- Glorify::Renderer.render(text.force_encoding('UTF-8'))
64
+ def glorify text, options = {}
65
+ Glorify::Renderer.new(options).parse(text.force_encoding('UTF-8'))
66
66
  end
67
67
  end
68
68
  end
@@ -20,12 +20,12 @@ module Sinatra
20
20
  # end
21
21
  class Template < Tilt::Template
22
22
  def prepare # :nodoc:
23
- @engine = Glorify::Renderer
23
+ @engine = Glorify::Renderer.new(options)
24
24
  @output = nil
25
25
  end
26
26
 
27
27
  def evaluate(scope, locals, &block) # :nodoc:
28
- @output ||= @engine.render(data.force_encoding('UTF-8'))
28
+ @output ||= @engine.parse(data.force_encoding('UTF-8'))
29
29
  end
30
30
  end
31
31
  end
@@ -1,6 +1,6 @@
1
1
  module Sinatra
2
2
  module Glorify
3
3
  # Current version of Sinatra::Glorify
4
- VERSION = "0.4.0"
4
+ VERSION = "0.5.0"
5
5
  end
6
6
  end
@@ -0,0 +1 @@
1
+ <%= glorify(@some_code, :pipe => true) %>
@@ -0,0 +1 @@
1
+ <%= glorify(@some_code, :toc => true) %>
@@ -1 +1 @@
1
- <%= glorify(@some_code) %>
1
+ <%= glorify(@some_code, :pipe => true) %>
@@ -4,10 +4,9 @@ describe Sinatra::Glorify do
4
4
 
5
5
  it "should parse a header" do
6
6
  mock_app do
7
- Tilt.prefer Sinatra::Glorify::Template
8
7
  get('/') { markdown :header }
9
8
  end
10
- expected = "<h1 id=\"label-a+sip+of+glory\">a sip of glory<span><a href=\"#label-a+sip+of+glory\">&para;</a> <a href=\"#documentation\">&uarr;</a></span></h1>"
9
+ expected = '<h1 id="label-a+sip+of+glory">a sip of glory<span><a href="#label-a+sip+of+glory">&para;</a> <a href="#documentation">&uarr;</a></span></h1>'
11
10
  get('/')
12
11
  assert ok?
13
12
  assert_equal expected, body
@@ -15,10 +14,9 @@ describe Sinatra::Glorify do
15
14
 
16
15
  it "should parse code blocks" do
17
16
  mock_app do
18
- Tilt.prefer Sinatra::Glorify::Template
19
17
  get('/') { markdown :blocks }
20
18
  end
21
- expected = "<pre class=\"highlight text\">&quot;Hello, world!&quot;</pre>"
19
+ expected = '<pre class="highlight text">&quot;Hello, world!&quot;</pre>'
22
20
  get('/')
23
21
  assert ok?
24
22
  assert_equal expected, body
@@ -27,7 +25,6 @@ describe Sinatra::Glorify do
27
25
  it "should parse ruby blocks" do
28
26
  mock_app do
29
27
  get('/') do
30
- Tilt.prefer Sinatra::Glorify::Template
31
28
  markdown :ruby_blocks
32
29
  end
33
30
  end
@@ -51,6 +48,36 @@ describe Sinatra::Glorify do
51
48
  refute_empty Nokogiri::HTML(body).search("pre.highlight")
52
49
  end
53
50
 
51
+ it "should use helper with pipe" do
52
+ mock_app do
53
+ get('/') do
54
+ @some_code = File.open(
55
+ File.expand_path('../glorify/header.md', __FILE__),
56
+ "rb"
57
+ ).read
58
+ erb :helper_with_pipe
59
+ end
60
+ end
61
+ get('/')
62
+ assert ok?
63
+ assert_equal '<h1 id="label-a+sip+of+glory">a sip of glory</h1>', body
64
+ end
65
+
66
+ it "should use helper with toc" do
67
+ mock_app do
68
+ get('/') do
69
+ @some_code = File.open(
70
+ File.expand_path('../glorify/header.md', __FILE__),
71
+ "rb"
72
+ ).read
73
+ erb :helper_with_toc
74
+ end
75
+ end
76
+ get('/')
77
+ assert ok?
78
+ assert_equal "<li><a href='#label-a+sip+of+glory'>a sip of glory</a></li>", body
79
+ end
80
+
54
81
  it "should include a valid css helper for pygments" do
55
82
  mock_app
56
83
  get('/pygments.css')
@@ -59,4 +86,22 @@ describe Sinatra::Glorify do
59
86
  assert_match /text\/css/, content_type
60
87
  assert_empty validate_css(body).errors
61
88
  end
89
+
90
+ it "should render template with pipe" do
91
+ mock_app do
92
+ get('/') { markdown :header, :pipe => true }
93
+ end
94
+ get('/')
95
+ assert ok?
96
+ assert_equal '<h1 id="label-a+sip+of+glory">a sip of glory</h1>', body
97
+ end
98
+
99
+ it "should render template with toc" do
100
+ mock_app do
101
+ get('/') { markdown :header, :toc => true }
102
+ end
103
+ get('/')
104
+ assert ok?
105
+ assert_equal "<li><a href='#label-a+sip+of+glory'>a sip of glory</a></li>", body
106
+ end
62
107
  end
@@ -19,7 +19,10 @@ class MiniTest::Spec
19
19
  include W3CValidators
20
20
 
21
21
  def mock_app(base=Sinatra::Base, &block)
22
- @app = Sinatra.new(base, &block)
22
+ @app = Sinatra.new(base) do
23
+ Tilt.prefer Sinatra::Glorify::Template
24
+ class_eval &block if block_given?
25
+ end
23
26
  end
24
27
 
25
28
  def app
metadata CHANGED
@@ -1,8 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: glorify
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
5
- prerelease:
4
+ version: 0.5.0
6
5
  platform: ruby
7
6
  authors:
8
7
  - Zachary Scott
@@ -11,124 +10,109 @@ authors:
11
10
  autorequire:
12
11
  bindir: bin
13
12
  cert_chain: []
14
- date: 2013-03-20 00:00:00.000000000 Z
13
+ date: 2013-03-23 00:00:00.000000000 Z
15
14
  dependencies:
16
15
  - !ruby/object:Gem::Dependency
17
16
  name: sinatra
18
17
  requirement: !ruby/object:Gem::Requirement
19
- none: false
20
18
  requirements:
21
- - - ! '>='
19
+ - - '>='
22
20
  - !ruby/object:Gem::Version
23
21
  version: '0'
24
22
  type: :runtime
25
23
  prerelease: false
26
24
  version_requirements: !ruby/object:Gem::Requirement
27
- none: false
28
25
  requirements:
29
- - - ! '>='
26
+ - - '>='
30
27
  - !ruby/object:Gem::Version
31
28
  version: '0'
32
29
  - !ruby/object:Gem::Dependency
33
30
  name: rdoc-rouge
34
31
  requirement: !ruby/object:Gem::Requirement
35
- none: false
36
32
  requirements:
37
- - - ! '>='
33
+ - - '>='
38
34
  - !ruby/object:Gem::Version
39
35
  version: '0'
40
36
  type: :runtime
41
37
  prerelease: false
42
38
  version_requirements: !ruby/object:Gem::Requirement
43
- none: false
44
39
  requirements:
45
- - - ! '>='
40
+ - - '>='
46
41
  - !ruby/object:Gem::Version
47
42
  version: '0'
48
43
  - !ruby/object:Gem::Dependency
49
44
  name: nokogiri
50
45
  requirement: !ruby/object:Gem::Requirement
51
- none: false
52
46
  requirements:
53
- - - ! '>='
47
+ - - '>='
54
48
  - !ruby/object:Gem::Version
55
49
  version: '0'
56
50
  type: :runtime
57
51
  prerelease: false
58
52
  version_requirements: !ruby/object:Gem::Requirement
59
- none: false
60
53
  requirements:
61
- - - ! '>='
54
+ - - '>='
62
55
  - !ruby/object:Gem::Version
63
56
  version: '0'
64
57
  - !ruby/object:Gem::Dependency
65
58
  name: minitest
66
59
  requirement: !ruby/object:Gem::Requirement
67
- none: false
68
60
  requirements:
69
- - - ! '>='
61
+ - - '>='
70
62
  - !ruby/object:Gem::Version
71
63
  version: '0'
72
64
  type: :development
73
65
  prerelease: false
74
66
  version_requirements: !ruby/object:Gem::Requirement
75
- none: false
76
67
  requirements:
77
- - - ! '>='
68
+ - - '>='
78
69
  - !ruby/object:Gem::Version
79
70
  version: '0'
80
71
  - !ruby/object:Gem::Dependency
81
72
  name: rack-test
82
73
  requirement: !ruby/object:Gem::Requirement
83
- none: false
84
74
  requirements:
85
- - - ! '>='
75
+ - - '>='
86
76
  - !ruby/object:Gem::Version
87
77
  version: '0'
88
78
  type: :development
89
79
  prerelease: false
90
80
  version_requirements: !ruby/object:Gem::Requirement
91
- none: false
92
81
  requirements:
93
- - - ! '>='
82
+ - - '>='
94
83
  - !ruby/object:Gem::Version
95
84
  version: '0'
96
85
  - !ruby/object:Gem::Dependency
97
86
  name: rake
98
87
  requirement: !ruby/object:Gem::Requirement
99
- none: false
100
88
  requirements:
101
- - - ! '>='
89
+ - - '>='
102
90
  - !ruby/object:Gem::Version
103
91
  version: '0'
104
92
  type: :development
105
93
  prerelease: false
106
94
  version_requirements: !ruby/object:Gem::Requirement
107
- none: false
108
95
  requirements:
109
- - - ! '>='
96
+ - - '>='
110
97
  - !ruby/object:Gem::Version
111
98
  version: '0'
112
99
  - !ruby/object:Gem::Dependency
113
100
  name: w3c_validators
114
101
  requirement: !ruby/object:Gem::Requirement
115
- none: false
116
102
  requirements:
117
- - - ! '>='
103
+ - - '>='
118
104
  - !ruby/object:Gem::Version
119
105
  version: '0'
120
106
  type: :development
121
107
  prerelease: false
122
108
  version_requirements: !ruby/object:Gem::Requirement
123
- none: false
124
109
  requirements:
125
- - - ! '>='
110
+ - - '>='
126
111
  - !ruby/object:Gem::Version
127
112
  version: '0'
128
113
  - !ruby/object:Gem::Dependency
129
114
  name: rdoc
130
115
  requirement: !ruby/object:Gem::Requirement
131
- none: false
132
116
  requirements:
133
117
  - - '='
134
118
  - !ruby/object:Gem::Version
@@ -136,7 +120,6 @@ dependencies:
136
120
  type: :development
137
121
  prerelease: false
138
122
  version_requirements: !ruby/object:Gem::Requirement
139
- none: false
140
123
  requirements:
141
124
  - - '='
142
125
  - !ruby/object:Gem::Version
@@ -164,6 +147,8 @@ files:
164
147
  - lib/glorify/version.rb
165
148
  - spec/glorify/blocks.md
166
149
  - spec/glorify/header.md
150
+ - spec/glorify/helper_with_pipe.erb
151
+ - spec/glorify/helper_with_toc.erb
167
152
  - spec/glorify/ruby_blocks.md
168
153
  - spec/glorify/some_code.md
169
154
  - spec/glorify/with_helper.erb
@@ -171,32 +156,25 @@ files:
171
156
  - spec/spec_helper.rb
172
157
  homepage: http://zacharyscott.net/glorify/
173
158
  licenses: []
159
+ metadata: {}
174
160
  post_install_message:
175
161
  rdoc_options: []
176
162
  require_paths:
177
163
  - lib
178
164
  required_ruby_version: !ruby/object:Gem::Requirement
179
- none: false
180
165
  requirements:
181
- - - ! '>='
166
+ - - '>='
182
167
  - !ruby/object:Gem::Version
183
168
  version: '0'
184
- segments:
185
- - 0
186
- hash: 1006836911274585602
187
169
  required_rubygems_version: !ruby/object:Gem::Requirement
188
- none: false
189
170
  requirements:
190
- - - ! '>='
171
+ - - '>='
191
172
  - !ruby/object:Gem::Version
192
173
  version: '0'
193
- segments:
194
- - 0
195
- hash: 1006836911274585602
196
174
  requirements: []
197
175
  rubyforge_project:
198
- rubygems_version: 1.8.23
176
+ rubygems_version: 2.0.2
199
177
  signing_key:
200
- specification_version: 3
178
+ specification_version: 4
201
179
  summary: Sinatra helper to parse markdown with syntax highlighting like the pros
202
180
  test_files: []