lazyme 1.0.0 → 1.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.
Files changed (5) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +25 -28
  3. data/lib/lazyme.rb +14 -8
  4. data/lib/lazyme/version.rb +1 -1
  5. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5b09686fd2e0b808b94ccdba49bb0e1882b98e76
4
- data.tar.gz: 156254b2671083e56918e0c9289a717fb3363c14
3
+ metadata.gz: f50ecb308bcaae7e0fbcf71786c9fc90ba4eb53f
4
+ data.tar.gz: 0fcba3824fd50f877a946d7cc2d879f0b29f3ec7
5
5
  SHA512:
6
- metadata.gz: 347de17aa8bb6b5707653c69deea43802d489db09c5e39a88dd6ea49089a92fd91a4f0e30050a23f8123966acda3e60bb20045e6c05cddb5818b5155b97216bd
7
- data.tar.gz: 29d1dc90d3abd186e91238ed00c29543f003c31e2f437573029e2939714cb487dbb31ecd10ed89a7c319f882033cb64a07f56ba59469c134a2d1b82868f68506
6
+ metadata.gz: d4a06691f85e1a70323c3c01a1eee688c3ca674249d1e8085a4fc6166def03c62484a342a86122e78e49ee34ab845a91833434b6a815a48c147d6a0ecf925a43
7
+ data.tar.gz: 4ecfdd239ddc9ac85d5d5a143b82093c77124873bd22f73512d69679ea33cabda25d727830583d9b5e4adada9f9a240d64629208cba3f9521aaecb69439cf417
data/README.md CHANGED
@@ -10,34 +10,31 @@ gem install lazyme
10
10
  ## Usage
11
11
  ```
12
12
  lazyme =>
13
-
14
- ...
15
- +-----------------------------------------+----+
16
- | o . | 3 |
17
- | rvm | 3 |
18
- | z ios | 3 |
19
- | sudo vi /etc/hosts | 3 |
20
- | vi .git/config | 3 |
21
- | vi . | 3 |
22
- | gpl | 4 |
23
- | ping wp.pl | 4 |
24
- | z price | 4 |
25
- | c | 4 |
26
- | gpshh | 5 |
27
- | rss | 5 |
28
- | df | 5 |
29
- | .. | 5 |
30
- | vi README.md | 7 |
31
- | bu | 7 |
32
- | re | 7 |
33
- | cd | 7 |
34
- | gds | 8 |
35
- | ls | 9 |
36
- | s . | 11 |
37
- | gp | 12 |
38
- | gaa | 14 |
39
- | g | 43 |
40
- +-----------------------------------------+----+
13
+ +---------------------------------------------+-------+
14
+ | Lazyme |
15
+ +---------------------------------------------+-------+
16
+ |... | ... |
17
+ | ei | 21 |
18
+ | gpstg | 22 |
19
+ | gstp | 23 |
20
+ | zs | 28 |
21
+ | s . | 30 |
22
+ | zrr | 32 |
23
+ | gpshh | 60 |
24
+ | rss | 70 |
25
+ | c | 75 |
26
+ | gd | 107 |
27
+ | o . | 123 |
28
+ | gst | 130 |
29
+ | ls | 179 |
30
+ | gl | 310 |
31
+ | gp | 445 |
32
+ | gds | 540 |
33
+ | gaa | 817 |
34
+ | g | 3365 |
35
+ +---------------------------------------------+-------+
36
+ | Command | Count |
37
+ +---------------------------------------------+-------+
41
38
  ```
42
39
 
43
40
  You can set aliases by adding following lines into your `.bashrc` or `.zshrc` files:
@@ -12,28 +12,34 @@ module Lazyme
12
12
  end
13
13
 
14
14
  def call
15
- file = File.open(history_file_path)
16
- data = file.read.force_encoding('BINARY').
15
+ count = Hash.new(0)
17
16
 
17
+ File.read(history_file_path).force_encoding('BINARY').
18
18
  encode("UTF-8", invalid: :replace, undef: :replace).
19
19
  split("\n").map do |line|
20
20
  line.split(';').last
21
- end
22
-
23
- count = Hash.new(0)
24
-
25
- data.each do |item|
21
+ end.each do |item|
26
22
  if trimmed = trim(item)
27
23
  count[trimmed] = count[trimmed] + 1
28
24
  end
29
25
  end
30
26
 
31
27
  rows = count.sort_by {|_, v| v }.select { |el| el[1] > COUNT_LIMIT }
32
- puts Terminal::Table.new rows: rows
28
+
29
+ puts build_table(rows)
33
30
  end
34
31
 
35
32
  private
36
33
 
34
+ def build_table(rows)
35
+ Terminal::Table.new do |table|
36
+ headings = ['Command', 'Count']
37
+ table.title = "Lazyme"
38
+ table.rows = rows << :separator << headings
39
+ table.headings = headings
40
+ end
41
+ end
42
+
37
43
  def trim(item)
38
44
  if item && item.length == SIZE_LIMIT
39
45
  item.slice(0, SIZE_LIMIT)
@@ -1,3 +1,3 @@
1
1
  module Lazyme
2
- VERSION = "1.0.0"
2
+ VERSION = "1.0.1"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lazyme
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - pawurb