myrurema 0.0.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.mkd +80 -0
- data/Rakefile +45 -0
- data/VERSION +1 -0
- data/bin/rurema +140 -0
- data/features/basic_commands.feature +27 -0
- metadata +71 -0
data/README.mkd
ADDED
@@ -0,0 +1,80 @@
|
|
1
|
+
myrurema
|
2
|
+
========
|
3
|
+
|
4
|
+
myrurema は、Rubyの次世代日本語版リファレンスである
|
5
|
+
「Rubyリファレンスマニュアル刷新計画」(通称るりま) のリファレンスを
|
6
|
+
手軽に参照するためのツールです。
|
7
|
+
|
8
|
+
インストール
|
9
|
+
------------
|
10
|
+
|
11
|
+
Ruby >= 1.8.xと、Subversionが必要です。
|
12
|
+
|
13
|
+
RubyGemsでインストールします。
|
14
|
+
|
15
|
+
$ sudo gem install myrurema
|
16
|
+
|
17
|
+
するとruremaコマンドが使えるようになります。
|
18
|
+
|
19
|
+
$ rurema
|
20
|
+
(ヘルプが表示される)
|
21
|
+
|
22
|
+
使い方
|
23
|
+
------
|
24
|
+
|
25
|
+
順を追って説明します。
|
26
|
+
|
27
|
+
### 初期化
|
28
|
+
|
29
|
+
まず、リファレンスのデータをダウンロードする必要があります。
|
30
|
+
|
31
|
+
$ rurema --init
|
32
|
+
|
33
|
+
のようにすると、~/.rurema/以下にbitclustとdoctreeをダウンロードし、
|
34
|
+
新しくデータベースを作成します。
|
35
|
+
(データベースの作成には数分かかります。)
|
36
|
+
|
37
|
+
別のディレクトリにインストールしたい場合はruremadirオプションを指定します。
|
38
|
+
|
39
|
+
$ rurema --init --ruremadir=/some/where
|
40
|
+
|
41
|
+
### データベースについて
|
42
|
+
|
43
|
+
bitclustは、Rubyの各バージョンに合わせたデータベースを
|
44
|
+
作成するようになっています。デフォルトでは、お使いのRubyと
|
45
|
+
同じバージョンのデータベースを生成します。
|
46
|
+
|
47
|
+
別のRubyバージョン用のリファレンスデータベースを作成するには、
|
48
|
+
rubyverオプションを指定します。
|
49
|
+
|
50
|
+
$ rurema --init --rubyver=1.9.2
|
51
|
+
|
52
|
+
### リファレンスを引く
|
53
|
+
|
54
|
+
ruremaコマンドにメソッド名やクラス名を与えると、リファレンスを表示します。
|
55
|
+
|
56
|
+
$ rurema Array#index
|
57
|
+
|
58
|
+
### データベースの更新
|
59
|
+
|
60
|
+
Rubyリファレンス刷新計画では、最新のRubyに完全対応したリファレンスを目指し、
|
61
|
+
日夜更新が続いています。最新のリファレンスデータに更新するには、
|
62
|
+
--updateコマンドを使います。
|
63
|
+
|
64
|
+
$ rurema --update
|
65
|
+
|
66
|
+
この場合もruremadirオプション、rubyverオプションが指定可能です。
|
67
|
+
|
68
|
+
その他
|
69
|
+
------
|
70
|
+
|
71
|
+
ライセンスはbitclustのものに準じます。
|
72
|
+
|
73
|
+
* [Rubyリファレンスマニュアル刷新計画](http://redmine.ruby-lang.org/projects/show/rurema)
|
74
|
+
* [ソースコード(github)](http://github.com/yhara/myrurema)
|
75
|
+
|
76
|
+
myruremaはいまのところyharaが個人的に作成しています。
|
77
|
+
|
78
|
+
yhara (Yutaka HARA)
|
79
|
+
http://route477.net/
|
80
|
+
yutaka.hara.gmail.com
|
data/Rakefile
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
#
|
2
|
+
# Rakefile to creating gems
|
3
|
+
#
|
4
|
+
# configurations:
|
5
|
+
PROJECT_NAME = File.basename(File.dirname(__FILE__))
|
6
|
+
|
7
|
+
begin
|
8
|
+
require 'jeweler'
|
9
|
+
rescue LoadError
|
10
|
+
puts "Jeweler not available. Install it with: sudo gem install technicalpickles-jeweler -s http://gems.github.com"
|
11
|
+
end
|
12
|
+
|
13
|
+
Jeweler::Tasks.new do |gemspec|
|
14
|
+
gemspec.name = "#{PROJECT_NAME}"
|
15
|
+
gemspec.summary = "A tool for Rurema (the new Japanese Ruby reference manual)"
|
16
|
+
gemspec.email = "yutaka.hara/at/gmail.com"
|
17
|
+
gemspec.homepage = "http://github.com/yhara/#{PROJECT_NAME}"
|
18
|
+
gemspec.description = gemspec.summary
|
19
|
+
gemspec.authors = ["Yutaka HARA"]
|
20
|
+
gemspec.executables = ["rurema"]
|
21
|
+
end
|
22
|
+
|
23
|
+
desc "install current source as a gem"
|
24
|
+
task :dogfood => [:gemspec, :build] do
|
25
|
+
sh "sudo gem install pkg/#{PROJECT_NAME}-#{File.read("VERSION").chomp}.gem"
|
26
|
+
end
|
27
|
+
|
28
|
+
desc "uninstall the installed gem"
|
29
|
+
task :undogfood do
|
30
|
+
sh "sudo gem uninstall #{PROJECT_NAME}"
|
31
|
+
end
|
32
|
+
|
33
|
+
desc "uninstall, then install current source as gem"
|
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
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.0.0
|
data/bin/rurema
ADDED
@@ -0,0 +1,140 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require 'optparse'
|
3
|
+
require 'pathname'
|
4
|
+
|
5
|
+
class Pathname; alias / +; end
|
6
|
+
|
7
|
+
class Options
|
8
|
+
def initialize(argv)
|
9
|
+
@dry_run = false
|
10
|
+
@ruremadir = Pathname("~/.rurema").expand_path
|
11
|
+
@rubyver = RUBY_VERSION
|
12
|
+
@command = nil
|
13
|
+
@query = ""
|
14
|
+
|
15
|
+
@optionparser = OptionParser.new{|o|
|
16
|
+
o.on("--init",
|
17
|
+
"initialize rurema"){
|
18
|
+
@command = :init
|
19
|
+
}
|
20
|
+
o.on("--update",
|
21
|
+
"update documents and database"){
|
22
|
+
@command = :update
|
23
|
+
}
|
24
|
+
|
25
|
+
o.on("--dry-run",
|
26
|
+
"show commands only"){
|
27
|
+
@dry_run = true
|
28
|
+
}
|
29
|
+
o.on("--ruremadir=PATH",
|
30
|
+
"specify rurema directory (default: #{@ruremadir})"){|path|
|
31
|
+
@ruremadir = Pathname(path)
|
32
|
+
}
|
33
|
+
o.on("--rubyver=STR",
|
34
|
+
"specify Ruby version (default: #{@rubyver})"){|str|
|
35
|
+
@rubyver = str
|
36
|
+
}
|
37
|
+
o.on("--help",
|
38
|
+
"show this message"){
|
39
|
+
puts o
|
40
|
+
exit
|
41
|
+
}
|
42
|
+
}
|
43
|
+
@query = @optionparser.parse(argv).join(" ")
|
44
|
+
end
|
45
|
+
attr_reader :dry_run, :ruremadir, :rubyver
|
46
|
+
attr_reader :command, :query
|
47
|
+
|
48
|
+
def usage
|
49
|
+
puts @optionparser
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
class Rurema
|
54
|
+
SVN_URL = "http://jp.rubyist.net/svn/rurema"
|
55
|
+
|
56
|
+
def initialize(opt=Options.new(ARGV))
|
57
|
+
@opt = opt
|
58
|
+
end
|
59
|
+
|
60
|
+
def run
|
61
|
+
if @opt.command
|
62
|
+
send(@opt.command)
|
63
|
+
elsif @opt.query.empty?
|
64
|
+
@opt.usage
|
65
|
+
else
|
66
|
+
search(@opt.query, @opt.rubyver)
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
def init
|
71
|
+
sh "svn co -rHEAD #{SVN_URL}/doctree/trunk #{doctree_path}"
|
72
|
+
sh "svn co -rHEAD #{SVN_URL}/bitclust/trunk #{bitclust_path}"
|
73
|
+
init_db(@opt.rubyver)
|
74
|
+
end
|
75
|
+
|
76
|
+
def update
|
77
|
+
sh "svn up #{doctree_path}"
|
78
|
+
refresh_db(@opt.rubyver)
|
79
|
+
end
|
80
|
+
|
81
|
+
def search(query, ver)
|
82
|
+
unless has_db?(ver)
|
83
|
+
puts "You don't have a database for ruby #{ver}."
|
84
|
+
puts "Make it now? [y/n]"
|
85
|
+
if $stdin.gets.chomp.downcase == "y"
|
86
|
+
init_db(ver)
|
87
|
+
else
|
88
|
+
exit
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
sh "#{bitclust_path/'bin/refe.rb'}" +
|
93
|
+
" #{query} -d #{db_path(ver)}", :silent => true
|
94
|
+
end
|
95
|
+
|
96
|
+
def server
|
97
|
+
# TODO
|
98
|
+
end
|
99
|
+
|
100
|
+
private
|
101
|
+
|
102
|
+
def init_db(ver)
|
103
|
+
sh "#{bitclust_path/'bin/bitclust.rb'}" +
|
104
|
+
" -d #{db_path(ver)} init version=#{ver} encoding=euc-jp"
|
105
|
+
|
106
|
+
refresh_db(ver)
|
107
|
+
end
|
108
|
+
|
109
|
+
def refresh_db(ver)
|
110
|
+
puts "Updating Rurema database:"
|
111
|
+
puts "This will take a few minutes. Please be patient."
|
112
|
+
sh "#{bitclust_path/'bin/bitclust.rb'}" +
|
113
|
+
" -d #{db_path(ver)}" +
|
114
|
+
" update --stdlibtree=#{doctree_path/'refm/api/src'}"
|
115
|
+
end
|
116
|
+
|
117
|
+
def bitclust_path
|
118
|
+
@opt.ruremadir / "bitclust"
|
119
|
+
end
|
120
|
+
|
121
|
+
def doctree_path
|
122
|
+
@opt.ruremadir / "doctree"
|
123
|
+
end
|
124
|
+
|
125
|
+
def has_db?(ver)
|
126
|
+
db_path(ver).directory?
|
127
|
+
end
|
128
|
+
|
129
|
+
def db_path(ver)
|
130
|
+
raise ArgumentError, "malformed ver: #{ver}" unless ver =~ /\A\d.\d.\d\z/
|
131
|
+
@opt.ruremadir / "db" / ver
|
132
|
+
end
|
133
|
+
|
134
|
+
def sh(cmd, opt={})
|
135
|
+
puts cmd unless opt[:silent]
|
136
|
+
system cmd unless @opt.dry_run
|
137
|
+
end
|
138
|
+
end
|
139
|
+
|
140
|
+
Rurema.new.run
|
@@ -0,0 +1,27 @@
|
|
1
|
+
Feature: Basic commands
|
2
|
+
Background:
|
3
|
+
Given I have the config file with:
|
4
|
+
"""
|
5
|
+
rubys:
|
6
|
+
- name: MRI 1.8
|
7
|
+
command: 'gem'
|
8
|
+
"""
|
9
|
+
|
10
|
+
$B%7%J%j%*(B: $B=i4|2=(B
|
11
|
+
$BA0Ds!'$k$j$^%G%#%l%/%H%j$,$J$$(B
|
12
|
+
$B$b$7!V(Brurema --init$B!W$r<B9T$7$?(B
|
13
|
+
$B$J$i$P!"$k$j$^%G%#%l%/%H%j$K!V(Bbitclust doctree$B!W$,$G$-$k(B
|
14
|
+
$B$+$D!"%G!<%?%Y!<%9$,:F9=C[$5$l$k(B
|
15
|
+
|
16
|
+
$B%7%J%j%*(B: DB$B99?7(B
|
17
|
+
$BA0Ds!'$k$j$^%G%#%l%/%H%j$K!V(Bdoctree$B!W$,$"$k(B
|
18
|
+
$B$b$7!V(Brurema --update$B!W$r<B9T$7$?(B
|
19
|
+
$B$J$i$P!"(Bdoctree$B$,%"%C%W%G!<%H$5$l$k(B
|
20
|
+
$B$+$D!"%G!<%?%Y!<%9$,:F9=C[$5$l$k(B
|
21
|
+
|
22
|
+
$B%7%J%j%*(B: $B8!:w(B
|
23
|
+
$BA0Ds!'$k$j$^%G%#%l%/%H%j$K%G!<%?%Y!<%9$,$"$k(B
|
24
|
+
$BA0Ds!'$k$j$^%G%#%l%/%H%j$K!V(Bbitclust doctree db-x.x.x$B!W$,$"$k(B
|
25
|
+
$B$b$7!V(Brurema Array$B!W$r<B9T$7$?(B
|
26
|
+
$B$J$i$P!"(BArray$B$N%I%-%e%a%s%H$,I=<($5$l$k(B
|
27
|
+
|
metadata
ADDED
@@ -0,0 +1,71 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: myrurema
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 31
|
5
|
+
prerelease: false
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 0
|
9
|
+
- 0
|
10
|
+
version: 0.0.0
|
11
|
+
platform: ruby
|
12
|
+
authors:
|
13
|
+
- Yutaka HARA
|
14
|
+
autorequire:
|
15
|
+
bindir: bin
|
16
|
+
cert_chain: []
|
17
|
+
|
18
|
+
date: 2010-06-05 00:00:00 +09:00
|
19
|
+
default_executable: rurema
|
20
|
+
dependencies: []
|
21
|
+
|
22
|
+
description: A tool for Rurema (the new Japanese Ruby reference manual)
|
23
|
+
email: yutaka.hara/at/gmail.com
|
24
|
+
executables:
|
25
|
+
- rurema
|
26
|
+
extensions: []
|
27
|
+
|
28
|
+
extra_rdoc_files:
|
29
|
+
- README.mkd
|
30
|
+
files:
|
31
|
+
- README.mkd
|
32
|
+
- Rakefile
|
33
|
+
- VERSION
|
34
|
+
- bin/rurema
|
35
|
+
- features/basic_commands.feature
|
36
|
+
has_rdoc: true
|
37
|
+
homepage: http://github.com/yhara/myrurema
|
38
|
+
licenses: []
|
39
|
+
|
40
|
+
post_install_message:
|
41
|
+
rdoc_options:
|
42
|
+
- --charset=UTF-8
|
43
|
+
require_paths:
|
44
|
+
- lib
|
45
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
46
|
+
none: false
|
47
|
+
requirements:
|
48
|
+
- - ">="
|
49
|
+
- !ruby/object:Gem::Version
|
50
|
+
hash: 3
|
51
|
+
segments:
|
52
|
+
- 0
|
53
|
+
version: "0"
|
54
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
55
|
+
none: false
|
56
|
+
requirements:
|
57
|
+
- - ">="
|
58
|
+
- !ruby/object:Gem::Version
|
59
|
+
hash: 3
|
60
|
+
segments:
|
61
|
+
- 0
|
62
|
+
version: "0"
|
63
|
+
requirements: []
|
64
|
+
|
65
|
+
rubyforge_project:
|
66
|
+
rubygems_version: 1.3.7
|
67
|
+
signing_key:
|
68
|
+
specification_version: 3
|
69
|
+
summary: A tool for Rurema (the new Japanese Ruby reference manual)
|
70
|
+
test_files: []
|
71
|
+
|