jekyll_elm 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/jekyll_elm.rb +5 -55
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c8a5cd0f205d069219956b96942bee861b889081
|
4
|
+
data.tar.gz: 712612012dc2a9631a103f834ae4a5bb9dc9c5f6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fb5deda22e5e89f58232efaa64b5d9b0efc1d84c4543f2594230587308ae5a6c88f54c943b3b570f999ad3f53ca2f710cfa283a538a301ad8030899910b425b9
|
7
|
+
data.tar.gz: 073a0dac94090d2b617f518d6fb7321149ad1ffbd1284f6f854dddd370027deba1b31428885f7fbcf860421a8fd703a3ab025f450d239f61dec6141616508506
|
data/lib/jekyll_elm.rb
CHANGED
@@ -1,5 +1,4 @@
|
|
1
|
-
require '
|
2
|
-
require 'securerandom'
|
1
|
+
require 'elm_compiler'
|
3
2
|
|
4
3
|
module Jekyll
|
5
4
|
class ElmConverter < Converter
|
@@ -14,60 +13,11 @@ module Jekyll
|
|
14
13
|
end
|
15
14
|
|
16
15
|
def convert(content)
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
setup_dir
|
22
|
-
|
23
|
-
with_error_handling do
|
24
|
-
File.open(tmp_path, 'w') { |f| f.write(content) }
|
25
|
-
|
26
|
-
in_elm_dir do
|
27
|
-
_, err = Open3.capture3("elm --make --runtime=/javascripts/elm-runtime.js #{tmp_file}.elm")
|
28
|
-
puts "** ERROR: Elm:\n#{err}\n" if err.length > 0
|
29
|
-
end
|
30
|
-
|
31
|
-
output = File.read(File.join(elm_dir, 'build', "#{tmp_file}.html"))
|
32
|
-
end
|
33
|
-
|
34
|
-
output
|
35
|
-
end
|
36
|
-
|
37
|
-
private
|
38
|
-
|
39
|
-
def setup_dir
|
40
|
-
Dir.mkdir(elm_dir) unless File.exist?(elm_dir) && File.directory?(elm_dir)
|
41
|
-
end
|
42
|
-
|
43
|
-
def with_error_handling
|
44
|
-
begin
|
45
|
-
yield
|
46
|
-
rescue Errno::ENOENT => e
|
47
|
-
puts e
|
48
|
-
puts "** ERROR: elm isn't installed or could not be found."
|
49
|
-
puts "** ERROR: To install with cabal run: cabal install elm"
|
50
|
-
ensure
|
51
|
-
File.delete(tmp_path)
|
16
|
+
if content =~ /#{@config['excerpt_separator']}$/
|
17
|
+
content
|
18
|
+
else
|
19
|
+
ElmCompiler.new(content).process!
|
52
20
|
end
|
53
21
|
end
|
54
|
-
|
55
|
-
def in_elm_dir
|
56
|
-
Dir.chdir(elm_dir)
|
57
|
-
yield
|
58
|
-
Dir.chdir('..')
|
59
|
-
end
|
60
|
-
|
61
|
-
def elm_dir
|
62
|
-
'_elm'
|
63
|
-
end
|
64
|
-
|
65
|
-
def tmp_file
|
66
|
-
@tmp_file ||= SecureRandom.hex(16)
|
67
|
-
end
|
68
|
-
|
69
|
-
def tmp_path
|
70
|
-
@tmp_path ||= File.join(elm_dir, "#{tmp_file}.elm")
|
71
|
-
end
|
72
22
|
end
|
73
23
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jekyll_elm
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sonny Michaud
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-05-
|
11
|
+
date: 2014-05-06 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description:
|
14
14
|
email: michaud.sonny@gmail.com
|