haml_i18n_lint 0.1.0 → 0.2.0

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: ecf304ef294eaedc5987943e37c82a6fae828249
4
- data.tar.gz: ecf66fcdc35555df72196fb148151145339b1e98
3
+ metadata.gz: 78805af5b853ddbec51cf86d6c36a4066a3092b5
4
+ data.tar.gz: a3011cb66c6713c8477f19bb4d696c1fa7d0752b
5
5
  SHA512:
6
- metadata.gz: 8ea076bc580ead0b8e3a2577b0d790351e05abdb4306deac81b45460ad34389715d02269cd7a6e900754551a90a14315c5e6c44495549823850bf6bdfde74ad7
7
- data.tar.gz: f7ff2a318c1d17c9335fe512fb99bb1ecd4bb84bc8700384665eae61359ca84ae2d5426347fe09a0b84e2afc05736bb5d7b6bc6bf45082f6d78def218e49500e
6
+ metadata.gz: 159555954c585b89cf66e299c7d7f4e8fb14681f13261da1ddd30c472bd2f799d8c50f4dfd012f4909d19ae7e578e5d594c87edf6fc01f110f5c8098f92259b2
7
+ data.tar.gz: fb19c060fd2cc561d2dc8b27a253974eea8e0a9bdae8fc530db40a7470db44f87143ed06b21878cb0660e974767387e49870af19a65df2199839e9cd39c5badf
data/README.md CHANGED
@@ -38,7 +38,7 @@ The configuration file sample:
38
38
  # You can override Config#need_i18n? that returns the content in Haml template need i18n or not.
39
39
  def need_i18n?(content)
40
40
  # the default behaviours is ignore white spaces and digits
41
- /^[\s]+$/ !~ content && /[A-Za-z]/ =~ content
41
+ /^[\s]+$/ !~ content && /\p{Alpha}/ =~ content
42
42
  end
43
43
 
44
44
  # You can override Config#report in configuration file
@@ -5,3 +5,7 @@ source "https://rubygems.org"
5
5
  gem "haml", "~> 5.0.0"
6
6
 
7
7
  gemspec path: "../"
8
+
9
+ if ENV['TRAVIS']
10
+ gem "coveralls"
11
+ end
@@ -27,5 +27,4 @@ Gem::Specification.new do |spec|
27
27
  spec.add_development_dependency "test-unit"
28
28
  spec.add_development_dependency "bundler", "~> 1.14"
29
29
  spec.add_development_dependency "rake", "~> 10.0"
30
- spec.add_development_dependency "coveralls"
31
30
  end
@@ -11,15 +11,10 @@ module HamlI18nLint
11
11
  end
12
12
  end
13
13
 
14
- # @return [String] the translate method name
15
- def i18n_method
16
- 't'
17
- end
18
-
19
14
  # @param content [String] the text content found in haml template
20
15
  # @return [true, false] the content need i18n or not.
21
16
  def need_i18n?(content)
22
- /^[\s]+$/ !~ content && /[A-Za-z]/ =~ content
17
+ /^[\s]+$/ !~ content && /\p{Alpha}/ =~ content
23
18
  end
24
19
 
25
20
  # Output the formatted result
@@ -45,6 +40,11 @@ module HamlI18nLint
45
40
  Dir[*@options.files]
46
41
  end
47
42
 
43
+ # @return [String] the list of methods, which takes string. The string is no translation required.
44
+ def ignore_methods
45
+ %w(t render)
46
+ end
47
+
48
48
  private
49
49
 
50
50
  def load_config(config_content)
@@ -6,7 +6,12 @@ module HamlI18nLint
6
6
  super
7
7
  program = Ripper.sexp(@node.value[:text]).flatten
8
8
  str_num = program.flatten.count { |t| t == :string_literal }
9
- tstr_num = program.each_with_index.count { |t, i| [t, program[i + 1], program[i + 2]] == [:fcall, :@ident, lint_config.i18n_method.to_s] }
9
+ tstr_num = program.each_with_index.count do |t, i|
10
+ lint_config.ignore_methods.any? do |m|
11
+ [t, program[i + 1], program[i + 2]] == [:fcall, :@ident, m.to_s] ||
12
+ [t, program[i + 1], program[i + 2]] == [:command, :@ident, m.to_s]
13
+ end
14
+ end
10
15
 
11
16
  lint_add_matched_node(@node) unless str_num == tstr_num
12
17
  end
@@ -1,3 +1,3 @@
1
1
  module HamlI18nLint
2
- VERSION = "0.1.0"
2
+ VERSION = "0.2.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: haml_i18n_lint
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Seiei Miyagi
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-05-03 00:00:00.000000000 Z
11
+ date: 2017-05-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: haml
@@ -94,20 +94,6 @@ dependencies:
94
94
  - - "~>"
95
95
  - !ruby/object:Gem::Version
96
96
  version: '10.0'
97
- - !ruby/object:Gem::Dependency
98
- name: coveralls
99
- requirement: !ruby/object:Gem::Requirement
100
- requirements:
101
- - - ">="
102
- - !ruby/object:Gem::Version
103
- version: '0'
104
- type: :development
105
- prerelease: false
106
- version_requirements: !ruby/object:Gem::Requirement
107
- requirements:
108
- - - ">="
109
- - !ruby/object:Gem::Version
110
- version: '0'
111
97
  description:
112
98
  email:
113
99
  - hanachin@gmail.com
@@ -159,7 +145,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
159
145
  version: '0'
160
146
  requirements: []
161
147
  rubyforge_project:
162
- rubygems_version: 2.6.11
148
+ rubygems_version: 2.6.8
163
149
  signing_key:
164
150
  specification_version: 4
165
151
  summary: find out not translated yet plain text from your Haml template