agen 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/agen/finder.rb +21 -10
- data/lib/agen/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: df67e0e93c7d387a143caea30f6227dcbe30b3adcb6aab2ef1c820a4acd1dbba
|
4
|
+
data.tar.gz: dc330d76655aefdf9f0ceaafa5d421426e4883d422c5cfe48347609e3734acdc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1739ef52ab785d37134f7f91bbcc3875997086fe53f4e142afe35770e5fb28075a24dc9727eee7b986ceecc36f6f206cd84690cee5f10065eb44817de77db9c5
|
7
|
+
data.tar.gz: c05fab9189e7300f4915a293ee8b55d5a6a1e41a91003e786d46ad76bfc7f2c31ca1b2933524f45d0e1d537bdec3bd70604d863372eaec95a290e4995af5cba7
|
data/Gemfile.lock
CHANGED
data/lib/agen/finder.rb
CHANGED
@@ -2,20 +2,31 @@
|
|
2
2
|
|
3
3
|
module Agen
|
4
4
|
class Finder
|
5
|
+
LIMIT = 5
|
6
|
+
MIN_CHARS = 6
|
7
|
+
|
5
8
|
def initialize(histfile)
|
6
9
|
@histfile = histfile
|
7
10
|
end
|
8
11
|
|
9
|
-
def commands(limit
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
12
|
+
def commands(limit: LIMIT, min_chars: MIN_CHARS)
|
13
|
+
lines
|
14
|
+
.each_with_object(Hash.new(0)) do |line, commands|
|
15
|
+
cmd = line.split(";").last.delete("\n")
|
16
|
+
commands[cmd] += 1 if cmd != ""
|
17
|
+
rescue
|
18
|
+
end
|
19
|
+
.sort_by { |k, v| -v }
|
20
|
+
.to_h
|
21
|
+
.keys
|
22
|
+
.select { |line| line.length >= min_chars }
|
23
|
+
.first(limit)
|
24
|
+
end
|
25
|
+
|
26
|
+
private
|
27
|
+
|
28
|
+
def lines
|
29
|
+
File.readlines(@histfile).reverse
|
19
30
|
end
|
20
31
|
end
|
21
32
|
end
|
data/lib/agen/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: agen
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jonathan Thom
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-04-
|
11
|
+
date: 2021-04-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -103,7 +103,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
103
103
|
- !ruby/object:Gem::Version
|
104
104
|
version: '0'
|
105
105
|
requirements: []
|
106
|
-
rubygems_version: 3.
|
106
|
+
rubygems_version: 3.2.15
|
107
107
|
signing_key:
|
108
108
|
specification_version: 4
|
109
109
|
summary: Generate shell aliases based on commonly entered commands.
|