rdoc-view 0.0.5 → 0.0.7
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +13 -1
- data/lib/rdoc-view/version.rb +1 -1
- data/lib/rdoc-view.rb +21 -10
- data/lib/views/index-html.erb +51 -0
- data/rdoc-view.gemspec +2 -1
- metadata +20 -3
data/README.rdoc
CHANGED
@@ -8,17 +8,29 @@ RDocView is a real-time viewer of RDoc/Markdown/Textile which used WebSocket.
|
|
8
8
|
|
9
9
|
= Usage
|
10
10
|
|
11
|
-
rdoc-view [-p port] [-o addr] [-t type] filename
|
11
|
+
rdoc-view [-p port] [-o addr] [-t type] [--html] filename
|
12
12
|
|
13
13
|
-p port set the port (default is 4567)
|
14
14
|
-o addr set the host (default is 0.0.0.0)
|
15
15
|
-t type set the document type (rdoc or md or textile)
|
16
16
|
if omits, judging from the extension
|
17
|
+
-h, --html convert to html.
|
17
18
|
|
18
19
|
browse http://localhost:4567/
|
19
20
|
and edit filename by your favorite editor.
|
20
21
|
Change of a file is detected and a rendering is carried out in real time.
|
21
22
|
|
23
|
+
== Example.1 (Realtime Viewer)
|
24
|
+
|
25
|
+
$ rdoc-view README.md
|
26
|
+
$ google-chrome http://localhost:4567/ &
|
27
|
+
$ vim README.md
|
28
|
+
....
|
29
|
+
|
30
|
+
== Example.2 (Convert to HTML)
|
31
|
+
|
32
|
+
$ rdoc-view --html README.md > README.html
|
33
|
+
|
22
34
|
= Blog post
|
23
35
|
Japanese: http://mt.orz.at/archives/2012/11/realtimeviewerr.html
|
24
36
|
|
data/lib/rdoc-view/version.rb
CHANGED
data/lib/rdoc-view.rb
CHANGED
@@ -11,7 +11,7 @@ require "rdoc/markup/to_html"
|
|
11
11
|
|
12
12
|
require "sinatra/base"
|
13
13
|
require "sinatra-websocket"
|
14
|
-
require "
|
14
|
+
require "listen"
|
15
15
|
require "RedCloth"
|
16
16
|
|
17
17
|
module RDocView
|
@@ -40,20 +40,22 @@ module RDocView
|
|
40
40
|
module_function :convert
|
41
41
|
|
42
42
|
class ViewApp < Sinatra::Base
|
43
|
-
|
43
|
+
|
44
|
+
opt_html = false
|
44
45
|
opt_type = nil
|
45
46
|
OptionParser.new { |op |
|
46
47
|
op.on('-p port', 'set the port (default is 4567)') { |val| set :port, Integer(val) }
|
47
48
|
op.on('-o addr', 'set the host (default is 0.0.0.0)') { |val| set :bind, val }
|
48
49
|
op.on('-t type', 'set the document type (rdoc or md or textile)',
|
49
50
|
'if omits, judging from the extension') { |val| opt_type = val.downcase }
|
51
|
+
op.on('-h', '--html', 'convert to html.') { |val| opt_html = true }
|
50
52
|
}.parse!(ARGV)
|
51
53
|
set :environment, :production
|
52
54
|
|
53
55
|
raise "ARGV is empty." if ARGV.empty?
|
54
56
|
raise "File Not Found:#{ARGV[0]}" unless File.exists?(ARGV[0])
|
55
|
-
|
56
|
-
set :target_file, ARGV[0]
|
57
|
+
|
58
|
+
set :target_file, File.expand_path(ARGV[0])
|
57
59
|
set :server, "thin"
|
58
60
|
set :sockets, []
|
59
61
|
|
@@ -61,6 +63,16 @@ module RDocView
|
|
61
63
|
set :type, opt_type
|
62
64
|
set :type, File.extname(ARGV[0]).downcase().slice(1..-1) unless support_extensions.include?(opt_type)
|
63
65
|
|
66
|
+
# HTMLに変換して終了する
|
67
|
+
if opt_html then
|
68
|
+
html = RDocView.convert(settings.target_file, settings.type)
|
69
|
+
html.force_encoding("utf-8")
|
70
|
+
tmpl_file = File.expand_path(File.dirname(__FILE__) + "/views/index-html.erb")
|
71
|
+
tmpl = ERB.new(open(tmpl_file){|f|f.read})
|
72
|
+
puts tmpl.result(binding)
|
73
|
+
exit
|
74
|
+
end
|
75
|
+
|
64
76
|
send_func = Proc.new do | ws |
|
65
77
|
if File.exists?(settings.target_file) then
|
66
78
|
# convert to html
|
@@ -79,14 +91,13 @@ module RDocView
|
|
79
91
|
end
|
80
92
|
end
|
81
93
|
|
82
|
-
#
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
delete {|b,r| }
|
87
|
-
create {|b,r| send_func.call()}
|
94
|
+
# ファイル監視
|
95
|
+
listener = Listen::Listener.new(File.dirname(settings.target_file)) do |modified, added, removed|
|
96
|
+
if modified.include?(settings.target_file) || added.include?(settings.target_file) then
|
97
|
+
send_func.call()
|
88
98
|
end
|
89
99
|
end
|
100
|
+
listener.start(false)
|
90
101
|
|
91
102
|
# 簡易的なTimer。定期的にPingを飛ばす。
|
92
103
|
th_timer = Thread.new() do
|
@@ -0,0 +1,51 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html lang="ja">
|
3
|
+
<head>
|
4
|
+
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
5
|
+
<title>RDoc Document Viewer</title>
|
6
|
+
<link href="http://developer.github.com/css/reset.css" rel="stylesheet" type="text/css" />
|
7
|
+
<link href="http://developer.github.com/css/960.css" rel="stylesheet" type="text/css" />
|
8
|
+
<link href="http://developer.github.com/css/uv_active4d.css" rel="stylesheet" type="text/css" />
|
9
|
+
<link href="http://developer.github.com/shared/css/documentation.css" rel="stylesheet" type="text/css">
|
10
|
+
<link href="http://developer.github.com/shared/css/pygments.css" rel="stylesheet" type="text/css">
|
11
|
+
<style>
|
12
|
+
.logo {
|
13
|
+
padding-top: 10px;
|
14
|
+
font-size: 48px;
|
15
|
+
}
|
16
|
+
.closed {
|
17
|
+
color: #e91000;
|
18
|
+
}
|
19
|
+
.error {
|
20
|
+
color: #e91000;
|
21
|
+
}
|
22
|
+
.opened {
|
23
|
+
color: #0065e9;
|
24
|
+
}
|
25
|
+
div.content {
|
26
|
+
width: 100%;
|
27
|
+
}
|
28
|
+
</style>
|
29
|
+
<style media="style">
|
30
|
+
#status {
|
31
|
+
display: none;
|
32
|
+
}
|
33
|
+
</style>
|
34
|
+
</head>
|
35
|
+
<body class="api">
|
36
|
+
|
37
|
+
<div id="header-wrapper">
|
38
|
+
<div id="header">
|
39
|
+
<a class="logo"><%=File.basename(settings.target_file)%></a>
|
40
|
+
</div>
|
41
|
+
</div>
|
42
|
+
|
43
|
+
<div id="wrapper">
|
44
|
+
<div class="content">
|
45
|
+
<%=html%>
|
46
|
+
</div>
|
47
|
+
</div>
|
48
|
+
|
49
|
+
</body>
|
50
|
+
</html>
|
51
|
+
|
data/rdoc-view.gemspec
CHANGED
@@ -19,7 +19,8 @@ Gem::Specification.new do |gem|
|
|
19
19
|
|
20
20
|
gem.add_dependency "sinatra"
|
21
21
|
gem.add_dependency "sinatra-websocket"
|
22
|
-
gem.add_dependency "
|
22
|
+
gem.add_dependency "listen"
|
23
|
+
gem.add_dependency "rb-inotify", "~> 0.8.8"
|
23
24
|
gem.add_dependency "rdoc"
|
24
25
|
gem.add_dependency "RedCloth"
|
25
26
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rdoc-view
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.7
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-01-
|
12
|
+
date: 2013-01-28 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: sinatra
|
@@ -44,7 +44,7 @@ dependencies:
|
|
44
44
|
- !ruby/object:Gem::Version
|
45
45
|
version: '0'
|
46
46
|
- !ruby/object:Gem::Dependency
|
47
|
-
name:
|
47
|
+
name: listen
|
48
48
|
requirement: !ruby/object:Gem::Requirement
|
49
49
|
none: false
|
50
50
|
requirements:
|
@@ -59,6 +59,22 @@ dependencies:
|
|
59
59
|
- - ! '>='
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: '0'
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
name: rb-inotify
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
66
|
+
requirements:
|
67
|
+
- - ~>
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: 0.8.8
|
70
|
+
type: :runtime
|
71
|
+
prerelease: false
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ~>
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: 0.8.8
|
62
78
|
- !ruby/object:Gem::Dependency
|
63
79
|
name: rdoc
|
64
80
|
requirement: !ruby/object:Gem::Requirement
|
@@ -106,6 +122,7 @@ files:
|
|
106
122
|
- bin/rdoc-view
|
107
123
|
- lib/rdoc-view.rb
|
108
124
|
- lib/rdoc-view/version.rb
|
125
|
+
- lib/views/index-html.erb
|
109
126
|
- lib/views/index.erb
|
110
127
|
- rdoc-view.gemspec
|
111
128
|
homepage: ''
|