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.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/jekyll_elm.rb +5 -55
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1082ea78f316664d9c8422db10550e3f19fbc45e
4
- data.tar.gz: a8288cc02f798c165e4121756ec9626c6851647f
3
+ metadata.gz: c8a5cd0f205d069219956b96942bee861b889081
4
+ data.tar.gz: 712612012dc2a9631a103f834ae4a5bb9dc9c5f6
5
5
  SHA512:
6
- metadata.gz: 1ff647fc4dc8e06dec511d2ab3ac6e87edee75b9861f827260c1d1b44f92faa02bcf96790134c53aaf9aed0df08b09497bdf3909017f50f1abf9bf8a35cdd51e
7
- data.tar.gz: 8a88279884617715c0bc64b6ad57891b16b6cda9a4d35ec35cdc7a2cb0762fe48d92a7196b536422547831b7087d39a30b6f304197306ea3a092c240d1169827
6
+ metadata.gz: fb5deda22e5e89f58232efaa64b5d9b0efc1d84c4543f2594230587308ae5a6c88f54c943b3b570f999ad3f53ca2f710cfa283a538a301ad8030899910b425b9
7
+ data.tar.gz: 073a0dac94090d2b617f518d6fb7321149ad1ffbd1284f6f854dddd370027deba1b31428885f7fbcf860421a8fd703a3ab025f450d239f61dec6141616508506
data/lib/jekyll_elm.rb CHANGED
@@ -1,5 +1,4 @@
1
- require 'open3'
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
- return content if content =~ /#{@config['excerpt_separator']}$/
18
-
19
- output = nil
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.2
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-05 00:00:00.000000000 Z
11
+ date: 2014-05-06 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description:
14
14
  email: michaud.sonny@gmail.com