octocounter 0.1.2 → 0.1.3

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b8b355d77d9ffad5e641bff456c9747f5bb75afc
4
- data.tar.gz: 14d4018beb029824024de7c6780211a2b13167de
3
+ metadata.gz: b11e8449a533df79b3aed3ebca176d6cc9b27f4a
4
+ data.tar.gz: 33a52e733f7f3a8884438d90c7110ff8d6680563
5
5
  SHA512:
6
- metadata.gz: c6b541aee5e70606b124062f3210f0a0d806fa874c41e97b1fe9ac3bcf5e7b93ec65a3cf2cb8c97430c8683840f8e16cf9c002cb2c41f3d414ce8a70c0621f8b
7
- data.tar.gz: c91b003310aa8d0368d987f49a55076b445fd83a31ec5d96140fe36fbb05462a957f15da83c42827a11541f3ded571893fb5e374e841d25833a1255ba0957f01
6
+ metadata.gz: 17da731f05194708b0e283c66b1dc0ce42ba95edd8d303936ed88c7b319f928f098c274745247814b4ccec25bf981f3d1d6333dbcd96be2acd581f3504cb4d10
7
+ data.tar.gz: cd71a58760533d70d7d0dfadcd1c1a4a52800b7c8fef3cf34b10ca2c3361bda985082002557bb528551b348408f043cc59ebd2d850084301b21bcf13eeda48dd
data/README.md CHANGED
@@ -7,8 +7,14 @@
7
7
 
8
8
  ## Usage
9
9
 
10
+ * show biggest count
11
+
10
12
  `$ octocounter path/to/directory`
11
13
 
14
+ * show all list files
15
+
16
+ `$ octocounter path/to/directory --all`
17
+
12
18
  ## Result
13
19
 
14
20
  | Files | Content | Count |
@@ -6,12 +6,13 @@ module Octocounter
6
6
 
7
7
  REGEX_PATH = %r{/\/$/}
8
8
 
9
- attr_accessor :path, :list
9
+ attr_accessor :path, :list, :all
10
10
 
11
- def initialize(path)
11
+ def initialize(path, all)
12
12
  path = "#{path}/" unless path =~ REGEX_PATH
13
13
  @path = path
14
14
  @list = []
15
+ @all = all
15
16
  end
16
17
 
17
18
  def calculate
@@ -53,9 +54,16 @@ module Octocounter
53
54
  end
54
55
 
55
56
  def print_to_screen
56
- rows = calculate.map do |item|
57
- [item[:files], content(item), item[:count]]
58
- end
57
+ rows =
58
+ if all
59
+ calculate.map do |item|
60
+ [item[:files], content(item), item[:count]]
61
+ end
62
+ else
63
+ item = calculate.inject { |memo, i| memo && (memo[:count] > i[:count]) ? memo : i }
64
+ [[item[:files], content(item), item[:count]]]
65
+ end
66
+
59
67
  puts Terminal::Table.new headings: ["Files", "Content", "Count"], rows: rows, style: { all_separators: true }
60
68
  end
61
69
  end
@@ -1,3 +1,3 @@
1
1
  module Octocounter
2
- VERSION = "0.1.2"
2
+ VERSION = "0.1.3"
3
3
  end
data/lib/octocounter.rb CHANGED
@@ -25,10 +25,11 @@ module Octocounter
25
25
  command :run do |c|
26
26
  c.syntax = "octocounter path/to/directory"
27
27
  c.description = DESCRIPTION
28
- c.action do |args|
28
+ c.option '--all', String, "Show all list"
29
+ c.action do |args, options|
29
30
  path = args.shift || abort(PATH_ARG)
30
31
 
31
- counter = Octocounter::Counter.new(path)
32
+ counter = Octocounter::Counter.new(path, options.all)
32
33
 
33
34
  counter.print_to_screen
34
35
  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.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dimas J. Taniawan