grepo 0.1.4 → 0.1.5
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 +4 -4
- data/bin/grepo +16 -3
- data/lib/grepo.rb +20 -15
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 91c96fa7f55a0e07b910a9eed01a7b7fe37d820b
|
4
|
+
data.tar.gz: 5a9224fadf7c8870369fbd4e1db9a1ea0a7b90f7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a85bdda56d97297d71d0e39a95b9bda0b12bba82047380e01c6d96ae0f57b3ba8349e5d350465a95b2e8b83ee00725bf15a9841f22c6edb65af30a1a8fe696d0
|
7
|
+
data.tar.gz: 5ec7006b18998df266ce8da47cf76ac5b53d6c205fef3a3443f41e08fb33eb3eb7baff6c6f6974c4700a56c4d27ddbed0ef308bd5480ec9c1795d987347f1ea6
|
data/bin/grepo
CHANGED
@@ -5,19 +5,32 @@ require_relative '../lib/grepo.rb'
|
|
5
5
|
arg = ARGV
|
6
6
|
action_arg = arg[0]
|
7
7
|
|
8
|
+
def get_depth
|
9
|
+
if arg[3]
|
10
|
+
depth_arg = arg[3].split(":")
|
11
|
+
if depth_arg[1]
|
12
|
+
return depth_arg[1].to_i
|
13
|
+
else
|
14
|
+
return 1
|
15
|
+
end
|
16
|
+
else
|
17
|
+
return 1
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
8
21
|
case action_arg
|
9
22
|
when "find"
|
10
23
|
file_one = arg[1] || "config/locales/en.yml"
|
11
24
|
file_two = arg[2] || "app/"
|
12
25
|
|
13
|
-
depth = arg[3]
|
26
|
+
depth = get_depth arg[3]
|
14
27
|
|
15
|
-
Grepo.new.find(file_one,
|
28
|
+
Grepo.new.find(file_one, file_two, {depth: depth} )
|
16
29
|
when "compare"
|
17
30
|
file_one = arg[1] || "config/locales/hr.yml"
|
18
31
|
file_two = arg[2] || "config/locales/en.yml"
|
19
32
|
|
20
|
-
depth = arg[3]
|
33
|
+
depth = get_depth arg[3]
|
21
34
|
|
22
35
|
Grepo.new.compare(file_one, file_two, {depth: depth})
|
23
36
|
when "find_duplicates"
|
data/lib/grepo.rb
CHANGED
@@ -58,12 +58,12 @@ class Grepo
|
|
58
58
|
# what IS NOT in en.yml
|
59
59
|
difference = @for_compare_two - @for_compare_one
|
60
60
|
if difference.count > 0
|
61
|
-
puts "
|
61
|
+
puts "In #{file_two} and not in #{file_one} :"
|
62
62
|
difference.each do |dif|
|
63
63
|
puts " #{dif}"
|
64
64
|
end
|
65
65
|
else
|
66
|
-
puts "Same
|
66
|
+
puts "Same in #{file_one} and #{file_two}"
|
67
67
|
end
|
68
68
|
end
|
69
69
|
|
@@ -152,20 +152,24 @@ class Grepo
|
|
152
152
|
end
|
153
153
|
|
154
154
|
# now find out which keys are repeating and print them out like: hr.form.whatever
|
155
|
-
duplicated_keys.
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
else
|
163
|
-
# print double keys that have nested keys
|
164
|
-
dk[:value].keys.map{|v| "#{dk[:key]}.#{v}"}.each do |sub_str|
|
165
|
-
look_for = @grep_for.find{|str| str.include? sub_str}
|
155
|
+
if duplicated_keys.count > 0
|
156
|
+
duplicated_keys.map do |dk|
|
157
|
+
puts "There are some duplicated:"
|
158
|
+
if dk[:value].is_a? String
|
159
|
+
# print double keys that haw no more nested keys
|
160
|
+
look_for = @grep_for.find{|str| str.include? "#{dk[:key]}:#{dk[:value].delete(" ")}"}
|
161
|
+
|
166
162
|
puts " #{look_for.split(":")[0]}" if look_for
|
163
|
+
else
|
164
|
+
# print double keys that have nested keys
|
165
|
+
dk[:value].keys.map{|v| "#{dk[:key]}.#{v}"}.each do |sub_str|
|
166
|
+
look_for = @grep_for.find{|str| str.include? sub_str}
|
167
|
+
puts " #{look_for.split(":")[0]}" if look_for
|
168
|
+
end
|
167
169
|
end
|
168
170
|
end
|
171
|
+
else
|
172
|
+
puts "There are no duplicates!"
|
169
173
|
end
|
170
174
|
end
|
171
175
|
end
|
@@ -207,8 +211,9 @@ class Grepo
|
|
207
211
|
end
|
208
212
|
end
|
209
213
|
|
214
|
+
#Grepo.new.find("test_project/config/locales/en.yml", "test_project/app/")
|
210
215
|
#Grepo.new.find("config/locales/en.yml", "app/", {depth: 1} )
|
211
216
|
#Grepo.new.find("config/locales/en.yml", "umye_cms/app/", {depth: 0})
|
212
|
-
#Grepo.new.compare("config/locales/hr.yml", "config/locales/en.yml", {depth: 1})
|
217
|
+
#Grepo.new.compare("test_project/config/locales/hr.yml", "test_project/config/locales/en.yml", {depth: 1})
|
213
218
|
#Grepo.new.compare("config/locales/hr.yml")
|
214
|
-
#Grepo.new.find_duplicates("config/
|
219
|
+
#Grepo.new.find_duplicates("test_project/config/locales_json/en.json")
|