myrurema 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +2 -13
- data/VERSION +1 -1
- data/bin/rurema +48 -15
- metadata +4 -4
data/Rakefile
CHANGED
@@ -22,24 +22,13 @@ end
|
|
22
22
|
|
23
23
|
desc "install current source as a gem"
|
24
24
|
task :dogfood => [:gemspec, :build] do
|
25
|
-
sh "
|
25
|
+
sh "gemi pkg/#{PROJECT_NAME}-#{File.read("VERSION").chomp}.gem"
|
26
26
|
end
|
27
27
|
|
28
28
|
desc "uninstall the installed gem"
|
29
29
|
task :undogfood do
|
30
|
-
sh "
|
30
|
+
sh "gemi -u #{PROJECT_NAME}"
|
31
31
|
end
|
32
32
|
|
33
33
|
desc "uninstall, then install current source as gem"
|
34
34
|
task :redogfood => [:undogfood, :dogfood]
|
35
|
-
|
36
|
-
desc "uninstall temporary gem and install from github"
|
37
|
-
task :nodogfood do
|
38
|
-
sh "sudo gem uninstall #{PROJECT_NAME}"
|
39
|
-
sh "sudo gem install yhara-#{PROJECT_NAME}"
|
40
|
-
end
|
41
|
-
|
42
|
-
desc "check for gem to be built"
|
43
|
-
task :stalk do
|
44
|
-
sh "gemstalk yhara #{PROJECT_NAME}"
|
45
|
-
end
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.2
|
data/bin/rurema
CHANGED
@@ -43,23 +43,31 @@ class Options
|
|
43
43
|
"specify Ruby version (default: #{@rubyver})"){|str|
|
44
44
|
@rubyver = str
|
45
45
|
}
|
46
|
+
o.on("--version",
|
47
|
+
"show version of myrurema"){
|
48
|
+
puts MyRurema::VERSION
|
49
|
+
exit
|
50
|
+
}
|
46
51
|
o.on("--help",
|
47
52
|
"show this message"){
|
48
53
|
puts o
|
49
54
|
exit
|
50
55
|
}
|
51
56
|
}
|
52
|
-
@query = @optionparser.parse(argv)
|
57
|
+
@query, @num = @optionparser.parse(argv)
|
58
|
+
@query = "" if @query.nil?
|
59
|
+
@num = @num.to_i if @num
|
53
60
|
end
|
54
61
|
attr_reader :dry_run, :ruremadir, :rubyver, :open_browser
|
55
|
-
attr_reader :command, :query
|
62
|
+
attr_reader :command, :query, :num
|
56
63
|
|
57
64
|
def usage
|
58
65
|
puts @optionparser
|
59
66
|
end
|
60
67
|
end
|
61
68
|
|
62
|
-
class
|
69
|
+
class MyRurema
|
70
|
+
VERSION = File.read((Pathname(__FILE__).dirname/"../VERSION").expand_path)
|
63
71
|
SVN_URL = "http://jp.rubyist.net/svn/rurema"
|
64
72
|
|
65
73
|
def initialize(opt=Options.new(ARGV))
|
@@ -67,10 +75,13 @@ class Rurema
|
|
67
75
|
end
|
68
76
|
|
69
77
|
def run
|
70
|
-
|
78
|
+
case
|
79
|
+
when @opt.command
|
71
80
|
send(@opt.command)
|
72
|
-
|
81
|
+
when @opt.query.empty?
|
73
82
|
@opt.usage
|
83
|
+
when @opt.num
|
84
|
+
search_num(@opt.query, @opt.num, @opt.rubyver)
|
74
85
|
else
|
75
86
|
search(@opt.query, @opt.rubyver)
|
76
87
|
end
|
@@ -88,20 +99,26 @@ class Rurema
|
|
88
99
|
end
|
89
100
|
|
90
101
|
def search(query, ver)
|
91
|
-
|
92
|
-
puts "You don't have a database for ruby #{ver}."
|
93
|
-
puts "Make it now? [y/n]"
|
94
|
-
if $stdin.gets.chomp.downcase == "y"
|
95
|
-
init_db(ver)
|
96
|
-
else
|
97
|
-
exit
|
98
|
-
end
|
99
|
-
end
|
102
|
+
should_have_db(ver)
|
100
103
|
|
101
104
|
sh "#{bitclust_path/'bin/refe.rb'}" +
|
102
105
|
" #{query} -d #{db_path(ver)}", :silent => true
|
103
106
|
end
|
104
107
|
|
108
|
+
def search_num(query, num, ver)
|
109
|
+
should_have_db(ver)
|
110
|
+
|
111
|
+
result = `#{bitclust_path/'bin/refe.rb'} #{query} -d #{db_path(ver)}`
|
112
|
+
word = result.split[num-1]
|
113
|
+
if word
|
114
|
+
word.gsub!(/\.#/, ".") # avoid multi-hit for a module function
|
115
|
+
puts "searching #{word}"
|
116
|
+
search(word, ver)
|
117
|
+
else
|
118
|
+
error "less than #{num} entries found"
|
119
|
+
end
|
120
|
+
end
|
121
|
+
|
105
122
|
def server
|
106
123
|
th = Thread.new{
|
107
124
|
sh "#{bitclust_path/'standalone.rb'}" +
|
@@ -142,6 +159,18 @@ class Rurema
|
|
142
159
|
@opt.ruremadir / "doctree"
|
143
160
|
end
|
144
161
|
|
162
|
+
def should_have_db(ver)
|
163
|
+
unless has_db?(ver)
|
164
|
+
puts "You don't have a database for ruby #{ver}."
|
165
|
+
puts "Make it now? [y/n]"
|
166
|
+
if $stdin.gets.chomp.downcase == "y"
|
167
|
+
init_db(ver)
|
168
|
+
else
|
169
|
+
exit
|
170
|
+
end
|
171
|
+
end
|
172
|
+
end
|
173
|
+
|
145
174
|
def has_db?(ver)
|
146
175
|
db_path(ver).directory?
|
147
176
|
end
|
@@ -154,6 +183,10 @@ class Rurema
|
|
154
183
|
puts cmd unless opt[:silent]
|
155
184
|
system cmd unless @opt.dry_run
|
156
185
|
end
|
186
|
+
|
187
|
+
def error(msg)
|
188
|
+
$stderr.puts msg
|
189
|
+
end
|
157
190
|
end
|
158
191
|
|
159
|
-
|
192
|
+
MyRurema.new.run
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: myrurema
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 27
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 2
|
10
|
+
version: 0.0.2
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Yutaka HARA
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2010-
|
18
|
+
date: 2010-07-02 00:00:00 +09:00
|
19
19
|
default_executable: rurema
|
20
20
|
dependencies: []
|
21
21
|
|