leandocument 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +12 -0
- data/bin/leandocument +12 -4
- data/lib/leandocument/document.rb +33 -2
- data/lib/leandocument/server.rb +2 -2
- data/lib/leandocument/version.rb +1 -1
- data/public/javascripts/application.js +2 -0
- metadata +2 -2
data/README.md
CHANGED
@@ -10,6 +10,7 @@
|
|
10
10
|
|
11
11
|
or
|
12
12
|
> $ git clone https://github.com/LeanDocument/README.git
|
13
|
+
|
13
14
|
> $ cd README
|
14
15
|
|
15
16
|
and
|
@@ -18,6 +19,17 @@ and
|
|
18
19
|
|
19
20
|
> open http://localhost:4567/
|
20
21
|
|
22
|
+
## ChangeLog
|
23
|
+
|
24
|
+
### 0.0.4
|
25
|
+
|
26
|
+
- Support brother text.
|
27
|
+
|
28
|
+
## TODO
|
29
|
+
# Output to HTML
|
30
|
+
|
31
|
+
$ leandocument -o OUTPUT_PATH
|
32
|
+
|
21
33
|
![Index](https://dl.dropbox.com/u/49508/leandocument/index.png)
|
22
34
|
|
23
35
|
## LICENSE
|
data/bin/leandocument
CHANGED
@@ -1,9 +1,13 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
require "slop"
|
3
3
|
argv = ARGV.dup
|
4
|
-
slop = Slop.
|
5
|
-
|
6
|
-
|
4
|
+
slop = Slop.parse do
|
5
|
+
banner "$ leandocument [options]"
|
6
|
+
on :p, :port=, "port number for http server (default is 4567)"
|
7
|
+
on :o, :output=, "HTML output path(option)"
|
8
|
+
on :l, :lang=, "Target language(option)"
|
9
|
+
end
|
10
|
+
|
7
11
|
begin
|
8
12
|
slop.parse!(argv)
|
9
13
|
rescue => e
|
@@ -17,4 +21,8 @@ options[:port] ||= 4567
|
|
17
21
|
$LOAD_PATH.unshift File.expand_path("../../lib", __FILE__)
|
18
22
|
require "leandocument"
|
19
23
|
|
20
|
-
|
24
|
+
unless options[:output].nil?
|
25
|
+
Leandocument::Server.output(options)
|
26
|
+
else
|
27
|
+
Leandocument::Server.start(options)
|
28
|
+
end
|
@@ -13,7 +13,7 @@ module Leandocument
|
|
13
13
|
# settings :: LeanDocument Settings. TODO read settings.
|
14
14
|
# base_path :: Document path.
|
15
15
|
# indent :: Document indent. Child documents are plus on from parent. Then change to h[2-7] tag from h[1-6] tag. <h1> -> <h2>
|
16
|
-
attr_accessor :lang, :settings, :base_path, :indent, :extension, :web_path, :childs, :repository, :commit
|
16
|
+
attr_accessor :lang, :settings, :base_path, :indent, :extension, :web_path, :childs, :repository, :commit, :browsers, :filename
|
17
17
|
|
18
18
|
# Generate Document class.
|
19
19
|
# ==== Args
|
@@ -21,13 +21,15 @@ module Leandocument
|
|
21
21
|
# ==== Return
|
22
22
|
# New Leandocument Document class.
|
23
23
|
def initialize(options = {})
|
24
|
-
self.lang = options[:lang] ||
|
24
|
+
self.lang = options[:lang] || setting_value("default_locale")
|
25
25
|
self.base_path = options[:base_path] || Dir.pwd
|
26
26
|
self.web_path = "#{options[:web_path]}/"
|
27
27
|
self.indent = options[:indent] || 1
|
28
28
|
self.settings = options[:settings] || load_config
|
29
29
|
self.extension = get_extension
|
30
|
+
self.filename = options[:filename] || file_name
|
30
31
|
self.childs = []
|
32
|
+
self.browsers = []
|
31
33
|
self.repository = options[:repository]
|
32
34
|
self.commit = options[:commit]
|
33
35
|
end
|
@@ -40,6 +42,11 @@ module Leandocument
|
|
40
42
|
path = File.dirname(file_path)
|
41
43
|
# Get child content.
|
42
44
|
# A reflexive.
|
45
|
+
files(path).each do |file|
|
46
|
+
doc = Document.new :base_path => self.base_path, :lang => self.lang, :indent => self.indent, :settings => self.settings, :web_path => self.web_path, :commit => self.commit, :repository => self.repository, :filename => file
|
47
|
+
self.browsers << doc
|
48
|
+
page += doc.to_html
|
49
|
+
end
|
43
50
|
dirs(path).each do |dir|
|
44
51
|
# Plus one indent from parent. Change h[1-6] tag to h[2-7] if indent is 1.
|
45
52
|
doc = Document.new :base_path => dir, :lang => self.lang, :indent => self.indent + 1, :settings => self.settings, :web_path => dir.gsub(self.base_path, ""), :commit => self.commit, :repository => self.repository
|
@@ -81,6 +88,11 @@ module Leandocument
|
|
81
88
|
end
|
82
89
|
|
83
90
|
def file_name(ext = nil)
|
91
|
+
return self.filename if self.filename
|
92
|
+
basic_file_name(ext)
|
93
|
+
end
|
94
|
+
|
95
|
+
def basic_file_name(ext = nil)
|
84
96
|
"README.#{self.lang}.#{ext ? ext : self.extension}"
|
85
97
|
end
|
86
98
|
|
@@ -152,6 +164,25 @@ module Leandocument
|
|
152
164
|
File::ftype(expand_path) == "directory" ? expand_path : nil
|
153
165
|
end
|
154
166
|
|
167
|
+
def f(f, path)
|
168
|
+
return nil if f =~ /^\./
|
169
|
+
expand_path = File.expand_path(f, path)
|
170
|
+
File::ftype(expand_path) == "file" && browser?(f) ? f : nil
|
171
|
+
end
|
172
|
+
|
173
|
+
def browser?(f)
|
174
|
+
return nil if f == basic_file_name
|
175
|
+
f =~ /^README.*\.#{self.lang}\.#{self.extension}/
|
176
|
+
end
|
177
|
+
|
178
|
+
def files(path)
|
179
|
+
return [] if self.filename != basic_file_name
|
180
|
+
ary = Dir.entries(path).collect do |f|
|
181
|
+
f(f, path)
|
182
|
+
end
|
183
|
+
ary.delete(nil)
|
184
|
+
ary
|
185
|
+
end
|
155
186
|
# Return child directories from target directory
|
156
187
|
# ==== Args
|
157
188
|
# path :: Target directory
|
data/lib/leandocument/server.rb
CHANGED
@@ -8,8 +8,8 @@ module Leandocument
|
|
8
8
|
enable :partial_underscores
|
9
9
|
set :public_folder, File.dirname(File.dirname(File.dirname(__FILE__))) + '/public'
|
10
10
|
set :views, File.dirname(File.dirname(File.dirname(__FILE__))) + '/views'
|
11
|
-
def self.start
|
12
|
-
self.run!
|
11
|
+
def self.start(options = {})
|
12
|
+
self.run!(options)
|
13
13
|
end
|
14
14
|
|
15
15
|
get '/' do
|
data/lib/leandocument/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: leandocument
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
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: 2012-10-
|
12
|
+
date: 2012-10-16 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: slop
|