tocmd 0.4.2 → 0.4.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/tocmd +17 -39
- data/bin/tocmd_conf +16 -38
- data/bin/tocmd_local +13 -37
- data/lib/tocmd.rb +14 -8
- data/lib/tocmd/translator.rb +4 -5
- data/lib/tocmd/translator_conf.rb +4 -5
- data/lib/tocmd/translator_local.rb +7 -6
- data/lib/tocmd/version.rb +1 -1
- metadata +27 -13
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: eaa1ed8669a947520418be972e59994a0d345c97
|
4
|
+
data.tar.gz: f76856ff82a21137011c19d3d637938db05bd412
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8d69e2830297356c702b46e1be4017901ecce113aac37f726bc4b357675d9c36e8ce8a632420e8372b96b73e9227224b639a8c82a5193231cfece7cdb8c298b8
|
7
|
+
data.tar.gz: d91c3ae3d07feb0d5479ca47702719abb32663f920a72578ed615c1d5a28f9048719f8d3b160b50cc48fcf0532f5c5b373cde72fbae0a083de37db2a9f6ca9d4
|
data/bin/tocmd
CHANGED
@@ -3,21 +3,11 @@
|
|
3
3
|
|
4
4
|
require 'tocmd'
|
5
5
|
require 'pathname'
|
6
|
-
|
7
|
-
# puts Mdpreview.hi(ARGV)
|
8
|
-
#
|
9
|
-
# puts __FILE__
|
10
|
-
# puts File.dirname(__FILE__)
|
11
|
-
|
6
|
+
require 'optparse'
|
12
7
|
|
13
8
|
# File.join(File.dirname(__FILE__), '..', 'lib')
|
14
9
|
path = Pathname.new(File.join(File.dirname(__FILE__), '..')).realpath.to_s
|
15
10
|
|
16
|
-
# p "开始#{Dir.pwd}"
|
17
|
-
# p "path = #{path}"
|
18
|
-
|
19
|
-
require 'optparse'
|
20
|
-
|
21
11
|
options = {}
|
22
12
|
option_parser = OptionParser.new do |opts|
|
23
13
|
# 这里是这个命令行工具的帮助信息
|
@@ -46,40 +36,28 @@ option_parser = OptionParser.new do |opts|
|
|
46
36
|
rescue
|
47
37
|
ensure
|
48
38
|
end
|
49
|
-
|
50
|
-
# begin
|
51
|
-
# Dir.mkdir(File.join(src_p ,".toc"), 0700) #=> 0
|
52
|
-
# rescue
|
53
|
-
# ensure
|
54
|
-
# f = File.new(File.join(vendor_path ,"template.html"), "w+").path
|
55
|
-
# FileUtils.cp(f ,File.join(src_p ,".toc"))
|
56
|
-
# end
|
57
|
-
#
|
58
39
|
|
59
40
|
# Option 作为flag,带argument,用于将argument作为数值解析,比如"name"信息
|
60
41
|
#下面的“value”就是用户使用时输入的argument
|
61
|
-
opts.on('-f sourceFileNAME', '--
|
62
|
-
|
63
|
-
|
64
|
-
Tocmd.hi(src_p + '/' + value)
|
42
|
+
opts.on('-f sourceFileNAME', '--file sourceFileNAME', 'Pass-in source file name') do |value|
|
43
|
+
options[:fname] = src_p + '/' + value
|
65
44
|
end
|
66
45
|
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
if value == '.'
|
72
|
-
Tocmd.hi_dir(src_p + '/' )
|
73
|
-
else
|
74
|
-
Tocmd.hi_dir(src_p + '/' + value)
|
75
|
-
end
|
76
|
-
|
46
|
+
# 目录参数
|
47
|
+
opts.on('-d sourceDirNAME', '--directory sourceDirNAME', 'Pass-in source directory name') do |value|
|
48
|
+
options[:dname] = value == '.' ? (src_p + '/') : (src_p + '/' + value)
|
77
49
|
end
|
78
50
|
|
79
|
-
#
|
80
|
-
|
81
|
-
|
82
|
-
|
51
|
+
# 是否需要浏览器打开参数
|
52
|
+
opts.on('', '--no-browser', 'Not open with browser after translate') do |_value|
|
53
|
+
Tocmd.set_no_browser(true)
|
54
|
+
end
|
83
55
|
end.parse!
|
84
56
|
|
85
|
-
|
57
|
+
if options.has_key?(:fname) && !options[:fname].nil? && options[:fname] != ''
|
58
|
+
Tocmd.hi(options[:fname])
|
59
|
+
end
|
60
|
+
|
61
|
+
if options.has_key?(:dname) && !options[:dname].nil? && options[:dname] != ''
|
62
|
+
Tocmd.hi_dir(options[:dname])
|
63
|
+
end
|
data/bin/tocmd_conf
CHANGED
@@ -3,21 +3,11 @@
|
|
3
3
|
|
4
4
|
require 'tocmd'
|
5
5
|
require 'pathname'
|
6
|
-
|
7
|
-
# puts Mdpreview.hi(ARGV)
|
8
|
-
#
|
9
|
-
# puts __FILE__
|
10
|
-
# puts File.dirname(__FILE__)
|
11
|
-
|
6
|
+
require 'optparse'
|
12
7
|
|
13
8
|
# File.join(File.dirname(__FILE__), '..', 'lib')
|
14
9
|
path = Pathname.new(File.join(File.dirname(__FILE__), '..')).realpath.to_s
|
15
10
|
|
16
|
-
# p "开始#{Dir.pwd}"
|
17
|
-
# p "path = #{path}"
|
18
|
-
|
19
|
-
require 'optparse'
|
20
|
-
|
21
11
|
options = {}
|
22
12
|
option_parser = OptionParser.new do |opts|
|
23
13
|
# 这里是这个命令行工具的帮助信息
|
@@ -46,40 +36,28 @@ option_parser = OptionParser.new do |opts|
|
|
46
36
|
rescue
|
47
37
|
ensure
|
48
38
|
end
|
49
|
-
|
50
|
-
# begin
|
51
|
-
# Dir.mkdir(File.join(src_p ,".toc"), 0700) #=> 0
|
52
|
-
# rescue
|
53
|
-
# ensure
|
54
|
-
# f = File.new(File.join(vendor_path ,"template.html"), "w+").path
|
55
|
-
# FileUtils.cp(f ,File.join(src_p ,".toc"))
|
56
|
-
# end
|
57
|
-
#
|
58
39
|
|
59
40
|
# Option 作为flag,带argument,用于将argument作为数值解析,比如"name"信息
|
60
41
|
#下面的“value”就是用户使用时输入的argument
|
61
42
|
opts.on('-f sourceFileNAME', '--name sourceFileNAME', 'Pass-in source file name') do |value|
|
62
|
-
|
63
|
-
|
64
|
-
Tocmd.hi_local(src_p + '/' + value)
|
43
|
+
options[:fname] = src_p + '/' + value
|
65
44
|
end
|
66
45
|
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
if value == '.'
|
72
|
-
Tocmd.hi_dir_local(src_p + '/' )
|
73
|
-
else
|
74
|
-
Tocmd.hi_dir_local(src_p + '/' + value)
|
75
|
-
end
|
76
|
-
|
46
|
+
# 目录参数
|
47
|
+
opts.on('-d dirNAME', '--name sourceFileNAME', 'Pass-in source file name') do |value|
|
48
|
+
options[:dname] = value == '.' ? (src_p + '/') : (src_p + '/' + value)
|
77
49
|
end
|
78
50
|
|
79
|
-
#
|
80
|
-
|
81
|
-
|
82
|
-
|
51
|
+
# 转换完成后,是否需要浏览器打开参数
|
52
|
+
opts.on('', '--no-browser', 'Not open with browser after transform') do |_value|
|
53
|
+
Tocmd.set_no_browser(true)
|
54
|
+
end
|
83
55
|
end.parse!
|
84
56
|
|
85
|
-
|
57
|
+
if options.has_key?(:fname) && !options[:fname].nil? && options[:fname] != ''
|
58
|
+
Tocmd.hi_conf(options[:fname])
|
59
|
+
end
|
60
|
+
|
61
|
+
if options.has_key?(:dname) && !options[:dname].nil? && options[:dname] != ''
|
62
|
+
Tocmd.hi_dir_conf(options[:dname])
|
63
|
+
end
|
data/bin/tocmd_local
CHANGED
@@ -3,21 +3,11 @@
|
|
3
3
|
|
4
4
|
require 'tocmd'
|
5
5
|
require 'pathname'
|
6
|
-
|
7
|
-
# puts Mdpreview.hi(ARGV)
|
8
|
-
#
|
9
|
-
# puts __FILE__
|
10
|
-
# puts File.dirname(__FILE__)
|
11
|
-
|
6
|
+
require 'optparse'
|
12
7
|
|
13
8
|
# File.join(File.dirname(__FILE__), '..', 'lib')
|
14
9
|
path = Pathname.new(File.join(File.dirname(__FILE__), '..')).realpath.to_s
|
15
10
|
|
16
|
-
# p "开始#{Dir.pwd}"
|
17
|
-
# p "path = #{path}"
|
18
|
-
|
19
|
-
require 'optparse'
|
20
|
-
|
21
11
|
options = {}
|
22
12
|
option_parser = OptionParser.new do |opts|
|
23
13
|
# 这里是这个命令行工具的帮助信息
|
@@ -46,40 +36,26 @@ option_parser = OptionParser.new do |opts|
|
|
46
36
|
rescue
|
47
37
|
ensure
|
48
38
|
end
|
49
|
-
|
50
|
-
# begin
|
51
|
-
# Dir.mkdir(File.join(src_p ,".toc"), 0700) #=> 0
|
52
|
-
# rescue
|
53
|
-
# ensure
|
54
|
-
# f = File.new(File.join(vendor_path ,"template.html"), "w+").path
|
55
|
-
# FileUtils.cp(f ,File.join(src_p ,".toc"))
|
56
|
-
# end
|
57
|
-
#
|
58
39
|
|
59
40
|
# Option 作为flag,带argument,用于将argument作为数值解析,比如"name"信息
|
60
41
|
#下面的“value”就是用户使用时输入的argument
|
61
42
|
opts.on('-f sourceFileNAME', '--name sourceFileNAME', 'Pass-in source file name') do |value|
|
62
|
-
|
63
|
-
|
64
|
-
Tocmd.hi_local(src_p + '/' + value)
|
43
|
+
options[:fname] = src_p + '/' + value
|
65
44
|
end
|
66
45
|
|
67
46
|
opts.on('-d dirNAME', '--name sourceFileNAME', 'Pass-in source file name') do |value|
|
68
|
-
|
69
|
-
p value
|
70
|
-
|
71
|
-
if value == '.'
|
72
|
-
Tocmd.hi_dir_local(src_p + '/' )
|
73
|
-
else
|
74
|
-
Tocmd.hi_dir_local(src_p + '/' + value)
|
75
|
-
end
|
76
|
-
|
47
|
+
options[:dname] = value == '.' ? (src_p + '/') : (src_p + '/' + value)
|
77
48
|
end
|
78
49
|
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
# end
|
50
|
+
opts.on('', '--no-browser', 'Not open with browser after transform') do |_value|
|
51
|
+
Tocmd.set_no_browser(true)
|
52
|
+
end
|
83
53
|
end.parse!
|
84
54
|
|
85
|
-
|
55
|
+
if options.has_key?(:fname) && !options[:fname].nil? && options[:fname] != ''
|
56
|
+
Tocmd.hi_local(options[:fname])
|
57
|
+
end
|
58
|
+
|
59
|
+
if options.has_key?(:dname) && !options[:dname].nil? && options[:dname] != ''
|
60
|
+
Tocmd.hi_dir_local(options[:dname])
|
61
|
+
end
|
data/lib/tocmd.rb
CHANGED
@@ -4,17 +4,23 @@ require "tocmd/translator_local"
|
|
4
4
|
require "tocmd/translator_conf"
|
5
5
|
|
6
6
|
module Tocmd
|
7
|
+
@no_browser = false
|
8
|
+
|
9
|
+
def self.set_no_browser(flag)
|
10
|
+
@no_browser = flag
|
11
|
+
end
|
12
|
+
|
7
13
|
# ---------------- tocmd command -----------------
|
8
14
|
def self.hi(a)
|
9
15
|
translator = Translator.new(a)
|
10
|
-
translator.hi
|
16
|
+
translator.hi(@no_browser)
|
11
17
|
# puts version info
|
12
18
|
p VERSION
|
13
19
|
end
|
14
20
|
|
15
21
|
def self.hi_dir(a)
|
16
22
|
translator = Translator.new(a)
|
17
|
-
translator.hi_dir
|
23
|
+
translator.hi_dir(@no_browser)
|
18
24
|
# puts version info
|
19
25
|
p VERSION
|
20
26
|
end
|
@@ -22,29 +28,29 @@ module Tocmd
|
|
22
28
|
# ---------------- tocmd_local command -----------------
|
23
29
|
def self.hi_local(a)
|
24
30
|
translator = TranslatorLocal.new(a)
|
25
|
-
translator.hi
|
31
|
+
translator.hi(@no_browser)
|
26
32
|
# puts version info
|
27
33
|
p VERSION
|
28
34
|
end
|
29
35
|
|
30
36
|
def self.hi_dir_local(a)
|
31
37
|
translator = TranslatorLocal.new(a)
|
32
|
-
translator.hi_dir
|
38
|
+
translator.hi_dir(@no_browser)
|
33
39
|
# puts version info
|
34
40
|
p VERSION
|
35
41
|
end
|
36
42
|
|
37
43
|
# ---------------- tocmd_conf command -----------------
|
38
|
-
def self.
|
44
|
+
def self.hi_conf(a)
|
39
45
|
translator = TranslatorConf.new(a)
|
40
|
-
translator.hi
|
46
|
+
translator.hi(@no_browser)
|
41
47
|
# puts version info
|
42
48
|
p VERSION
|
43
49
|
end
|
44
50
|
|
45
|
-
def self.
|
51
|
+
def self.hi_dir_conf(a)
|
46
52
|
translator = TranslatorConf.new(a)
|
47
|
-
translator.hi_dir
|
53
|
+
translator.hi_dir(@no_browser)
|
48
54
|
# puts version info
|
49
55
|
p VERSION
|
50
56
|
end
|
data/lib/tocmd/translator.rb
CHANGED
@@ -13,7 +13,7 @@ class Tocmd::Translator
|
|
13
13
|
@editor_path = Pathname.new(File.expand_path('../../../vendor', __FILE__)).realpath.to_s
|
14
14
|
end
|
15
15
|
|
16
|
-
def hi
|
16
|
+
def hi(no_browser)
|
17
17
|
generate_meta_js
|
18
18
|
# cp_source_file_to_cur_file
|
19
19
|
|
@@ -30,14 +30,13 @@ class Tocmd::Translator
|
|
30
30
|
|
31
31
|
build_with_dir(@source_file_path ,dest_dir)
|
32
32
|
|
33
|
-
open_in_browser
|
33
|
+
open_in_browser unless no_browser
|
34
34
|
end
|
35
35
|
|
36
|
-
def hi_dir
|
36
|
+
def hi_dir(no_browser)
|
37
37
|
generate_meta_js
|
38
38
|
# cp_source_file_to_cur_file
|
39
39
|
|
40
|
-
|
41
40
|
ar = @source_file_path.split('/')
|
42
41
|
# ar.pop()
|
43
42
|
|
@@ -51,7 +50,7 @@ class Tocmd::Translator
|
|
51
50
|
|
52
51
|
build_with_dir(src_path ,dest_dir)
|
53
52
|
|
54
|
-
open_in_browser
|
53
|
+
open_in_browser unless no_browser
|
55
54
|
end
|
56
55
|
|
57
56
|
def open_in_browser
|
@@ -14,7 +14,7 @@ class Tocmd::TranslatorConf
|
|
14
14
|
|
15
15
|
end
|
16
16
|
|
17
|
-
def hi
|
17
|
+
def hi(no_browser)
|
18
18
|
generate_meta_js
|
19
19
|
# cp_source_file_to_cur_file
|
20
20
|
|
@@ -37,11 +37,10 @@ class Tocmd::TranslatorConf
|
|
37
37
|
# build now
|
38
38
|
build_with_dir(@source_file_path ,dest_dir)
|
39
39
|
|
40
|
-
|
41
|
-
open_in_browser
|
40
|
+
open_in_browser unless no_browser
|
42
41
|
end
|
43
42
|
|
44
|
-
def hi_dir
|
43
|
+
def hi_dir(no_browser)
|
45
44
|
generate_meta_js
|
46
45
|
# cp_source_file_to_cur_file
|
47
46
|
|
@@ -63,7 +62,7 @@ class Tocmd::TranslatorConf
|
|
63
62
|
|
64
63
|
build_with_dir(src_path ,dest_dir)
|
65
64
|
|
66
|
-
open_in_browser
|
65
|
+
open_in_browser unless no_browser
|
67
66
|
end
|
68
67
|
|
69
68
|
def _toc_config(dest_dir)
|
@@ -3,7 +3,7 @@ require 'pathname'
|
|
3
3
|
require 'fileutils'
|
4
4
|
require 'os'
|
5
5
|
|
6
|
-
class Tocmd::TranslatorLocal
|
6
|
+
class Tocmd::TranslatorLocal
|
7
7
|
def initialize(source_file_path)
|
8
8
|
#源文件路径
|
9
9
|
@source_file_path = source_file_path
|
@@ -13,7 +13,7 @@ class Tocmd::TranslatorLocal
|
|
13
13
|
@editor_path = Pathname.new(File.expand_path('../../../vendor', __FILE__)).realpath.to_s
|
14
14
|
end
|
15
15
|
|
16
|
-
def hi
|
16
|
+
def hi(no_browser)
|
17
17
|
generate_meta_js
|
18
18
|
# cp_source_file_to_cur_file
|
19
19
|
|
@@ -34,11 +34,11 @@ class Tocmd::TranslatorLocal
|
|
34
34
|
# build now
|
35
35
|
build_with_dir(@source_file_path ,dest_dir)
|
36
36
|
|
37
|
-
#
|
38
|
-
open_in_browser
|
37
|
+
# open in browser unless specify no browser
|
38
|
+
open_in_browser unless no_browser
|
39
39
|
end
|
40
40
|
|
41
|
-
def hi_dir
|
41
|
+
def hi_dir(no_browser)
|
42
42
|
generate_meta_js
|
43
43
|
# cp_source_file_to_cur_file
|
44
44
|
|
@@ -58,7 +58,8 @@ class Tocmd::TranslatorLocal
|
|
58
58
|
|
59
59
|
build_with_dir(src_path ,dest_dir)
|
60
60
|
|
61
|
-
|
61
|
+
# open in browser unless specify no browser
|
62
|
+
open_in_browser unless no_browser
|
62
63
|
end
|
63
64
|
|
64
65
|
def open_in_browser
|
data/lib/tocmd/version.rb
CHANGED
metadata
CHANGED
@@ -1,41 +1,55 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tocmd
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- shiren1118
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-02-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: redcarpet
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - '>='
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '0'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- -
|
24
|
+
- - '>='
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: pygments.rb
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- -
|
31
|
+
- - '>='
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '0'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- -
|
38
|
+
- - '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: os
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - '>='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - '>='
|
39
53
|
- !ruby/object:Gem::Version
|
40
54
|
version: '0'
|
41
55
|
description: convert markdown to html with i5ting_ztree_toc plugin
|
@@ -48,16 +62,15 @@ executables:
|
|
48
62
|
extensions: []
|
49
63
|
extra_rdoc_files: []
|
50
64
|
files:
|
51
|
-
- bin/tocmd
|
52
|
-
- bin/tocmd_conf
|
53
|
-
- bin/tocmd_local
|
54
65
|
- lib/tocmd.rb
|
55
66
|
- lib/tocmd/markdown_render.rb
|
56
67
|
- lib/tocmd/translator.rb
|
57
68
|
- lib/tocmd/translator_conf.rb
|
58
69
|
- lib/tocmd/translator_local.rb
|
59
70
|
- lib/tocmd/version.rb
|
60
|
-
-
|
71
|
+
- bin/tocmd
|
72
|
+
- bin/tocmd_conf
|
73
|
+
- bin/tocmd_local
|
61
74
|
- vendor/meta.js
|
62
75
|
- vendor/template.html
|
63
76
|
- vendor/toc/css/demo.css
|
@@ -87,6 +100,7 @@ files:
|
|
87
100
|
- vendor/toc/style/github-bf51422f4bb36427d391e4b75a1daa083c2d840e.css
|
88
101
|
- vendor/toc/style/github2-d731afd4f624c99a4b19ad69f3083cd6d02b81d5.css
|
89
102
|
- vendor/toc/style/makedownpad.css
|
103
|
+
- test/mdptest.rb
|
90
104
|
homepage: http://ruby-china.org/topics/17028
|
91
105
|
licenses: []
|
92
106
|
metadata: {}
|
@@ -96,17 +110,17 @@ require_paths:
|
|
96
110
|
- lib
|
97
111
|
required_ruby_version: !ruby/object:Gem::Requirement
|
98
112
|
requirements:
|
99
|
-
- -
|
113
|
+
- - '>='
|
100
114
|
- !ruby/object:Gem::Version
|
101
115
|
version: '0'
|
102
116
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
103
117
|
requirements:
|
104
|
-
- -
|
118
|
+
- - '>='
|
105
119
|
- !ruby/object:Gem::Version
|
106
120
|
version: '0'
|
107
121
|
requirements: []
|
108
122
|
rubyforge_project:
|
109
|
-
rubygems_version: 2.
|
123
|
+
rubygems_version: 2.0.14.1
|
110
124
|
signing_key:
|
111
125
|
specification_version: 4
|
112
126
|
summary: convert markdown to html with i5ting_ztree_toc plugin
|