find_t 1.0.1 → 1.0.3

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: 6e4d7134a5f1feba750d2fa4a4f0f2bc4d984bd5
4
- data.tar.gz: fd45ca500f534e058f4fe985e2b353afb3a1b52c
3
+ metadata.gz: a4a926c96e0aaa6482c0b05a2175e0e3754d111e
4
+ data.tar.gz: 5292bc4df7c41911ef089bdb5c22d8036f8c2038
5
5
  SHA512:
6
- metadata.gz: b1a3217a2383719f609e84d2b637295766d981b841ca4d856c0d405239805658064ea6e0c98de08c2adab23085fef0388eb17df87c533eb561d900109289c611
7
- data.tar.gz: 23f7c68b75a9f5a765aa614f303c803931246118cc41da6e3ce642c5ea4eaffba9fda45a6366ca03d80d39bdce3fd967eba18cbe163e00f87bc1f5c2cd88580f
6
+ metadata.gz: 59fe4d65a7ad78c9c5f7a19375f2b1ec2cb65bd4986c30421da0a1658be0ebdcf3b08c47575b61626e87f1d1f88f14890a1f8f1bbff2a4a69790bc7784a04121
7
+ data.tar.gz: c1e2ddd6d11c79cc4997c9eed100de668d15dc99748b3458ab13178eded3ae1ff3c043cece42e1759cb3c4c4ab771cc6230dc299c865dcaf9d1271952d66fee7
data/README.md CHANGED
@@ -1,7 +1,7 @@
1
1
  find_t
2
2
  ======
3
3
 
4
- **Find locale files of where translation for the key is defined.**
4
+ **Find locale files where translation for key is defined.**
5
5
 
6
6
  - Lookup all defined translations through languages
7
7
  - Detect conflicts for the same translation key across files
@@ -25,13 +25,13 @@ Synopsis
25
25
  --------
26
26
 
27
27
  ```
28
- find_t [--rails] {key}
28
+ find_t [-rails] {key}
29
29
  ```
30
30
 
31
- | Option | Description |
32
- | --------- | --------------------------------------------- |
33
- | `--rails` | Include full locale files in Rails' load path |
34
- | `{key}` | A translation key to search for |
31
+ | Option | Description |
32
+ | -------- | --------------------------------------------- |
33
+ | `-rails` | Include full locale files in Rails' load path |
34
+ | `{key}` | A translation key to search for |
35
35
 
36
36
 
37
37
  Sample
@@ -39,14 +39,15 @@ Sample
39
39
 
40
40
  ```sh
41
41
  $ find_t 'exception.projectshow'
42
+ Starting find_t at /Users/ykiwng/Develop/wantedly/wantedly
42
43
  Scanning...
43
44
 
44
- == en
45
+ ==> en
45
46
 
46
47
  - config/locales/99_naka/en.yml:23
47
48
  "Sorry, you have to sign up to view this page!"
48
49
 
49
- == ja
50
+ ==> ja
50
51
 
51
52
  - config/locales/01_model/ja.yml:3
52
53
  "この募集は、現在非公開です"
data/bin/find_t CHANGED
@@ -5,4 +5,4 @@ require 'bundler'
5
5
  require 'find_t'
6
6
  require 'find_t/cli'
7
7
 
8
- FindT::CLI.new ARGV, File.dirname(Bundler.default_gemfile)
8
+ FindT::CLI.new ARGV, File.dirname(Bundler.default_gemfile), STDOUT.isatty
data/find_t.gemspec CHANGED
@@ -8,8 +8,8 @@ Gem::Specification.new do |spec|
8
8
  spec.version = FindT::VERSION
9
9
  spec.authors = ['Yuki Iwanaga']
10
10
  spec.email = ['yuki@creasty.com']
11
- spec.summary = %q{Find locale files of where translation for the key is defined}
12
- spec.description = %q{Find locale files of where translation for the key is defined}
11
+ spec.summary = %q{Find locale files where translation for key is defined}
12
+ spec.description = %q{Find locale files where translation for key is defined}
13
13
  spec.homepage = 'https://github.com/creasty/find_t'
14
14
  spec.license = 'MIT'
15
15
 
data/lib/find_t/cli.rb CHANGED
@@ -6,7 +6,7 @@ require_relative 'printer'
6
6
  module FindT
7
7
  class CLI
8
8
 
9
- def initialize(args, root_path)
9
+ def initialize(args, root_path, isatty)
10
10
  @root_path = root_path
11
11
 
12
12
  parse_options! args
@@ -15,6 +15,7 @@ module FindT
15
15
  root_path: @root_path,
16
16
  rails: @options['rails'],
17
17
  )
18
+ @printer = Printer.new @root_path, isatty
18
19
 
19
20
  run
20
21
  end
@@ -25,9 +26,9 @@ module FindT
25
26
  end
26
27
 
27
28
  private def run
29
+ @printer.print_header
28
30
  founds = @scanner.scan @name
29
- printer = Printer.new @root_path
30
- printer.print @name, founds
31
+ @printer.print_results founds
31
32
  end
32
33
 
33
34
  end
@@ -31,11 +31,9 @@ module FindT
31
31
  level = indent.size >> 1
32
32
 
33
33
  if level == 0 && text == ''
34
- self.locale = scope
35
- return
36
- end
37
-
38
- if level == @current_level
34
+ @current_locale = scope
35
+ @current_level = 1
36
+ elsif level == @current_level
39
37
  if scope == current_scope
40
38
  if level == @size
41
39
  @founds << {
@@ -57,10 +55,5 @@ module FindT
57
55
  @scopes[@current_level]
58
56
  end
59
57
 
60
- private def locale=(locale)
61
- @current_locale = locale
62
- @current_level = 1
63
- end
64
-
65
58
  end
66
59
  end
@@ -4,13 +4,30 @@ require 'pathname'
4
4
  module FindT
5
5
  class Printer
6
6
 
7
- def initialize(root_path)
7
+ COLORS = {
8
+ black: 0,
9
+ red: 1,
10
+ green: 2,
11
+ yellow: 3,
12
+ blue: 4,
13
+ magenta: 5,
14
+ cyan: 6,
15
+ white: 7,
16
+ }
17
+
18
+ def initialize(root_path, isatty)
8
19
  @root_path = Pathname.new root_path
20
+ @isatty = isatty
21
+ end
22
+
23
+ def print_header
24
+ puts 'Starting find_t at %s' % @root_path.to_s
25
+ puts 'Scanning...'
9
26
  end
10
27
 
11
- def print(name, founds)
28
+ def print_results(founds)
12
29
  unless founds.any?
13
- print_empty name
30
+ print_empty
14
31
  return
15
32
  end
16
33
 
@@ -27,14 +44,14 @@ module FindT
27
44
  end
28
45
  end
29
46
 
30
- private def print_empty(name)
47
+ private def print_empty
31
48
  puts
32
- puts "Can't find '%s'" % name
49
+ puts color("Can't find translation for the key", :red)
33
50
  end
34
51
 
35
52
  private def print_title(title)
36
53
  puts
37
- puts '== %s' % title
54
+ puts color('==> %s' % title, :yellow)
38
55
  puts
39
56
  end
40
57
 
@@ -44,7 +61,7 @@ module FindT
44
61
 
45
62
  puts <<-EOS
46
63
  - #{file}:#{found[:line]}#{conflicted ? '' : ' [CONFLICTED]'}
47
- #{text}
64
+ #{color(text, :green)}
48
65
  EOS
49
66
  end
50
67
 
@@ -57,5 +74,9 @@ EOS
57
74
  Pathname.new(file).relative_path_from(@root_path).to_s
58
75
  end
59
76
 
77
+ private def color(str, c)
78
+ @isatty ? "\e[1;%dm%s\e[0m" % [30 + COLORS[c], str] : str
79
+ end
80
+
60
81
  end
61
82
  end
@@ -2,7 +2,7 @@ module FindT
2
2
 
3
3
  MAJOR = 1
4
4
  MINOR = 0
5
- REVISION = 1
5
+ REVISION = 3
6
6
 
7
7
  VERSION = [MAJOR, MINOR, REVISION].compact.join '.'
8
8
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: find_t
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yuki Iwanaga
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-02-28 00:00:00.000000000 Z
11
+ date: 2015-03-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -38,7 +38,7 @@ dependencies:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
40
  version: '10.0'
41
- description: Find locale files of where translation for the key is defined
41
+ description: Find locale files where translation for key is defined
42
42
  email:
43
43
  - yuki@creasty.com
44
44
  executables:
@@ -83,5 +83,5 @@ rubyforge_project:
83
83
  rubygems_version: 2.4.5
84
84
  signing_key:
85
85
  specification_version: 4
86
- summary: Find locale files of where translation for the key is defined
86
+ summary: Find locale files where translation for key is defined
87
87
  test_files: []