jekyll_elm 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/lib/jekyll_elm.rb +75 -0
- metadata +44 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 5e8f6144dd84561be7a467cca510e951ed75eb4b
|
4
|
+
data.tar.gz: cc56e073f2b4669020bd2b205fbcbd245b072ca8
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 14627370ef72398aab96e8ee2fac40b470403120456d642c99b2e77b1efc95df5fce73a2e68798470d63c2719b12a923f138d7da55fa04d46ec6583c758ed8b3
|
7
|
+
data.tar.gz: 9c284af538985f7131329550ce5b134ee2722be3df433f15905be88346e12e2112ccc70b8d11642077e5a59cedffe10685935969038c61ccfdac7cec0bb5dfa9
|
data/lib/jekyll_elm.rb
ADDED
@@ -0,0 +1,75 @@
|
|
1
|
+
require 'open3'
|
2
|
+
require 'securerandom'
|
3
|
+
|
4
|
+
require 'pry'
|
5
|
+
|
6
|
+
module Jekyll
|
7
|
+
class ElmConverter < Converter
|
8
|
+
safe false
|
9
|
+
|
10
|
+
def matches(ext)
|
11
|
+
ext =~ /^\.elm$/i
|
12
|
+
end
|
13
|
+
|
14
|
+
def output_ext(ext)
|
15
|
+
'.html'
|
16
|
+
end
|
17
|
+
|
18
|
+
def convert(content)
|
19
|
+
return content if content =~ /#{@config['excerpt_separator']}$/
|
20
|
+
|
21
|
+
output = nil
|
22
|
+
|
23
|
+
setup_dir
|
24
|
+
|
25
|
+
with_error_handling do
|
26
|
+
File.open(tmp_path, 'w') { |f| f.write(content) }
|
27
|
+
|
28
|
+
in_elm_dir do
|
29
|
+
_, err = Open3.capture3("elm --make --runtime=/javascripts/elm-runtime.js #{tmp_file}.elm")
|
30
|
+
puts "** ERROR: Elm:\n#{err}\n" if err.length > 0
|
31
|
+
end
|
32
|
+
|
33
|
+
output = File.read(File.join(elm_dir, 'build', "#{tmp_file}.html"))
|
34
|
+
end
|
35
|
+
|
36
|
+
output
|
37
|
+
end
|
38
|
+
|
39
|
+
private
|
40
|
+
|
41
|
+
def setup_dir
|
42
|
+
Dir.mkdir(elm_dir) unless File.exist?(elm_dir) && File.directory?(elm_dir)
|
43
|
+
end
|
44
|
+
|
45
|
+
def with_error_handling
|
46
|
+
begin
|
47
|
+
yield
|
48
|
+
rescue Errno::ENOENT => e
|
49
|
+
puts e
|
50
|
+
puts "** ERROR: elm isn't installed or could not be found."
|
51
|
+
puts "** ERROR: To install with cabal run: cabal install elm"
|
52
|
+
ensure
|
53
|
+
File.delete(tmp_path)
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
def in_elm_dir
|
58
|
+
Dir.chdir(elm_dir)
|
59
|
+
yield
|
60
|
+
Dir.chdir('..')
|
61
|
+
end
|
62
|
+
|
63
|
+
def elm_dir
|
64
|
+
'_elm'
|
65
|
+
end
|
66
|
+
|
67
|
+
def tmp_file
|
68
|
+
@tmp_file ||= SecureRandom.hex(16)
|
69
|
+
end
|
70
|
+
|
71
|
+
def tmp_path
|
72
|
+
@tmp_path ||= File.join(elm_dir, "#{tmp_file}.elm")
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
metadata
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: jekyll_elm
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Sonny Michaud
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-05-05 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description:
|
14
|
+
email: michaud.sonny@gmail.com
|
15
|
+
executables: []
|
16
|
+
extensions: []
|
17
|
+
extra_rdoc_files: []
|
18
|
+
files:
|
19
|
+
- lib/jekyll_elm.rb
|
20
|
+
homepage:
|
21
|
+
licenses:
|
22
|
+
- MIT
|
23
|
+
metadata: {}
|
24
|
+
post_install_message:
|
25
|
+
rdoc_options: []
|
26
|
+
require_paths:
|
27
|
+
- lib
|
28
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
29
|
+
requirements:
|
30
|
+
- - '>='
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '0'
|
33
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
34
|
+
requirements:
|
35
|
+
- - '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
requirements: []
|
39
|
+
rubyforge_project:
|
40
|
+
rubygems_version: 2.0.3
|
41
|
+
signing_key:
|
42
|
+
specification_version: 4
|
43
|
+
summary: Elm support for Jekyll
|
44
|
+
test_files: []
|