hamlit 2.13.2 → 2.14.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 +4 -4
- data/.github/workflows/test.yml +7 -1
- data/.gitignore +1 -1
- data/CHANGELOG.md +18 -0
- data/README.md +1 -0
- data/lib/hamlit/cli.rb +34 -10
- data/lib/hamlit/version.rb +1 -1
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3a301e3719b15a8bd389c69273087c6133a0f64a50794e256106c65fb402a652
|
4
|
+
data.tar.gz: f5548a7ca946d6339a4767c13fc4dfcf8779274a95d179dccabf4ceb269aa35e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c5858d26f7573e085d1da827a3d9eee1a6c8252e8a6a0459a8e1022dc99a2cb15cce1bd4931ffc2df26815e85a717df0fd119f3585d605aaeb67a5c7c38021df
|
7
|
+
data.tar.gz: 6fa9187e20778096808fce4e997df74c67b9d980ba4219baf55b64f9930b87c3b35b21a74c50355c6a443750e6d5465d6b6977dd322aeea5bdc7ecdb57d44519
|
data/.github/workflows/test.yml
CHANGED
@@ -21,10 +21,16 @@ jobs:
|
|
21
21
|
- ruby:2.5
|
22
22
|
- ruby:2.6
|
23
23
|
- ruby:2.7
|
24
|
+
- ruby:3.0
|
24
25
|
# TODO: add jruby and truffleruby
|
25
26
|
steps:
|
26
27
|
- uses: actions/checkout@v2
|
28
|
+
- uses: actions/cache@v2
|
29
|
+
with:
|
30
|
+
path: vendor/bundle
|
31
|
+
key: ${{ runner.os }}-${{ matrix.ruby }}-gems-${{ hashFiles('**/Gemfile.lock') }}
|
32
|
+
restore-keys: ${{ runner.os }}-gems-
|
27
33
|
- run: apt-get update && apt-get install -y nodejs # For execjs
|
28
34
|
- name: bundle install
|
29
|
-
run: bundle install -j$(nproc) --retry 3
|
35
|
+
run: bundle config path vendor/bundle && bundle install -j$(nproc) --retry 3
|
30
36
|
- run: bundle exec rake test
|
data/.gitignore
CHANGED
data/CHANGELOG.md
CHANGED
@@ -4,6 +4,24 @@ All notable changes to this project will be documented in this file. This
|
|
4
4
|
project adheres to [Semantic Versioning](http://semver.org/). This change log is based upon
|
5
5
|
[keep-a-changelog](https://github.com/olivierlacan/keep-a-changelog).
|
6
6
|
|
7
|
+
## [2.14.1](https://github.com/k0kubun/hamlit/compare/v2.14.0...v2.14.1) - 2021-01-07
|
8
|
+
|
9
|
+
### Added
|
10
|
+
|
11
|
+
- Add `-c` option to `hamlit compile` that works like `haml -c` [#166](https://github.com/k0kubun/hamlit/issues/166)
|
12
|
+
*Thanks to @knightq*
|
13
|
+
|
14
|
+
## [2.14.0](https://github.com/k0kubun/hamlit/compare/v2.13.2...v2.14.0) - 2021-01-07
|
15
|
+
|
16
|
+
### Changed
|
17
|
+
|
18
|
+
- CLI changes
|
19
|
+
- Remove `-c` shorthand of `--color`.
|
20
|
+
- Make `--color` default. Please use `--no-color` to disable it.
|
21
|
+
- `--color` uses IRB instead of Pry for syntax highlight.
|
22
|
+
- Syntax highlight of `hamlit compile` is enabled only with IRB of Ruby 2.7+.
|
23
|
+
- Syntax highlight of `hamlit parse` / `hamlit temple` is enabled only with IRB of Ruby 3.1+.
|
24
|
+
|
7
25
|
## [2.13.2](https://github.com/k0kubun/hamlit/compare/v2.13.1...v2.13.2) - 2020-12-27
|
8
26
|
|
9
27
|
### Added
|
data/README.md
CHANGED
@@ -2,6 +2,7 @@
|
|
2
2
|
|
3
3
|
[](http://badge.fury.io/rb/hamlit)
|
4
4
|
[](https://travis-ci.org/k0kubun/hamlit)
|
5
|
+
[](https://github.com/k0kubun/hamlit/actions?query=workflow%3Atest)
|
5
6
|
|
6
7
|
Hamlit is a high performance [Haml](https://github.com/haml/haml) implementation.
|
7
8
|
|
data/lib/hamlit/cli.rb
CHANGED
@@ -13,25 +13,33 @@ module Hamlit
|
|
13
13
|
def render(file)
|
14
14
|
process_load_options
|
15
15
|
code = generate_code(file)
|
16
|
-
puts eval(code)
|
16
|
+
puts eval(code, binding, file)
|
17
17
|
end
|
18
18
|
|
19
19
|
desc 'compile HAML', 'Show compile result'
|
20
20
|
option :actionview, type: :boolean, default: false, aliases: %w[-a]
|
21
|
-
option :color, type: :boolean, default:
|
21
|
+
option :color, type: :boolean, default: true
|
22
|
+
option :check, type: :boolean, default: false, aliases: %w[-c]
|
22
23
|
def compile(file)
|
23
24
|
code = generate_code(file)
|
25
|
+
if options[:check]
|
26
|
+
if error = validate_ruby(code, file)
|
27
|
+
abort error.message.split("\n").first
|
28
|
+
end
|
29
|
+
puts "Syntax OK"
|
30
|
+
return
|
31
|
+
end
|
24
32
|
puts_code(code, color: options[:color])
|
25
33
|
end
|
26
34
|
|
27
35
|
desc 'temple HAML', 'Show temple intermediate expression'
|
28
|
-
option :color, type: :boolean, default:
|
36
|
+
option :color, type: :boolean, default: true
|
29
37
|
def temple(file)
|
30
38
|
pp_object(generate_temple(file), color: options[:color])
|
31
39
|
end
|
32
40
|
|
33
41
|
desc 'parse HAML', 'Show parse result'
|
34
|
-
option :color, type: :boolean, default:
|
42
|
+
option :color, type: :boolean, default: true
|
35
43
|
def parse(file)
|
36
44
|
pp_object(generate_ast(file), color: options[:color])
|
37
45
|
end
|
@@ -107,24 +115,40 @@ module Hamlit
|
|
107
115
|
render(args.first.to_s)
|
108
116
|
end
|
109
117
|
|
110
|
-
def puts_code(code, color:
|
118
|
+
def puts_code(code, color: true)
|
119
|
+
begin
|
120
|
+
require 'irb/color'
|
121
|
+
rescue LoadError
|
122
|
+
color = false
|
123
|
+
end
|
111
124
|
if color
|
112
|
-
|
113
|
-
puts Pry.Code(code).highlighted
|
125
|
+
puts IRB::Color.colorize_code(code)
|
114
126
|
else
|
115
127
|
puts code
|
116
128
|
end
|
117
129
|
end
|
118
130
|
|
119
131
|
# Enable colored pretty printing only for development environment.
|
120
|
-
def pp_object(arg, color:
|
132
|
+
def pp_object(arg, color: true)
|
133
|
+
begin
|
134
|
+
require 'irb/color_printer'
|
135
|
+
rescue LoadError
|
136
|
+
color = false
|
137
|
+
end
|
121
138
|
if color
|
122
|
-
|
123
|
-
Pry::ColorPrinter.pp(arg)
|
139
|
+
IRB::ColorPrinter.pp(arg)
|
124
140
|
else
|
125
141
|
require 'pp'
|
126
142
|
pp(arg)
|
127
143
|
end
|
128
144
|
end
|
145
|
+
|
146
|
+
def validate_ruby(code, file)
|
147
|
+
begin
|
148
|
+
eval("BEGIN {return nil}; #{code}", binding, file)
|
149
|
+
rescue ::SyntaxError # Not to be confused with Hamlit::SyntaxError
|
150
|
+
$!
|
151
|
+
end
|
152
|
+
end
|
129
153
|
end
|
130
154
|
end
|
data/lib/hamlit/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hamlit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.14.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Takashi Kokubun
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-01-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: temple
|
@@ -376,7 +376,7 @@ homepage: https://github.com/k0kubun/hamlit
|
|
376
376
|
licenses:
|
377
377
|
- MIT
|
378
378
|
metadata: {}
|
379
|
-
post_install_message:
|
379
|
+
post_install_message:
|
380
380
|
rdoc_options: []
|
381
381
|
require_paths:
|
382
382
|
- lib
|
@@ -391,8 +391,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
391
391
|
- !ruby/object:Gem::Version
|
392
392
|
version: '0'
|
393
393
|
requirements: []
|
394
|
-
rubygems_version: 3.
|
395
|
-
signing_key:
|
394
|
+
rubygems_version: 3.3.0.dev
|
395
|
+
signing_key:
|
396
396
|
specification_version: 4
|
397
397
|
summary: High Performance Haml Implementation
|
398
398
|
test_files: []
|