elm-compiler 0.3.0 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.github/workflows/ci.yml +18 -0
- data/.gitignore +3 -0
- data/Gemfile +1 -0
- data/README.md +5 -5
- data/Rakefile +1 -0
- data/elm-compiler.gemspec +2 -3
- data/elm.json +24 -0
- data/lib/elm/compiler/version.rb +1 -1
- data/lib/elm/compiler.rb +41 -15
- metadata +17 -34
- data/.rubocop.yml +0 -11
- data/.travis.yml +0 -11
- data/bin/rubocop +0 -16
- data/elm-package.json +0 -15
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 850e6bbb8b9adc11e42322b89e1b61beb4c92dba7e5b9172569ef506637ce05d
|
4
|
+
data.tar.gz: e7979cac94a9b0fa3a0307d69eb1b3071f73ae1ca8859aa2e2fc1bb3071d513d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cfb7aee36120a88c85ed5133b32a6ed4d57790ffd57d52313fbf07e3c7be3c33ae18c6b17e82aad30269479291332d3f2fd5e62cd9367686d4b914f3f7b8ab5c
|
7
|
+
data.tar.gz: 870870911f6e04eb1f4b31afd958627693e77c8d43ed845f6862b0feea8032a492d45a3404034e680db68bb447bba7ee512ca82671df2f4efce14525350ab3e2
|
@@ -0,0 +1,18 @@
|
|
1
|
+
name: CI
|
2
|
+
on: [push, pull_request]
|
3
|
+
jobs:
|
4
|
+
test:
|
5
|
+
strategy:
|
6
|
+
fail-fast: false
|
7
|
+
matrix:
|
8
|
+
ruby: [ 2.7, '3.0', '3.1' ]
|
9
|
+
|
10
|
+
runs-on: ubuntu-latest
|
11
|
+
steps:
|
12
|
+
- uses: actions/checkout@v2
|
13
|
+
- uses: ruby/setup-ruby@v1
|
14
|
+
with:
|
15
|
+
ruby-version: ${{ matrix.ruby }}
|
16
|
+
bundler-cache: true
|
17
|
+
- run: bundle exec rake
|
18
|
+
|
data/.gitignore
CHANGED
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# elm-compiler
|
2
2
|
|
3
|
-
[![Build Status](https://
|
3
|
+
[![Build Status](https://github.com/fbonetti/ruby-elm-compiler/actions/workflows/ci.yml/badge.svg)](https://github.com/fbonetti/ruby-elm-compiler/actions/workflows/ci.yml)
|
4
4
|
|
5
5
|
Ruby wrapper for the [Elm language compiler](https://github.com/elm-lang/elm-compiler).
|
6
6
|
|
@@ -28,16 +28,16 @@ Or install it yourself as:
|
|
28
28
|
|
29
29
|
## Usage
|
30
30
|
|
31
|
-
> NOTE: Make sure [Elm](http://elm-lang.org/install) is installed. If the `elm
|
31
|
+
> NOTE: Make sure [Elm](http://elm-lang.org/install) is installed. If the `elm` executable can't be found in the current `PATH` or via the `elm_path` option, the exception `Elm::Compiler::ExecutableNotFound` will be thrown.
|
32
32
|
|
33
33
|
```ruby
|
34
|
-
Elm::Compiler.compile(elm_files, output_path: nil,
|
34
|
+
Elm::Compiler.compile(elm_files, output_path: nil, elm_path: nil, debug: false)
|
35
35
|
```
|
36
36
|
|
37
37
|
* `elm_files`: Accepts a single file path or an array of file paths.
|
38
38
|
* `output_path`: Path to the output file. If left blank, the compiled Javascript will be returned as a string.
|
39
|
-
* `
|
40
|
-
|
39
|
+
* `elm_path`: Path to the `elm` executable. If left blank, the executable will be looked up in the current `PATH`, if that cannot be found, it will download elm to /tmp/elm-0.19.1 and use that.
|
40
|
+
* `debug`: Whether or not to compile in debug mode. Default is false.
|
41
41
|
|
42
42
|
|
43
43
|
## Examples
|
data/Rakefile
CHANGED
data/elm-compiler.gemspec
CHANGED
@@ -18,8 +18,7 @@ Gem::Specification.new do |spec|
|
|
18
18
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
19
19
|
spec.require_paths = ['lib']
|
20
20
|
|
21
|
-
spec.add_development_dependency 'bundler', '~> 1.11'
|
22
|
-
spec.add_development_dependency 'rake', '~> 10.0'
|
23
21
|
spec.add_development_dependency 'rspec', '~> 3.0'
|
24
|
-
spec.add_development_dependency '
|
22
|
+
spec.add_development_dependency 'rake'
|
23
|
+
spec.add_development_dependency 'byebug'
|
25
24
|
end
|
data/elm.json
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
{
|
2
|
+
"type": "application",
|
3
|
+
"source-directories": [
|
4
|
+
"spec/fixtures"
|
5
|
+
],
|
6
|
+
"elm-version": "0.19.1",
|
7
|
+
"dependencies": {
|
8
|
+
"direct": {
|
9
|
+
"elm/browser": "1.0.2",
|
10
|
+
"elm/core": "1.0.5",
|
11
|
+
"elm/html": "1.0.0"
|
12
|
+
},
|
13
|
+
"indirect": {
|
14
|
+
"elm/json": "1.1.3",
|
15
|
+
"elm/time": "1.0.0",
|
16
|
+
"elm/url": "1.0.0",
|
17
|
+
"elm/virtual-dom": "1.0.3"
|
18
|
+
}
|
19
|
+
},
|
20
|
+
"test-dependencies": {
|
21
|
+
"direct": {},
|
22
|
+
"indirect": {}
|
23
|
+
}
|
24
|
+
}
|
data/lib/elm/compiler/version.rb
CHANGED
data/lib/elm/compiler.rb
CHANGED
@@ -5,38 +5,64 @@ require 'tempfile'
|
|
5
5
|
module Elm
|
6
6
|
class Compiler
|
7
7
|
class << self
|
8
|
-
|
9
|
-
|
8
|
+
attr_writer :elm_path
|
9
|
+
def elm_path
|
10
|
+
@elm_path ||= elm_from_env_path || our_elm_path
|
11
|
+
end
|
10
12
|
|
13
|
+
def compile(elm_files, output_path: nil, elm_path: self.elm_path, debug: false)
|
14
|
+
fail ExecutableNotFound unless elm_executable_exists?(elm_path)
|
11
15
|
if output_path
|
12
|
-
elm_make(
|
16
|
+
elm_make(elm_path, elm_files, output_path, debug)
|
13
17
|
else
|
14
|
-
compile_to_string(
|
18
|
+
compile_to_string(elm_path, elm_files, debug)
|
15
19
|
end
|
16
20
|
end
|
17
21
|
|
18
22
|
private
|
19
23
|
|
20
|
-
def
|
21
|
-
Open3.popen2(elm_make_path){}.nil?
|
22
|
-
rescue Errno::ENOENT, Errno::EACCES
|
23
|
-
false
|
24
|
-
end
|
25
|
-
|
26
|
-
def compile_to_string(elm_make_path, elm_files, debug)
|
24
|
+
def compile_to_string(elm_path, elm_files, debug)
|
27
25
|
Tempfile.open(['elm', '.js']) do |tempfile|
|
28
|
-
elm_make(
|
26
|
+
elm_make(elm_path, elm_files, tempfile.path, debug)
|
29
27
|
return File.read tempfile.path
|
30
28
|
end
|
31
29
|
end
|
32
30
|
|
33
|
-
def elm_make(
|
34
|
-
args = [
|
35
|
-
|
31
|
+
def elm_make(elm_path, elm_files, output_path, debug)
|
32
|
+
args = [
|
33
|
+
{"LANG" => "en_US.UTF8" },
|
34
|
+
elm_path,
|
35
|
+
"make",
|
36
|
+
*elm_files,
|
37
|
+
"--output=#{output_path}",
|
38
|
+
debug ? "--debug" : "--optimize",
|
39
|
+
]
|
36
40
|
Open3.popen3(*args) do |_stdin, _stdout, stderr, wait_thr|
|
37
41
|
fail CompileError, stderr.gets(nil) if wait_thr.value.exitstatus != 0
|
38
42
|
end
|
39
43
|
end
|
44
|
+
|
45
|
+
def elm_executable_exists?(path)
|
46
|
+
`#{path} --version`.strip == "0.19.1"
|
47
|
+
rescue
|
48
|
+
false
|
49
|
+
end
|
50
|
+
|
51
|
+
def elm_from_env_path
|
52
|
+
`which elm`.chomp.tap { |p| return nil if p == "" }
|
53
|
+
end
|
54
|
+
|
55
|
+
def our_elm_path
|
56
|
+
path = "/tmp/elm-0.19.1"
|
57
|
+
unless elm_executable_exists?(path)
|
58
|
+
system """
|
59
|
+
curl -sfLo #{path}.gz https://github.com/elm/compiler/releases/download/0.19.1/binary-for-linux-64-bit.gz
|
60
|
+
gunzip -f #{path}.gz
|
61
|
+
chmod +x #{path}
|
62
|
+
"""
|
63
|
+
end
|
64
|
+
path
|
65
|
+
end
|
40
66
|
end
|
41
67
|
end
|
42
68
|
end
|
metadata
CHANGED
@@ -1,71 +1,57 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: elm-compiler
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Frank Bonetti
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-08-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name:
|
14
|
+
name: rspec
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
19
|
+
version: '3.0'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '
|
26
|
+
version: '3.0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rake
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - "
|
31
|
+
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
33
|
+
version: '0'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- - "
|
38
|
+
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '
|
40
|
+
version: '0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
|
-
name:
|
42
|
+
name: byebug
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- - "
|
45
|
+
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: '
|
47
|
+
version: '0'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- - "
|
53
|
-
- !ruby/object:Gem::Version
|
54
|
-
version: '3.0'
|
55
|
-
- !ruby/object:Gem::Dependency
|
56
|
-
name: rubocop
|
57
|
-
requirement: !ruby/object:Gem::Requirement
|
58
|
-
requirements:
|
59
|
-
- - "~>"
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
version: 0.35.1
|
62
|
-
type: :development
|
63
|
-
prerelease: false
|
64
|
-
version_requirements: !ruby/object:Gem::Requirement
|
65
|
-
requirements:
|
66
|
-
- - "~>"
|
52
|
+
- - ">="
|
67
53
|
- !ruby/object:Gem::Version
|
68
|
-
version: 0
|
54
|
+
version: '0'
|
69
55
|
description: Allows you compile Elm files and write to a file or stdout
|
70
56
|
email:
|
71
57
|
- frank.r.bonetti@gmail.com
|
@@ -73,20 +59,18 @@ executables: []
|
|
73
59
|
extensions: []
|
74
60
|
extra_rdoc_files: []
|
75
61
|
files:
|
62
|
+
- ".github/workflows/ci.yml"
|
76
63
|
- ".gitignore"
|
77
64
|
- ".rspec"
|
78
|
-
- ".rubocop.yml"
|
79
|
-
- ".travis.yml"
|
80
65
|
- Gemfile
|
81
66
|
- LICENSE.txt
|
82
67
|
- README.md
|
83
68
|
- Rakefile
|
84
69
|
- bin/console
|
85
70
|
- bin/rspec
|
86
|
-
- bin/rubocop
|
87
71
|
- bin/setup
|
88
72
|
- elm-compiler.gemspec
|
89
|
-
- elm
|
73
|
+
- elm.json
|
90
74
|
- lib/elm-compiler.rb
|
91
75
|
- lib/elm/compiler.rb
|
92
76
|
- lib/elm/compiler/exceptions.rb
|
@@ -110,8 +94,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
110
94
|
- !ruby/object:Gem::Version
|
111
95
|
version: '0'
|
112
96
|
requirements: []
|
113
|
-
|
114
|
-
rubygems_version: 2.5.1
|
97
|
+
rubygems_version: 3.1.6
|
115
98
|
signing_key:
|
116
99
|
specification_version: 4
|
117
100
|
summary: Ruby wrapper for the Elm compiler
|
data/.rubocop.yml
DELETED
data/.travis.yml
DELETED
data/bin/rubocop
DELETED
@@ -1,16 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
#
|
3
|
-
# This file was generated by Bundler.
|
4
|
-
#
|
5
|
-
# The application 'rubocop' is installed as part of a gem, and
|
6
|
-
# this file is here to facilitate running it.
|
7
|
-
#
|
8
|
-
|
9
|
-
require 'pathname'
|
10
|
-
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile',
|
11
|
-
Pathname.new(__FILE__).realpath)
|
12
|
-
|
13
|
-
require 'rubygems'
|
14
|
-
require 'bundler/setup'
|
15
|
-
|
16
|
-
load Gem.bin_path('rubocop', 'rubocop')
|
data/elm-package.json
DELETED
@@ -1,15 +0,0 @@
|
|
1
|
-
{
|
2
|
-
"version": "1.0.0",
|
3
|
-
"summary": "elm-package.json for rspec test suite",
|
4
|
-
"repository": "https://github.com/user/project.git",
|
5
|
-
"license": "BSD3",
|
6
|
-
"source-directories": [
|
7
|
-
"."
|
8
|
-
],
|
9
|
-
"exposed-modules": [],
|
10
|
-
"dependencies": {
|
11
|
-
"elm-lang/core": "5.0.0 <= v < 6.0.0",
|
12
|
-
"elm-lang/html": "2.0.0 <= v < 3.0.0"
|
13
|
-
},
|
14
|
-
"elm-version": "0.18.0 <= v < 0.19.0"
|
15
|
-
}
|