haml_i18n_lint 0.10.0 → 0.11.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d33d3da626c5b6b8b7431491df426c3a04ab815f
4
- data.tar.gz: 45cdf88fbe8861263baea6e8e98f7a428022652b
3
+ metadata.gz: 92371c38e13089e237c3f9208a03300effdbad22
4
+ data.tar.gz: 12be2772d233c1a7f173857f6de0bdaf4e0faf01
5
5
  SHA512:
6
- metadata.gz: 5ca4f944d1a8ae07523ce545b8f22fbe408c628916a8ab713405b3df793897a5f1af5b90aeeb784c9d6aa17a9ed282cae3c274e632d9f59aa8823f289c0dd059
7
- data.tar.gz: dbad78a31f25ffd4c14b6e5b5decac9a1ecbfe528d1d319e4a1c465f8d5ba15c2c0c064e779ad2c2e070cc4a70ab17a06d81fc0c12505accfec7f65a8dc26baa
6
+ metadata.gz: 261397e52363434dd01c5410c449b7e674770db7faff5a3872a9cf227e917884b15a1a2f2ff541ef136e0d3b2e90dec2de072475d95d520a32badaf36125c815
7
+ data.tar.gz: c5ba7e28a4d3eb3b3f4bc4fec4c0d5002ab0bcda68359a414595fcfce5d1913c86fa0200a2fe6a00f8c579ed607e0947b8fa4a217498515b09b9492fec449189
checksums.yaml.gz.sig CHANGED
Binary file
@@ -8,9 +8,6 @@ Gem::Specification.new do |spec|
8
8
  spec.version = HamlI18nLint::VERSION
9
9
  spec.authors = ["Seiei Miyagi"]
10
10
  spec.email = ["hanachin@gmail.com"]
11
- spec.cert_chain = ["certs/hanachin.pem"]
12
- spec.signing_key = File.expand_path("~/.ssh/gem-private_key.pem") if $0 =~ /gem\z/
13
-
14
11
  spec.summary = "find out not translated yet plain text from your Haml template"
15
12
  spec.homepage = "https://github.com/okinawarb/haml_i18n_lint"
16
13
  spec.license = "MIT"
@@ -1,3 +1,5 @@
1
+ require "haml_i18n_lint/ruby_parser"
2
+
1
3
  module HamlI18nLint
2
4
  class Linter
3
5
  module CompilerExtension
@@ -111,7 +113,7 @@ module HamlI18nLint
111
113
  if Ripper.lex(script.rstrip).any? { |(_, on_kw, kw_do)| on_kw == :on_kw && kw_do == "do" }
112
114
  script << "\nend\n"
113
115
  end
114
- sexp = Ripper.sexp(script)
116
+ sexp = RubyParser.sexp(script)
115
117
 
116
118
  string_literal_found = false
117
119
  walk = -> (sexp) do
@@ -121,7 +123,7 @@ module HamlI18nLint
121
123
  return if lint_config.ignore_keys.any? { |k| lint_assoc_new?(sexp, k) }
122
124
 
123
125
  if lint_string_literal?(sexp) && lint_string_literal_need_i18n?(sexp)
124
- string_literal_found = true
126
+ string_literal_found = sexp[1]
125
127
  return
126
128
  end
127
129
 
@@ -132,7 +134,7 @@ module HamlI18nLint
132
134
 
133
135
  walk.(sexp)
134
136
 
135
- lint_add(script) if string_literal_found
137
+ lint_add(string_literal_found) if string_literal_found
136
138
  end
137
139
 
138
140
  end
@@ -1,5 +1,3 @@
1
- require 'ripper'
2
-
3
1
  module HamlI18nLint
4
2
  # Linter linting a Haml template
5
3
  class Linter
@@ -0,0 +1,54 @@
1
+ require "ripper"
2
+
3
+ module HamlI18nLint
4
+ class RubyParser < Ripper::SexpBuilderPP
5
+
6
+ def self.sexp(src, filename = '-', lineno = 1)
7
+ builder = new(src, filename, lineno)
8
+ sexp = builder.parse
9
+ sexp unless builder.error?
10
+ end
11
+
12
+ def initialize(src, *)
13
+ @src = src
14
+ super
15
+ end
16
+
17
+ def on_tstring_beg(tok)
18
+ @buf ||= []
19
+ @buf << [[lineno, column]]
20
+ super
21
+ end
22
+
23
+ def on_heredoc_beg(tok)
24
+ @buf ||= []
25
+ @buf << [[lineno, column]]
26
+ super
27
+ end
28
+
29
+ def on_tstring_end(tok)
30
+ @buf.last << [lineno, column]
31
+ super
32
+ end
33
+
34
+ def on_heredoc_end(tok)
35
+ @buf.last << [lineno, column + tok.size-1]
36
+ super
37
+ end
38
+
39
+ def on_string_literal(*args)
40
+ pos = @buf.pop
41
+ lineno_pos = pos.map(&:first)
42
+ column_pos = pos.map(&:last)
43
+ lines = @src.lines[lineno_pos.first-1...lineno_pos.last]
44
+ if lineno_pos.first == lineno_pos.last
45
+ lines[0] = lines[0].byteslice(column_pos.first..column_pos.last).force_encoding(@src.encoding)
46
+ else
47
+ lines[0] = lines[0].dup.tap { |l| l.force_encoding(Encoding::BINARY)[0...column_pos.first] = ''; l.force_encoding(@src.encoding) }
48
+ lines[-1] = lines[-1].dup.tap { |l| l.force_encoding(Encoding::BINARY)[column_pos.last+1..-1] = ''; l.force_encoding(@src.encoding) }
49
+ end
50
+ args.unshift(:string_literal, lines.join, pos)
51
+ args
52
+ end
53
+ end
54
+ end
@@ -1,3 +1,3 @@
1
1
  module HamlI18nLint
2
- VERSION = "0.10.0"
2
+ VERSION = "0.11.0"
3
3
  end
data.tar.gz.sig CHANGED
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: haml_i18n_lint
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.10.0
4
+ version: 0.11.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Seiei Miyagi
@@ -30,7 +30,7 @@ cert_chain:
30
30
  +zDzgwp9Z4A8i47ioz1YEGIkQhDKZeGQznwkht0zsrtswEAiOisL5uJDtWvQiwt6
31
31
  a9nBgrpUm8NHrucdUDtMYjixgmU=
32
32
  -----END CERTIFICATE-----
33
- date: 2017-05-13 00:00:00.000000000 Z
33
+ date: 2017-05-30 00:00:00.000000000 Z
34
34
  dependencies:
35
35
  - !ruby/object:Gem::Dependency
36
36
  name: haml
@@ -140,7 +140,6 @@ files:
140
140
  - Rakefile
141
141
  - bin/console
142
142
  - bin/setup
143
- - certs/hanachin.pem
144
143
  - examples/output_yaml.rb
145
144
  - examples/react.rb
146
145
  - examples/sample.rb
@@ -156,6 +155,7 @@ files:
156
155
  - lib/haml_i18n_lint/linter5.rb
157
156
  - lib/haml_i18n_lint/linter5/compiler_extension.rb
158
157
  - lib/haml_i18n_lint/options.rb
158
+ - lib/haml_i18n_lint/ruby_parser.rb
159
159
  - lib/haml_i18n_lint/runner.rb
160
160
  - lib/haml_i18n_lint/version.rb
161
161
  homepage: https://github.com/okinawarb/haml_i18n_lint
metadata.gz.sig CHANGED
@@ -1,2 +1,3 @@
1
- �9��ql�ʲn4X�����&%�D}� Rs(|��{�'96r ̘A�kBI��"r��#��p�D�5?)��9N�'�>��I�2��`���. ��>�*�$B����%�bj}�ֱ
2
- Q�Ϋ4����_��!�9�)�T������h��5; �A{7���P:�z"���;�E� �+�
1
+ h|a }�G4�l1w���:���A1���h̝�rkY��}p*Lr��#"�.�۬m��mV��s��kr�”%�p���@ L�:j��I\.wc7=L}<'��*u\�϶��C��� �����|���Hvѥ�
2
+ iU�������tC��W�B{��/[w������i��Ͱ=���4@�
3
+ K���7z�mᐢY�:ҁ���M��4���R��;��X kG��Y�-U���҆�䁜��
data/certs/hanachin.pem DELETED
@@ -1,21 +0,0 @@
1
- -----BEGIN CERTIFICATE-----
2
- MIIDcDCCAligAwIBAgIBATANBgkqhkiG9w0BAQUFADA/MREwDwYDVQQDDAhoYW5h
3
- Y2hpbjEVMBMGCgmSJomT8ixkARkWBWdtYWlsMRMwEQYKCZImiZPyLGQBGRYDY29t
4
- MB4XDTE3MDUwNDE0NDYxOVoXDTE4MDUwNDE0NDYxOVowPzERMA8GA1UEAwwIaGFu
5
- YWNoaW4xFTATBgoJkiaJk/IsZAEZFgVnbWFpbDETMBEGCgmSJomT8ixkARkWA2Nv
6
- bTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAN03A8Jvk7k0aVLmIHrj
7
- soZLOppADifbdH+FoXUfWXFeu9x/hq8UsuMyTuSF6oNZRihzk7yakKBcv8B44wc2
8
- Kfui97h+UOqBib5oPZOrJjW34dSfnHgdsPskZRK1yvMW0X88q7K+9iBT78Xpkf40
9
- XkDh7mEyA0sC25n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