octocounter 0.1.0 → 0.1.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 +4 -4
- data/README.md +2 -2
- data/lib/octocounter/counter.rb +6 -3
- data/lib/octocounter/version.rb +1 -1
- 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: b24b5139412adc0e56b9bf45205c7655953b6632
|
4
|
+
data.tar.gz: 0188cf89c6d316d084d0ef2dc707665edcc1c831
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7b4618bdf98cd02735b43764e75a2bdf3126d816d4336ee86e66ff640fba42f7dc8c1ded88a1761f95b21031f63fdf6a315515958da6c936f24a4d4b41af2f97
|
7
|
+
data.tar.gz: 551109fc6ab98a4993a5e9bb76aaf24a985af6cf6f9c1a511052ded172f09756a6943b33213cbb77caf79df487cf7fc3dd7a6528ed179eda8c0976adea88a69b
|
data/README.md
CHANGED
data/lib/octocounter/counter.rb
CHANGED
@@ -13,11 +13,12 @@ module Octocounter
|
|
13
13
|
def calculate
|
14
14
|
list = []
|
15
15
|
Dir.glob(path + "**/*").select { |f| File.file?(f) }.each do |file|
|
16
|
+
file_path = File.open(file).path
|
16
17
|
if matched = list.find { |item| FileUtils.compare_file(item[:file], file) }
|
17
18
|
matched[:count] += 1
|
18
|
-
matched[:files] = "#{matched[:files]}\n#{
|
19
|
+
matched[:files] = "#{matched[:files]}\n#{file_path}"
|
19
20
|
else
|
20
|
-
list.push(files:
|
21
|
+
list.push(files: file_path, file: file, count: 1)
|
21
22
|
end
|
22
23
|
end
|
23
24
|
list
|
@@ -25,7 +26,9 @@ module Octocounter
|
|
25
26
|
|
26
27
|
def print_to_screen
|
27
28
|
rows = calculate.map do |item|
|
28
|
-
|
29
|
+
content = File.open(item[:file]).read.encode('UTF-8', 'binary', invalid: :replace, undef: :replace, replace: '')[0..100]
|
30
|
+
content = content.scan(/.{40}/).join("\n")
|
31
|
+
[item[:files], content, item[:count]]
|
29
32
|
end
|
30
33
|
puts Terminal::Table.new headings: ["Files", "Content", "Count"], rows: rows, style: { all_separators: true }
|
31
34
|
end
|
data/lib/octocounter/version.rb
CHANGED