fira 0.6.1 → 0.6.2
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/erb_specs.rb +35 -0
- data/spec/fira_spec.rb +13 -64
- data/spec/html_specs.rb +182 -0
- data/spec/spec_helper.rb +0 -200
- metadata +6 -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 = /<[^\/%!]\w* /
|
11
|
+
TAG_OPEN_REGEX = /<[^\/%!]\w* /x
|
12
12
|
TAG_END_REGEX = /([\/]?>)/
|
13
13
|
|
14
14
|
def parse_text(text)
|
@@ -40,7 +40,7 @@ module Fira
|
|
40
40
|
end
|
41
41
|
end
|
42
42
|
|
43
|
-
return output
|
43
|
+
return output.gsub( /\s+/, " " )
|
44
44
|
end
|
45
45
|
|
46
46
|
def parse_classes(text)
|
data/lib/fira/version.rb
CHANGED
data/spec/erb_specs.rb
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
def erb
|
2
|
+
<<-FIRA
|
3
|
+
<span #my-id><% something.id %></span>
|
4
|
+
<p #id .class3 >
|
5
|
+
some text
|
6
|
+
</p>
|
7
|
+
FIRA
|
8
|
+
end
|
9
|
+
|
10
|
+
def res_erb
|
11
|
+
<<-FIRA
|
12
|
+
<span id="my-id"><% something.id %></span>
|
13
|
+
<p id="id" class="class3">
|
14
|
+
some text
|
15
|
+
</p>
|
16
|
+
FIRA
|
17
|
+
end
|
18
|
+
|
19
|
+
def erb_in_tag
|
20
|
+
<<-FIRA
|
21
|
+
<span #my-id class="<%= something.id %>" ></span>
|
22
|
+
<p #id .class3 >
|
23
|
+
some text
|
24
|
+
</p>
|
25
|
+
FIRA
|
26
|
+
end
|
27
|
+
|
28
|
+
def res_erb_in_tag
|
29
|
+
<<-FIRA
|
30
|
+
<span id="my-id" class="<%= something.id %>" ></span>
|
31
|
+
<p id="id" class="class3">
|
32
|
+
some text
|
33
|
+
</p>
|
34
|
+
FIRA
|
35
|
+
end
|
data/spec/fira_spec.rb
CHANGED
@@ -1,70 +1,19 @@
|
|
1
1
|
require 'spec_helper'
|
2
|
+
require 'html_specs'
|
3
|
+
require 'erb_specs'
|
2
4
|
|
3
5
|
describe Fira do
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
it
|
12
|
-
result = Fira.render
|
13
|
-
|
14
|
-
|
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
|
-
|
46
|
-
context 'Data tags' do
|
47
|
-
it 'simple data tags' do
|
48
|
-
result = Fira.render data_attribute_simple
|
49
|
-
result.should == res_data_attribute_simple
|
50
|
-
end
|
51
|
-
|
52
|
-
it 'multiple data tags' do
|
53
|
-
result = Fira.render data_attribute_multiple
|
54
|
-
result.should == res_data_attribute_multiple
|
55
|
-
end
|
56
|
-
end
|
57
|
-
end
|
58
|
-
|
59
|
-
context 'ERB' do
|
60
|
-
it 'simple erb' do
|
61
|
-
result = Fira.render erb
|
62
|
-
result.should == res_erb
|
63
|
-
end
|
64
|
-
|
65
|
-
it 'erb in-tag' do
|
66
|
-
result = Fira.render erb_in_tag
|
67
|
-
result.should == res_erb_in_tag
|
6
|
+
specs = %w{
|
7
|
+
simple multi_line nested_single_line nested_multi_line two_classes
|
8
|
+
inside_text inside_quotes html_comments data_attribute_simple
|
9
|
+
data_attribute_multiple erb erb_in_tag multiline_opening_tag
|
10
|
+
}
|
11
|
+
|
12
|
+
specs.each do |method_name|
|
13
|
+
it "#{method_name}" do
|
14
|
+
result = Fira.render(send(method_name))
|
15
|
+
res_name = "res_#{method_name}"
|
16
|
+
result.should == send(res_name).gsub( /\s+/, " " )
|
68
17
|
end
|
69
18
|
end
|
70
19
|
|
data/spec/html_specs.rb
ADDED
@@ -0,0 +1,182 @@
|
|
1
|
+
def simple
|
2
|
+
<<-FIRA
|
3
|
+
<p #id .class3>some text</p>
|
4
|
+
FIRA
|
5
|
+
end
|
6
|
+
|
7
|
+
def res_simple
|
8
|
+
<<-FIRA
|
9
|
+
<p id="id" class="class3">some text</p>
|
10
|
+
FIRA
|
11
|
+
end
|
12
|
+
|
13
|
+
def multi_line
|
14
|
+
<<-FIRA
|
15
|
+
<p #id .class3>
|
16
|
+
some text
|
17
|
+
</p>
|
18
|
+
FIRA
|
19
|
+
end
|
20
|
+
|
21
|
+
def res_multi_line
|
22
|
+
<<-FIRA
|
23
|
+
<p id="id" class="class3">
|
24
|
+
some text
|
25
|
+
</p>
|
26
|
+
FIRA
|
27
|
+
end
|
28
|
+
|
29
|
+
def nested_single_line
|
30
|
+
<<-FIRA
|
31
|
+
<p #id .class3><span #span .one>some text</span>
|
32
|
+
some text
|
33
|
+
</p>
|
34
|
+
FIRA
|
35
|
+
end
|
36
|
+
|
37
|
+
def res_nested_single_line
|
38
|
+
<<-FIRA
|
39
|
+
<p id="id" class="class3"><span id="span" class="one">some text</span>
|
40
|
+
some text
|
41
|
+
</p>
|
42
|
+
FIRA
|
43
|
+
end
|
44
|
+
|
45
|
+
def two_classes
|
46
|
+
<<-FIRA
|
47
|
+
<p #id .class3 .class4>
|
48
|
+
some text
|
49
|
+
</p>
|
50
|
+
FIRA
|
51
|
+
end
|
52
|
+
|
53
|
+
def res_two_classes
|
54
|
+
<<-FIRA
|
55
|
+
<p id="id" class="class3 class4">
|
56
|
+
some text
|
57
|
+
</p>
|
58
|
+
FIRA
|
59
|
+
end
|
60
|
+
|
61
|
+
def nested_multi_line
|
62
|
+
<<-FIRA
|
63
|
+
<p #id .class3>
|
64
|
+
<span #span8 .one>some text</span>
|
65
|
+
some text
|
66
|
+
<input type='text' #user value='user' .orange />
|
67
|
+
</p>
|
68
|
+
FIRA
|
69
|
+
end
|
70
|
+
|
71
|
+
def res_nested_multi_line
|
72
|
+
<<-FIRA
|
73
|
+
<p id="id" class="class3">
|
74
|
+
<span id="span8" class="one">some text</span>
|
75
|
+
some text
|
76
|
+
<input id="user" class="orange" type='text' value='user'/>
|
77
|
+
</p>
|
78
|
+
FIRA
|
79
|
+
end
|
80
|
+
|
81
|
+
def inside_text
|
82
|
+
<<-FIRA
|
83
|
+
<p #id .class3>#span .one some text
|
84
|
+
#span .one some text
|
85
|
+
<span>.one #span some text</span>
|
86
|
+
</p>
|
87
|
+
FIRA
|
88
|
+
end
|
89
|
+
|
90
|
+
def res_inside_text
|
91
|
+
<<-FIRA
|
92
|
+
<p id="id" class="class3">#span .one some text
|
93
|
+
#span .one some text
|
94
|
+
<span>.one #span some text</span>
|
95
|
+
</p>
|
96
|
+
FIRA
|
97
|
+
end
|
98
|
+
|
99
|
+
def inside_quotes
|
100
|
+
<<-FIRA
|
101
|
+
<p rel="something .steve and #an id" #id .class3>
|
102
|
+
some text
|
103
|
+
</p>
|
104
|
+
FIRA
|
105
|
+
end
|
106
|
+
|
107
|
+
def res_inside_quotes
|
108
|
+
<<-FIRA
|
109
|
+
<p id="id" class="class3" rel="something .steve and #an id">
|
110
|
+
some text
|
111
|
+
</p>
|
112
|
+
FIRA
|
113
|
+
end
|
114
|
+
|
115
|
+
def html_comments
|
116
|
+
<<-FIRA
|
117
|
+
<div class="span12">
|
118
|
+
<h1><%= @applicant.first_name + " " + @applicant.last_name %>, you are applying for: </h1>
|
119
|
+
<h3><span .main-color><%= @position.name %></span> @ <%= @position.client.name %></h3>
|
120
|
+
<!-- <div .user-info>
|
121
|
+
<h2><a href="/dashboard"><%= @applicant.first_name + " " + @applicant.last_name %></a></h2>
|
122
|
+
<button type="button" .button .edit-profile>Edit</button>
|
123
|
+
</div> -->
|
124
|
+
</div>
|
125
|
+
FIRA
|
126
|
+
end
|
127
|
+
|
128
|
+
def res_html_comments
|
129
|
+
<<-FIRA
|
130
|
+
<div class="span12">
|
131
|
+
<h1><%= @applicant.first_name + " " + @applicant.last_name %>, you are applying for: </h1>
|
132
|
+
<h3><span class="main-color"><%= @position.name %></span> @ <%= @position.client.name %></h3>
|
133
|
+
<!-- <div .user-info>
|
134
|
+
<h2><a href="/dashboard"><%= @applicant.first_name + " " + @applicant.last_name %></a></h2>
|
135
|
+
<button type="button" .button .edit-profile>Edit</button>
|
136
|
+
</div> -->
|
137
|
+
</div>
|
138
|
+
FIRA
|
139
|
+
end
|
140
|
+
|
141
|
+
def data_attribute_simple
|
142
|
+
<<-FIRA
|
143
|
+
<span $convo-id="72" ></span>
|
144
|
+
FIRA
|
145
|
+
end
|
146
|
+
|
147
|
+
def res_data_attribute_simple
|
148
|
+
<<-FIRA
|
149
|
+
<span data-convo-id="72"></span>
|
150
|
+
FIRA
|
151
|
+
end
|
152
|
+
|
153
|
+
def data_attribute_multiple
|
154
|
+
<<-FIRA
|
155
|
+
<span $convo-id="72" $city="Provo" ></span>
|
156
|
+
FIRA
|
157
|
+
end
|
158
|
+
|
159
|
+
def res_data_attribute_multiple
|
160
|
+
<<-FIRA
|
161
|
+
<span data-convo-id="72" data-city="Provo"></span>
|
162
|
+
FIRA
|
163
|
+
end
|
164
|
+
|
165
|
+
def multiline_opening_tag
|
166
|
+
<<-FIRA
|
167
|
+
<button
|
168
|
+
.btn .btn-primary .btn-large
|
169
|
+
#finish-new-money
|
170
|
+
$user-id="<%= @user.id %>"
|
171
|
+
>Done!</button>
|
172
|
+
FIRA
|
173
|
+
end
|
174
|
+
|
175
|
+
def res_multiline_opening_tag
|
176
|
+
<<-FIRA
|
177
|
+
<button
|
178
|
+
id="finish-new-money"
|
179
|
+
class="btn btn-primary btn-large" data-user-id="<%= @user.id %>"
|
180
|
+
>Done!</button>
|
181
|
+
FIRA
|
182
|
+
end
|
data/spec/spec_helper.rb
CHANGED
@@ -4,204 +4,4 @@ require 'fira'
|
|
4
4
|
RSpec.configure do |config|
|
5
5
|
config.color_enabled = true
|
6
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
|
184
|
-
|
185
|
-
def data_attribute_simple
|
186
|
-
<<-FIRA
|
187
|
-
<span $convo-id="72" ></span>
|
188
|
-
FIRA
|
189
|
-
end
|
190
|
-
|
191
|
-
def res_data_attribute_simple
|
192
|
-
<<-FIRA
|
193
|
-
<span data-convo-id="72"></span>
|
194
|
-
FIRA
|
195
|
-
end
|
196
|
-
|
197
|
-
def data_attribute_multiple
|
198
|
-
<<-FIRA
|
199
|
-
<span $convo-id="72" $city="Provo" ></span>
|
200
|
-
FIRA
|
201
|
-
end
|
202
|
-
|
203
|
-
def res_data_attribute_multiple
|
204
|
-
<<-FIRA
|
205
|
-
<span data-convo-id="72" data-city="Provo"></span>
|
206
|
-
FIRA
|
207
7
|
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.6.
|
4
|
+
version: 0.6.2
|
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:
|
12
|
+
date: 2014-01-29 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activesupport
|
@@ -124,7 +124,9 @@ 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/erb_specs.rb
|
127
128
|
- spec/fira_spec.rb
|
129
|
+
- spec/html_specs.rb
|
128
130
|
- spec/spec_helper.rb
|
129
131
|
homepage: http://cameronsutter.github.io/fira
|
130
132
|
licenses: []
|
@@ -151,6 +153,7 @@ signing_key:
|
|
151
153
|
specification_version: 3
|
152
154
|
summary: Smarter HTML
|
153
155
|
test_files:
|
156
|
+
- spec/erb_specs.rb
|
154
157
|
- spec/fira_spec.rb
|
158
|
+
- spec/html_specs.rb
|
155
159
|
- spec/spec_helper.rb
|
156
|
-
has_rdoc:
|