snipcheat 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/snipcheat/output.rb +5 -12
- data/lib/snipcheat/version.rb +1 -1
- data/spec/output_spec.rb +8 -0
- metadata +2 -2
data/lib/snipcheat/output.rb
CHANGED
@@ -8,27 +8,20 @@ module Snipcheat
|
|
8
8
|
end
|
9
9
|
|
10
10
|
def write
|
11
|
-
|
11
|
+
File.open(@out_file, 'w') do |f|
|
12
12
|
f.write(to_s)
|
13
13
|
end
|
14
14
|
end
|
15
15
|
|
16
16
|
def to_s
|
17
|
-
engine = Haml::Engine.new(template)
|
18
|
-
|
17
|
+
engine = Haml::Engine.new(template('simple.html.haml'), escape_html: true)
|
18
|
+
engine.render(Object.new, snippets: @snippets, css: template('styles.css'))
|
19
19
|
end
|
20
20
|
|
21
21
|
private
|
22
22
|
|
23
|
-
def
|
24
|
-
f = File.open(File.join(File.dirname(__FILE__), '..', 'templates',
|
25
|
-
f.read
|
26
|
-
ensure
|
27
|
-
f.close
|
28
|
-
end
|
29
|
-
|
30
|
-
def template
|
31
|
-
f = File.open(File.join(File.dirname(__FILE__), '..', 'templates', 'simple.html.haml'))
|
23
|
+
def template(filename)
|
24
|
+
f = File.open(File.join(File.dirname(__FILE__), '..', 'templates', filename))
|
32
25
|
f.read
|
33
26
|
ensure
|
34
27
|
f.close
|
data/lib/snipcheat/version.rb
CHANGED
data/spec/output_spec.rb
CHANGED
@@ -12,6 +12,14 @@ module Snipcheat
|
|
12
12
|
out.should match 'magic'
|
13
13
|
out.should match 'all.files'
|
14
14
|
end
|
15
|
+
|
16
|
+
it "escapes html" do
|
17
|
+
snippets = [double(content: '<trololo>', tab_trigger: 'ttr', description: '<trololo>', scope: 'all.files')]
|
18
|
+
out = Output.new(snippets, :path).to_s
|
19
|
+
|
20
|
+
out.should match '<trololo>'
|
21
|
+
out.should_not match '<trololo>'
|
22
|
+
end
|
15
23
|
end
|
16
24
|
end
|
17
25
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: snipcheat
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
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: 2013-01-16 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: crack
|