danger-duplicate_localizable_strings 0.0.1
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 +7 -0
- data/.gitignore +3 -0
- data/.travis.yml +12 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +127 -0
- data/Guardfile +19 -0
- data/LICENSE.txt +22 -0
- data/README.md +29 -0
- data/Rakefile +23 -0
- data/danger-duplicate_localizable_strings.gemspec +47 -0
- data/lib/danger_duplicate_localizable_strings.rb +1 -0
- data/lib/danger_plugin.rb +1 -0
- data/lib/duplicate_localizable_strings/gem_version.rb +3 -0
- data/lib/duplicate_localizable_strings/plugin.rb +81 -0
- data/spec/duplicate_localizable_strings_spec.rb +74 -0
- data/spec/fixtures/LocalizableWithDuplicates1.strings +5 -0
- data/spec/fixtures/LocalizableWithDuplicates2.strings +5 -0
- data/spec/fixtures/LocalizableWithoutDuplicates.strings +5 -0
- data/spec/spec_helper.rb +59 -0
- metadata +209 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA1:
|
|
3
|
+
metadata.gz: b6a90fd23894198d3ca7d5711bba1e3cf7eada6c
|
|
4
|
+
data.tar.gz: cb90d887b1b154a2c2c5a5b1184a1b4572715314
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: b14b627da6ee9f36198992b1c94d6c757f5b91b80880bcaa7e6530d0f79a04bb76546326b29b01a9a0c5d266de12d1e47da57f82083c0920fcd9f0e253c6cce7
|
|
7
|
+
data.tar.gz: 6650330149fd4c232e3958d97fdb6cd68e05d034ea000fa29af4233e23c6ce504f7f857ca753ac04e314f4ae568aeac8f7f8465f2d7472242fbaec728957fa17
|
data/.gitignore
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
PATH
|
|
2
|
+
remote: .
|
|
3
|
+
specs:
|
|
4
|
+
danger-duplicate_localizable_strings (0.0.1)
|
|
5
|
+
danger (~> 2.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.0)
|
|
13
|
+
claide-plugins (0.9.1)
|
|
14
|
+
cork
|
|
15
|
+
nap
|
|
16
|
+
open4 (~> 1.3)
|
|
17
|
+
coderay (1.1.1)
|
|
18
|
+
colored (1.2)
|
|
19
|
+
cork (0.1.0)
|
|
20
|
+
colored (~> 1.2)
|
|
21
|
+
danger (2.1.2)
|
|
22
|
+
claide (~> 1.0)
|
|
23
|
+
claide-plugins (> 0.9.0)
|
|
24
|
+
colored (~> 1.2)
|
|
25
|
+
cork (~> 0.1)
|
|
26
|
+
faraday (~> 0)
|
|
27
|
+
faraday-http-cache (~> 1.0)
|
|
28
|
+
git (~> 1)
|
|
29
|
+
kramdown (~> 1.5)
|
|
30
|
+
octokit (~> 4.2)
|
|
31
|
+
terminal-table (~> 1)
|
|
32
|
+
diff-lcs (1.2.5)
|
|
33
|
+
faraday (0.9.2)
|
|
34
|
+
multipart-post (>= 1.2, < 3)
|
|
35
|
+
faraday-http-cache (1.3.0)
|
|
36
|
+
faraday (~> 0.8)
|
|
37
|
+
ffi (1.9.14)
|
|
38
|
+
formatador (0.2.5)
|
|
39
|
+
git (1.3.0)
|
|
40
|
+
guard (2.14.0)
|
|
41
|
+
formatador (>= 0.2.4)
|
|
42
|
+
listen (>= 2.7, < 4.0)
|
|
43
|
+
lumberjack (~> 1.0)
|
|
44
|
+
nenv (~> 0.1)
|
|
45
|
+
notiffany (~> 0.0)
|
|
46
|
+
pry (>= 0.9.12)
|
|
47
|
+
shellany (~> 0.0)
|
|
48
|
+
thor (>= 0.18.1)
|
|
49
|
+
guard-compat (1.2.1)
|
|
50
|
+
guard-rspec (4.7.3)
|
|
51
|
+
guard (~> 2.1)
|
|
52
|
+
guard-compat (~> 1.1)
|
|
53
|
+
rspec (>= 2.99.0, < 4.0)
|
|
54
|
+
kramdown (1.11.1)
|
|
55
|
+
listen (3.0.7)
|
|
56
|
+
rb-fsevent (>= 0.9.3)
|
|
57
|
+
rb-inotify (>= 0.9.7)
|
|
58
|
+
lumberjack (1.0.10)
|
|
59
|
+
method_source (0.8.2)
|
|
60
|
+
multipart-post (2.0.0)
|
|
61
|
+
nap (1.1.0)
|
|
62
|
+
nenv (0.3.0)
|
|
63
|
+
notiffany (0.1.1)
|
|
64
|
+
nenv (~> 0.1)
|
|
65
|
+
shellany (~> 0.0)
|
|
66
|
+
octokit (4.3.0)
|
|
67
|
+
sawyer (~> 0.7.0, >= 0.5.3)
|
|
68
|
+
open4 (1.3.4)
|
|
69
|
+
parser (2.3.1.2)
|
|
70
|
+
ast (~> 2.2)
|
|
71
|
+
powerpack (0.1.1)
|
|
72
|
+
pry (0.10.4)
|
|
73
|
+
coderay (~> 1.1.0)
|
|
74
|
+
method_source (~> 0.8.1)
|
|
75
|
+
slop (~> 3.4)
|
|
76
|
+
rainbow (2.1.0)
|
|
77
|
+
rake (10.5.0)
|
|
78
|
+
rb-fsevent (0.9.7)
|
|
79
|
+
rb-inotify (0.9.7)
|
|
80
|
+
ffi (>= 0.5.0)
|
|
81
|
+
rspec (3.5.0)
|
|
82
|
+
rspec-core (~> 3.5.0)
|
|
83
|
+
rspec-expectations (~> 3.5.0)
|
|
84
|
+
rspec-mocks (~> 3.5.0)
|
|
85
|
+
rspec-core (3.5.2)
|
|
86
|
+
rspec-support (~> 3.5.0)
|
|
87
|
+
rspec-expectations (3.5.0)
|
|
88
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
|
89
|
+
rspec-support (~> 3.5.0)
|
|
90
|
+
rspec-mocks (3.5.0)
|
|
91
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
|
92
|
+
rspec-support (~> 3.5.0)
|
|
93
|
+
rspec-support (3.5.0)
|
|
94
|
+
rubocop (0.42.0)
|
|
95
|
+
parser (>= 2.3.1.1, < 3.0)
|
|
96
|
+
powerpack (~> 0.1)
|
|
97
|
+
rainbow (>= 1.99.1, < 3.0)
|
|
98
|
+
ruby-progressbar (~> 1.7)
|
|
99
|
+
unicode-display_width (~> 1.0, >= 1.0.1)
|
|
100
|
+
ruby-progressbar (1.8.1)
|
|
101
|
+
sawyer (0.7.0)
|
|
102
|
+
addressable (>= 2.3.5, < 2.5)
|
|
103
|
+
faraday (~> 0.8, < 0.10)
|
|
104
|
+
shellany (0.0.1)
|
|
105
|
+
slop (3.6.0)
|
|
106
|
+
terminal-table (1.6.0)
|
|
107
|
+
thor (0.19.1)
|
|
108
|
+
unicode-display_width (1.1.0)
|
|
109
|
+
yard (0.9.5)
|
|
110
|
+
|
|
111
|
+
PLATFORMS
|
|
112
|
+
ruby
|
|
113
|
+
|
|
114
|
+
DEPENDENCIES
|
|
115
|
+
bundler (~> 1.3)
|
|
116
|
+
danger-duplicate_localizable_strings!
|
|
117
|
+
guard (~> 2.14)
|
|
118
|
+
guard-rspec (~> 4.7)
|
|
119
|
+
listen (= 3.0.7)
|
|
120
|
+
pry
|
|
121
|
+
rake (~> 10.0)
|
|
122
|
+
rspec (~> 3.4)
|
|
123
|
+
rubocop (~> 0.41)
|
|
124
|
+
yard (~> 0.8)
|
|
125
|
+
|
|
126
|
+
BUNDLED WITH
|
|
127
|
+
1.12.5
|
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 AirHelp <ah-mobile@airhelp.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,29 @@
|
|
|
1
|
+
# danger-duplicate_localizable_strings
|
|
2
|
+
|
|
3
|
+
A [Danger](https://github.com/danger/danger) plugin that detect duplicate entries in Localizable.strings.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
$ gem install danger-duplicate_localizable_strings
|
|
8
|
+
|
|
9
|
+
## Usage
|
|
10
|
+
|
|
11
|
+
Just call
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
check_localizable_duplicates
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
in your `Dangerfile` and you're all set 🎉
|
|
18
|
+
|
|
19
|
+
You can also call `localizable_duplicate_entries` to get an array of hashes
|
|
20
|
+
containing Localizable.strings file path under `file` and duplicate entry
|
|
21
|
+
key under `key`.
|
|
22
|
+
|
|
23
|
+
## Development
|
|
24
|
+
|
|
25
|
+
1. Clone this repo
|
|
26
|
+
2. Run `bundle install` to setup dependencies.
|
|
27
|
+
3. Run `bundle exec rake spec` to run the tests.
|
|
28
|
+
4. Use `bundle exec guard` to automatically have tests run as you make changes.
|
|
29
|
+
5. Make your changes.
|
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,47 @@
|
|
|
1
|
+
# coding: utf-8
|
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
|
+
require 'duplicate_localizable_strings/gem_version.rb'
|
|
5
|
+
|
|
6
|
+
Gem::Specification.new do |spec|
|
|
7
|
+
spec.name = 'danger-duplicate_localizable_strings'
|
|
8
|
+
spec.version = DuplicateLocalizableStrings::VERSION
|
|
9
|
+
spec.authors = ['AirHelp']
|
|
10
|
+
spec.email = ['ah-mobile@airhelp.com']
|
|
11
|
+
spec.description = %q{A danger plugin for checking detecting duplicates in Localizable.strings files.}
|
|
12
|
+
spec.summary = %q{A danger plugin for checking detecting duplicates in Localizable.strings files.}
|
|
13
|
+
spec.homepage = 'https://github.com/AirHelp/danger-duplicate_localizable_strings'
|
|
14
|
+
spec.license = 'MIT'
|
|
15
|
+
|
|
16
|
+
spec.files = `git ls-files`.split($/)
|
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
|
19
|
+
spec.require_paths = ['lib']
|
|
20
|
+
|
|
21
|
+
spec.add_runtime_dependency 'danger', '~>2.0'
|
|
22
|
+
|
|
23
|
+
# General ruby development
|
|
24
|
+
spec.add_development_dependency 'bundler', '~> 1.3'
|
|
25
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
|
26
|
+
|
|
27
|
+
# Testing support
|
|
28
|
+
spec.add_development_dependency 'rspec', '~> 3.4'
|
|
29
|
+
|
|
30
|
+
# Linting code and docs
|
|
31
|
+
spec.add_development_dependency "rubocop", "~> 0.41"
|
|
32
|
+
spec.add_development_dependency "yard", "~> 0.8"
|
|
33
|
+
|
|
34
|
+
# Makes testing easy via `bundle exec guard`
|
|
35
|
+
spec.add_development_dependency 'guard', '~> 2.14'
|
|
36
|
+
spec.add_development_dependency 'guard-rspec', '~> 4.7'
|
|
37
|
+
|
|
38
|
+
# If you want to work on older builds of ruby
|
|
39
|
+
spec.add_development_dependency 'listen', '3.0.7'
|
|
40
|
+
|
|
41
|
+
# This gives you the chance to run a REPL inside your test
|
|
42
|
+
# via
|
|
43
|
+
# require 'pry'
|
|
44
|
+
# binding.pry
|
|
45
|
+
# This will stop test execution and let you inspect the results
|
|
46
|
+
spec.add_development_dependency 'pry'
|
|
47
|
+
end
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
require 'duplicate_localizable_strings/gem_version'
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
require 'duplicate_localizable_strings/plugin'
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
module Danger
|
|
2
|
+
#
|
|
3
|
+
# Simple plugin that checks for duplicate entries in changed
|
|
4
|
+
# Localizable.strings files
|
|
5
|
+
#
|
|
6
|
+
# @example Checks whether there are duplicate entries in Localizable.strings
|
|
7
|
+
#
|
|
8
|
+
# check_localizable_duplicates
|
|
9
|
+
#
|
|
10
|
+
# @tags localization
|
|
11
|
+
#
|
|
12
|
+
class DangerCheckLocalizableDuplicates < Plugin
|
|
13
|
+
#
|
|
14
|
+
# Returns an array of all detected duplicate entries. An entry is
|
|
15
|
+
# represented by a has with file path under 'file' key and the
|
|
16
|
+
# Localizable.strings key under 'key' key.
|
|
17
|
+
#
|
|
18
|
+
# @return [Array of duplicate Localizable.strings entries]
|
|
19
|
+
#
|
|
20
|
+
def localizable_duplicate_entries
|
|
21
|
+
localizable_files = (git.modified_files + git.added_files) - git.deleted_files
|
|
22
|
+
localizable_files.select! { |line| line.end_with?('.strings') }
|
|
23
|
+
|
|
24
|
+
duplicate_entries = []
|
|
25
|
+
|
|
26
|
+
localizable_files.each do |file|
|
|
27
|
+
lines = File.readlines(file)
|
|
28
|
+
|
|
29
|
+
# Grab just the keys, translations might be different
|
|
30
|
+
keys = lines.map { |e| e.split('=').first }
|
|
31
|
+
# Filter newlines and comments
|
|
32
|
+
keys = keys.select do |e|
|
|
33
|
+
e != "\n" && !e.start_with?('/*') && !e.start_with?('//')
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
# Grab keys that appear more than once
|
|
37
|
+
duplicate_keys = keys.select { |e| keys.rindex(e) != keys.index(e) }
|
|
38
|
+
# And make sure we have one entry per duplicate key
|
|
39
|
+
duplicate_keys = duplicate_keys.uniq
|
|
40
|
+
|
|
41
|
+
duplicate_keys.each do |key|
|
|
42
|
+
duplicate_entries << { 'file' => file, 'key' => key }
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
duplicate_entries
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
#
|
|
50
|
+
# Prints passed duplicated entries.
|
|
51
|
+
#
|
|
52
|
+
# @return [void]
|
|
53
|
+
#
|
|
54
|
+
def print_duplicate_entries(duplicate_entries)
|
|
55
|
+
message = "#### Found duplicate entries in Localizable.strings files \n"
|
|
56
|
+
|
|
57
|
+
message << "| File | Key |\n"
|
|
58
|
+
message << "| ---- | --- |\n"
|
|
59
|
+
|
|
60
|
+
duplicate_entries.each do |entry|
|
|
61
|
+
file = entry['file']
|
|
62
|
+
key = entry['key']
|
|
63
|
+
|
|
64
|
+
message << "| #{file} | #{key} | \n"
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
markdown message
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
#
|
|
71
|
+
# Checks whether there are any duplicated entries in all Localizable.strings
|
|
72
|
+
# files and prints out any found duplicates.
|
|
73
|
+
#
|
|
74
|
+
# @return [void]
|
|
75
|
+
#
|
|
76
|
+
def check_localizable_duplicates
|
|
77
|
+
entries = localizable_duplicate_entries
|
|
78
|
+
print_duplicate_entries entries unless entries.empty?
|
|
79
|
+
end
|
|
80
|
+
end
|
|
81
|
+
end
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
require File.expand_path('../spec_helper', __FILE__)
|
|
2
|
+
|
|
3
|
+
module Danger
|
|
4
|
+
describe Danger::DangerDuplicateLocalizableStrings do
|
|
5
|
+
it 'should be a plugin' do
|
|
6
|
+
expect(Danger::DangerDuplicateLocalizableStrings.new(nil)).to be_a Danger::Plugin
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
describe 'with Dangerfile' do
|
|
10
|
+
before do
|
|
11
|
+
@dangerfile = testing_dangerfile
|
|
12
|
+
@plugin = @dangerfile.duplicate_localizable_strings
|
|
13
|
+
|
|
14
|
+
allow(@plugin.git).to receive(:deleted_files).and_return([])
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
context 'when there are Localizable.strings files in changeset' do
|
|
18
|
+
context 'when the Localizable.strings file contains duplicates' do
|
|
19
|
+
before do
|
|
20
|
+
allow(@plugin.git).to receive(:modified_files)
|
|
21
|
+
.and_return(['spec/fixtures/LocalizableWithDuplicates1.strings'])
|
|
22
|
+
allow(@plugin.git).to receive(:added_files)
|
|
23
|
+
.and_return(['spec/fixtures/LocalizableWithDuplicates2.strings'])
|
|
24
|
+
|
|
25
|
+
@plugin.check_localizable_duplicates
|
|
26
|
+
@output = @plugin.status_report[:markdowns].first
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
it 'contains header' do
|
|
30
|
+
expect(@output).to include('Found duplicate entries in Localizable.strings files')
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
it 'contains information about key from first file' do
|
|
34
|
+
expect(@output).to include('| spec/fixtures/LocalizableWithDuplicates1.strings | "Fixture Key 2 In File 1" |')
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
it 'contains infromation about key from second file' do
|
|
38
|
+
expect(@output).to include('| spec/fixtures/LocalizableWithDuplicates2.strings | "Fixture Key 3 In File 2" |')
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
context 'when the Localizable.strings file does not contain duplicates' do
|
|
43
|
+
before do
|
|
44
|
+
allow(@plugin.git).to receive(:modified_files)
|
|
45
|
+
.and_return(['spec/fixtures/ModifiedSwiftFile.swift'])
|
|
46
|
+
allow(@plugin.git).to receive(:added_files)
|
|
47
|
+
.and_return(['spec/fixtures/LocalizableWithoutDuplicates.strings'])
|
|
48
|
+
|
|
49
|
+
@plugin.check_localizable_duplicates
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
it 'does not warn about duplicate entries in Localizable.strings' do
|
|
53
|
+
expect(@plugin.status_report[:markdowns].first).to be_nil
|
|
54
|
+
end
|
|
55
|
+
end
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
context 'when there are no Localizable.strings files in changeset' do
|
|
59
|
+
before do
|
|
60
|
+
allow(@plugin.git).to receive(:modified_files)
|
|
61
|
+
.and_return(['spec/fixtures/ModifiedSwiftFile.swift'])
|
|
62
|
+
allow(@plugin.git).to receive(:added_files)
|
|
63
|
+
.and_return(['spec/fixtures/AddedSwiftFile.swift'])
|
|
64
|
+
|
|
65
|
+
@plugin.check_localizable_duplicates
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
it 'does not warn about duplicate entries in Localizable.strings' do
|
|
69
|
+
expect(@plugin.status_report[:markdowns].first).to be_nil
|
|
70
|
+
end
|
|
71
|
+
end
|
|
72
|
+
end
|
|
73
|
+
end
|
|
74
|
+
end
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
"Fixture Key 1 In File 1"="Fixture Value 1 In File 1";
|
|
2
|
+
"Fixture Key 2 In File 1"="Fixture Value 2 In File 1";
|
|
3
|
+
"Fixture Key 2 In File 1"="Fixture Value 2 In File 1";
|
|
4
|
+
"Fixture Key 3 In File 1"="Fixture Value 3 In File 1";
|
|
5
|
+
"Fixture Key 4 In File 1"="Fixture Value 4 In File 1";
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
"Fixture Key 1 In File 2"="Fixture Value 1 In File 2";
|
|
2
|
+
"Fixture Key 2 In File 2"="Fixture Value 2 In File 2";
|
|
3
|
+
"Fixture Key 3 In File 2"="Fixture Value 3 In File 2";
|
|
4
|
+
"Fixture Key 3 In File 2"="Fixture Value 3 In File 2";
|
|
5
|
+
"Fixture Key 4 In File 2"="Fixture Value 4 In File 2";
|
data/spec/spec_helper.rb
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
require 'pathname'
|
|
2
|
+
ROOT = Pathname.new(File.expand_path('../../', __FILE__))
|
|
3
|
+
$:.unshift((ROOT + 'lib').to_s)
|
|
4
|
+
$:.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,209 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: danger-duplicate_localizable_strings
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.0.1
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- AirHelp
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: bin
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2016-08-09 00:00:00.000000000 Z
|
|
12
|
+
dependencies:
|
|
13
|
+
- !ruby/object:Gem::Dependency
|
|
14
|
+
name: danger
|
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
|
16
|
+
requirements:
|
|
17
|
+
- - ~>
|
|
18
|
+
- !ruby/object:Gem::Version
|
|
19
|
+
version: '2.0'
|
|
20
|
+
type: :runtime
|
|
21
|
+
prerelease: false
|
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
23
|
+
requirements:
|
|
24
|
+
- - ~>
|
|
25
|
+
- !ruby/object:Gem::Version
|
|
26
|
+
version: '2.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 for checking detecting duplicates in Localizable.strings
|
|
154
|
+
files.
|
|
155
|
+
email:
|
|
156
|
+
- ah-mobile@airhelp.com
|
|
157
|
+
executables: []
|
|
158
|
+
extensions: []
|
|
159
|
+
extra_rdoc_files: []
|
|
160
|
+
files:
|
|
161
|
+
- .gitignore
|
|
162
|
+
- .travis.yml
|
|
163
|
+
- Gemfile
|
|
164
|
+
- Gemfile.lock
|
|
165
|
+
- Guardfile
|
|
166
|
+
- LICENSE.txt
|
|
167
|
+
- README.md
|
|
168
|
+
- Rakefile
|
|
169
|
+
- danger-duplicate_localizable_strings.gemspec
|
|
170
|
+
- lib/danger_duplicate_localizable_strings.rb
|
|
171
|
+
- lib/danger_plugin.rb
|
|
172
|
+
- lib/duplicate_localizable_strings/gem_version.rb
|
|
173
|
+
- lib/duplicate_localizable_strings/plugin.rb
|
|
174
|
+
- spec/duplicate_localizable_strings_spec.rb
|
|
175
|
+
- spec/fixtures/LocalizableWithDuplicates1.strings
|
|
176
|
+
- spec/fixtures/LocalizableWithDuplicates2.strings
|
|
177
|
+
- spec/fixtures/LocalizableWithoutDuplicates.strings
|
|
178
|
+
- spec/spec_helper.rb
|
|
179
|
+
homepage: https://github.com/AirHelp/danger-duplicate_localizable_strings
|
|
180
|
+
licenses:
|
|
181
|
+
- MIT
|
|
182
|
+
metadata: {}
|
|
183
|
+
post_install_message:
|
|
184
|
+
rdoc_options: []
|
|
185
|
+
require_paths:
|
|
186
|
+
- lib
|
|
187
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
188
|
+
requirements:
|
|
189
|
+
- - '>='
|
|
190
|
+
- !ruby/object:Gem::Version
|
|
191
|
+
version: '0'
|
|
192
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
193
|
+
requirements:
|
|
194
|
+
- - '>='
|
|
195
|
+
- !ruby/object:Gem::Version
|
|
196
|
+
version: '0'
|
|
197
|
+
requirements: []
|
|
198
|
+
rubyforge_project:
|
|
199
|
+
rubygems_version: 2.4.6
|
|
200
|
+
signing_key:
|
|
201
|
+
specification_version: 4
|
|
202
|
+
summary: A danger plugin for checking detecting duplicates in Localizable.strings
|
|
203
|
+
files.
|
|
204
|
+
test_files:
|
|
205
|
+
- spec/duplicate_localizable_strings_spec.rb
|
|
206
|
+
- spec/fixtures/LocalizableWithDuplicates1.strings
|
|
207
|
+
- spec/fixtures/LocalizableWithDuplicates2.strings
|
|
208
|
+
- spec/fixtures/LocalizableWithoutDuplicates.strings
|
|
209
|
+
- spec/spec_helper.rb
|