hamlit 1.6.6 → 1.6.7

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: bda4c6ff22c6943b23ebaf8358f66b2f6f01fb66
4
- data.tar.gz: 9db2e3e2d27fa2efd0c485cd8441ab07c83478d4
3
+ metadata.gz: ed569855be3cfd062957586173c438777bbad1bf
4
+ data.tar.gz: cb9f5d24e5290a801e38a9c1558e01e18dfd2c8b
5
5
  SHA512:
6
- metadata.gz: bb8134311dd9d4cf6aa281abfbf5070093bb887c65a18a37a6c6e152720b1f20a6b88074ea908e8fb6b50ad0fb3c512745d9d54b01ff48246c9312518a37738a
7
- data.tar.gz: 4a42cdc7aac2be14ca3f575dec01d7a29add11edff720b0f8a74e94d0227bda47efd4d71b6e79d0fa278cfe99085f6d5b743b1fe011da52c985c6a7e109020b1
6
+ metadata.gz: c599f0dcbac927f422137f528949f4ee6111a3f8104caf062e7abe1e23dc861f8ba4f3aae4119bf4dc72b2b5d86265250e7d7dd1d8a967d1d0d887fa2f04c98c
7
+ data.tar.gz: 8f53b9e6279a35eb5430846173017b09a3b88350b8c29c8f113c2bef31735524760ea9b19e8a12d185f7b35df5fd8e4a3b5938af6f8a705ca71d9259c3be260e
data/CHANGELOG.md CHANGED
@@ -1,3 +1,8 @@
1
+ ## v1.6.7
2
+
3
+ - Remove unused variables and avoid shadowing
4
+ - To suppress warnings in application using `rspec --warnings`
5
+
1
6
  ## v1.6.6
2
7
 
3
8
  - Allow hyphenated HTML-style attributes
data/README.md CHANGED
@@ -1,4 +1,9 @@
1
- # Hamlit [![Build Status](https://travis-ci.org/k0kubun/hamlit.svg?branch=master)](https://travis-ci.org/k0kubun/hamlit)
1
+ # Hamlit
2
+
3
+ [![Gem Version](https://badge.fury.io/rb/hamlit.svg)](http://badge.fury.io/rb/hamlit)
4
+ [![Build Status](https://travis-ci.org/k0kubun/hamlit.svg?branch=master)](https://travis-ci.org/k0kubun/hamlit)
5
+ [![Coverage Status](https://coveralls.io/repos/k0kubun/hamlit/badge.svg?branch=master)](https://coveralls.io/r/k0kubun/hamlit?branch=master)
6
+ [![Code Climate](https://codeclimate.com/github/k0kubun/hamlit/badges/gpa.svg)](https://codeclimate.com/github/k0kubun/hamlit)
2
7
 
3
8
  Hamlit is a high performance [haml](https://github.com/haml/haml) implementation.
4
9
 
data/hamlit.gemspec CHANGED
@@ -26,6 +26,7 @@ Gem::Specification.new do |spec|
26
26
  spec.add_development_dependency "benchmark-ips"
27
27
  spec.add_development_dependency "bundler"
28
28
  spec.add_development_dependency "coffee-script"
29
+ spec.add_development_dependency "coveralls"
29
30
  spec.add_development_dependency "erubis"
30
31
  spec.add_development_dependency "faml"
31
32
  spec.add_development_dependency "haml"
@@ -35,6 +36,7 @@ Gem::Specification.new do |spec|
35
36
  spec.add_development_dependency "redcarpet"
36
37
  spec.add_development_dependency "rspec", ">= 3"
37
38
  spec.add_development_dependency "sass"
39
+ spec.add_development_dependency "simplecov"
38
40
  spec.add_development_dependency "slim"
39
41
  spec.add_development_dependency "therubyracer"
40
42
  spec.add_development_dependency "unindent"
@@ -21,8 +21,8 @@ module Hamlit
21
21
 
22
22
  def build(*args)
23
23
  result = ''
24
- attributes = args.inject({}) do |attributes, arg|
25
- merge_attributes(attributes, arg)
24
+ attributes = args.inject({}) do |attrs, arg|
25
+ merge_attributes(attrs, arg)
26
26
  end
27
27
 
28
28
  attributes.each do |key, value|
@@ -58,7 +58,7 @@ module Hamlit
58
58
 
59
59
  def read_value!(tokens)
60
60
  skip_tokens!(tokens, :on_sp)
61
- (row, col), type, str = tokens.shift
61
+ _, _, str = tokens.shift
62
62
  return nil if str != '='
63
63
 
64
64
  skip_tokens!(tokens, :on_sp)
@@ -79,8 +79,7 @@ module Hamlit
79
79
  open_count = 0
80
80
 
81
81
  all_tokens.each do |token|
82
- (row, col), type, str = token
83
- case type
82
+ case type_of(token)
84
83
  when :on_tstring_beg then open_count += 1
85
84
  when :on_tstring_end then open_count -= 1
86
85
  end
@@ -73,16 +73,16 @@ module Hamlit
73
73
  # Give up static compilation when variables are detected.
74
74
  def assert_static_value!(value)
75
75
  tokens = Ripper.lex(value)
76
- tokens.each do |(row, col), type, str|
77
- raise RuntimeBuild if type == :on_ident
76
+ tokens.each do |token|
77
+ raise RuntimeBuild if type_of(token) == :on_ident
78
78
  end
79
79
  end
80
80
 
81
81
  # Give up static compilation when the value is a variable or an array.
82
82
  def detect_joinable_value!(value)
83
83
  tokens = Ripper.lex(value)
84
- tokens.each do |(row, col), type, str|
85
- raise RuntimeBuild if JOINABLE_TOKENS.include?(type)
84
+ tokens.each do |token|
85
+ raise RuntimeBuild if JOINABLE_TOKENS.include?(type_of(token))
86
86
  end
87
87
  end
88
88
 
@@ -138,7 +138,7 @@ module Hamlit
138
138
  end
139
139
 
140
140
  def read_string!(tokens)
141
- (row, col), type, str = tokens.shift
141
+ _, type, str = tokens.shift
142
142
  return '' if type == :on_tstring_end
143
143
 
144
144
  raise SyntaxError if type_of(tokens.shift) != :on_tstring_end
@@ -147,7 +147,7 @@ module Hamlit
147
147
 
148
148
  def assert_rocket!(tokens, *types)
149
149
  skip_tokens!(tokens, :on_sp)
150
- (row, col), type, str = tokens.shift
150
+ _, type, str = tokens.shift
151
151
 
152
152
  raise SyntaxError unless type == :on_op && str == '=>'
153
153
  end
@@ -175,7 +175,7 @@ module Hamlit
175
175
  bracket: 0,
176
176
  }
177
177
 
178
- Ripper.lex(str).each do |(row, col), type, str|
178
+ Ripper.lex(str).each do |(_, col), type, _|
179
179
  if columns.include?(col) && open_count == 1 && count.values.all?(&:zero?)
180
180
  result << col
181
181
  end
@@ -46,7 +46,6 @@ module Hamlit
46
46
 
47
47
  offset = 2 # 2 is the length of '%' and marker
48
48
  open_pos = nil
49
- close_pos = nil
50
49
  open_count = 0
51
50
  literal = literalify_string(exp, marker)
52
51
 
@@ -74,7 +73,7 @@ module Hamlit
74
73
  literal = literalify_string(exp, marker)
75
74
  open_count = 0
76
75
 
77
- Ripper.lex(literal).each do |(row, col), type, str|
76
+ Ripper.lex(literal).each do |_, type, str|
78
77
  case type
79
78
  when :on_embexpr_beg
80
79
  open_count += 1
@@ -1,8 +1,11 @@
1
1
  require 'ripper'
2
+ require 'hamlit/concerns/lexable'
2
3
 
3
4
  module Hamlit
4
5
  module Concerns
5
6
  module Balanceable
7
+ include Lexable
8
+
6
9
  def fetch_balanced_braces(all_tokens)
7
10
  fetch_balanced_tokens(all_tokens, :on_lbrace, :on_rbrace)
8
11
  end
@@ -34,8 +37,7 @@ module Hamlit
34
37
  open_count = start_count
35
38
 
36
39
  all_tokens.each_with_index do |token, index|
37
- (row, col), type, str = token
38
- case type
40
+ case type_of(token)
39
41
  when open_token then open_count += 1
40
42
  when close_token then open_count -= 1
41
43
  end
@@ -51,8 +53,7 @@ module Hamlit
51
53
  open_count = start_count
52
54
 
53
55
  tokens.each do |token|
54
- (row, col), type, str = token
55
- case type
56
+ case type_of(token)
56
57
  when open_token then open_count += 1
57
58
  when close_token then open_count -= 1
58
59
  end
@@ -15,7 +15,7 @@ module Hamlit
15
15
  # Return nearest line's indent level since next line. This method ignores
16
16
  # empty line. It returns -1 if next_line does not exist.
17
17
  def next_indent
18
- return 1 if !@indent_space && fetch_indent(next_line).length > 0
18
+ return 1 if !defined?(@indent_space) && fetch_indent(next_line).length > 0
19
19
  count_indent(next_line)
20
20
  end
21
21
 
@@ -48,7 +48,7 @@ module Hamlit
48
48
  end
49
49
  @indent_logs << indent
50
50
 
51
- if !@indent_space && @indent_logs.last != ''
51
+ if !defined?(@indent_space) && @indent_logs.last != ''
52
52
  @indent_space = @indent_logs.last
53
53
  end
54
54
  validate_indentation_consistency!(indent)
@@ -59,7 +59,7 @@ module Hamlit
59
59
 
60
60
  def has_block?
61
61
  return false unless next_line
62
- return fetch_indent(next_line).length > 0 unless @indent_space
62
+ return fetch_indent(next_line).length > 0 unless defined?(@indent_space)
63
63
 
64
64
  next_indent > @current_indent
65
65
  end
@@ -69,7 +69,7 @@ module Hamlit
69
69
  # Validate the template is using consitent indentation, 2 spaces or a tab.
70
70
  def validate_indentation_consistency!(indent)
71
71
  return false if indent.empty?
72
- return false if !@indent_space || @indent_space.empty?
72
+ return false if !defined?(@indent_space) || @indent_space.empty?
73
73
 
74
74
  unless acceptable_indent?(indent)
75
75
  syntax_error!("Inconsistent indentation: #{indent_label(indent)} used for indentation, "\
@@ -105,7 +105,8 @@ module Hamlit
105
105
  end
106
106
 
107
107
  def indent_rule
108
- (@indent_space || '').length
108
+ return 0 unless defined?(@indent_space)
109
+ @indent_space.length
109
110
  end
110
111
 
111
112
  def fetch_indent(str)
@@ -82,7 +82,7 @@ module Hamlit
82
82
  prefix = find_prefix(code)
83
83
  code = "#{prefix}#{code}"
84
84
 
85
- Ripper.lex(code).each do |(row, col), type, str|
85
+ Ripper.lex(code).each do |_, type, str|
86
86
  if type == :on_comment
87
87
  with_comment = true
88
88
  next
@@ -65,8 +65,8 @@ module Hamlit
65
65
  end
66
66
 
67
67
  ast = []
68
- attributes.each do |name, values|
69
- ast << [:html, :attr, name, [:static, values.join(' ')]]
68
+ attributes.each do |attr, values|
69
+ ast << [:html, :attr, attr, [:static, values.join(' ')]]
70
70
  end
71
71
  ast
72
72
  end
@@ -1,3 +1,3 @@
1
1
  module Hamlit
2
- VERSION = "1.6.6"
2
+ VERSION = "1.6.7"
3
3
  end
data/spec/spec_helper.rb CHANGED
@@ -1,8 +1,16 @@
1
+ require 'coveralls'
2
+ require 'simplecov'
1
3
  require 'unindent'
2
4
  require_relative 'spec_helper/document_generator'
3
5
  require_relative 'spec_helper/render_helper'
4
6
  require_relative 'spec_helper/test_case'
5
7
 
8
+ SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[
9
+ SimpleCov::Formatter::HTMLFormatter,
10
+ Coveralls::SimpleCov::Formatter
11
+ ]
12
+ SimpleCov.start
13
+
6
14
  RSpec.configure do |config|
7
15
  config.include RenderHelper
8
16
 
@@ -80,7 +80,7 @@ module RenderHelper
80
80
 
81
81
  def expect_implementation(impl, test, options, type, &block)
82
82
  if type == :error
83
- expect { block.call(test, options) }.to raise_error
83
+ expect_any_error { block.call(test, options) }
84
84
  begin
85
85
  block.call(test, options)
86
86
  rescue Exception => e
@@ -101,6 +101,14 @@ module RenderHelper
101
101
  end
102
102
  end
103
103
 
104
+ def expect_any_error(&block)
105
+ origin = RSpec::Expectations.configuration.warn_about_potential_false_positives?
106
+ RSpec::Expectations.configuration.warn_about_potential_false_positives = false
107
+ expect { block.call(test, options) }.to raise_error
108
+ ensure
109
+ RSpec::Expectations.configuration.warn_about_potential_false_positives = origin
110
+ end
111
+
104
112
  def array_wrap(arr)
105
113
  return arr if arr.is_a?(Array)
106
114
  [arr]
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: 1.6.6
4
+ version: 1.6.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Takashi Kokubun
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-06-24 00:00:00.000000000 Z
11
+ date: 2015-06-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: escape_utils
@@ -108,6 +108,20 @@ dependencies:
108
108
  - - ">="
109
109
  - !ruby/object:Gem::Version
110
110
  version: '0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: coveralls
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
111
125
  - !ruby/object:Gem::Dependency
112
126
  name: erubis
113
127
  requirement: !ruby/object:Gem::Requirement
@@ -234,6 +248,20 @@ dependencies:
234
248
  - - ">="
235
249
  - !ruby/object:Gem::Version
236
250
  version: '0'
251
+ - !ruby/object:Gem::Dependency
252
+ name: simplecov
253
+ requirement: !ruby/object:Gem::Requirement
254
+ requirements:
255
+ - - ">="
256
+ - !ruby/object:Gem::Version
257
+ version: '0'
258
+ type: :development
259
+ prerelease: false
260
+ version_requirements: !ruby/object:Gem::Requirement
261
+ requirements:
262
+ - - ">="
263
+ - !ruby/object:Gem::Version
264
+ version: '0'
237
265
  - !ruby/object:Gem::Dependency
238
266
  name: slim
239
267
  requirement: !ruby/object:Gem::Requirement