huffshell 0.0.5 → 0.0.7
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.
- data/Gemfile.lock +1 -1
- data/bin/huffshell +2 -1
- data/lib/command/command_suggestion.rb +0 -2
- data/lib/command/command_word.rb +3 -1
- data/lib/huffshell.rb +16 -0
- data/lib/readers/oh_my_zsh_reader.rb +13 -8
- data/lib/shell/binary_checker.rb +1 -1
- data/lib/shell/script_line.rb +1 -1
- data/lib/tree/word_tree_node.rb +12 -4
- metadata +30 -50
data/Gemfile.lock
CHANGED
data/bin/huffshell
CHANGED
@@ -1,7 +1,6 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
3
|
require 'huffshell'
|
4
|
-
require 'colorize'
|
5
4
|
|
6
5
|
cs = CommandSuggestor.new
|
7
6
|
|
@@ -21,6 +20,8 @@ OhMyZshReader.new(history_filename).
|
|
21
20
|
shell_commands.
|
22
21
|
each{ |l| cs.add(l) }
|
23
22
|
|
23
|
+
puts cs.wordtree.root.line_count
|
24
|
+
|
24
25
|
puts ""
|
25
26
|
puts "============="
|
26
27
|
puts [cs.commands.size.to_s.green, "unique keywords"].join(" ")
|
data/lib/command/command_word.rb
CHANGED
data/lib/huffshell.rb
CHANGED
@@ -1,5 +1,21 @@
|
|
1
1
|
require 'readers/oh_my_zsh_reader'
|
2
2
|
|
3
|
+
# ruby 1.8.6
|
4
|
+
class String
|
5
|
+
def initial
|
6
|
+
self[0,1]
|
7
|
+
end
|
8
|
+
|
9
|
+
def green
|
10
|
+
self
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
begin
|
15
|
+
require 'colorize'
|
16
|
+
rescue LoadError
|
17
|
+
end
|
18
|
+
|
3
19
|
require 'command/command_word'
|
4
20
|
require 'command/command_suggestor'
|
5
21
|
require 'command/command_suggestion'
|
@@ -6,7 +6,12 @@ class OhMyZshReader
|
|
6
6
|
def initialize(file_name)
|
7
7
|
@file_name = file_name
|
8
8
|
|
9
|
-
|
9
|
+
path = File.expand_path(file_name)
|
10
|
+
if File.exists?(path)
|
11
|
+
file = File.open(path, 'r')
|
12
|
+
else
|
13
|
+
raise "File does not exist." + path.inspect
|
14
|
+
end
|
10
15
|
|
11
16
|
@file_contents = ""
|
12
17
|
|
@@ -16,7 +21,7 @@ class OhMyZshReader
|
|
16
21
|
ic = Iconv.new('UTF-8', 'UTF-8')
|
17
22
|
file.each do |l|
|
18
23
|
begin
|
19
|
-
@file_contents += ic.iconv(l)
|
24
|
+
@file_contents += ic.iconv(l) + "\n"
|
20
25
|
rescue
|
21
26
|
puts "Encoding error: #{l}"
|
22
27
|
end
|
@@ -30,15 +35,15 @@ class OhMyZshReader
|
|
30
35
|
|
31
36
|
private
|
32
37
|
|
33
|
-
def
|
34
|
-
|
38
|
+
def raw_lines
|
39
|
+
file_contents.split("\n")
|
35
40
|
end
|
36
41
|
|
37
|
-
def
|
38
|
-
|
42
|
+
def filtered_lines
|
43
|
+
raw_lines.select{|l| valid_line?(l) }
|
39
44
|
end
|
40
45
|
|
41
|
-
def
|
42
|
-
|
46
|
+
def valid_line?(line)
|
47
|
+
line.initial == ":"
|
43
48
|
end
|
44
49
|
end
|
data/lib/shell/binary_checker.rb
CHANGED
data/lib/shell/script_line.rb
CHANGED
data/lib/tree/word_tree_node.rb
CHANGED
@@ -1,5 +1,3 @@
|
|
1
|
-
require 'colorize'
|
2
|
-
|
3
1
|
class WordTreeNode
|
4
2
|
include Enumerable
|
5
3
|
|
@@ -46,7 +44,13 @@ class WordTreeNode
|
|
46
44
|
end
|
47
45
|
|
48
46
|
def truncate!(minimum)
|
49
|
-
|
47
|
+
# Ruby 1.9.2
|
48
|
+
# children.select!{|k, v| v.line_count >= minimum }
|
49
|
+
|
50
|
+
ret = {}
|
51
|
+
children.each{|k, v| ret[k] = v if v.line_count >= minimum }
|
52
|
+
self.children = ret
|
53
|
+
|
50
54
|
children.each{|k, v| v.truncate!(minimum) }
|
51
55
|
end
|
52
56
|
|
@@ -66,7 +70,11 @@ class WordTreeNode
|
|
66
70
|
end
|
67
71
|
|
68
72
|
def minimum(min)
|
69
|
-
|
73
|
+
# 1.9.2 compatibility
|
74
|
+
# children.select{|k, v| v.line_count >= min }
|
75
|
+
ret = {}
|
76
|
+
children.each{|k, v| ret[k] = v if v.line_count >= min }
|
77
|
+
ret
|
70
78
|
end
|
71
79
|
|
72
80
|
end
|
metadata
CHANGED
@@ -1,45 +1,35 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: huffshell
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.7
|
5
5
|
prerelease:
|
6
|
-
segments:
|
7
|
-
- 0
|
8
|
-
- 0
|
9
|
-
- 5
|
10
|
-
version: 0.0.5
|
11
6
|
platform: ruby
|
12
|
-
authors:
|
7
|
+
authors:
|
13
8
|
- Paul McKellar
|
14
9
|
autorequire:
|
15
10
|
bindir: bin
|
16
11
|
cert_chain: []
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
- !ruby/object:Gem::Dependency
|
12
|
+
date: 2012-06-18 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
21
15
|
name: colorize
|
22
|
-
|
23
|
-
requirement: &id001 !ruby/object:Gem::Requirement
|
16
|
+
requirement: &70228294016280 !ruby/object:Gem::Requirement
|
24
17
|
none: false
|
25
|
-
requirements:
|
26
|
-
- -
|
27
|
-
- !ruby/object:Gem::Version
|
28
|
-
|
29
|
-
segments:
|
30
|
-
- 0
|
31
|
-
version: "0"
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
32
22
|
type: :runtime
|
33
|
-
|
34
|
-
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: *70228294016280
|
25
|
+
description: A parser and recommendation system for your shell aliases based on your
|
26
|
+
shell history
|
35
27
|
email: paul.mckellar@gmail.com
|
36
|
-
executables:
|
28
|
+
executables:
|
37
29
|
- huffshell
|
38
30
|
extensions: []
|
39
|
-
|
40
31
|
extra_rdoc_files: []
|
41
|
-
|
42
|
-
files:
|
32
|
+
files:
|
43
33
|
- lib/command/command_suggestion.rb
|
44
34
|
- lib/command/command_suggestor.rb
|
45
35
|
- lib/command/command_word.rb
|
@@ -58,36 +48,26 @@ files:
|
|
58
48
|
- Readme.md
|
59
49
|
homepage: https://github.com/paulmars/huffshell
|
60
50
|
licenses: []
|
61
|
-
|
62
51
|
post_install_message:
|
63
52
|
rdoc_options: []
|
64
|
-
|
65
|
-
require_paths:
|
53
|
+
require_paths:
|
66
54
|
- lib
|
67
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
55
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
68
56
|
none: false
|
69
|
-
requirements:
|
70
|
-
- -
|
71
|
-
- !ruby/object:Gem::Version
|
72
|
-
|
73
|
-
|
74
|
-
- 0
|
75
|
-
version: "0"
|
76
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
57
|
+
requirements:
|
58
|
+
- - ! '>='
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: '0'
|
61
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
77
62
|
none: false
|
78
|
-
requirements:
|
79
|
-
- -
|
80
|
-
- !ruby/object:Gem::Version
|
81
|
-
|
82
|
-
segments:
|
83
|
-
- 0
|
84
|
-
version: "0"
|
63
|
+
requirements:
|
64
|
+
- - ! '>='
|
65
|
+
- !ruby/object:Gem::Version
|
66
|
+
version: '0'
|
85
67
|
requirements: []
|
86
|
-
|
87
68
|
rubyforge_project:
|
88
|
-
rubygems_version: 1.8.
|
69
|
+
rubygems_version: 1.8.10
|
89
70
|
signing_key:
|
90
71
|
specification_version: 3
|
91
72
|
summary: Automatic shell alias recommondations based on usage!
|
92
73
|
test_files: []
|
93
|
-
|