leandocument 0.0.10 → 0.0.11
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +4 -0
- data/lib/leandocument/document.rb +33 -5
- data/lib/leandocument/version.rb +1 -1
- metadata +2 -2
data/README.md
CHANGED
@@ -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, :browsers, :filename
|
16
|
+
attr_accessor :lang, :settings, :base_path, :indent, :extension, :web_path, :childs, :repository, :commit, :browsers, :filename, :error_message
|
17
17
|
|
18
18
|
# Generate Document class.
|
19
19
|
# ==== Args
|
@@ -34,11 +34,22 @@ module Leandocument
|
|
34
34
|
self.commit = options[:commit]
|
35
35
|
end
|
36
36
|
|
37
|
+
def e?
|
38
|
+
return (self.error_message = "File not found. #{file_path}(#{SUPPORT_EXTENSIONS.join("|")})") unless get_extension
|
39
|
+
return (self.error_message = "Something wrong setting file. #{config_file_path}") unless self.settings
|
40
|
+
return (self.error_message = "File convert error. Please check file encoding. LeanDocument is allow only UTF-8. #{file_path}") unless self.title
|
41
|
+
nil
|
42
|
+
end
|
43
|
+
|
44
|
+
def e
|
45
|
+
self.error_message
|
46
|
+
end
|
47
|
+
|
37
48
|
# Generate HTML content.
|
38
49
|
# ==== Return
|
39
50
|
# HTML content.
|
40
51
|
def to_html
|
41
|
-
return
|
52
|
+
return e if e?
|
42
53
|
page = render.to_html
|
43
54
|
path = File.dirname(file_path)
|
44
55
|
# Get child content.
|
@@ -58,7 +69,12 @@ module Leandocument
|
|
58
69
|
end
|
59
70
|
|
60
71
|
def title
|
61
|
-
render
|
72
|
+
return "" unless render
|
73
|
+
begin
|
74
|
+
render.title
|
75
|
+
rescue ArgumentError => e
|
76
|
+
nil
|
77
|
+
end
|
62
78
|
end
|
63
79
|
|
64
80
|
def toc
|
@@ -83,9 +99,20 @@ module Leandocument
|
|
83
99
|
return nil
|
84
100
|
end
|
85
101
|
|
102
|
+
def config_file_path
|
103
|
+
"#{self.base_path}/#{SETTING_FILE_NAME}"
|
104
|
+
end
|
105
|
+
|
86
106
|
def load_config
|
87
|
-
|
88
|
-
|
107
|
+
if File.exist?(config_file_path)
|
108
|
+
begin
|
109
|
+
YAML.load_file(config_file_path)
|
110
|
+
rescue Psych::SyntaxError => e
|
111
|
+
nil
|
112
|
+
end
|
113
|
+
else
|
114
|
+
{}
|
115
|
+
end
|
89
116
|
end
|
90
117
|
|
91
118
|
def file_name(ext = nil)
|
@@ -130,6 +157,7 @@ module Leandocument
|
|
130
157
|
end
|
131
158
|
|
132
159
|
def render
|
160
|
+
return nil unless self.extension
|
133
161
|
send("render_#{self.extension}")
|
134
162
|
end
|
135
163
|
|
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.11
|
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-18 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: slop
|