logi 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -1
- data/.travis.yml +11 -0
- data/CHANGES.md +16 -0
- data/README.md +31 -2
- data/Rakefile +9 -17
- data/TODO.md +7 -0
- data/example/layout/list.html.erb +2 -2
- data/lib/logi.rb +1 -1
- data/lib/logi/command.rb +47 -0
- data/lib/logi/command/list.rb +11 -3
- data/lib/logi/command/post.rb +5 -1
- data/lib/logi/compiler.rb +12 -3
- data/lib/logi/config.rb +6 -14
- data/lib/logi/default.rb +24 -0
- data/lib/logi/layout/empty.html.erb +1 -0
- data/lib/logi/loader.rb +2 -1
- data/lib/logi/logger.rb +2 -2
- data/lib/logi/post.rb +5 -1
- data/lib/logi/runner.rb +16 -14
- data/lib/logi/test.rb +13 -0
- data/lib/logi/version.rb +1 -1
- data/logi.gemspec +17 -5
- data/task/gemgem.rb +150 -154
- data/test/test_example.rb +34 -0
- metadata +27 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5de594ac9c881a4153b5e2bc19dde37a01adb8dd
|
4
|
+
data.tar.gz: 8ec9ecf75ce2d0c4aff2e04d451519cd57788648
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 084251b20f1df902bc977d9e567989bc0d0831bb587942065f1ceca3a833971cfc56ec695ac48750b3ca38e4f9d665e537c2482f2edbc7110b7de850dcbf8e64
|
7
|
+
data.tar.gz: b063fdba5b23b23caeca987377980adb5b709ff9515156a891cc29101fb38011bb981b6b5558bcc06a2215df688182cffe704fba08d64cf9f420c72fa38c9b07
|
data/.gitignore
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
pkg
|
1
|
+
/pkg/
|
2
2
|
*.rbc
|
data/.travis.yml
ADDED
data/CHANGES.md
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
# CHANGES
|
2
|
+
|
3
|
+
## logi 0.1.1 -- 2013-09-30
|
4
|
+
|
5
|
+
* It would no longer give errors if layout is absent.
|
6
|
+
Instead, it would emit a warning and use an empty layout.
|
7
|
+
* It would now expand the root you're passing.
|
8
|
+
* All commands would now follow --quiet or --nocolor options.
|
9
|
+
* JRuby support is fixed. (IO.copy_stream cannot work on non-files
|
10
|
+
on JRuby)
|
11
|
+
* `logi -h` would now print the example site path.
|
12
|
+
* [logi-list] It would now sort the posts with links.
|
13
|
+
|
14
|
+
## logi 0.1.0 -- 2013-09-20
|
15
|
+
|
16
|
+
* Birthday!
|
data/README.md
CHANGED
@@ -24,13 +24,42 @@ Highly customizable static blog/wiki generator.
|
|
24
24
|
|
25
25
|
## REQUIREMENTS:
|
26
26
|
|
27
|
-
*
|
27
|
+
* Ruby 1.9+ (Also tested with JRuby and Rubinius)
|
28
28
|
* Tilt for built-in post/list generator: `gem install tilt`
|
29
|
+
* Kramdown for markdown generator: `gem install kramdown`
|
29
30
|
|
30
31
|
## INSTALLATION:
|
31
32
|
|
33
|
+
If you have Ruby installed, you could simply run:
|
34
|
+
|
32
35
|
gem install logi
|
33
|
-
gem install tilt
|
36
|
+
gem install tilt # If you want to use built-in generators
|
37
|
+
gem install kramdown # If you want to use Markdown with tilt
|
38
|
+
|
39
|
+
If you need to install Ruby, first you should try the one provided
|
40
|
+
by your package manager.
|
41
|
+
|
42
|
+
For Arch Linux, run:
|
43
|
+
|
44
|
+
sudo pacman -Syu # Update packages list first
|
45
|
+
sudo pacman -S ruby
|
46
|
+
|
47
|
+
For Mac OS X, if you have Homebrew installed, run:
|
48
|
+
|
49
|
+
brew update # Update packages list first
|
50
|
+
brew install ruby --with-doc
|
51
|
+
|
52
|
+
For Windows, you might want to try [RubyInstaller][].
|
53
|
+
|
54
|
+
If your package manager does not yet provide Ruby 2.0,
|
55
|
+
you could try [ruby-install][] which could compile and
|
56
|
+
handle Ruby's own dependencies for you.
|
57
|
+
|
58
|
+
Or just [grab the source tarball][ruby-download] and install it manually.
|
59
|
+
|
60
|
+
[RubyInstaller]: http://rubyinstaller.org/
|
61
|
+
[ruby-install]: https://github.com/postmodern/ruby-install
|
62
|
+
[ruby-download]: https://www.ruby-lang.org/en/downloads/
|
34
63
|
|
35
64
|
## SYNOPSIS:
|
36
65
|
|
data/Rakefile
CHANGED
@@ -1,24 +1,16 @@
|
|
1
|
-
# encoding: utf-8
|
2
1
|
|
3
2
|
begin
|
4
3
|
require "#{dir = File.dirname(__FILE__)}/task/gemgem"
|
5
4
|
rescue LoadError
|
6
|
-
sh
|
7
|
-
exec Gem.ruby,
|
5
|
+
sh 'git submodule update --init'
|
6
|
+
exec Gem.ruby, '-S', $PROGRAM_NAME, *ARGV
|
8
7
|
end
|
9
8
|
|
10
|
-
Gemgem.dir
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
s.name = 'logi'
|
18
|
-
s.version = Logi::VERSION
|
19
|
-
%w[].each{ |g| s.add_dependency(g) }
|
20
|
-
%w[bacon muack tilt].each{ |g| s.add_development_dependency(g) }
|
21
|
-
end
|
22
|
-
|
23
|
-
Gemgem.write
|
9
|
+
Gemgem.init(dir) do |s|
|
10
|
+
require 'logi/version'
|
11
|
+
s.name = 'logi'
|
12
|
+
s.version = Logi::VERSION
|
13
|
+
%w[].each{ |g| s.add_dependency(g) }
|
14
|
+
%w[bacon muack
|
15
|
+
tilt kramdown].each{ |g| s.add_development_dependency(g) }
|
24
16
|
end
|
data/TODO.md
ADDED
data/lib/logi.rb
CHANGED
data/lib/logi/command.rb
ADDED
@@ -0,0 +1,47 @@
|
|
1
|
+
|
2
|
+
class Logi; end
|
3
|
+
module Logi::Command
|
4
|
+
module_function
|
5
|
+
def check_argv path, layout
|
6
|
+
[check_path(path), check_path(layout)]
|
7
|
+
end
|
8
|
+
|
9
|
+
def check_path path
|
10
|
+
if File.exist?(path)
|
11
|
+
path
|
12
|
+
else
|
13
|
+
require 'logi/logger'
|
14
|
+
extend Logi::Logger
|
15
|
+
log red("ERROR: Post does not exist: #{cyan(strip_path(path))}")
|
16
|
+
exit(1)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
def check_layout layout
|
21
|
+
if File.exist?(layout)
|
22
|
+
layout
|
23
|
+
else
|
24
|
+
require 'logi/default'
|
25
|
+
require 'logi/logger'
|
26
|
+
extend Logi::Logger
|
27
|
+
log red("WARN: Layout does not exist: #{cyan(strip_path(layout))}")
|
28
|
+
Logi::Default.empty_layout
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
def options
|
33
|
+
@options ||= {:quiet => tribool(ENV['LOGI_QUIET' ]),
|
34
|
+
:nocolor => tribool(ENV['LOGI_NOCOLOR'])}
|
35
|
+
end
|
36
|
+
|
37
|
+
def tribool value
|
38
|
+
case value
|
39
|
+
when 'true'
|
40
|
+
true
|
41
|
+
when 'false'
|
42
|
+
false
|
43
|
+
else
|
44
|
+
nil
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
data/lib/logi/command/list.rb
CHANGED
@@ -1,10 +1,18 @@
|
|
1
1
|
|
2
|
+
require 'logi/command'
|
3
|
+
|
2
4
|
require 'tilt'
|
3
5
|
|
4
6
|
class Logi ; end
|
5
7
|
module Logi::Command; end
|
6
8
|
module Logi::Command::List
|
7
|
-
|
9
|
+
extend Logi::Command
|
10
|
+
|
11
|
+
class Post < Struct.new(:link, :title)
|
12
|
+
def <=> that
|
13
|
+
link <=> that.link
|
14
|
+
end
|
15
|
+
end
|
8
16
|
|
9
17
|
module_function
|
10
18
|
def run argv
|
@@ -13,7 +21,7 @@ module Logi::Command::List
|
|
13
21
|
@posts = Dir["#{dir}/**/*.*"].map{ |post|
|
14
22
|
name = post.sub("#{dir}/", '')
|
15
23
|
Post.new(name.sub(/\..+$/, '.html'), name.sub(/\..+$/, ''))
|
16
|
-
}
|
17
|
-
puts Tilt.new(layout).render(self)
|
24
|
+
}.sort
|
25
|
+
puts Tilt.new(check_layout(layout)).render(self)
|
18
26
|
end
|
19
27
|
end
|
data/lib/logi/command/post.rb
CHANGED
@@ -1,12 +1,16 @@
|
|
1
1
|
|
2
|
+
require 'logi/command'
|
3
|
+
|
2
4
|
require 'tilt'
|
3
5
|
|
4
6
|
class Logi ; end
|
5
7
|
module Logi::Command; end
|
6
8
|
module Logi::Command::Post
|
9
|
+
extend Logi::Command
|
10
|
+
|
7
11
|
module_function
|
8
12
|
def run argv
|
9
|
-
path, layout = argv
|
13
|
+
path, layout = check_argv(*argv)
|
10
14
|
puts Tilt.new(layout).render{Tilt[path].new{$stdin.read}.render}
|
11
15
|
end
|
12
16
|
end
|
data/lib/logi/compiler.rb
CHANGED
@@ -13,22 +13,31 @@ class Logi::Compiler
|
|
13
13
|
end
|
14
14
|
|
15
15
|
def compile command, path, layout
|
16
|
-
log_compile(command, path, layout)
|
17
16
|
wiki = IO.popen("logi-wiki #{path}", 'r')
|
18
17
|
out = IO.popen("logi-#{command} #{path} #{layout}", 'r+')
|
19
|
-
|
18
|
+
copy_stream(wiki, out)
|
20
19
|
out.close_write
|
20
|
+
log_compile(command, path, layout) unless out.eof?
|
21
21
|
out
|
22
22
|
end
|
23
23
|
|
24
24
|
def write output, out
|
25
|
+
return if out.eof?
|
25
26
|
log_write(output)
|
26
27
|
FileUtils.mkdir_p(File.dirname(output))
|
27
|
-
|
28
|
+
copy_stream(out, output)
|
28
29
|
ensure
|
29
30
|
out.close
|
30
31
|
end
|
31
32
|
|
33
|
+
def copy_stream from, to
|
34
|
+
IO.copy_stream(from, to)
|
35
|
+
rescue TypeError # JRuby can only copy from file to file
|
36
|
+
to.write(from.read(8192)) until from.eof?
|
37
|
+
ensure
|
38
|
+
from.close
|
39
|
+
end
|
40
|
+
|
32
41
|
private
|
33
42
|
def log_compile command, path, layout
|
34
43
|
w = red('logi-wiki')
|
data/lib/logi/config.rb
CHANGED
@@ -1,18 +1,10 @@
|
|
1
1
|
|
2
|
+
require 'logi/default'
|
2
3
|
require 'logi/loader'
|
3
4
|
|
4
5
|
class Logi; end
|
5
6
|
class Logi::Config < Struct.new(:post_path, :layout_path,
|
6
7
|
:output_path, :default_layout)
|
7
|
-
def self.default_root_path ; '.' ; end
|
8
|
-
def self.default_post_path ; 'post' ; end
|
9
|
-
def self.default_layout_path; 'layout'; end
|
10
|
-
def self.default_output_path; 'public'; end
|
11
|
-
def self.default_command ; 'post' ; end
|
12
|
-
def self.default_layout
|
13
|
-
File.expand_path("#{__dir__}/layout/default.html.erb")
|
14
|
-
end
|
15
|
-
|
16
8
|
attr_reader :options
|
17
9
|
attr_accessor
|
18
10
|
def initialize options={}
|
@@ -25,7 +17,7 @@ class Logi::Config < Struct.new(:post_path, :layout_path,
|
|
25
17
|
end
|
26
18
|
|
27
19
|
def root
|
28
|
-
options[:root] ||
|
20
|
+
File.expand_path(options[:root] || Logi::Default.default_root_path)
|
29
21
|
end
|
30
22
|
|
31
23
|
def path
|
@@ -40,7 +32,7 @@ class Logi::Config < Struct.new(:post_path, :layout_path,
|
|
40
32
|
if layout = post.options[:layout] || default_layout
|
41
33
|
"#{root}/#{layout_path}/#{layout}"
|
42
34
|
else
|
43
|
-
|
35
|
+
Logi::Default.default_layout
|
44
36
|
end
|
45
37
|
end
|
46
38
|
|
@@ -49,14 +41,14 @@ class Logi::Config < Struct.new(:post_path, :layout_path,
|
|
49
41
|
end
|
50
42
|
|
51
43
|
def post_path
|
52
|
-
super ||
|
44
|
+
super || Logi::Default.default_post_path
|
53
45
|
end
|
54
46
|
|
55
47
|
def layout_path
|
56
|
-
super ||
|
48
|
+
super || Logi::Default.default_layout_path
|
57
49
|
end
|
58
50
|
|
59
51
|
def output_path
|
60
|
-
super ||
|
52
|
+
super || Logi::Default.default_output_path
|
61
53
|
end
|
62
54
|
end
|
data/lib/logi/default.rb
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
|
2
|
+
class Logi; end
|
3
|
+
module Logi::Default
|
4
|
+
module_function
|
5
|
+
def default_root_path ; '.' ; end
|
6
|
+
def default_post_path ; 'post' ; end
|
7
|
+
def default_layout_path; 'layout'; end
|
8
|
+
def default_output_path; 'public'; end
|
9
|
+
def default_command ; 'post' ; end
|
10
|
+
def default_layout
|
11
|
+
File.expand_path("#{__dir__}/layout/default.html.erb")
|
12
|
+
end
|
13
|
+
def empty_layout
|
14
|
+
File.expand_path("#{__dir__}/layout/empty.html.erb")
|
15
|
+
end
|
16
|
+
def example_directory
|
17
|
+
File.expand_path("#{__dir__}/../../example")
|
18
|
+
end
|
19
|
+
|
20
|
+
# For Ruby 1.9-
|
21
|
+
def __dir__
|
22
|
+
File.dirname(__FILE__)
|
23
|
+
end unless respond_to?(:__dir__, true)
|
24
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
<%= yield %>
|
data/lib/logi/loader.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
|
2
|
+
require 'logi/default'
|
2
3
|
require 'logi/post'
|
3
4
|
|
4
5
|
class Logi; end
|
@@ -14,7 +15,7 @@ class Logi::Loader
|
|
14
15
|
Dir["#{prefix}/**/*.*"].each do |fullpath|
|
15
16
|
path = fullpath.sub("#{prefix}/", '')
|
16
17
|
config.posts[path] ||=
|
17
|
-
Logi::Post.new(
|
18
|
+
Logi::Post.new(Logi::Default.default_command, path, {}, nil)
|
18
19
|
end
|
19
20
|
end
|
20
21
|
|
data/lib/logi/logger.rb
CHANGED
@@ -4,7 +4,7 @@ module Logi::Logger
|
|
4
4
|
module_function
|
5
5
|
def log msg
|
6
6
|
return if options[:quiet]
|
7
|
-
puts msg
|
7
|
+
$stderr.puts msg
|
8
8
|
end
|
9
9
|
|
10
10
|
def black text; color(30, text); end
|
@@ -18,7 +18,7 @@ module Logi::Logger
|
|
18
18
|
def color rgb, text
|
19
19
|
if nocolor = options[:nocolor]
|
20
20
|
text
|
21
|
-
elsif nocolor.nil? && !$
|
21
|
+
elsif nocolor.nil? && !$stderr.tty? # auto-detect
|
22
22
|
text
|
23
23
|
else
|
24
24
|
"\e[#{rgb}m#{text}\e[0m"
|
data/lib/logi/post.rb
CHANGED
data/lib/logi/runner.rb
CHANGED
@@ -12,13 +12,15 @@ module Logi::Runner
|
|
12
12
|
['-h, --help' , 'Print this message' ],
|
13
13
|
['-v, --version' , 'Print the version' ],
|
14
14
|
['defaults:' , '' ],
|
15
|
-
[' root directory' , Logi::
|
16
|
-
[' post directory' , Logi::
|
17
|
-
['layout directory' , Logi::
|
18
|
-
['output directory' , Logi::
|
19
|
-
[' post command' , Logi::
|
15
|
+
[' root directory' , Logi::Default. default_root_path],
|
16
|
+
[' post directory' , Logi::Default. default_post_path],
|
17
|
+
['layout directory' , Logi::Default.default_layout_path],
|
18
|
+
['output directory' , Logi::Default.default_output_path],
|
19
|
+
[' post command' , Logi::Default.default_command ],
|
20
20
|
[' layout file' , Logi::Logger.strip_path(
|
21
|
-
Logi::
|
21
|
+
Logi::Default.default_layout) ],
|
22
|
+
[' example site' , Logi::Logger.strip_path(
|
23
|
+
Logi::Default.example_directory)]]
|
22
24
|
end
|
23
25
|
|
24
26
|
def run argv=ARGV
|
@@ -32,19 +34,19 @@ module Logi::Runner
|
|
32
34
|
until argv.empty?
|
33
35
|
case arg = argv.shift
|
34
36
|
when /^-c/, '--color'
|
35
|
-
options[:nocolor] = false
|
37
|
+
ENV['LOGI_NOCOLOR'] = (options[:nocolor] = false).to_s
|
36
38
|
parse_next(argv, arg)
|
37
39
|
|
38
40
|
when /^-n/, '--no-color'
|
39
|
-
options[:nocolor] = true
|
41
|
+
ENV['LOGI_NOCOLOR'] = (options[:nocolor] = true).to_s
|
40
42
|
parse_next(argv, arg)
|
41
43
|
|
42
44
|
when /^-V/, '--verbose'
|
43
|
-
options[:quiet] = false
|
45
|
+
ENV['LOGI_QUIET'] = (options[:quiet] = false).to_s
|
44
46
|
parse_next(argv, arg)
|
45
47
|
|
46
48
|
when /^-q/, '--quiet'
|
47
|
-
options[:quiet] = true
|
49
|
+
ENV['LOGI_QUIET'] = (options[:quiet] = true).to_s
|
48
50
|
parse_next(argv, arg)
|
49
51
|
|
50
52
|
when /^-h/, '--help'
|
@@ -52,8 +54,8 @@ module Logi::Runner
|
|
52
54
|
exit
|
53
55
|
|
54
56
|
when /^-v/, '--version'
|
55
|
-
require '
|
56
|
-
puts(
|
57
|
+
require 'logi/version'
|
58
|
+
puts(Logi::VERSION)
|
57
59
|
exit
|
58
60
|
|
59
61
|
else
|
@@ -68,10 +70,10 @@ module Logi::Runner
|
|
68
70
|
end
|
69
71
|
|
70
72
|
def help
|
71
|
-
require 'logi/
|
73
|
+
require 'logi/default'
|
72
74
|
require 'logi/logger'
|
73
75
|
optt = options.transpose
|
74
|
-
maxn =
|
76
|
+
maxn = optt.first.map(&:size).max
|
75
77
|
maxd = [optt.last .map(&:size).max, `tput cols`.to_i - maxn - 4].min
|
76
78
|
"Usage: logi [OPTIONS] [PATH to logi root]\n" +
|
77
79
|
options.map{ |(name, desc)|
|
data/lib/logi/test.rb
ADDED
data/lib/logi/version.rb
CHANGED
data/logi.gemspec
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
|
-
# stub: logi 0.1.
|
2
|
+
# stub: logi 0.1.1 ruby lib
|
3
3
|
|
4
4
|
Gem::Specification.new do |s|
|
5
5
|
s.name = "logi"
|
6
|
-
s.version = "0.1.
|
6
|
+
s.version = "0.1.1"
|
7
7
|
|
8
8
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
9
9
|
s.authors = ["Lin Jen-Shin (godfat)"]
|
10
|
-
s.date = "2013-09-
|
10
|
+
s.date = "2013-09-30"
|
11
11
|
s.description = "Highly customizable static blog/wiki generator."
|
12
12
|
s.email = ["godfat (XD) godfat.org"]
|
13
13
|
s.executables = [
|
@@ -18,10 +18,13 @@ Gem::Specification.new do |s|
|
|
18
18
|
s.files = [
|
19
19
|
".gitignore",
|
20
20
|
".gitmodules",
|
21
|
+
".travis.yml",
|
22
|
+
"CHANGES.md",
|
21
23
|
"Gemfile",
|
22
24
|
"LICENSE",
|
23
25
|
"README.md",
|
24
26
|
"Rakefile",
|
27
|
+
"TODO.md",
|
25
28
|
"bin/logi",
|
26
29
|
"bin/logi-list",
|
27
30
|
"bin/logi-post",
|
@@ -39,25 +42,31 @@ Gem::Specification.new do |s|
|
|
39
42
|
"example/public/list.html",
|
40
43
|
"example/public/misc/about.html",
|
41
44
|
"lib/logi.rb",
|
45
|
+
"lib/logi/command.rb",
|
42
46
|
"lib/logi/command/list.rb",
|
43
47
|
"lib/logi/command/post.rb",
|
44
48
|
"lib/logi/command/wiki.rb",
|
45
49
|
"lib/logi/compiler.rb",
|
46
50
|
"lib/logi/config.rb",
|
51
|
+
"lib/logi/default.rb",
|
47
52
|
"lib/logi/layout/default.html.erb",
|
53
|
+
"lib/logi/layout/empty.html.erb",
|
48
54
|
"lib/logi/loader.rb",
|
49
55
|
"lib/logi/logger.rb",
|
50
56
|
"lib/logi/post.rb",
|
51
57
|
"lib/logi/runner.rb",
|
58
|
+
"lib/logi/test.rb",
|
52
59
|
"lib/logi/version.rb",
|
53
60
|
"logi.gemspec",
|
54
61
|
"task/.gitignore",
|
55
|
-
"task/gemgem.rb"
|
62
|
+
"task/gemgem.rb",
|
63
|
+
"test/test_example.rb"]
|
56
64
|
s.homepage = "https://github.com/godfat/logi"
|
57
65
|
s.licenses = ["Apache License 2.0"]
|
58
66
|
s.require_paths = ["lib"]
|
59
|
-
s.rubygems_version = "2.1.
|
67
|
+
s.rubygems_version = "2.1.5"
|
60
68
|
s.summary = "Highly customizable static blog/wiki generator."
|
69
|
+
s.test_files = ["test/test_example.rb"]
|
61
70
|
|
62
71
|
if s.respond_to? :specification_version then
|
63
72
|
s.specification_version = 4
|
@@ -66,14 +75,17 @@ Gem::Specification.new do |s|
|
|
66
75
|
s.add_development_dependency(%q<bacon>, [">= 0"])
|
67
76
|
s.add_development_dependency(%q<muack>, [">= 0"])
|
68
77
|
s.add_development_dependency(%q<tilt>, [">= 0"])
|
78
|
+
s.add_development_dependency(%q<kramdown>, [">= 0"])
|
69
79
|
else
|
70
80
|
s.add_dependency(%q<bacon>, [">= 0"])
|
71
81
|
s.add_dependency(%q<muack>, [">= 0"])
|
72
82
|
s.add_dependency(%q<tilt>, [">= 0"])
|
83
|
+
s.add_dependency(%q<kramdown>, [">= 0"])
|
73
84
|
end
|
74
85
|
else
|
75
86
|
s.add_dependency(%q<bacon>, [">= 0"])
|
76
87
|
s.add_dependency(%q<muack>, [">= 0"])
|
77
88
|
s.add_dependency(%q<tilt>, [">= 0"])
|
89
|
+
s.add_dependency(%q<kramdown>, [">= 0"])
|
78
90
|
end
|
79
91
|
end
|
data/task/gemgem.rb
CHANGED
@@ -1,14 +1,26 @@
|
|
1
1
|
|
2
|
-
require 'pathname'
|
3
|
-
|
4
2
|
module Gemgem
|
5
3
|
class << self
|
6
|
-
attr_accessor :dir, :spec
|
4
|
+
attr_accessor :dir, :spec, :spec_create
|
7
5
|
end
|
8
6
|
|
9
7
|
module_function
|
8
|
+
def gem_tag ; "#{spec.name}-#{spec.version}" ; end
|
9
|
+
def gem_path ; "#{pkg_dir}/#{gem_tag}.gem" ; end
|
10
|
+
def spec_path ; "#{dir}/#{spec.name}.gemspec" ; end
|
11
|
+
def pkg_dir ; "#{dir}/pkg" ; end
|
12
|
+
def escaped_dir; @escaped_dir ||= Regexp.escape(dir); end
|
13
|
+
|
14
|
+
def init dir, &block
|
15
|
+
self.dir = dir
|
16
|
+
$LOAD_PATH.unshift("#{dir}/lib")
|
17
|
+
ENV['RUBYLIB'] = "#{dir}/lib:#{ENV['RUBYLIB']}"
|
18
|
+
ENV['PATH'] = "#{dir}/bin:#{ENV['PATH']}"
|
19
|
+
self.spec_create = block
|
20
|
+
end
|
21
|
+
|
10
22
|
def create
|
11
|
-
|
23
|
+
spec = Gem::Specification.new do |s|
|
12
24
|
s.authors = ['Lin Jen-Shin (godfat)']
|
13
25
|
s.email = ['godfat (XD) godfat.org']
|
14
26
|
|
@@ -16,163 +28,146 @@ module Gemgem
|
|
16
28
|
s.summary = description.first
|
17
29
|
s.license = readme['LICENSE'].sub(/.+\n\n/, '').lines.first.strip
|
18
30
|
|
19
|
-
s.
|
20
|
-
s.
|
21
|
-
s.
|
22
|
-
s.
|
23
|
-
|
24
|
-
|
25
|
-
}
|
26
|
-
spec
|
27
|
-
spec
|
31
|
+
s.date = Time.now.strftime('%Y-%m-%d')
|
32
|
+
s.files = gem_files
|
33
|
+
s.test_files = test_files
|
34
|
+
s.executables = bin_files
|
35
|
+
end
|
36
|
+
spec_create.call(spec)
|
37
|
+
spec.homepage = "https://github.com/godfat/#{spec.name}"
|
38
|
+
self.spec = spec
|
28
39
|
end
|
29
40
|
|
30
|
-
def
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
ps.inject('HEADER' => ps.first){ |r, s, i|
|
39
|
-
r[s[/\w+/]] = s
|
40
|
-
r
|
41
|
-
}
|
41
|
+
def write
|
42
|
+
File.open(spec_path, 'w'){ |f| f << split_lines(spec.to_ruby) }
|
43
|
+
end
|
44
|
+
|
45
|
+
def split_lines ruby
|
46
|
+
ruby.gsub(/(.+?)\s*=\s*\[(.+?)\]/){ |s|
|
47
|
+
if $2.index(',')
|
48
|
+
"#{$1} = [\n #{$2.split(',').map(&:strip).join(",\n ")}]"
|
42
49
|
else
|
43
|
-
|
50
|
+
s
|
44
51
|
end
|
52
|
+
}
|
45
53
|
end
|
46
54
|
|
47
|
-
def
|
48
|
-
|
55
|
+
def strip_path path
|
56
|
+
strip_home_path(strip_cwd_path(path))
|
49
57
|
end
|
50
58
|
|
51
|
-
def
|
52
|
-
path
|
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
|
59
|
+
def strip_home_path path
|
60
|
+
path.sub(ENV['HOME'], '~')
|
63
61
|
end
|
64
62
|
|
65
|
-
def
|
66
|
-
|
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
|
63
|
+
def strip_cwd_path path
|
64
|
+
path.sub(Dir.pwd, '.')
|
73
65
|
end
|
74
66
|
|
75
|
-
def
|
76
|
-
|
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
|
67
|
+
def git *args
|
68
|
+
`git --git-dir=#{dir}/.git #{args.join(' ')}`
|
87
69
|
end
|
88
70
|
|
89
|
-
def
|
90
|
-
|
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"
|
71
|
+
def sh_git *args
|
72
|
+
Rake.sh('git', "--git-dir=#{dir}/.git", *args)
|
96
73
|
end
|
97
74
|
|
98
|
-
def
|
99
|
-
|
75
|
+
def sh_gem *args
|
76
|
+
Rake.sh(Gem.ruby, '-S', 'gem', *args)
|
100
77
|
end
|
101
78
|
|
102
|
-
def
|
103
|
-
|
104
|
-
f << split_lines(spec.to_ruby) }
|
79
|
+
def glob path=dir
|
80
|
+
Dir.glob("#{path}/**/*", File::FNM_DOTMATCH)
|
105
81
|
end
|
106
82
|
|
107
|
-
def
|
108
|
-
|
109
|
-
if
|
110
|
-
|
83
|
+
def readme
|
84
|
+
@readme ||=
|
85
|
+
if (path = "#{Gemgem.dir}/README.md") && File.exist?(path)
|
86
|
+
ps = "##{File.read(path)}".
|
87
|
+
scan(/((#+)[^\n]+\n\n.+?(?=(\n\n\2[^#\n]+\n)|\Z))/m).map(&:first)
|
88
|
+
ps.inject('HEADER' => ps.first){ |r, s, i|
|
89
|
+
r[s[/\w+/]] = s
|
90
|
+
r
|
91
|
+
}
|
111
92
|
else
|
112
|
-
|
93
|
+
{}
|
113
94
|
end
|
114
|
-
|
95
|
+
end
|
96
|
+
|
97
|
+
def description
|
98
|
+
# JRuby String#lines is returning an enumerator
|
99
|
+
@description ||= (readme['DESCRIPTION']||'').sub(/.+\n\n/, '').lines.to_a
|
115
100
|
end
|
116
101
|
|
117
102
|
def all_files
|
118
|
-
@all_files ||=
|
119
|
-
|
120
|
-
|
103
|
+
@all_files ||= fold_files(glob).sort
|
104
|
+
end
|
105
|
+
|
106
|
+
def fold_files files
|
107
|
+
files.inject([]){ |r, path|
|
108
|
+
if File.file?(path) && path !~ %r{/\.git(/|$)} &&
|
109
|
+
(rpath = path[%r{^#{escaped_dir}/(.*$)}, 1])
|
110
|
+
r << rpath
|
111
|
+
elsif File.symlink?(path) # walk into symlinks...
|
112
|
+
r.concat(fold_files(glob(File.expand_path(path,
|
113
|
+
File.readlink(path)))))
|
121
114
|
else
|
122
|
-
|
115
|
+
r
|
123
116
|
end
|
124
|
-
}
|
117
|
+
}
|
125
118
|
end
|
126
119
|
|
127
120
|
def gem_files
|
128
|
-
@gem_files ||= all_files
|
121
|
+
@gem_files ||= all_files.reject{ |f|
|
122
|
+
f =~ ignored_pattern && !git_files.include?(f)
|
123
|
+
}
|
129
124
|
end
|
130
125
|
|
131
|
-
def
|
132
|
-
@
|
133
|
-
|
126
|
+
def test_files
|
127
|
+
@test_files ||= gem_files.grep(%r{^test/(.+?/)*test_.+?\.rb$})
|
128
|
+
end
|
129
|
+
|
130
|
+
def bin_files
|
131
|
+
@bin_files ||= gem_files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
134
132
|
end
|
135
133
|
|
136
134
|
def git_files
|
137
135
|
@git_files ||= if File.exist?("#{dir}/.git")
|
138
|
-
|
136
|
+
git('ls-files').split("\n")
|
139
137
|
else
|
140
138
|
[]
|
141
139
|
end
|
142
140
|
end
|
143
141
|
|
144
|
-
|
145
|
-
|
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
|
142
|
+
def ignored_files
|
143
|
+
@ignored_files ||= all_files.grep(ignored_pattern)
|
148
144
|
end
|
149
145
|
|
150
|
-
def
|
151
|
-
@
|
152
|
-
gitignore.split("\n").reject{ |pattern|
|
153
|
-
pattern.strip == ''
|
154
|
-
}).map{ |pattern| %r{^([^/]+/)*?#{Regexp.escape(pattern)}(/[^/]+)*?$} }
|
146
|
+
def ignored_pattern
|
147
|
+
@ignored_pattern ||= Regexp.new(expand_patterns(gitignore).join('|'))
|
155
148
|
end
|
156
149
|
|
157
150
|
def expand_patterns pathes
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
151
|
+
# http://git-scm.com/docs/gitignore
|
152
|
+
pathes.flat_map{ |path|
|
153
|
+
case path
|
154
|
+
when %r{\*}
|
155
|
+
Regexp.escape(path).gsub(/\\\*/, '[^/]*')
|
156
|
+
when %r{^/}
|
157
|
+
"^#{Regexp.escape(path[1..-1])}"
|
158
|
+
else # we didn't implement negative pattern for now
|
159
|
+
Regexp.escape(path)
|
166
160
|
end
|
167
|
-
}
|
161
|
+
}
|
168
162
|
end
|
169
163
|
|
170
164
|
def gitignore
|
171
|
-
if File.exist?(path = "#{dir}/.gitignore")
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
165
|
+
@gitignore ||= if File.exist?(path = "#{dir}/.gitignore")
|
166
|
+
File.read(path).lines.
|
167
|
+
reject{ |l| l == /^\s*(#|\s+$)/ }.map(&:strip)
|
168
|
+
else
|
169
|
+
[]
|
170
|
+
end
|
176
171
|
end
|
177
172
|
end
|
178
173
|
|
@@ -180,22 +175,37 @@ namespace :gem do
|
|
180
175
|
|
181
176
|
desc 'Install gem'
|
182
177
|
task :install => [:build] do
|
183
|
-
|
178
|
+
Gemgem.sh_gem('install', Gemgem.gem_path)
|
184
179
|
end
|
185
180
|
|
186
181
|
desc 'Build gem'
|
187
182
|
task :build => [:spec] do
|
188
|
-
|
189
|
-
|
190
|
-
|
183
|
+
require 'fileutils'
|
184
|
+
require 'rubygems/package'
|
185
|
+
gem = nil
|
186
|
+
Dir.chdir(Gemgem.dir) do
|
187
|
+
gem = Gem::Package.build(Gem::Specification.load(Gemgem.spec_path))
|
188
|
+
FileUtils.mkdir_p(Gemgem.pkg_dir)
|
189
|
+
FileUtils.mv(gem, Gemgem.pkg_dir) # gem is relative path, but might be ok
|
190
|
+
end
|
191
|
+
puts "\e[35mGem built: \e[33m" \
|
192
|
+
"#{Gemgem.strip_path("#{Gemgem.pkg_dir}/#{gem}")}\e[0m"
|
193
|
+
end
|
194
|
+
|
195
|
+
desc 'Generate gemspec'
|
196
|
+
task :spec do
|
197
|
+
Gemgem.create
|
198
|
+
Gemgem.write
|
191
199
|
end
|
192
200
|
|
193
201
|
desc 'Release gem'
|
194
202
|
task :release => [:spec, :check, :build] do
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
203
|
+
Gemgem.module_eval do
|
204
|
+
sh_git('tag', Gemgem.gem_tag)
|
205
|
+
sh_git('push')
|
206
|
+
sh_git('push', '--tags')
|
207
|
+
sh_gem('push', Gemgem.gem_path)
|
208
|
+
end
|
199
209
|
end
|
200
210
|
|
201
211
|
task :check do
|
@@ -218,51 +228,37 @@ end # of gem namespace
|
|
218
228
|
|
219
229
|
desc 'Run tests in memory'
|
220
230
|
task :test do
|
231
|
+
next if Gemgem.test_files.empty?
|
232
|
+
|
221
233
|
require 'bacon'
|
222
234
|
Bacon.extend(Bacon::TestUnitOutput)
|
223
235
|
Bacon.summary_on_exit
|
224
|
-
|
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
|
+
Gemgem.test_files.each{ |file| require "#{Gemgem.dir}/#{file[0..-4]}" }
|
236
237
|
end
|
237
238
|
|
238
|
-
desc '
|
239
|
-
task
|
240
|
-
|
241
|
-
end
|
239
|
+
desc 'Remove ignored files'
|
240
|
+
task :clean => ['gem:spec'] do
|
241
|
+
next if Gemgem.ignored_files.empty?
|
242
242
|
|
243
|
-
|
244
|
-
|
245
|
-
puts
|
246
|
-
|
243
|
+
require 'fileutils'
|
244
|
+
trash = File.expand_path("~/.Trash/#{Gemgem.spec.name}")
|
245
|
+
puts "Move the following files into:" \
|
246
|
+
" \e[35m#{Gemgem.strip_path(trash)}\e[33m"
|
247
247
|
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
248
|
+
Gemgem.ignored_files.each do |file|
|
249
|
+
from = "#{Gemgem.dir}/#{file}"
|
250
|
+
to = "#{trash}/#{File.dirname(file)}"
|
251
|
+
puts Gemgem.strip_path(from)
|
252
252
|
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
" --files #{Gemgem.spec.extra_rdoc_files.join(',')}")
|
257
|
-
end
|
253
|
+
FileUtils.mkdir_p(to)
|
254
|
+
FileUtils.mv(from, to)
|
255
|
+
end
|
258
256
|
|
259
|
-
|
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}" }
|
257
|
+
print "\e[0m"
|
264
258
|
end
|
265
259
|
|
266
260
|
task :default do
|
267
|
-
|
261
|
+
# Is there a reliable way to do this in the current process?
|
262
|
+
# It failed miserably before between Rake versions...
|
263
|
+
exec "#{Gem.ruby} -S #{$PROGRAM_NAME} -f #{Rake.application.rakefile} -T"
|
268
264
|
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
|
2
|
+
require 'logi/test'
|
3
|
+
|
4
|
+
describe Logi do
|
5
|
+
logi = Logi.new(:root => "#{File.dirname(__FILE__)}/../example")
|
6
|
+
conf = logi.config
|
7
|
+
comp = logi.compiler
|
8
|
+
|
9
|
+
after do
|
10
|
+
Muack.verify
|
11
|
+
end
|
12
|
+
|
13
|
+
should 'make' do
|
14
|
+
logs = []
|
15
|
+
stub(comp).log(is_a(String)){ |msg| logs << "#{msg}\n" }
|
16
|
+
|
17
|
+
mock(comp).write(is_a(String), is_a(IO)){ |path, io|
|
18
|
+
File.read(path).should.eq(io.read)
|
19
|
+
}.times(conf.posts.size)
|
20
|
+
|
21
|
+
logi.make
|
22
|
+
|
23
|
+
logs.join.gsub(/\e\[\d+m/, '').should.eq <<-MESSAGE
|
24
|
+
logi-wiki ./example/post/hello.md |
|
25
|
+
logi-post ./example/post/hello.md ./example/layout/another.html.erb
|
26
|
+
logi-wiki ./example/post/index.md |
|
27
|
+
logi-post ./example/post/index.md ./example/layout/default.html.erb
|
28
|
+
logi-wiki ./example/post/list |
|
29
|
+
logi-list ./example/post/list ./example/layout/list.html.erb
|
30
|
+
logi-wiki ./example/post/misc/about.md |
|
31
|
+
logi-post ./example/post/misc/about.md ./example/layout/default.html.erb
|
32
|
+
MESSAGE
|
33
|
+
end
|
34
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: logi
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Lin Jen-Shin (godfat)
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-09-
|
11
|
+
date: 2013-09-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bacon
|
@@ -52,6 +52,20 @@ dependencies:
|
|
52
52
|
- - '>='
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: kramdown
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - '>='
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
55
69
|
description: Highly customizable static blog/wiki generator.
|
56
70
|
email:
|
57
71
|
- godfat (XD) godfat.org
|
@@ -65,10 +79,13 @@ extra_rdoc_files: []
|
|
65
79
|
files:
|
66
80
|
- .gitignore
|
67
81
|
- .gitmodules
|
82
|
+
- .travis.yml
|
83
|
+
- CHANGES.md
|
68
84
|
- Gemfile
|
69
85
|
- LICENSE
|
70
86
|
- README.md
|
71
87
|
- Rakefile
|
88
|
+
- TODO.md
|
72
89
|
- bin/logi
|
73
90
|
- bin/logi-list
|
74
91
|
- bin/logi-post
|
@@ -86,20 +103,25 @@ files:
|
|
86
103
|
- example/public/list.html
|
87
104
|
- example/public/misc/about.html
|
88
105
|
- lib/logi.rb
|
106
|
+
- lib/logi/command.rb
|
89
107
|
- lib/logi/command/list.rb
|
90
108
|
- lib/logi/command/post.rb
|
91
109
|
- lib/logi/command/wiki.rb
|
92
110
|
- lib/logi/compiler.rb
|
93
111
|
- lib/logi/config.rb
|
112
|
+
- lib/logi/default.rb
|
94
113
|
- lib/logi/layout/default.html.erb
|
114
|
+
- lib/logi/layout/empty.html.erb
|
95
115
|
- lib/logi/loader.rb
|
96
116
|
- lib/logi/logger.rb
|
97
117
|
- lib/logi/post.rb
|
98
118
|
- lib/logi/runner.rb
|
119
|
+
- lib/logi/test.rb
|
99
120
|
- lib/logi/version.rb
|
100
121
|
- logi.gemspec
|
101
122
|
- task/.gitignore
|
102
123
|
- task/gemgem.rb
|
124
|
+
- test/test_example.rb
|
103
125
|
homepage: https://github.com/godfat/logi
|
104
126
|
licenses:
|
105
127
|
- Apache License 2.0
|
@@ -120,8 +142,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
120
142
|
version: '0'
|
121
143
|
requirements: []
|
122
144
|
rubyforge_project:
|
123
|
-
rubygems_version: 2.1.
|
145
|
+
rubygems_version: 2.1.5
|
124
146
|
signing_key:
|
125
147
|
specification_version: 4
|
126
148
|
summary: Highly customizable static blog/wiki generator.
|
127
|
-
test_files:
|
149
|
+
test_files:
|
150
|
+
- test/test_example.rb
|