lazyme 0.0.1 → 1.0.0

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: c10f4ede7be3f915b135ed794958859832f56d02
4
- data.tar.gz: 1bf95937bc2ca061d15bc1b8cd615a12c8fcceb1
3
+ metadata.gz: 5b09686fd2e0b808b94ccdba49bb0e1882b98e76
4
+ data.tar.gz: 156254b2671083e56918e0c9289a717fb3363c14
5
5
  SHA512:
6
- metadata.gz: 1f910020d4f8a9483bb34c7dea761d4d7e910190dee87369292d857b292d68faae94a3daba62d10f083226a8715f587732881610890a5c1c93a15987fe5be2f3
7
- data.tar.gz: 570cdf86c3b0be0290e45038e67b2a11ce83c4b51490ed25adda973a05135ce79dafe509be125d432e502716dc795ca6f1dda7928ffe2eb8024ef8564f525298
6
+ metadata.gz: 347de17aa8bb6b5707653c69deea43802d489db09c5e39a88dd6ea49089a92fd91a4f0e30050a23f8123966acda3e60bb20045e6c05cddb5818b5155b97216bd
7
+ data.tar.gz: 29d1dc90d3abd186e91238ed00c29543f003c31e2f437573029e2939714cb487dbb31ecd10ed89a7c319f882033cb64a07f56ba59469c134a2d1b82868f68506
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Lazyme [![Gem Version](https://badge.fury.io/rb/lazyme.svg)](http://badge.fury.io/rb/lazyme)
2
2
 
3
- Lazyme a simple gem that helps you optimise your laziness. You can display your most used shell commands so that you can change them into aliases and evetually type less.
3
+ Lazyme is a simple gem that helps you optimise your laziness. It displays your most often used shell commands so that you can change them into aliases and eventually type less.
4
4
 
5
5
  ## Installation
6
6
  ```bash
@@ -9,4 +9,41 @@ gem install lazyme
9
9
 
10
10
  ## Usage
11
11
  ```
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
+ +-----------------------------------------+----+
41
+ ```
42
+
43
+ You can set aliases by adding following lines into your `.bashrc` or `.zshrc` files:
44
+
45
+ ```
46
+ alias gr='grep --color'
47
+ alias gaa='git add . -A'
48
+ ```
12
49
 
data/bin/lazyme CHANGED
@@ -5,4 +5,4 @@ $LOAD_PATH.unshift(File.dirname(__FILE__) + '/../lib') unless $LOAD_PATH.include
5
5
 
6
6
  require 'lazyme'
7
7
 
8
- Lazyme::Main.new.call
8
+ Lazyme::Main.call
@@ -11,6 +11,7 @@ Gem::Specification.new do |gem|
11
11
  gem.summary = %q{ Lazyme a simple gem that helps you optimise your laziness }
12
12
  gem.description = %q{ Display your most used shell commands count }
13
13
  gem.homepage = "http://github.com/pawurb/lazyme"
14
+ gem.add_dependency "terminal-table"
14
15
  gem.files = `git ls-files`.split("\n")
15
16
  gem.executables = ['lazyme']
16
17
  gem.require_paths = ["lib"]
@@ -1,8 +1,16 @@
1
1
  require 'lazyme/version'
2
+ require 'terminal-table'
2
3
  require 'pp'
3
4
 
4
5
  module Lazyme
5
6
  class Main
7
+ SIZE_LIMIT = 80
8
+ COUNT_LIMIT = 2
9
+
10
+ def self.call
11
+ new.call
12
+ end
13
+
6
14
  def call
7
15
  file = File.open(history_file_path)
8
16
  data = file.read.force_encoding('BINARY').
@@ -15,12 +23,25 @@ module Lazyme
15
23
  count = Hash.new(0)
16
24
 
17
25
  data.each do |item|
18
- if item
19
- count[item] = count[item] + 1
26
+ if trimmed = trim(item)
27
+ count[trimmed] = count[trimmed] + 1
20
28
  end
21
29
  end
22
30
 
23
- pp Hash[count.sort_by {|_, v| v }]
31
+ rows = count.sort_by {|_, v| v }.select { |el| el[1] > COUNT_LIMIT }
32
+ puts Terminal::Table.new rows: rows
33
+ end
34
+
35
+ private
36
+
37
+ def trim(item)
38
+ if item && item.length == SIZE_LIMIT
39
+ item.slice(0, SIZE_LIMIT)
40
+ elsif item && item.length > SIZE_LIMIT
41
+ item.slice(0, SIZE_LIMIT) + "..."
42
+ elsif item && item.length < SIZE_LIMIT
43
+ item
44
+ end
24
45
  end
25
46
 
26
47
  def history_file_path
@@ -1,3 +1,3 @@
1
1
  module Lazyme
2
- VERSION = "0.0.1"
2
+ VERSION = "1.0.0"
3
3
  end
metadata CHANGED
@@ -1,15 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lazyme
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - pawurb
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-08-28 00:00:00.000000000 Z
12
- dependencies: []
11
+ date: 2017-12-10 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: terminal-table
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
13
27
  description: " Display your most used shell commands count "
14
28
  email:
15
29
  - p.urbanek89@gmail.com
@@ -47,7 +61,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
47
61
  version: '0'
48
62
  requirements: []
49
63
  rubyforge_project:
50
- rubygems_version: 2.6.8
64
+ rubygems_version: 2.6.14
51
65
  signing_key:
52
66
  specification_version: 4
53
67
  summary: Lazyme a simple gem that helps you optimise your laziness