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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 43ec40b6400566c0adf7aed5269f7993406411cf1037168bb9ce08b5470d780b
4
- data.tar.gz: 2d14004d0980aac0df863d338d57b578fcfa6ad05c9be420284749a25e0fd955
3
+ metadata.gz: df67e0e93c7d387a143caea30f6227dcbe30b3adcb6aab2ef1c820a4acd1dbba
4
+ data.tar.gz: dc330d76655aefdf9f0ceaafa5d421426e4883d422c5cfe48347609e3734acdc
5
5
  SHA512:
6
- metadata.gz: a29757826256b1216ff6a64bf55a7319e8387b316d6f348fb8b331ec03e019d32b6ef6b9333a13e4009581746b826717860f620970a68014d64f334080f1f726
7
- data.tar.gz: da2af239a0df07715433ba9699ac5e2f55cf0041a14aee9c5967b967624f9112cf0ddbe456d8d57c1cb615e5eb61b6ec264f4ba2e65d607a8f1ec5161370c709
6
+ metadata.gz: 1739ef52ab785d37134f7f91bbcc3875997086fe53f4e142afe35770e5fb28075a24dc9727eee7b986ceecc36f6f206cd84690cee5f10065eb44817de77db9c5
7
+ data.tar.gz: c05fab9189e7300f4915a293ee8b55d5a6a1e41a91003e786d46ad76bfc7f2c31ca1b2933524f45d0e1d537bdec3bd70604d863372eaec95a290e4995af5cba7
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- agen (0.1.2)
4
+ agen (0.1.3)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
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 = 5)
10
- File.readlines(@histfile).reverse.each_with_object(Hash.new(0)) do |line, commands|
11
- begin
12
- cmd = line.split(";").last.delete("\n")
13
- if cmd != ""
14
- commands[line.split(";").last.delete("\n")] += 1
15
- end
16
- rescue
17
- end
18
- end.sort_by { |k, v| -v }.to_h.keys.first(limit)
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Agen
4
- VERSION = "0.1.2"
4
+ VERSION = "0.1.3"
5
5
  end
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.2
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-24 00:00:00.000000000 Z
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.1.4
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.