manr 0.0.1 → 0.1.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.
- data/README.md +14 -0
- data/bin/manr +45 -4
- data/lib/manr/version.rb +1 -1
- data/manr.gemspec +2 -1
- metadata +6 -5
data/README.md
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
# Manr
|
2
|
+
Manr is random man. It shows you random man page.
|
3
|
+
|
4
|
+
## Why is all that ?
|
5
|
+
It will help you to get know better your operating system.
|
6
|
+
|
7
|
+
## How to install it ?
|
8
|
+
gem install manr
|
9
|
+
|
10
|
+
## How to use it ?
|
11
|
+
Type this into console
|
12
|
+
|
13
|
+
$> manr
|
14
|
+
|
data/bin/manr
CHANGED
@@ -2,6 +2,10 @@
|
|
2
2
|
require 'find'
|
3
3
|
|
4
4
|
module Manr
|
5
|
+
@@list = []
|
6
|
+
@@cache_path = File.expand_path("~/.manr/cache")
|
7
|
+
@@allowed_mans = ["man1", "man5", "man6", "man8"]
|
8
|
+
|
5
9
|
def self.convert_path(path)
|
6
10
|
path = path.split("/")
|
7
11
|
path = path[path.size-1]
|
@@ -9,20 +13,57 @@ module Manr
|
|
9
13
|
path[0]
|
10
14
|
end
|
11
15
|
|
12
|
-
def self.
|
13
|
-
|
16
|
+
def self.check_allowed_man(path)
|
17
|
+
ok = false
|
18
|
+
|
19
|
+
@@allowed_mans.each do |m|
|
20
|
+
ok = ok || path.include?(m)
|
21
|
+
end
|
22
|
+
|
23
|
+
ok
|
24
|
+
end
|
25
|
+
|
26
|
+
def self.check_cache
|
27
|
+
File.exists?(@@cache_path)
|
28
|
+
end
|
29
|
+
|
30
|
+
def self.generate_cache
|
31
|
+
puts "Generating new cache..."
|
14
32
|
dir = "/usr/share/man"
|
33
|
+
@@list = []
|
15
34
|
|
16
35
|
Find.find(dir) do |path|
|
17
36
|
unless FileTest.directory?(path)
|
18
|
-
list += [convert_path(path)] if path.match(/gz$/) && path
|
37
|
+
@@list += [convert_path(path)] if path.match(/gz$/) && check_allowed_man(path)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
@@list.uniq!
|
42
|
+
@@list.sort!
|
43
|
+
|
44
|
+
dir_path = File.expand_path("~/.manr")
|
45
|
+
|
46
|
+
Dir.mkdir(dir_path) unless File.directory?(dir_path)
|
47
|
+
|
48
|
+
File.open(@@cache_path, 'w') { |f| f.write(@@list.join("\n")) }
|
49
|
+
end
|
50
|
+
|
51
|
+
def self.load_cache
|
52
|
+
@@list = []
|
53
|
+
|
54
|
+
File.open(@@cache_path, "r") do |infile|
|
55
|
+
while (line = infile.gets)
|
56
|
+
@@list += [line]
|
19
57
|
end
|
20
58
|
end
|
59
|
+
end
|
21
60
|
|
22
|
-
|
61
|
+
def self.random_manual
|
62
|
+
man = @@list[rand(@@list.size)]
|
23
63
|
exec "man #{man}"
|
24
64
|
end
|
25
65
|
end
|
26
66
|
|
67
|
+
Manr.check_cache ? Manr.load_cache : Manr.generate_cache
|
27
68
|
Manr.random_manual
|
28
69
|
|
data/lib/manr/version.rb
CHANGED
data/manr.gemspec
CHANGED
@@ -10,7 +10,7 @@ Gem::Specification.new do |s|
|
|
10
10
|
s.email = ["piotr.debosz@gmail.com"]
|
11
11
|
s.homepage = ""
|
12
12
|
s.summary = %q{Manr is random man}
|
13
|
-
s.description = %q{Manr will help you get to know your
|
13
|
+
s.description = %q{Manr will help you get to know your operating system better}
|
14
14
|
|
15
15
|
s.rubyforge_project = "manr"
|
16
16
|
|
@@ -19,3 +19,4 @@ Gem::Specification.new do |s|
|
|
19
19
|
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
20
20
|
s.require_paths = ["lib"]
|
21
21
|
end
|
22
|
+
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: manr
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 27
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
-
- 0
|
9
8
|
- 1
|
10
|
-
|
9
|
+
- 0
|
10
|
+
version: 0.1.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Piotr Pawel Debosz
|
@@ -15,11 +15,11 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-06-
|
18
|
+
date: 2011-06-26 00:00:00 +02:00
|
19
19
|
default_executable:
|
20
20
|
dependencies: []
|
21
21
|
|
22
|
-
description: Manr will help you get to know your
|
22
|
+
description: Manr will help you get to know your operating system better
|
23
23
|
email:
|
24
24
|
- piotr.debosz@gmail.com
|
25
25
|
executables:
|
@@ -31,6 +31,7 @@ extra_rdoc_files: []
|
|
31
31
|
files:
|
32
32
|
- .gitignore
|
33
33
|
- Gemfile
|
34
|
+
- README.md
|
34
35
|
- Rakefile
|
35
36
|
- bin/manr
|
36
37
|
- lib/manr.rb
|