octocounter 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1986e2604a478a589d294af732615d734e817c46
4
- data.tar.gz: d68394fb74ecf08f5021e65f640d384d60eba1c2
3
+ metadata.gz: b24b5139412adc0e56b9bf45205c7655953b6632
4
+ data.tar.gz: 0188cf89c6d316d084d0ef2dc707665edcc1c831
5
5
  SHA512:
6
- metadata.gz: a433f0bddc2cfcf1fc11aace886a3f6918ebca9349446eb81b4d28e36ffe36cc8f4656c8504c061cbb6c7b88da2746f9a35f1b29ab6dd1609f75edde88d4bccb
7
- data.tar.gz: c1fd8734f20f64a58af67ab2ecb291f4a56e4c69cbbbd8331e8f24e7a1f34f235daf03829f3067cbf8aa8a148d8e5ba38ecf3a0b5142bf1542632a88718f5285
6
+ metadata.gz: 7b4618bdf98cd02735b43764e75a2bdf3126d816d4336ee86e66ff640fba42f7dc8c1ded88a1761f95b21031f63fdf6a315515958da6c936f24a4d4b41af2f97
7
+ data.tar.gz: 551109fc6ab98a4993a5e9bb76aaf24a985af6cf6f9c1a511052ded172f09756a6943b33213cbb77caf79df487cf7fc3dd7a6528ed179eda8c0976adea88a69b
data/README.md CHANGED
@@ -3,11 +3,11 @@
3
3
 
4
4
  ## Installation
5
5
 
6
- $ gem install octocounter
6
+ `$ gem install octocounter`
7
7
 
8
8
  ## Usage
9
9
 
10
- $ octocounter path/to/directory
10
+ `$ octocounter path/to/directory`
11
11
 
12
12
  ## Result
13
13
 
@@ -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#{File.open(file).path}"
19
+ matched[:files] = "#{matched[:files]}\n#{file_path}"
19
20
  else
20
- list.push(files: File.open(file).path, file: file, count: 1)
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
- [item[:files], File.open(item[:file]).read[1..100], item[:count]]
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
@@ -1,3 +1,3 @@
1
1
  module Octocounter
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: octocounter
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dimas J. Taniawan