fira 0.5.2 → 0.5.3
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/fira/engine.rb +2 -2
- data/lib/fira/version.rb +1 -1
- data/spec/fira_spec.rb +58 -0
- data/spec/spec_helper.rb +183 -0
- metadata +7 -3
data/lib/fira/engine.rb
CHANGED
@@ -8,7 +8,7 @@ module Fira
|
|
8
8
|
ID_REGEX = / #([^0-9][a-z_A-Z0-9_\-]+)/
|
9
9
|
CLASS_REGEX = / \.([^0-9][a-z_A-Z0-9_\-]+)/
|
10
10
|
QUOTE_REGEX = /\S+=["']?(?:.(?!["']?\s+(?:\S+)=|[>"']))+.["']?/
|
11
|
-
TAG_OPEN_REGEX = /<[
|
11
|
+
TAG_OPEN_REGEX = /<[^\/%!]\w* /
|
12
12
|
TAG_END_REGEX = /([\/]?>)/
|
13
13
|
|
14
14
|
def parse_text(text)
|
@@ -75,7 +75,7 @@ module Fira
|
|
75
75
|
|
76
76
|
def is_opening_tag?(text)
|
77
77
|
val = text =~ TAG_OPEN_REGEX
|
78
|
-
val ?
|
78
|
+
val.nil? || val > 0 ? false : true
|
79
79
|
end
|
80
80
|
|
81
81
|
|
data/lib/fira/version.rb
CHANGED
data/spec/fira_spec.rb
ADDED
@@ -0,0 +1,58 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Fira do
|
4
|
+
context 'HTML' do
|
5
|
+
|
6
|
+
it 'simple' do
|
7
|
+
result = Fira.render simple
|
8
|
+
result.should == res_simple
|
9
|
+
end
|
10
|
+
|
11
|
+
it 'multi line' do
|
12
|
+
result = Fira.render multi_line
|
13
|
+
result.should == res_multi_line
|
14
|
+
end
|
15
|
+
|
16
|
+
it 'nested single line' do
|
17
|
+
result = Fira.render nested_single_line
|
18
|
+
result.should == res_nested_single_line
|
19
|
+
end
|
20
|
+
|
21
|
+
it 'nested multi line' do
|
22
|
+
result = Fira.render nested_multi_line
|
23
|
+
result.should == res_nested_multi_line
|
24
|
+
end
|
25
|
+
|
26
|
+
it 'two classes' do
|
27
|
+
result = Fira.render two_classes
|
28
|
+
result.should == res_two_classes
|
29
|
+
end
|
30
|
+
|
31
|
+
it 'inside text' do
|
32
|
+
result = Fira.render inside_text
|
33
|
+
result.should == res_inside_text
|
34
|
+
end
|
35
|
+
|
36
|
+
it 'inside quotes' do
|
37
|
+
result = Fira.render inside_quotes
|
38
|
+
result.should == res_inside_quotes
|
39
|
+
end
|
40
|
+
|
41
|
+
it 'comments' do
|
42
|
+
result = Fira.render html_comments
|
43
|
+
result.should == res_html_comments
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
context 'ERB' do
|
48
|
+
it 'simple erb' do
|
49
|
+
result = Fira.render erb
|
50
|
+
result.should == res_erb
|
51
|
+
end
|
52
|
+
|
53
|
+
it 'erb in-tag' do
|
54
|
+
result = Fira.render erb_in_tag
|
55
|
+
result.should == res_erb_in_tag
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,183 @@
|
|
1
|
+
require 'rspec'
|
2
|
+
require 'fira'
|
3
|
+
|
4
|
+
RSpec.configure do |config|
|
5
|
+
config.color_enabled = true
|
6
|
+
config.formatter = 'documentation'
|
7
|
+
end
|
8
|
+
|
9
|
+
def simple
|
10
|
+
<<-FIRA
|
11
|
+
<p #id .class3>some text</p>
|
12
|
+
FIRA
|
13
|
+
end
|
14
|
+
|
15
|
+
def res_simple
|
16
|
+
<<-FIRA
|
17
|
+
<p id="id" class="class3">some text</p>
|
18
|
+
FIRA
|
19
|
+
end
|
20
|
+
|
21
|
+
def multi_line
|
22
|
+
<<-FIRA
|
23
|
+
<p #id .class3>
|
24
|
+
some text
|
25
|
+
</p>
|
26
|
+
FIRA
|
27
|
+
end
|
28
|
+
|
29
|
+
def res_multi_line
|
30
|
+
<<-FIRA
|
31
|
+
<p id="id" class="class3">
|
32
|
+
some text
|
33
|
+
</p>
|
34
|
+
FIRA
|
35
|
+
end
|
36
|
+
|
37
|
+
def nested_single_line
|
38
|
+
<<-FIRA
|
39
|
+
<p #id .class3><span #span .one>some text</span>
|
40
|
+
some text
|
41
|
+
</p>
|
42
|
+
FIRA
|
43
|
+
end
|
44
|
+
|
45
|
+
def res_nested_single_line
|
46
|
+
<<-FIRA
|
47
|
+
<p id="id" class="class3"><span id="span" class="one">some text</span>
|
48
|
+
some text
|
49
|
+
</p>
|
50
|
+
FIRA
|
51
|
+
end
|
52
|
+
|
53
|
+
def two_classes
|
54
|
+
<<-FIRA
|
55
|
+
<p #id .class3 .class4>
|
56
|
+
some text
|
57
|
+
</p>
|
58
|
+
FIRA
|
59
|
+
end
|
60
|
+
|
61
|
+
def res_two_classes
|
62
|
+
<<-FIRA
|
63
|
+
<p id="id" class="class3 class4">
|
64
|
+
some text
|
65
|
+
</p>
|
66
|
+
FIRA
|
67
|
+
end
|
68
|
+
|
69
|
+
def nested_multi_line
|
70
|
+
<<-FIRA
|
71
|
+
<p #id .class3>
|
72
|
+
<span #span8 .one>some text</span>
|
73
|
+
some text
|
74
|
+
<input type='text' #user value='user' .orange />
|
75
|
+
</p>
|
76
|
+
FIRA
|
77
|
+
end
|
78
|
+
|
79
|
+
def res_nested_multi_line
|
80
|
+
<<-FIRA
|
81
|
+
<p id="id" class="class3">
|
82
|
+
<span id="span8" class="one">some text</span>
|
83
|
+
some text
|
84
|
+
<input id="user" class="orange" type='text' value='user'/>
|
85
|
+
</p>
|
86
|
+
FIRA
|
87
|
+
end
|
88
|
+
|
89
|
+
def inside_text
|
90
|
+
<<-FIRA
|
91
|
+
<p #id .class3>#span .one some text
|
92
|
+
#span .one some text
|
93
|
+
<span>.one #span some text</span>
|
94
|
+
</p>
|
95
|
+
FIRA
|
96
|
+
end
|
97
|
+
|
98
|
+
def res_inside_text
|
99
|
+
<<-FIRA
|
100
|
+
<p id="id" class="class3">#span .one some text
|
101
|
+
#span .one some text
|
102
|
+
<span>.one #span some text</span>
|
103
|
+
</p>
|
104
|
+
FIRA
|
105
|
+
end
|
106
|
+
|
107
|
+
def inside_quotes
|
108
|
+
<<-FIRA
|
109
|
+
<p rel="something .steve and #an id" #id .class3>
|
110
|
+
some text
|
111
|
+
</p>
|
112
|
+
FIRA
|
113
|
+
end
|
114
|
+
|
115
|
+
def res_inside_quotes
|
116
|
+
<<-FIRA
|
117
|
+
<p id="id" class="class3" rel="something .steve and #an id">
|
118
|
+
some text
|
119
|
+
</p>
|
120
|
+
FIRA
|
121
|
+
end
|
122
|
+
|
123
|
+
def html_comments
|
124
|
+
<<-FIRA
|
125
|
+
<div class="span12">
|
126
|
+
<h1><%= @applicant.first_name + " " + @applicant.last_name %>, you are applying for: </h1>
|
127
|
+
<h3><span .main-color><%= @position.name %></span> @ <%= @position.client.name %></h3>
|
128
|
+
<!-- <div .user-info>
|
129
|
+
<h2><a href="/dashboard"><%= @applicant.first_name + " " + @applicant.last_name %></a></h2>
|
130
|
+
<button type="button" .button .edit-profile>Edit</button>
|
131
|
+
</div> -->
|
132
|
+
</div>
|
133
|
+
FIRA
|
134
|
+
end
|
135
|
+
|
136
|
+
def res_html_comments
|
137
|
+
<<-FIRA
|
138
|
+
<div class="span12">
|
139
|
+
<h1><%= @applicant.first_name + " " + @applicant.last_name %>, you are applying for: </h1>
|
140
|
+
<h3><span class="main-color"><%= @position.name %></span> @ <%= @position.client.name %></h3>
|
141
|
+
<!-- <div .user-info>
|
142
|
+
<h2><a href="/dashboard"><%= @applicant.first_name + " " + @applicant.last_name %></a></h2>
|
143
|
+
<button type="button" .button .edit-profile>Edit</button>
|
144
|
+
</div> -->
|
145
|
+
</div>
|
146
|
+
FIRA
|
147
|
+
end
|
148
|
+
|
149
|
+
def erb
|
150
|
+
<<-FIRA
|
151
|
+
<span #my-id><% something.id %></span>
|
152
|
+
<p #id .class3 >
|
153
|
+
some text
|
154
|
+
</p>
|
155
|
+
FIRA
|
156
|
+
end
|
157
|
+
|
158
|
+
def res_erb
|
159
|
+
<<-FIRA
|
160
|
+
<span id="my-id"><% something.id %></span>
|
161
|
+
<p id="id" class="class3" >
|
162
|
+
some text
|
163
|
+
</p>
|
164
|
+
FIRA
|
165
|
+
end
|
166
|
+
|
167
|
+
def erb_in_tag
|
168
|
+
<<-FIRA
|
169
|
+
<span #my-id class="<%= something.id %>" ></span>
|
170
|
+
<p #id .class3 >
|
171
|
+
some text
|
172
|
+
</p>
|
173
|
+
FIRA
|
174
|
+
end
|
175
|
+
|
176
|
+
def res_erb_in_tag
|
177
|
+
<<-FIRA
|
178
|
+
<span id="my-id" class="<%= something.id %>" ></span>
|
179
|
+
<p id="id" class="class3" >
|
180
|
+
some text
|
181
|
+
</p>
|
182
|
+
FIRA
|
183
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fira
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-05-
|
12
|
+
date: 2013-05-27 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activesupport
|
@@ -124,6 +124,8 @@ files:
|
|
124
124
|
- lib/generators/fira/scaffold/templates/index.html.fira
|
125
125
|
- lib/generators/fira/scaffold/templates/new.html.fira
|
126
126
|
- lib/generators/fira/scaffold/templates/show.html.fira
|
127
|
+
- spec/fira_spec.rb
|
128
|
+
- spec/spec_helper.rb
|
127
129
|
homepage: https://github.com/cameronsutter/fira
|
128
130
|
licenses: []
|
129
131
|
post_install_message:
|
@@ -148,5 +150,7 @@ rubygems_version: 1.8.23
|
|
148
150
|
signing_key:
|
149
151
|
specification_version: 3
|
150
152
|
summary: Smarter HTML
|
151
|
-
test_files:
|
153
|
+
test_files:
|
154
|
+
- spec/fira_spec.rb
|
155
|
+
- spec/spec_helper.rb
|
152
156
|
has_rdoc:
|