logi 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 3e5822f2e42cc3471ef6d3d064aa493c9b019130
4
+ data.tar.gz: fa4d5a7300bf72369ac2b13046ef7d698e527106
5
+ SHA512:
6
+ metadata.gz: 2524d659b6cbc5184f3232fd927021e441069e7d9a91871635b0c6d8151484ae26f3412086da3ee29f55e76a0f311718d6e43033407bf2c096f90dc977fb2a9d
7
+ data.tar.gz: f38cba42afef7f74612e191517c45041e0c98edfb7fae33c68c3c06c608e79a011d360b55ea35a4e129f4f600c15f1cdfccb0ba558672ccaa63983b1c132d9b2
@@ -0,0 +1,3 @@
1
+ [submodule "task"]
2
+ path = task
3
+ url = git://github.com/godfat/gemgem.git
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+
2
+ source 'http://rubygems.org'
3
+ gemspec
4
+ gem 'rake'
data/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
@@ -0,0 +1,49 @@
1
+ # Logi[![Build Status](https://secure.travis-ci.org/godfat/logi.png?branch=master)](http://travis-ci.org/godfat/logi)
2
+
3
+ by Lin Jen-Shin ([godfat](http://godfat.org))
4
+
5
+ ## LINKS:
6
+
7
+ * [github](https://github.com/godfat/logi)
8
+ * [rubygems](https://rubygems.org/gems/logi)
9
+ * [rdoc](http://rdoc.info/github/godfat/logi)
10
+
11
+ ## DESCRIPTION:
12
+
13
+ Highly customizable static blog/wiki generator.
14
+
15
+ ## FEATURES:
16
+
17
+ Stay tuned...
18
+
19
+ ## REQUIREMENTS:
20
+
21
+ * Tested with MRI (official CRuby) 2.0.0, Rubinius and JRuby.
22
+
23
+ ## INSTALLATION:
24
+
25
+ gem install logi
26
+
27
+ ## SYNOPSIS:
28
+
29
+ ## CONTRIBUTORS:
30
+
31
+ * Lin Jen-Shin (@godfat)
32
+
33
+ ## LICENSE:
34
+
35
+ Apache License 2.0
36
+
37
+ Copyright (c) 2013, Lin Jen-Shin (godfat)
38
+
39
+ Licensed under the Apache License, Version 2.0 (the "License");
40
+ you may not use this file except in compliance with the License.
41
+ You may obtain a copy of the License at
42
+
43
+ <http://www.apache.org/licenses/LICENSE-2.0>
44
+
45
+ Unless required by applicable law or agreed to in writing, software
46
+ distributed under the License is distributed on an "AS IS" BASIS,
47
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
48
+ See the License for the specific language governing permissions and
49
+ limitations under the License.
@@ -0,0 +1,24 @@
1
+ # encoding: utf-8
2
+
3
+ begin
4
+ require "#{dir = File.dirname(__FILE__)}/task/gemgem"
5
+ rescue LoadError
6
+ sh "git submodule update --init"
7
+ exec Gem.ruby, "-S", "rake", *ARGV
8
+ end
9
+
10
+ Gemgem.dir = dir
11
+ ($LOAD_PATH << File.expand_path("#{Gemgem.dir}/lib")).uniq!
12
+
13
+ desc 'Generate gemspec'
14
+ task 'gem:spec' do
15
+ Gemgem.spec = Gemgem.create do |s|
16
+ require 'logi/version'
17
+ s.name = 'logi'
18
+ s.version = Logi::VERSION
19
+ %w[tilt].each{ |g| s.add_dependency(g) }
20
+ %w[bacon muack].each{ |g| s.add_development_dependency(g) }
21
+ end
22
+
23
+ Gemgem.write
24
+ end
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'logi/runner'
4
+ Logi::Runner.run(ARGV)
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'logi/runner'
4
+ Logi::Runner.list(ARGV)
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'logi/runner'
4
+ Logi::Runner.post(ARGV)
@@ -0,0 +1,8 @@
1
+
2
+ layout 'default.html.erb'
3
+
4
+ post_path 'post'
5
+ output_path 'public'
6
+
7
+ post 'hello.md', :layout => 'another.html.erb'
8
+ list 'list' , :layout => 'another.html.erb'
@@ -0,0 +1,12 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <title>Another Logi</title>
6
+ <link href="//netdna.bootstrapcdn.com/twitter-bootstrap/2.3.2/css/bootstrap-combined.min.css" rel="stylesheet">
7
+ </head>
8
+ <body>
9
+ <h1>This is a specialized layout.</h1>
10
+ <%= yield %>
11
+ </body>
12
+ </html>
@@ -0,0 +1,12 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <title>Logi's example blog</title>
6
+ <link href="//netdna.bootstrapcdn.com/twitter-bootstrap/2.3.2/css/bootstrap-combined.min.css" rel="stylesheet">
7
+ </head>
8
+ <body>
9
+ <h1>This is the default layout from user.</h1>
10
+ <%= yield %>
11
+ </body>
12
+ </html>
@@ -0,0 +1,12 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <title>About Logi's example blog</title>
6
+ <link href="//netdna.bootstrapcdn.com/twitter-bootstrap/2.3.2/css/bootstrap-combined.min.css" rel="stylesheet">
7
+ </head>
8
+ <body>
9
+ <h1>This is the layout for about page.</h1>
10
+ <%= yield %>
11
+ </body>
12
+ </html>
@@ -0,0 +1,4 @@
1
+
2
+ # Hello, World!
3
+
4
+ This is my first post!
@@ -0,0 +1,4 @@
1
+
2
+ # Logi's example blog
3
+
4
+ Welcome to Logi's example blog.
@@ -0,0 +1,6 @@
1
+
2
+ # About
3
+
4
+ This is a [[about]] [[about|page]].
5
+
6
+ > This is a \[\[about\]\] \[\[about\|page\]\].
@@ -0,0 +1,15 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <title>Logi</title>
6
+ <link href="//netdna.bootstrapcdn.com/twitter-bootstrap/2.3.2/css/bootstrap-combined.min.css" rel="stylesheet">
7
+ </head>
8
+ <body>
9
+
10
+ <h1 id="hello-world">Hello, World!</h1>
11
+
12
+ <p>This is my first post!</p>
13
+
14
+ </body>
15
+ </html>
@@ -0,0 +1,15 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <title>Logi</title>
6
+ <link href="//netdna.bootstrapcdn.com/twitter-bootstrap/2.3.2/css/bootstrap-combined.min.css" rel="stylesheet">
7
+ </head>
8
+ <body>
9
+
10
+ <h1 id="logis-example-blog">Logi's example blog</h1>
11
+
12
+ <p>Welcome to Logi's example blog.</p>
13
+
14
+ </body>
15
+ </html>
@@ -0,0 +1,19 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <title>Logi</title>
6
+ <link href="//netdna.bootstrapcdn.com/twitter-bootstrap/2.3.2/css/bootstrap-combined.min.css" rel="stylesheet">
7
+ </head>
8
+ <body>
9
+
10
+ <h1 id="about">About</h1>
11
+
12
+ <p>This is a <a href="/about.html">about</a> <a href="/about.html">page</a>.</p>
13
+
14
+ <blockquote>
15
+ <p>This is a [[about]] [[about|page]].</p>
16
+ </blockquote>
17
+
18
+ </body>
19
+ </html>
@@ -0,0 +1,66 @@
1
+
2
+ require 'logi/config'
3
+
4
+ require 'fileutils'
5
+ require 'cgi'
6
+ require 'tilt'
7
+
8
+ class Logi
9
+ attr_reader :root
10
+ def initialize root='.'
11
+ @root = File.expand_path(root)
12
+ end
13
+
14
+ def make
15
+ contents.each do |path, content|
16
+ output = "#{full_output_path}/#{post_name(path)}.html"
17
+ FileUtils.mkdir_p(File.dirname(output))
18
+ File.write(output, content)
19
+ end
20
+ end
21
+
22
+ def posts
23
+ @posts ||= Dir["#{full_post_path}/**/*.*"].inject({}) do |r, path|
24
+ r[path] = layout_for(path)
25
+ r
26
+ end
27
+ end
28
+
29
+ def contents
30
+ @contents ||= posts.inject({}) do |r, (path, layout)|
31
+ content = File.read(path).gsub(/\[\[(.+?)(\|(.+?))?\]\]/) do
32
+ %Q{<a href="/#{CGI.escape_html($1)}.html">#{$3 || $1}</a>}
33
+ end
34
+ r[path] = Tilt.new(layout).render{Tilt[path].new{content}.render}
35
+ r
36
+ end
37
+ end
38
+
39
+ def config
40
+ @config ||= Logi::Config.new(root)
41
+ end
42
+
43
+ def layout_for post
44
+ config.layout[post] || Logi::Config.default_layout
45
+ end
46
+
47
+ def post_path
48
+ config['post_path'] || Logi::Config.default_post_path
49
+ end
50
+
51
+ def output_path
52
+ config['output_path'] || Logi::Config.default_output_path
53
+ end
54
+
55
+ def post_name path
56
+ path.sub("#{full_post_path}/", '').sub(/\..+$/, '')
57
+ end
58
+
59
+ def full_post_path
60
+ "#{root}/#{post_path}"
61
+ end
62
+
63
+ def full_output_path
64
+ "#{root}/#{output_path}"
65
+ end
66
+ end
File without changes
File without changes
@@ -0,0 +1,27 @@
1
+
2
+ class Logi::Config
3
+ def self.default_layout
4
+ File.expand_path("#{__dir__}/layout/default.html.erb")
5
+ end
6
+
7
+ def self.default_post_path
8
+ 'post'
9
+ end
10
+
11
+ def self.default_output_path
12
+ 'public'
13
+ end
14
+
15
+ attr_reader :root
16
+ def initialize root
17
+ @root = root
18
+ end
19
+
20
+ def layout
21
+ {}
22
+ end
23
+
24
+ def [] name
25
+ nil
26
+ end
27
+ end
@@ -0,0 +1,11 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <title>Logi</title>
6
+ <link href="//netdna.bootstrapcdn.com/twitter-bootstrap/2.3.2/css/bootstrap-combined.min.css" rel="stylesheet">
7
+ </head>
8
+ <body>
9
+ <%= yield %>
10
+ </body>
11
+ </html>
@@ -0,0 +1,36 @@
1
+
2
+ class Logi; end
3
+ module Logi::Runner
4
+ module_function
5
+ def options
6
+ end
7
+
8
+ def run argv=ARGV
9
+ require 'logi'
10
+ Logi.new('example').make
11
+ end
12
+
13
+ def post argv=ARGV
14
+ require 'logi/command/post'
15
+ end
16
+
17
+ def list argv=ARGV
18
+ require 'logi/command/list'
19
+ end
20
+
21
+ def parse argv
22
+ end
23
+
24
+ def help
25
+ maxn = options.transpose.first.map(&:size).max
26
+ maxd = options.transpose.last .map(&:size).max
27
+ "Usage: logi [OPTIONS]\n" +
28
+ options.map{ |(name, desc)|
29
+ if name.end_with?(':')
30
+ name
31
+ else
32
+ sprintf(" %-*s %-*s", maxn, name, maxd, desc)
33
+ end
34
+ }.join("\n")
35
+ end
36
+ end
@@ -0,0 +1,4 @@
1
+
2
+ class Logi
3
+ VERSION = '0.0.1'
4
+ end
@@ -0,0 +1,69 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ Gem::Specification.new do |s|
4
+ s.name = "logi"
5
+ s.version = "0.0.1"
6
+
7
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
+ s.authors = ["Lin Jen-Shin (godfat)"]
9
+ s.date = "2013-09-08"
10
+ s.description = "Highly customizable static blog/wiki generator."
11
+ s.email = ["godfat (XD) godfat.org"]
12
+ s.executables = [
13
+ "logi",
14
+ "logi-list",
15
+ "logi-post"]
16
+ s.files = [
17
+ ".gitmodules",
18
+ "Gemfile",
19
+ "LICENSE",
20
+ "README.md",
21
+ "Rakefile",
22
+ "bin/logi",
23
+ "bin/logi-list",
24
+ "bin/logi-post",
25
+ "example/config/logi.rb",
26
+ "example/layout/another.html.erb",
27
+ "example/layout/default.html.erb",
28
+ "example/layout/misc/about.html.erb",
29
+ "example/post/hello.md",
30
+ "example/post/index.md",
31
+ "example/post/misc/about.md",
32
+ "example/public/hello.html",
33
+ "example/public/index.html",
34
+ "example/public/misc/about.html",
35
+ "lib/logi.rb",
36
+ "lib/logi/command/list.rb",
37
+ "lib/logi/command/post.rb",
38
+ "lib/logi/config.rb",
39
+ "lib/logi/layout/default.html.erb",
40
+ "lib/logi/runner.rb",
41
+ "lib/logi/version.rb",
42
+ "logi.gemspec",
43
+ "pkg/logi-0.0.1.gem",
44
+ "task/.gitignore",
45
+ "task/gemgem.rb"]
46
+ s.homepage = "https://github.com/godfat/logi"
47
+ s.licenses = ["Apache License 2.0"]
48
+ s.require_paths = ["lib"]
49
+ s.rubygems_version = "2.0.7"
50
+ s.summary = "Highly customizable static blog/wiki generator."
51
+
52
+ if s.respond_to? :specification_version then
53
+ s.specification_version = 4
54
+
55
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
56
+ s.add_runtime_dependency(%q<tilt>, [">= 0"])
57
+ s.add_development_dependency(%q<bacon>, [">= 0"])
58
+ s.add_development_dependency(%q<muack>, [">= 0"])
59
+ else
60
+ s.add_dependency(%q<tilt>, [">= 0"])
61
+ s.add_dependency(%q<bacon>, [">= 0"])
62
+ s.add_dependency(%q<muack>, [">= 0"])
63
+ end
64
+ else
65
+ s.add_dependency(%q<tilt>, [">= 0"])
66
+ s.add_dependency(%q<bacon>, [">= 0"])
67
+ s.add_dependency(%q<muack>, [">= 0"])
68
+ end
69
+ end
Binary file
@@ -0,0 +1 @@
1
+ *.rbc
@@ -0,0 +1,268 @@
1
+
2
+ require 'pathname'
3
+
4
+ module Gemgem
5
+ class << self
6
+ attr_accessor :dir, :spec
7
+ end
8
+
9
+ module_function
10
+ def create
11
+ yield(spec = Gem::Specification.new{ |s|
12
+ s.authors = ['Lin Jen-Shin (godfat)']
13
+ s.email = ['godfat (XD) godfat.org']
14
+
15
+ s.description = description.join
16
+ s.summary = description.first
17
+ s.license = readme['LICENSE'].sub(/.+\n\n/, '').lines.first.strip
18
+
19
+ s.rubygems_version = Gem::VERSION
20
+ s.date = Time.now.strftime('%Y-%m-%d')
21
+ s.files = gem_files
22
+ s.test_files = gem_files.grep(%r{^test/(.+?/)*test_.+?\.rb$})
23
+ s.executables = Dir['bin/*'].map{ |f| File.basename(f) }
24
+ s.require_paths = %w[lib]
25
+ })
26
+ spec.homepage ||= "https://github.com/godfat/#{spec.name}"
27
+ spec
28
+ end
29
+
30
+ def readme
31
+ path = %w[README.md README].find{ |name|
32
+ File.exist?("#{Gemgem.dir}/#{name}")
33
+ }
34
+ @readme ||=
35
+ if path
36
+ ps = "##{File.read(path)}".
37
+ scan(/((#+)[^\n]+\n\n.+?(?=(\n\n\2[^#\n]+\n)|\Z))/m).map(&:first)
38
+ ps.inject('HEADER' => ps.first){ |r, s, i|
39
+ r[s[/\w+/]] = s
40
+ r
41
+ }
42
+ else
43
+ {}
44
+ end
45
+ end
46
+
47
+ def description
48
+ @description ||= (readme['DESCRIPTION']||'').sub(/.+\n\n/, '').lines
49
+ end
50
+
51
+ def changes
52
+ path = %w[CHANGES.md CHANGES].find{ |name|
53
+ File.exist?("#{Gemgem.dir}/#{name}")
54
+ }
55
+ @changes ||=
56
+ if path
57
+ date = '\d+{4}\-\d+{2}\-\d{2}'
58
+ File.read(path).match(
59
+ /([^\n]+#{date}\n\n(.+?))(?=\n\n[^\n]+#{date}\n|\Z)/m)[1]
60
+ else
61
+ ''
62
+ end
63
+ end
64
+
65
+ def ann_md
66
+ "#{readme['HEADER'].sub(/([\w\-]+)/, "[\\1](#{spec.homepage})")}\n\n" \
67
+ "##{readme['DESCRIPTION'][/[^\n]+\n\n[^\n]+/]}\n\n" \
68
+ "### CHANGES:\n\n" \
69
+ "###{changes}\n\n" \
70
+ "##{readme['INSTALLATION']}\n\n" +
71
+ if readme['SYNOPSIS'] then "##{readme['SYNOPSIS'][/[^\n]+\n\n[^\n]+/]}"
72
+ else '' end
73
+ end
74
+
75
+ def ann_html
76
+ gem 'nokogiri'
77
+ gem 'kramdown'
78
+
79
+ IO.popen('kramdown', 'r+') do |md|
80
+ md.puts Gemgem.ann_md
81
+ md.close_write
82
+ require 'nokogiri'
83
+ html = Nokogiri::XML.parse("<gemgem>#{md.read}</gemgem>")
84
+ html.css('*').each{ |n| n.delete('id') }
85
+ html.root.children.to_html
86
+ end
87
+ end
88
+
89
+ def ann_email
90
+ "#{readme['HEADER'].sub(/([\w\-]+)/, "\\1 <#{spec.homepage}>")}\n\n" \
91
+ "#{readme['DESCRIPTION']}\n\n" \
92
+ "#{readme['INSTALLATION']}\n\n" +
93
+ if readme['SYNOPSIS'] then "##{readme['SYNOPSIS']}\n\n" else '' end +
94
+ "## CHANGES:\n\n" \
95
+ "##{changes}\n\n"
96
+ end
97
+
98
+ def gem_tag
99
+ "#{spec.name}-#{spec.version}"
100
+ end
101
+
102
+ def write
103
+ File.open("#{dir}/#{spec.name}.gemspec", 'w'){ |f|
104
+ f << split_lines(spec.to_ruby) }
105
+ end
106
+
107
+ def split_lines ruby
108
+ ruby.gsub(/(.+?)\s*=\s*\[(.+?)\]/){ |s|
109
+ if $2.index(',')
110
+ "#{$1} = [\n #{$2.split(',').map(&:strip).join(",\n ")}]"
111
+ else
112
+ s
113
+ end
114
+ }
115
+ end
116
+
117
+ def all_files
118
+ @all_files ||= find_files(Pathname.new(dir)).map{ |file|
119
+ if file.to_s =~ %r{\.git/|\.git$}
120
+ nil
121
+ else
122
+ file.to_s
123
+ end
124
+ }.compact.sort
125
+ end
126
+
127
+ def gem_files
128
+ @gem_files ||= all_files - ignored_files
129
+ end
130
+
131
+ def ignored_files
132
+ @ignored_file ||= all_files.select{ |path| ignore_patterns.find{ |ignore|
133
+ path =~ ignore && !git_files.include?(path)}}
134
+ end
135
+
136
+ def git_files
137
+ @git_files ||= if File.exist?("#{dir}/.git")
138
+ `git ls-files`.split("\n")
139
+ else
140
+ []
141
+ end
142
+ end
143
+
144
+ # protected
145
+ def find_files path
146
+ path.children.select(&:file?).map{|file| file.to_s[(dir.size+1)..-1]} +
147
+ path.children.select(&:directory?).map{|dir| find_files(dir)}.flatten
148
+ end
149
+
150
+ def ignore_patterns
151
+ @ignore_files ||= expand_patterns(
152
+ gitignore.split("\n").reject{ |pattern|
153
+ pattern.strip == ''
154
+ }).map{ |pattern| %r{^([^/]+/)*?#{Regexp.escape(pattern)}(/[^/]+)*?$} }
155
+ end
156
+
157
+ def expand_patterns pathes
158
+ pathes.map{ |path|
159
+ if path !~ /\*/
160
+ path
161
+ else
162
+ expand_patterns(
163
+ Dir[path] +
164
+ Pathname.new(File.dirname(path)).children.select(&:directory?).
165
+ map{ |prefix| "#{prefix}/#{File.basename(path)}" })
166
+ end
167
+ }.flatten
168
+ end
169
+
170
+ def gitignore
171
+ if File.exist?(path = "#{dir}/.gitignore")
172
+ File.read(path)
173
+ else
174
+ ''
175
+ end
176
+ end
177
+ end
178
+
179
+ namespace :gem do
180
+
181
+ desc 'Install gem'
182
+ task :install => [:build] do
183
+ sh("#{Gem.ruby} -S gem install pkg/#{Gemgem.gem_tag}.gem")
184
+ end
185
+
186
+ desc 'Build gem'
187
+ task :build => [:spec] do
188
+ sh("#{Gem.ruby} -S gem build #{Gemgem.spec.name}.gemspec")
189
+ sh("mkdir -p pkg")
190
+ sh("mv #{Gemgem.gem_tag}.gem pkg/")
191
+ end
192
+
193
+ desc 'Release gem'
194
+ task :release => [:spec, :check, :build] do
195
+ sh("git tag #{Gemgem.gem_tag}")
196
+ sh("git push")
197
+ sh("git push --tags")
198
+ sh("#{Gem.ruby} -S gem push pkg/#{Gemgem.gem_tag}.gem")
199
+ end
200
+
201
+ task :check do
202
+ ver = Gemgem.spec.version.to_s
203
+
204
+ if ENV['VERSION'].nil?
205
+ puts("\e[35mExpected " \
206
+ "\e[33mVERSION\e[35m=\e[33m#{ver}\e[0m")
207
+ exit(1)
208
+
209
+ elsif ENV['VERSION'] != ver
210
+ puts("\e[35mExpected \e[33mVERSION\e[35m=\e[33m#{ver} " \
211
+ "\e[35mbut got\n " \
212
+ "\e[33mVERSION\e[35m=\e[33m#{ENV['VERSION']}\e[0m")
213
+ exit(2)
214
+ end
215
+ end
216
+
217
+ end # of gem namespace
218
+
219
+ desc 'Run tests in memory'
220
+ task :test do
221
+ require 'bacon'
222
+ Bacon.extend(Bacon::TestUnitOutput)
223
+ Bacon.summary_on_exit
224
+ $LOAD_PATH.unshift('lib')
225
+ Dir['./test/**/test_*.rb'].each{ |file| require file[0..-4] }
226
+ end
227
+
228
+ desc 'Run tests with shell'
229
+ task 'test:shell', :RUBY_OPTS do |t, args|
230
+ files = Dir['test/**/test_*.rb'].join(' ')
231
+
232
+ cmd = [Gem.ruby, args[:RUBY_OPTS],
233
+ '-I', 'lib', '-S', 'bacon', '--quiet', files]
234
+
235
+ sh(cmd.compact.join(' '))
236
+ end
237
+
238
+ desc 'Generate ann markdown'
239
+ task 'ann:md' => ['gem:spec'] do
240
+ puts Gemgem.ann_md
241
+ end
242
+
243
+ desc 'Generate ann html'
244
+ task 'ann:html' => ['gem:spec'] do
245
+ puts Gemgem.ann_html
246
+ end
247
+
248
+ desc 'Generate ann email'
249
+ task 'ann:email' => ['gem:spec'] do
250
+ puts Gemgem.ann_email
251
+ end
252
+
253
+ desc 'Generate rdoc'
254
+ task :doc => ['gem:spec'] do
255
+ sh("yardoc -o rdoc --main README.md" \
256
+ " --files #{Gemgem.spec.extra_rdoc_files.join(',')}")
257
+ end
258
+
259
+ desc 'Remove ignored files'
260
+ task :clean => ['gem:spec'] do
261
+ trash = "~/.Trash/#{Gemgem.spec.name}/"
262
+ sh "mkdir -p #{trash}" unless File.exist?(File.expand_path(trash))
263
+ Gemgem.ignored_files.each{ |file| sh "mv #{file} #{trash}" }
264
+ end
265
+
266
+ task :default do
267
+ puts `#{Gem.ruby} -S #{$PROGRAM_NAME} -T`
268
+ end
metadata ADDED
@@ -0,0 +1,118 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: logi
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Lin Jen-Shin (godfat)
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-09-08 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: tilt
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '>='
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '>='
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: bacon
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: muack
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ description: Highly customizable static blog/wiki generator.
56
+ email:
57
+ - godfat (XD) godfat.org
58
+ executables:
59
+ - logi
60
+ - logi-list
61
+ - logi-post
62
+ extensions: []
63
+ extra_rdoc_files: []
64
+ files:
65
+ - .gitmodules
66
+ - Gemfile
67
+ - LICENSE
68
+ - README.md
69
+ - Rakefile
70
+ - bin/logi
71
+ - bin/logi-list
72
+ - bin/logi-post
73
+ - example/config/logi.rb
74
+ - example/layout/another.html.erb
75
+ - example/layout/default.html.erb
76
+ - example/layout/misc/about.html.erb
77
+ - example/post/hello.md
78
+ - example/post/index.md
79
+ - example/post/misc/about.md
80
+ - example/public/hello.html
81
+ - example/public/index.html
82
+ - example/public/misc/about.html
83
+ - lib/logi.rb
84
+ - lib/logi/command/list.rb
85
+ - lib/logi/command/post.rb
86
+ - lib/logi/config.rb
87
+ - lib/logi/layout/default.html.erb
88
+ - lib/logi/runner.rb
89
+ - lib/logi/version.rb
90
+ - logi.gemspec
91
+ - pkg/logi-0.0.1.gem
92
+ - task/.gitignore
93
+ - task/gemgem.rb
94
+ homepage: https://github.com/godfat/logi
95
+ licenses:
96
+ - Apache License 2.0
97
+ metadata: {}
98
+ post_install_message:
99
+ rdoc_options: []
100
+ require_paths:
101
+ - lib
102
+ required_ruby_version: !ruby/object:Gem::Requirement
103
+ requirements:
104
+ - - '>='
105
+ - !ruby/object:Gem::Version
106
+ version: '0'
107
+ required_rubygems_version: !ruby/object:Gem::Requirement
108
+ requirements:
109
+ - - '>='
110
+ - !ruby/object:Gem::Version
111
+ version: '0'
112
+ requirements: []
113
+ rubyforge_project:
114
+ rubygems_version: 2.0.7
115
+ signing_key:
116
+ specification_version: 4
117
+ summary: Highly customizable static blog/wiki generator.
118
+ test_files: []