qman 0.0.2 → 0.0.3
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 +4 -4
- data/bin/qman +102 -3
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 39020bb45440170f34a28a085026ed013f94c494
|
|
4
|
+
data.tar.gz: 9c91d6b559267e453cdd2ab787a730d7e0fba2ac
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: a318150529536982de3d670f550fa204fbca2b0ed100576141b86a0c8a8bd20663bb6b1631807981bcb6f46890f5c80a4d00db84ba09d75b6a10746c0b1d9835
|
|
7
|
+
data.tar.gz: a6c51f25a025c3e0411498e040bb11d4c273ea4474c410f1a890c336260145e9880158140b10bea94c82a19c3bab304bf802ffbdcf6677863f3a96ff6dbaecc2
|
data/bin/qman
CHANGED
|
@@ -5,9 +5,108 @@ require 'git'
|
|
|
5
5
|
require 'logger'
|
|
6
6
|
require 'open-uri'
|
|
7
7
|
require 'json'
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
|
|
9
|
+
require 'git'
|
|
10
|
+
require 'fileutils'
|
|
11
|
+
|
|
12
|
+
class Settings
|
|
13
|
+
QMAN_CONFIG_DIR = File.expand_path "~/.qman"
|
|
14
|
+
QMAN_CONFIG_FILEPATH = QMAN_CONFIG_DIR + "/repo_url"
|
|
15
|
+
QMAN_DATA_DIRNAME = "data"
|
|
16
|
+
|
|
17
|
+
def repo_path
|
|
18
|
+
QMAN_CONFIG_DIR + "/" + QMAN_DATA_DIRNAME
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
attr_accessor :repo_url
|
|
22
|
+
|
|
23
|
+
def initialize
|
|
24
|
+
if File.exists? QMAN_CONFIG_FILEPATH
|
|
25
|
+
@repo_url = File.readlines(QMAN_CONFIG_FILEPATH).first.chomp
|
|
26
|
+
else
|
|
27
|
+
first_time_config
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def first_time_config
|
|
32
|
+
@repo_url = get_first_time_repo_url
|
|
33
|
+
while not validate_repo_url(repo_url)
|
|
34
|
+
puts "Repo invalid. Retry:"
|
|
35
|
+
@repo_url = STDIN.gets
|
|
36
|
+
@repo_url = repo_url.chomp
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
FileUtils.mkdir_p(QMAN_CONFIG_DIR)
|
|
40
|
+
File.open(QMAN_CONFIG_FILEPATH, 'w') { |file| file.write(@repo_url) }
|
|
41
|
+
|
|
42
|
+
# Clone the repository
|
|
43
|
+
g = Git.clone(@repo_url, QMAN_DATA_DIRNAME, :path => QMAN_CONFIG_DIR)
|
|
44
|
+
if g.nil?
|
|
45
|
+
puts "Could not clone the repo."
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
def get_first_time_repo_url
|
|
50
|
+
puts "Welcome! This is the first time you run qman."
|
|
51
|
+
puts "Please inform the repo to be used (you can create a new one for free at github.com):"
|
|
52
|
+
repo_url = STDIN.gets
|
|
53
|
+
repo_url = repo_url.chomp
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
def validate_repo_url(url)
|
|
57
|
+
return true
|
|
58
|
+
end
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
def print_mod
|
|
62
|
+
'####################################################' + "\n" +
|
|
63
|
+
' ________ _____ ______ ________ ________ ' + "\n" +
|
|
64
|
+
' |\ __ \|\ _ \ _ \|\ __ \|\ ___ \ ' + "\n" +
|
|
65
|
+
' \ \ \|\ \ \ \\\\\__\ \ \ \ \|\ \ \ \\\\ \ \ ' + "\n" +
|
|
66
|
+
' \ \ \\\\\ \ \ \\|__|\\ \ \ \ __ \ \ \\\\ \ \ ' + "\n" +
|
|
67
|
+
' \ \ \\\\\ \ \ \ \ \ \ \ \ \ \ \ \\\\ \ \ ' + "\n" +
|
|
68
|
+
' \ \_____ \ \__\ \ \__\ \__\ \__\ \__\\\\ \__\ ' + "\n" +
|
|
69
|
+
' \|___| \__\|__| \|__|\|__|\|__|\|__| \|__| ' + "\n" +
|
|
70
|
+
' \|__| ' + "\n" +
|
|
71
|
+
'####################################################' + "\n\n" +
|
|
72
|
+
'Collaborative MAN pages ' + "\n\n"
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
def print_no_results(query)
|
|
76
|
+
"( Sorry, I could no find qman files related to #{query} )" + "\n\n" +
|
|
77
|
+
' o ^__^ ' + "\n" +
|
|
78
|
+
' o (oo)\_______ ' + "\n" +
|
|
79
|
+
' (__)\ )\/\ ' + "\n" +
|
|
80
|
+
' ||----w | ' + "\n" +
|
|
81
|
+
' || || ' + "\n"
|
|
82
|
+
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
def levenshtein_distance(s, t)
|
|
86
|
+
m = s.length
|
|
87
|
+
n = t.length
|
|
88
|
+
return m if n == 0
|
|
89
|
+
return n if m == 0
|
|
90
|
+
d = Array.new(m+1) {Array.new(n+1)}
|
|
91
|
+
|
|
92
|
+
(0..m).each {|i| d[i][0] = i}
|
|
93
|
+
(0..n).each {|j| d[0][j] = j}
|
|
94
|
+
(1..n).each do |j|
|
|
95
|
+
(1..m).each do |i|
|
|
96
|
+
d[i][j] = if s[i-1] == t[j-1]
|
|
97
|
+
d[i-1][j-1]
|
|
98
|
+
else
|
|
99
|
+
[ d[i-1][j]+1,
|
|
100
|
+
d[i][j-1]+1,
|
|
101
|
+
d[i-1][j-1]+1,
|
|
102
|
+
].min
|
|
103
|
+
end
|
|
104
|
+
end
|
|
105
|
+
end
|
|
106
|
+
d[m][n]
|
|
107
|
+
end
|
|
108
|
+
|
|
109
|
+
|
|
11
110
|
|
|
12
111
|
ARGV << '-h' if ARGV.empty?
|
|
13
112
|
|