danger-missed_localizable_strings 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +3 -0
- data/.travis.yml +12 -0
- data/.yardoc/checksums +4 -0
- data/.yardoc/complete +0 -0
- data/.yardoc/object_types +0 -0
- data/.yardoc/objects/root.dat +0 -0
- data/.yardoc/proxy_types +0 -0
- data/CHANGELOG.md +3 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +139 -0
- data/Guardfile +19 -0
- data/LICENSE.txt +22 -0
- data/README.md +47 -0
- data/Rakefile +23 -0
- data/danger-missed_localizable_strings.gemspec +51 -0
- data/lib/danger_missed_localizable_strings.rb +1 -0
- data/lib/danger_plugin.rb +1 -0
- data/lib/missed_localizable_strings/gem_version.rb +3 -0
- data/lib/missed_localizable_strings/plugin.rb +103 -0
- data/spec/fixtures/LocalizableOrigin.strings +4 -0
- data/spec/fixtures/LocalizableWithOmissions1.strings +2 -0
- data/spec/fixtures/LocalizableWithOmissions2.strings +3 -0
- data/spec/fixtures/LocalizableWithoutOmissions.strings +4 -0
- data/spec/missed_localizable_strings_spec.rb +102 -0
- data/spec/spec_helper.rb +59 -0
- metadata +215 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 0344eefe9052e5f8719042e825c87ae3e6bd5d44
|
4
|
+
data.tar.gz: 33b5f6e88ce76578ffda5a71fca13d99460dd845
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: c412565b70798e6c954943937b96be949fdb19ff013c1cab0006d39f455e8cd7dd677661be2f56dd6432733120bc88c317ac9f8b24fca0c4197a599861795c63
|
7
|
+
data.tar.gz: 3e2faf3fba862933fa9dbb96aa633918a8e8154039f55904f14b2cb46036995926d81e889f0ffe00ac83b6b57999e16da4c912eb8a0cca112a3f4db1743a6b28
|
data/.gitignore
ADDED
data/.travis.yml
ADDED
data/.yardoc/checksums
ADDED
@@ -0,0 +1,4 @@
|
|
1
|
+
/Users/antondomashnev/Work/danger-missed_localizable_strings/lib/danger_missed_localizable_strings.rb 2d45fd4ac15406370e8e2cde5f836928de1571a5
|
2
|
+
/Users/antondomashnev/Work/danger-missed_localizable_strings/lib/danger_plugin.rb 7cb3e51b1fbf41517b379e9664c71a6a146f3e9f
|
3
|
+
/Users/antondomashnev/Work/danger-missed_localizable_strings/lib/missed_localizable_strings/gem_version.rb 46d5544bbb04c0851dcd51e15d4d2e9dc6d26b32
|
4
|
+
/Users/antondomashnev/Work/danger-missed_localizable_strings/lib/missed_localizable_strings/plugin.rb 584819b8773bd4811b791922a93f2f867bdc85f7
|
data/.yardoc/complete
ADDED
File without changes
|
Binary file
|
Binary file
|
data/.yardoc/proxy_types
ADDED
Binary file
|
data/CHANGELOG.md
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,139 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
danger-missed_localizable_strings (1.0.0)
|
5
|
+
danger-plugin-api (~> 1.0)
|
6
|
+
|
7
|
+
GEM
|
8
|
+
remote: https://rubygems.org/
|
9
|
+
specs:
|
10
|
+
addressable (2.4.0)
|
11
|
+
ast (2.3.0)
|
12
|
+
claide (1.0.1)
|
13
|
+
claide-plugins (0.9.2)
|
14
|
+
cork
|
15
|
+
nap
|
16
|
+
open4 (~> 1.3)
|
17
|
+
coderay (1.1.1)
|
18
|
+
colored (1.2)
|
19
|
+
cork (0.2.0)
|
20
|
+
colored (~> 1.2)
|
21
|
+
danger (3.5.4)
|
22
|
+
claide (~> 1.0)
|
23
|
+
claide-plugins (>= 0.9.2)
|
24
|
+
colored (~> 1.2)
|
25
|
+
cork (~> 0.1)
|
26
|
+
faraday (~> 0.9)
|
27
|
+
faraday-http-cache (~> 1.0)
|
28
|
+
git (~> 1)
|
29
|
+
gitlab (~> 3.7.0)
|
30
|
+
kramdown (~> 1.5)
|
31
|
+
octokit (~> 4.2)
|
32
|
+
terminal-table (~> 1)
|
33
|
+
danger-plugin-api (1.0.0)
|
34
|
+
danger (> 2.0)
|
35
|
+
diff-lcs (1.2.5)
|
36
|
+
faraday (0.9.2)
|
37
|
+
multipart-post (>= 1.2, < 3)
|
38
|
+
faraday-http-cache (1.3.1)
|
39
|
+
faraday (~> 0.8)
|
40
|
+
ffi (1.9.14)
|
41
|
+
formatador (0.2.5)
|
42
|
+
git (1.3.0)
|
43
|
+
gitlab (3.7.0)
|
44
|
+
httparty (~> 0.13.0)
|
45
|
+
terminal-table
|
46
|
+
guard (2.14.0)
|
47
|
+
formatador (>= 0.2.4)
|
48
|
+
listen (>= 2.7, < 4.0)
|
49
|
+
lumberjack (~> 1.0)
|
50
|
+
nenv (~> 0.1)
|
51
|
+
notiffany (~> 0.0)
|
52
|
+
pry (>= 0.9.12)
|
53
|
+
shellany (~> 0.0)
|
54
|
+
thor (>= 0.18.1)
|
55
|
+
guard-compat (1.2.1)
|
56
|
+
guard-rspec (4.7.3)
|
57
|
+
guard (~> 2.1)
|
58
|
+
guard-compat (~> 1.1)
|
59
|
+
rspec (>= 2.99.0, < 4.0)
|
60
|
+
httparty (0.13.7)
|
61
|
+
json (~> 1.8)
|
62
|
+
multi_xml (>= 0.5.2)
|
63
|
+
json (1.8.3)
|
64
|
+
kramdown (1.12.0)
|
65
|
+
listen (3.0.7)
|
66
|
+
rb-fsevent (>= 0.9.3)
|
67
|
+
rb-inotify (>= 0.9.7)
|
68
|
+
lumberjack (1.0.10)
|
69
|
+
method_source (0.8.2)
|
70
|
+
multi_xml (0.5.5)
|
71
|
+
multipart-post (2.0.0)
|
72
|
+
nap (1.1.0)
|
73
|
+
nenv (0.3.0)
|
74
|
+
notiffany (0.1.1)
|
75
|
+
nenv (~> 0.1)
|
76
|
+
shellany (~> 0.0)
|
77
|
+
octokit (4.3.0)
|
78
|
+
sawyer (~> 0.7.0, >= 0.5.3)
|
79
|
+
open4 (1.3.4)
|
80
|
+
parser (2.3.1.4)
|
81
|
+
ast (~> 2.2)
|
82
|
+
powerpack (0.1.1)
|
83
|
+
pry (0.10.4)
|
84
|
+
coderay (~> 1.1.0)
|
85
|
+
method_source (~> 0.8.1)
|
86
|
+
slop (~> 3.4)
|
87
|
+
rainbow (2.1.0)
|
88
|
+
rake (10.5.0)
|
89
|
+
rb-fsevent (0.9.7)
|
90
|
+
rb-inotify (0.9.7)
|
91
|
+
ffi (>= 0.5.0)
|
92
|
+
rspec (3.5.0)
|
93
|
+
rspec-core (~> 3.5.0)
|
94
|
+
rspec-expectations (~> 3.5.0)
|
95
|
+
rspec-mocks (~> 3.5.0)
|
96
|
+
rspec-core (3.5.4)
|
97
|
+
rspec-support (~> 3.5.0)
|
98
|
+
rspec-expectations (3.5.0)
|
99
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
100
|
+
rspec-support (~> 3.5.0)
|
101
|
+
rspec-mocks (3.5.0)
|
102
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
103
|
+
rspec-support (~> 3.5.0)
|
104
|
+
rspec-support (3.5.0)
|
105
|
+
rubocop (0.43.0)
|
106
|
+
parser (>= 2.3.1.1, < 3.0)
|
107
|
+
powerpack (~> 0.1)
|
108
|
+
rainbow (>= 1.99.1, < 3.0)
|
109
|
+
ruby-progressbar (~> 1.7)
|
110
|
+
unicode-display_width (~> 1.0, >= 1.0.1)
|
111
|
+
ruby-progressbar (1.8.1)
|
112
|
+
sawyer (0.7.0)
|
113
|
+
addressable (>= 2.3.5, < 2.5)
|
114
|
+
faraday (~> 0.8, < 0.10)
|
115
|
+
shellany (0.0.1)
|
116
|
+
slop (3.6.0)
|
117
|
+
terminal-table (1.7.3)
|
118
|
+
unicode-display_width (~> 1.1.1)
|
119
|
+
thor (0.19.1)
|
120
|
+
unicode-display_width (1.1.1)
|
121
|
+
yard (0.9.5)
|
122
|
+
|
123
|
+
PLATFORMS
|
124
|
+
ruby
|
125
|
+
|
126
|
+
DEPENDENCIES
|
127
|
+
bundler (~> 1.3)
|
128
|
+
danger-missed_localizable_strings!
|
129
|
+
guard (~> 2.14)
|
130
|
+
guard-rspec (~> 4.7)
|
131
|
+
listen (= 3.0.7)
|
132
|
+
pry
|
133
|
+
rake (~> 10.0)
|
134
|
+
rspec (~> 3.4)
|
135
|
+
rubocop (~> 0.41)
|
136
|
+
yard (~> 0.8)
|
137
|
+
|
138
|
+
BUNDLED WITH
|
139
|
+
1.13.2
|
data/Guardfile
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
# A guardfile for making Danger Plugins
|
2
|
+
# For more info see https://github.com/guard/guard#readme
|
3
|
+
|
4
|
+
# To run, use `bundle exec guard`.
|
5
|
+
|
6
|
+
guard :rspec, cmd: 'bundle exec rspec' do
|
7
|
+
require 'guard/rspec/dsl'
|
8
|
+
dsl = Guard::RSpec::Dsl.new(self)
|
9
|
+
|
10
|
+
# RSpec files
|
11
|
+
rspec = dsl.rspec
|
12
|
+
watch(rspec.spec_helper) { rspec.spec_dir }
|
13
|
+
watch(rspec.spec_support) { rspec.spec_dir }
|
14
|
+
watch(rspec.spec_files)
|
15
|
+
|
16
|
+
# Ruby files
|
17
|
+
ruby = dsl.ruby
|
18
|
+
dsl.watch_spec_files_for(ruby.lib_files)
|
19
|
+
end
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2016 Anton Domashnev <antondomashnev@gmail.com>
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,47 @@
|
|
1
|
+
# danger-missed_localizable_strings
|
2
|
+
|
3
|
+
[![Build Status](https://travis-ci.org/Antondomashnev/danger-missed_localizable_strings.svg?branch=master)](https://travis-ci.org/Antondomashnev/danger-missed_localizable_strings)
|
4
|
+
|
5
|
+
Don't let developers to forget about the app localization.
|
6
|
+
Allow [Danger](https://github.com/danger/danger) to check whether there are
|
7
|
+
missing keys in any of modified or added .strings files in the PR.
|
8
|
+
|
9
|
+
## Important
|
10
|
+
|
11
|
+
Since [Danger](https://github.com/danger/danger) is developed in mind
|
12
|
+
to check only PR's. It won't help you if there is
|
13
|
+
already mis-synchronization of `Localizable.strings`.
|
14
|
+
To let the plugin do it's job, please update
|
15
|
+
project's `Localizable.strings` to contain all keys in each file.
|
16
|
+
|
17
|
+
## Installation
|
18
|
+
|
19
|
+
```sh
|
20
|
+
$ gem install danger-missed_localizable_strings
|
21
|
+
```
|
22
|
+
|
23
|
+
## Usage
|
24
|
+
|
25
|
+
Methods and attributes from this plugin are available in
|
26
|
+
your `Dangerfile` under the `missed_localizable_strings` namespace.
|
27
|
+
And that's it, there are no additional parameters currently =)
|
28
|
+
|
29
|
+
## Development
|
30
|
+
|
31
|
+
1. Clone this repo
|
32
|
+
2. Run `bundle install` to setup dependencies.
|
33
|
+
3. Run `bundle exec rake spec` to run the tests.
|
34
|
+
4. Use `bundle exec guard` to automatically have tests run as you make changes.
|
35
|
+
5. Make your changes.
|
36
|
+
|
37
|
+
## LICENSE
|
38
|
+
|
39
|
+
```
|
40
|
+
Copyright (c) 2016 Anton Domashnev
|
41
|
+
|
42
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
43
|
+
|
44
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
45
|
+
|
46
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
47
|
+
```
|
data/Rakefile
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'bundler/gem_tasks'
|
2
|
+
require 'rspec/core/rake_task'
|
3
|
+
require 'rubocop/rake_task'
|
4
|
+
|
5
|
+
RSpec::Core::RakeTask.new(:specs)
|
6
|
+
|
7
|
+
task default: :specs
|
8
|
+
|
9
|
+
task :spec do
|
10
|
+
Rake::Task['specs'].invoke
|
11
|
+
Rake::Task['rubocop'].invoke
|
12
|
+
Rake::Task['spec_docs'].invoke
|
13
|
+
end
|
14
|
+
|
15
|
+
desc 'Run RuboCop on the lib/specs directory'
|
16
|
+
RuboCop::RakeTask.new(:rubocop) do |task|
|
17
|
+
task.patterns = ['lib/**/*.rb', 'spec/**/*.rb']
|
18
|
+
end
|
19
|
+
|
20
|
+
desc 'Ensure that the plugin passes `danger plugins lint`'
|
21
|
+
task :spec_docs do
|
22
|
+
sh 'bundle exec danger plugins lint'
|
23
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
# rubocop:disable Metrics/LineLength
|
3
|
+
lib = File.expand_path('../lib', __FILE__)
|
4
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
5
|
+
require 'missed_localizable_strings/gem_version.rb'
|
6
|
+
|
7
|
+
Gem::Specification.new do |spec|
|
8
|
+
spec.name = 'danger-missed_localizable_strings'
|
9
|
+
spec.version = MissedLocalizableStrings::VERSION
|
10
|
+
spec.authors = ['Anton Domashnev']
|
11
|
+
spec.email = ['antondomashnev@gmail.com']
|
12
|
+
spec.description = 'A Danger plugin to check missing localizable strings.'
|
13
|
+
spec.summary = 'A Danger plugin to check missing localizable strings.'
|
14
|
+
spec.homepage = 'https://github.com/Antondomashnev/danger-missed_localizable_strings'
|
15
|
+
spec.license = 'MIT'
|
16
|
+
|
17
|
+
spec.files = `git ls-files`.split($INPUT_RECORD_SEPARATOR)
|
18
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
19
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
20
|
+
spec.require_paths = ['lib']
|
21
|
+
|
22
|
+
spec.add_runtime_dependency 'danger-plugin-api', '~> 1.0'
|
23
|
+
|
24
|
+
# General ruby development
|
25
|
+
spec.add_development_dependency 'bundler', '~> 1.3'
|
26
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
27
|
+
|
28
|
+
# Testing support
|
29
|
+
spec.add_development_dependency 'rspec', '~> 3.4'
|
30
|
+
|
31
|
+
# Linting code and docs
|
32
|
+
spec.add_development_dependency 'rubocop', '~> 0.41'
|
33
|
+
spec.add_development_dependency 'yard', '~> 0.8'
|
34
|
+
|
35
|
+
# Makes testing easy via `bundle exec guard`
|
36
|
+
spec.add_development_dependency 'guard', '~> 2.14'
|
37
|
+
spec.add_development_dependency 'guard-rspec', '~> 4.7'
|
38
|
+
|
39
|
+
# If you want to work on older builds of ruby
|
40
|
+
spec.add_development_dependency 'listen', '3.0.7'
|
41
|
+
|
42
|
+
# This gives you the chance to run a REPL inside your tests
|
43
|
+
# via:
|
44
|
+
#
|
45
|
+
# require 'pry'
|
46
|
+
# binding.pry
|
47
|
+
#
|
48
|
+
# This will stop test execution and let you inspect the results
|
49
|
+
spec.add_development_dependency 'pry'
|
50
|
+
end
|
51
|
+
# rubocop:enable Metrics/LineLength
|
@@ -0,0 +1 @@
|
|
1
|
+
require 'missed_localizable_strings/gem_version'
|
@@ -0,0 +1 @@
|
|
1
|
+
require 'missed_localizable_strings/plugin'
|
@@ -0,0 +1,103 @@
|
|
1
|
+
module Danger
|
2
|
+
#
|
3
|
+
# Sometimes developer adds new key in one Localizable.strings file
|
4
|
+
# and forgets to add the same key in another Localizable.strings file.
|
5
|
+
# This simple plugin warns the developer about these possible mistakes.
|
6
|
+
# Some parts of the code were taken from: https://github.com/AirHelp/danger-duplicate_localizable_strings
|
7
|
+
#
|
8
|
+
# @example Checks missing localizable strings in PR changeset
|
9
|
+
#
|
10
|
+
# check_localizable_omissions
|
11
|
+
#
|
12
|
+
# @see Anton Domashnev/danger-missed_localizable_strings
|
13
|
+
# @tags localization, cocoa
|
14
|
+
#
|
15
|
+
class DangerMissedLocalizableStrings < Plugin
|
16
|
+
#
|
17
|
+
# Checks whether there are any missed entries in
|
18
|
+
# all Localizable.strings from PR's changeset
|
19
|
+
# files and prints out any found entries.
|
20
|
+
#
|
21
|
+
# @return [void]
|
22
|
+
#
|
23
|
+
def check_localizable_omissions
|
24
|
+
localizable_files = not_deleted_localizable_files
|
25
|
+
keys_by_file = extract_keys_from_files(localizable_files)
|
26
|
+
entries = localizable_strings_missed_entries(keys_by_file)
|
27
|
+
print_missed_entries entries unless entries.empty?
|
28
|
+
end
|
29
|
+
|
30
|
+
private
|
31
|
+
|
32
|
+
#
|
33
|
+
# Returns an array of all detected missed keyes in Localizable.strings
|
34
|
+
# By entry means the hash with key => filename, value => key name
|
35
|
+
# Idea was taken from: https://github.com/AirHelp/danger-duplicate_localizable_strings
|
36
|
+
#
|
37
|
+
# @param keys_by_file {.strings file: [Array of keys]}
|
38
|
+
#
|
39
|
+
# @return [Array of missed Localizable.strings entries]
|
40
|
+
def localizable_strings_missed_entries(keys_by_file)
|
41
|
+
missed_entries = []
|
42
|
+
# The array with modified keyes from Localizable.strings
|
43
|
+
# file with the most number of keys
|
44
|
+
most_modified_strings_keys = keys_by_file.values.max_by(&:count)
|
45
|
+
keys_by_file.each do |file_name, modified_keyes|
|
46
|
+
missed_keyes = most_modified_strings_keys - modified_keyes
|
47
|
+
next if missed_keyes.empty?
|
48
|
+
missed_keyes.each do |key|
|
49
|
+
missed_entries << { 'file' => file_name, 'key' => key }
|
50
|
+
end
|
51
|
+
end
|
52
|
+
missed_entries
|
53
|
+
end
|
54
|
+
|
55
|
+
#
|
56
|
+
# Copy from print_duplicate_entries from https://github.com/AirHelp/danger-duplicate_localizable_strings
|
57
|
+
# Prints passed missed entries.
|
58
|
+
# @param [Hash] missed_entries
|
59
|
+
# A hash of `[file => keys]` entries to print.
|
60
|
+
#
|
61
|
+
# @return [void]
|
62
|
+
#
|
63
|
+
def print_missed_entries(missed_entries)
|
64
|
+
message = "#### Found missed keyes in Localizable.strings files \n\n"
|
65
|
+
|
66
|
+
message << "| File | Key |\n"
|
67
|
+
message << "| ---- | --- |\n"
|
68
|
+
|
69
|
+
missed_entries.each do |entry|
|
70
|
+
file = entry['file']
|
71
|
+
key = entry['key']
|
72
|
+
|
73
|
+
message << "| #{file} | #{key.strip} | \n"
|
74
|
+
end
|
75
|
+
|
76
|
+
markdown message
|
77
|
+
end
|
78
|
+
|
79
|
+
# A hash with keyes - Localizable.strings file and
|
80
|
+
# values - modified keys from file
|
81
|
+
def extract_keys_from_files(localizable_files)
|
82
|
+
keys_from_file = {}
|
83
|
+
localizable_files.each do |file|
|
84
|
+
lines = File.readlines(file)
|
85
|
+
|
86
|
+
# Grab just the keys, we don't need the translation
|
87
|
+
keys = lines.map { |e| e.split('=').first }
|
88
|
+
# Filter newlines and comments
|
89
|
+
keys = keys.select do |e|
|
90
|
+
e != "\n" && !e.start_with?('/*') && !e.start_with?('//')
|
91
|
+
end
|
92
|
+
keys_from_file[file] = keys
|
93
|
+
end
|
94
|
+
keys_from_file
|
95
|
+
end
|
96
|
+
|
97
|
+
def not_deleted_localizable_files
|
98
|
+
files = (git.modified_files + git.added_files) - git.deleted_files
|
99
|
+
localizable_files = files.select { |line| line.end_with?('.strings') }
|
100
|
+
localizable_files
|
101
|
+
end
|
102
|
+
end
|
103
|
+
end
|
@@ -0,0 +1,102 @@
|
|
1
|
+
require File.expand_path('../spec_helper', __FILE__)
|
2
|
+
|
3
|
+
module Danger
|
4
|
+
describe Danger::DangerMissedLocalizableStrings do
|
5
|
+
it 'should be a plugin' do
|
6
|
+
plugin = Danger::DangerMissedLocalizableStrings.new(nil)
|
7
|
+
expect(plugin).to be_a Danger::Plugin
|
8
|
+
end
|
9
|
+
|
10
|
+
describe 'with Dangerfile' do
|
11
|
+
before do
|
12
|
+
@dangerfile = testing_dangerfile
|
13
|
+
@my_plugin = @dangerfile.missed_localizable_strings
|
14
|
+
allow(@my_plugin.git).to receive(:deleted_files).and_return([])
|
15
|
+
end
|
16
|
+
|
17
|
+
context 'when there are no Localizable.strings in changeset' do
|
18
|
+
before do
|
19
|
+
allow(@my_plugin.git).to receive(:modified_files)
|
20
|
+
.and_return(['spec/fixtures/SomeModifiedFile.swift'])
|
21
|
+
allow(@my_plugin.git).to receive(:added_files)
|
22
|
+
.and_return(['spec/fixtures/AddedFile.m'])
|
23
|
+
@my_plugin.check_localizable_omissions
|
24
|
+
end
|
25
|
+
|
26
|
+
it 'does not warn about missed entries in Localizable.strings' do
|
27
|
+
expect(@my_plugin.status_report[:markdowns].first).to be_nil
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
context 'when there is one Localizable.strings file in changeset' do
|
32
|
+
before do
|
33
|
+
allow(@my_plugin.git).to receive(:modified_files)
|
34
|
+
.and_return(['spec/fixtures/SomeModifiedFile.swift'])
|
35
|
+
allow(@my_plugin.git).to receive(:added_files)
|
36
|
+
.and_return(['spec/fixtures/LocalizableOrigin.strings'])
|
37
|
+
@my_plugin.check_localizable_omissions
|
38
|
+
end
|
39
|
+
|
40
|
+
it 'does not warn about missed entries in Localizable.strings' do
|
41
|
+
expect(@my_plugin.status_report[:markdowns].first).to be_nil
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
context 'when there are multiple Localizable.strings in changeset' do
|
46
|
+
context 'when there are no missed keys in these files' do
|
47
|
+
before do
|
48
|
+
allow(@my_plugin.git).to receive(:modified_files)
|
49
|
+
.and_return(['spec/fixtures/LocalizableWithoutOmissions.strings'])
|
50
|
+
allow(@my_plugin.git).to receive(:added_files)
|
51
|
+
.and_return(['spec/fixtures/LocalizableOrigin.strings'])
|
52
|
+
@my_plugin.check_localizable_omissions
|
53
|
+
end
|
54
|
+
|
55
|
+
it 'does not warn about missed entries in Localizable.strings' do
|
56
|
+
expect(@my_plugin.status_report[:markdowns].first).to be_nil
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
context 'when there are missed keys in these files' do
|
61
|
+
before do
|
62
|
+
file1 = 'spec/fixtures/LocalizableWithOmissions1.strings'
|
63
|
+
file2 = 'spec/fixtures/LocalizableWithOmissions2.strings'
|
64
|
+
allow(@my_plugin.git).to receive(:modified_files)
|
65
|
+
.and_return([file1, file2])
|
66
|
+
allow(@my_plugin.git).to receive(:added_files)
|
67
|
+
.and_return(['spec/fixtures/LocalizableOrigin.strings'])
|
68
|
+
@my_plugin.check_localizable_omissions
|
69
|
+
@output = @my_plugin.status_report[:markdowns].first
|
70
|
+
end
|
71
|
+
|
72
|
+
it 'warns about missed entries in Localizable.strings' do
|
73
|
+
expect(@output).to_not be_nil
|
74
|
+
end
|
75
|
+
|
76
|
+
it 'contains header' do
|
77
|
+
title = 'Found missed keyes in Localizable.strings files'
|
78
|
+
expect(@output.to_s).to include(title)
|
79
|
+
end
|
80
|
+
|
81
|
+
it 'contains information about the first key from first file' do
|
82
|
+
file = 'spec/fixtures/LocalizableWithOmissions1.strings'
|
83
|
+
key = 'Day'
|
84
|
+
expect(@output.to_s).to include("| #{file} | \"#{key}\" |")
|
85
|
+
end
|
86
|
+
|
87
|
+
it 'contains infromation about the second key from first file' do
|
88
|
+
file = 'spec/fixtures/LocalizableWithOmissions1.strings'
|
89
|
+
key = 'Year'
|
90
|
+
expect(@output.to_s).to include("| #{file} | \"#{key}\" |")
|
91
|
+
end
|
92
|
+
|
93
|
+
it 'contains infromation about the first key from second file' do
|
94
|
+
file = 'spec/fixtures/LocalizableWithOmissions2.strings'
|
95
|
+
key = 'Hello'
|
96
|
+
expect(@output.to_s).to include("| #{file} | \"#{key}\" |")
|
97
|
+
end
|
98
|
+
end
|
99
|
+
end
|
100
|
+
end
|
101
|
+
end
|
102
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,59 @@
|
|
1
|
+
require 'pathname'
|
2
|
+
ROOT = Pathname.new(File.expand_path('../../', __FILE__))
|
3
|
+
$LOAD_PATH.unshift((ROOT + 'lib').to_s)
|
4
|
+
$LOAD_PATH.unshift((ROOT + 'spec').to_s)
|
5
|
+
|
6
|
+
require 'bundler/setup'
|
7
|
+
require 'pry'
|
8
|
+
|
9
|
+
require 'rspec'
|
10
|
+
require 'danger'
|
11
|
+
|
12
|
+
# Use coloured output, it's the best.
|
13
|
+
RSpec.configure do |config|
|
14
|
+
config.filter_gems_from_backtrace 'bundler'
|
15
|
+
config.color = true
|
16
|
+
config.tty = true
|
17
|
+
end
|
18
|
+
|
19
|
+
require 'danger_plugin'
|
20
|
+
|
21
|
+
# These functions are a subset of https://github.com/danger/danger/blob/master/spec/spec_helper.rb
|
22
|
+
# If you are expanding these files, see if it's already been done ^.
|
23
|
+
|
24
|
+
# A silent version of the user interface,
|
25
|
+
# it comes with an extra function `.string` which will
|
26
|
+
# strip all ANSI colours from the string.
|
27
|
+
|
28
|
+
# rubocop:disable Lint/NestedMethodDefinition
|
29
|
+
def testing_ui
|
30
|
+
@output = StringIO.new
|
31
|
+
def @output.winsize
|
32
|
+
[20, 9999]
|
33
|
+
end
|
34
|
+
|
35
|
+
cork = Cork::Board.new(out: @output)
|
36
|
+
def cork.string
|
37
|
+
out.string.gsub(/\e\[([;\d]+)?m/, '')
|
38
|
+
end
|
39
|
+
cork
|
40
|
+
end
|
41
|
+
# rubocop:enable Lint/NestedMethodDefinition
|
42
|
+
|
43
|
+
# Example environment (ENV) that would come from
|
44
|
+
# running a PR on TravisCI
|
45
|
+
def testing_env
|
46
|
+
{
|
47
|
+
'HAS_JOSH_K_SEAL_OF_APPROVAL' => 'true',
|
48
|
+
'TRAVIS_PULL_REQUEST' => '800',
|
49
|
+
'TRAVIS_REPO_SLUG' => 'artsy/eigen',
|
50
|
+
'TRAVIS_COMMIT_RANGE' => '759adcbd0d8f...13c4dc8bb61d',
|
51
|
+
'DANGER_GITHUB_API_TOKEN' => '123sbdq54erfsd3422gdfio'
|
52
|
+
}
|
53
|
+
end
|
54
|
+
|
55
|
+
# A stubbed out Dangerfile for use in tests
|
56
|
+
def testing_dangerfile
|
57
|
+
env = Danger::EnvironmentManager.new(testing_env)
|
58
|
+
Danger::Dangerfile.new(env, testing_ui)
|
59
|
+
end
|
metadata
ADDED
@@ -0,0 +1,215 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: danger-missed_localizable_strings
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Anton Domashnev
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-10-14 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: danger-plugin-api
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.3'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.3'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '10.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '10.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rspec
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '3.4'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '3.4'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rubocop
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0.41'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0.41'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: yard
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0.8'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0.8'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: guard
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - "~>"
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '2.14'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - "~>"
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '2.14'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: guard-rspec
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - "~>"
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '4.7'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - "~>"
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '4.7'
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: listen
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - '='
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: 3.0.7
|
132
|
+
type: :development
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - '='
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: 3.0.7
|
139
|
+
- !ruby/object:Gem::Dependency
|
140
|
+
name: pry
|
141
|
+
requirement: !ruby/object:Gem::Requirement
|
142
|
+
requirements:
|
143
|
+
- - ">="
|
144
|
+
- !ruby/object:Gem::Version
|
145
|
+
version: '0'
|
146
|
+
type: :development
|
147
|
+
prerelease: false
|
148
|
+
version_requirements: !ruby/object:Gem::Requirement
|
149
|
+
requirements:
|
150
|
+
- - ">="
|
151
|
+
- !ruby/object:Gem::Version
|
152
|
+
version: '0'
|
153
|
+
description: A Danger plugin to check missing localizable strings.
|
154
|
+
email:
|
155
|
+
- antondomashnev@gmail.com
|
156
|
+
executables: []
|
157
|
+
extensions: []
|
158
|
+
extra_rdoc_files: []
|
159
|
+
files:
|
160
|
+
- ".gitignore"
|
161
|
+
- ".travis.yml"
|
162
|
+
- ".yardoc/checksums"
|
163
|
+
- ".yardoc/complete"
|
164
|
+
- ".yardoc/object_types"
|
165
|
+
- ".yardoc/objects/root.dat"
|
166
|
+
- ".yardoc/proxy_types"
|
167
|
+
- CHANGELOG.md
|
168
|
+
- Gemfile
|
169
|
+
- Gemfile.lock
|
170
|
+
- Guardfile
|
171
|
+
- LICENSE.txt
|
172
|
+
- README.md
|
173
|
+
- Rakefile
|
174
|
+
- danger-missed_localizable_strings.gemspec
|
175
|
+
- lib/danger_missed_localizable_strings.rb
|
176
|
+
- lib/danger_plugin.rb
|
177
|
+
- lib/missed_localizable_strings/gem_version.rb
|
178
|
+
- lib/missed_localizable_strings/plugin.rb
|
179
|
+
- spec/fixtures/LocalizableOrigin.strings
|
180
|
+
- spec/fixtures/LocalizableWithOmissions1.strings
|
181
|
+
- spec/fixtures/LocalizableWithOmissions2.strings
|
182
|
+
- spec/fixtures/LocalizableWithoutOmissions.strings
|
183
|
+
- spec/missed_localizable_strings_spec.rb
|
184
|
+
- spec/spec_helper.rb
|
185
|
+
homepage: https://github.com/Antondomashnev/danger-missed_localizable_strings
|
186
|
+
licenses:
|
187
|
+
- MIT
|
188
|
+
metadata: {}
|
189
|
+
post_install_message:
|
190
|
+
rdoc_options: []
|
191
|
+
require_paths:
|
192
|
+
- lib
|
193
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
194
|
+
requirements:
|
195
|
+
- - ">="
|
196
|
+
- !ruby/object:Gem::Version
|
197
|
+
version: '0'
|
198
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
199
|
+
requirements:
|
200
|
+
- - ">="
|
201
|
+
- !ruby/object:Gem::Version
|
202
|
+
version: '0'
|
203
|
+
requirements: []
|
204
|
+
rubyforge_project:
|
205
|
+
rubygems_version: 2.5.1
|
206
|
+
signing_key:
|
207
|
+
specification_version: 4
|
208
|
+
summary: A Danger plugin to check missing localizable strings.
|
209
|
+
test_files:
|
210
|
+
- spec/fixtures/LocalizableOrigin.strings
|
211
|
+
- spec/fixtures/LocalizableWithOmissions1.strings
|
212
|
+
- spec/fixtures/LocalizableWithOmissions2.strings
|
213
|
+
- spec/fixtures/LocalizableWithoutOmissions.strings
|
214
|
+
- spec/missed_localizable_strings_spec.rb
|
215
|
+
- spec/spec_helper.rb
|