hamlit 2.0.2 → 2.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +0 -3
- data/CHANGELOG.md +17 -0
- data/benchmark/ext/build_data.rb +4 -2
- data/ext/hamlit/hamlit.c +7 -7
- data/hamlit.gemspec +0 -1
- data/lib/hamlit/cli.rb +15 -0
- data/lib/hamlit/version.rb +1 -1
- metadata +2 -16
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 28e31e01cf12674dcc7b8330ff324e2a02c98c5d
|
4
|
+
data.tar.gz: 373c61913cd374e989b8c0a6f35ab36a59282920
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9330c82678ae6fd23fe70b15a3460f5a6df890fe0008d18f8f2396dd749c66defb62a32cfa46d57e0b5360172327c5c9793a66c186e47ea9cc9d00e6f62fdef8
|
7
|
+
data.tar.gz: 381b81db56a1e1230e84080c1d5eb1b70ede41b46f976708a69f15a556a483a62b801976c2f80e71980c46a4a930d933c43de7d9a8a39ef97370d3ec94dfdf95
|
data/.travis.yml
CHANGED
@@ -14,8 +14,6 @@ matrix:
|
|
14
14
|
env: TASK=test
|
15
15
|
- rvm: 2.2
|
16
16
|
env: TASK=test
|
17
|
-
- rvm: 2.2
|
18
|
-
env: TASK=bench TEMPLATE=benchmark/dynamic_boolean_attribute.haml
|
19
17
|
- rvm: 2.2
|
20
18
|
env: TASK=bench TEMPLATE=benchmark/boolean_attribute.haml,benchmark/class_attribute.haml,benchmark/id_attribute.haml,benchmark/data_attribute.haml,benchmark/common_attribute.haml
|
21
19
|
- rvm: 2.2
|
@@ -31,7 +29,6 @@ matrix:
|
|
31
29
|
- rvm: 2.2
|
32
30
|
env: TASK=bench TEMPLATE=test/haml/templates/standard.haml COMPILE=1
|
33
31
|
allow_failures:
|
34
|
-
- env: TASK=bench TEMPLATE=benchmark/dynamic_boolean_attribute.haml
|
35
32
|
- env: TASK=bench TEMPLATE=benchmark/boolean_attribute.haml,benchmark/class_attribute.haml,benchmark/id_attribute.haml,benchmark/data_attribute.haml,benchmark/common_attribute.haml
|
36
33
|
- env: TASK=bench TEMPLATE=benchmark/dynamic_attributes/boolean_attribute.haml,benchmark/dynamic_attributes/class_attribute.haml,benchmark/dynamic_attributes/id_attribute.haml,benchmark/dynamic_attributes/data_attribute.haml,benchmark/dynamic_attributes/common_attribute.haml
|
37
34
|
- env: TASK=bench SLIM_BENCH=1
|
data/CHANGELOG.md
CHANGED
@@ -7,6 +7,23 @@ project adheres to [Semantic Versioning](http://semver.org/). This change log is
|
|
7
7
|
## [HEAD]
|
8
8
|
- No changes
|
9
9
|
|
10
|
+
## [2.1.0] - 2015-12-14
|
11
|
+
|
12
|
+
## Added
|
13
|
+
|
14
|
+
- `-I` and `-r` options are added to `hamlit render` command
|
15
|
+
[#37](https://github.com/k0kubun/hamlit/issues/37). *Thanks to @jhurliman*
|
16
|
+
|
17
|
+
## Changed
|
18
|
+
|
19
|
+
- Dropped obsolete `escape_utils` gem dependency
|
20
|
+
[#48](https://github.com/k0kubun/hamlit/pull/48). *Thanks to @eagletmt*
|
21
|
+
|
22
|
+
## Fixed
|
23
|
+
|
24
|
+
- Accept NUL character in attribute keys
|
25
|
+
[#49](https://github.com/k0kubun/hamlit/pull/49). *Thanks to @eagletmt*
|
26
|
+
|
10
27
|
## [2.0.2] - 2015-12-12
|
11
28
|
|
12
29
|
### Fixed
|
data/benchmark/ext/build_data.rb
CHANGED
@@ -9,7 +9,9 @@ require_relative '../utils/benchmark_ips_extension'
|
|
9
9
|
h = { 'user' => { id: 1234, name: 'k0kubun' }, book_id: 5432 }
|
10
10
|
|
11
11
|
Benchmark.ips do |x|
|
12
|
-
|
13
|
-
|
12
|
+
quote = "'"
|
13
|
+
faml_options = { data: h }
|
14
|
+
x.report("Faml::AB.build") { Faml::AttributeBuilder.build(quote, true, nil, faml_options) }
|
15
|
+
x.report("Hamlit.build_data") { Hamlit::AttributeBuilder.build_data(true, quote, h) }
|
14
16
|
x.compare!
|
15
17
|
end
|
data/ext/hamlit/hamlit.c
CHANGED
@@ -29,9 +29,9 @@ delete_falsey_values(VALUE values)
|
|
29
29
|
}
|
30
30
|
|
31
31
|
static int
|
32
|
-
str_eq(VALUE str, const char *cstr)
|
32
|
+
str_eq(VALUE str, const char *cstr, long n)
|
33
33
|
{
|
34
|
-
return
|
34
|
+
return RSTRING_LEN(str) == n && memcmp(RSTRING_PTR(str), cstr, n) == 0;
|
35
35
|
}
|
36
36
|
|
37
37
|
static VALUE
|
@@ -303,7 +303,7 @@ merge_all_attrs_i(VALUE key, VALUE value, VALUE merged)
|
|
303
303
|
VALUE array;
|
304
304
|
|
305
305
|
key = to_s(key);
|
306
|
-
if (str_eq(key, "id") || str_eq(key, "class") || str_eq(key, "data")) {
|
306
|
+
if (str_eq(key, "id", 2) || str_eq(key, "class", 5) || str_eq(key, "data", 4)) {
|
307
307
|
array = rb_hash_aref(merged, key);
|
308
308
|
if (NIL_P(array)) {
|
309
309
|
array = rb_ary_new2(1);
|
@@ -333,7 +333,7 @@ int
|
|
333
333
|
is_boolean_attribute(VALUE key)
|
334
334
|
{
|
335
335
|
VALUE boolean_attributes;
|
336
|
-
if (str_eq(rb_str_substr(key, 0, 5), "data-")) return 1;
|
336
|
+
if (str_eq(rb_str_substr(key, 0, 5), "data-", 5)) return 1;
|
337
337
|
|
338
338
|
boolean_attributes = rb_const_get(mAttributeBuilder, id_boolean_attributes);
|
339
339
|
return RTEST(rb_ary_includes(boolean_attributes, key));
|
@@ -412,11 +412,11 @@ hamlit_build(VALUE escape_attrs, VALUE quote, VALUE format, VALUE object_ref, VA
|
|
412
412
|
for (i = 0; i < RARRAY_LEN(keys); i++) {
|
413
413
|
key = rb_ary_entry(keys, i);
|
414
414
|
value = rb_hash_aref(attrs, key);
|
415
|
-
if (str_eq(key, "id")) {
|
415
|
+
if (str_eq(key, "id", 2)) {
|
416
416
|
hamlit_build_for_id(escape_attrs, quote, buf, value);
|
417
|
-
} else if (str_eq(key, "class")) {
|
417
|
+
} else if (str_eq(key, "class", 5)) {
|
418
418
|
hamlit_build_for_class(escape_attrs, quote, buf, value);
|
419
|
-
} else if (str_eq(key, "data")) {
|
419
|
+
} else if (str_eq(key, "data", 4)) {
|
420
420
|
hamlit_build_for_data(escape_attrs, quote, buf, value);
|
421
421
|
} else if (is_boolean_attribute(key)) {
|
422
422
|
hamlit_build_for_boolean(escape_attrs, quote, format, buf, key, value);
|
data/hamlit.gemspec
CHANGED
data/lib/hamlit/cli.rb
CHANGED
@@ -4,7 +4,10 @@ require 'thor'
|
|
4
4
|
module Hamlit
|
5
5
|
class CLI < Thor
|
6
6
|
desc 'render HAML', 'Render haml template'
|
7
|
+
option :load_path, type: :string, aliases: %w[-I]
|
8
|
+
option :require, type: :string, aliases: %w[-r]
|
7
9
|
def render(file)
|
10
|
+
process_load_options
|
8
11
|
code = generate_code(file)
|
9
12
|
puts eval(code)
|
10
13
|
end
|
@@ -27,6 +30,18 @@ module Hamlit
|
|
27
30
|
|
28
31
|
private
|
29
32
|
|
33
|
+
def process_load_options
|
34
|
+
if options[:load_path]
|
35
|
+
options[:load_path].split(':').each do |dir|
|
36
|
+
$LOAD_PATH.unshift(dir) unless $LOAD_PATH.include?(dir)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
if options[:require]
|
41
|
+
require options[:require]
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
30
45
|
def generate_code(file)
|
31
46
|
template = File.read(file)
|
32
47
|
if options[:actionview]
|
data/lib/hamlit/version.rb
CHANGED
metadata
CHANGED
@@ -1,29 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hamlit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0
|
4
|
+
version: 2.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Takashi Kokubun
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-12-
|
11
|
+
date: 2015-12-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
-
- !ruby/object:Gem::Dependency
|
14
|
-
name: escape_utils
|
15
|
-
requirement: !ruby/object:Gem::Requirement
|
16
|
-
requirements:
|
17
|
-
- - ">="
|
18
|
-
- !ruby/object:Gem::Version
|
19
|
-
version: '0'
|
20
|
-
type: :runtime
|
21
|
-
prerelease: false
|
22
|
-
version_requirements: !ruby/object:Gem::Requirement
|
23
|
-
requirements:
|
24
|
-
- - ">="
|
25
|
-
- !ruby/object:Gem::Version
|
26
|
-
version: '0'
|
27
13
|
- !ruby/object:Gem::Dependency
|
28
14
|
name: temple
|
29
15
|
requirement: !ruby/object:Gem::Requirement
|