vim_printer 0.1.4 → 0.1.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/README.md +15 -13
- data/lib/vim_printer/cli.rb +23 -21
- data/lib/vim_printer/core_ext/file.rb +3 -3
- data/lib/vim_printer/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3a75ff67ccc6b202fd6587fadac534be086941ad
|
4
|
+
data.tar.gz: 58fbbc9b941c6537f53e6d2616e25673591354b8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 067b0aedbd412da782ec5956ec20224532d8ad4bef8f46f8650a6cf416083874cbee841390b3dc34601c979260ed5b5652d313ad4856ec3e6a76449b14c5d67f
|
7
|
+
data.tar.gz: 640003a5420b48306f6d497069c655e5ec5a45652f696a19c7b214087eb98a7cc29353ea996bbb3cec15b49afa335d284a6fc832805ac8045f1b644f1b668eb3
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -55,10 +55,10 @@ The html output as renderd in the browser
|
|
55
55
|
- Run with the sample fixture files
|
56
56
|
|
57
57
|
```sh
|
58
|
-
vim_printer -b test/fixtures
|
58
|
+
vim_printer -b test/fixtures -e rb java -r
|
59
59
|
```
|
60
60
|
|
61
|
-
Will produce the file `
|
61
|
+
Will produce the file `vim_printer_fixtures.tar.gz` with the following result on the screen.
|
62
62
|
|
63
63
|
```
|
64
64
|
FYI: process file 1 of 8 : ./demo1.xxx.rb
|
@@ -69,7 +69,7 @@ FYI: process file 5 of 8 : ./java/demo3.xxx.java
|
|
69
69
|
FYI: process file 6 of 8 : ./java/demo3.yyy.java
|
70
70
|
FYI: process file 7 of 8 : ./java/demo4.xxx.java
|
71
71
|
FYI: process file 8 of 8 : ./java/demo4.yyy.java
|
72
|
-
Your output file is ./test/fixtures/
|
72
|
+
Your output file is ./test/fixtures/vim_printer_fixtures.tar.gz
|
73
73
|
```
|
74
74
|
|
75
75
|
### Usage
|
@@ -101,14 +101,14 @@ vim_printer --base-dir ./test/fixtures \
|
|
101
101
|
--theme solarized
|
102
102
|
```
|
103
103
|
|
104
|
-
Your output will be saved to the default `
|
104
|
+
Your output will be saved to the default `vim_printer_fixtures.tar.gz` in the directory where you run this command.
|
105
105
|
To see the output in your browser just type:
|
106
106
|
|
107
107
|
```sh
|
108
108
|
mkdir -p ~/Desktop/vim_printer
|
109
|
-
mv
|
109
|
+
mv vim_printer_fixtures.tar.gz ~/Desktop/vim_printer
|
110
110
|
cd ~/Desktop/vim_printer
|
111
|
-
tar zxvf
|
111
|
+
tar zxvf vim_printer_fixtures.tar.gz
|
112
112
|
```
|
113
113
|
|
114
114
|
- Print only files that contain the word `xxx` in the title
|
@@ -131,24 +131,26 @@ vim_printer -e ruby -f Gemfile Rakefile -r
|
|
131
131
|
|
132
132
|
```
|
133
133
|
Usage:
|
134
|
-
vim_printer
|
134
|
+
vim_printer print
|
135
135
|
|
136
136
|
Options:
|
137
137
|
-b, [--base-dir=BASE_DIR] # Base directory
|
138
138
|
# Default: . (current directory)
|
139
139
|
-e, [--exts=one two three] # List of extensions to search for
|
140
|
-
-f, [--non-exts=one two three] # List of
|
141
|
-
-n, [--inc-words=one two three] # List of words to be included in the result
|
142
|
-
-x, [--exc-words=one two three] # List of words to be excluded from the result
|
140
|
+
-f, [--non-exts=one two three] # List of files without extension to search for
|
141
|
+
-n, [--inc-words=one two three] # List of words in the filename to be included in the result if any
|
142
|
+
-x, [--exc-words=one two three] # List of words in the filename to be excluded from the result if any
|
143
143
|
-i, [--ignore-case], [--no-ignore-case] # Match case insensitively
|
144
144
|
# Default: true
|
145
145
|
-r, [--recursive], [--no-recursive] # Search for files recursively
|
146
146
|
# Default: true
|
147
|
-
-t, [--theme=THEME] # Vim colorscheme to use
|
148
|
-
# Default: default
|
149
147
|
-v, [--version], [--no-version] # Display version information
|
148
|
+
-t, [--theme=THEME] # Vim colorscheme to use
|
149
|
+
# Default: 'default'
|
150
|
+
-c, [--index], [--no-index] # Generate the index.html file for the result
|
151
|
+
# Default: true
|
150
152
|
|
151
|
-
Print
|
153
|
+
Print files to (x)html using Vim
|
152
154
|
```
|
153
155
|
|
154
156
|
### Development/Testing
|
data/lib/vim_printer/cli.rb
CHANGED
@@ -6,7 +6,7 @@ require_relative "../vim_printer"
|
|
6
6
|
module VimPrinter
|
7
7
|
include AgileUtils
|
8
8
|
class CLI < Thor
|
9
|
-
desc "print", "Print
|
9
|
+
desc "print", "Print files to (x)html using Vim"
|
10
10
|
method_option *AgileUtils::Options::BASE_DIR
|
11
11
|
method_option *AgileUtils::Options::EXTS
|
12
12
|
method_option *AgileUtils::Options::NON_EXTS
|
@@ -17,8 +17,13 @@ module VimPrinter
|
|
17
17
|
method_option *AgileUtils::Options::VERSION
|
18
18
|
method_option :theme,
|
19
19
|
aliases: "-t",
|
20
|
-
desc:
|
20
|
+
desc: "Vim colorscheme to use",
|
21
21
|
default: "default"
|
22
|
+
method_option :index,
|
23
|
+
aliases: "-c",
|
24
|
+
desc: "Generate the index.html file for the result",
|
25
|
+
type: :boolean,
|
26
|
+
default: true
|
22
27
|
def print
|
23
28
|
opts = options.symbolize_keys
|
24
29
|
if opts[:version]
|
@@ -32,24 +37,26 @@ module VimPrinter
|
|
32
37
|
def usage
|
33
38
|
puts <<-EOS
|
34
39
|
Usage:
|
35
|
-
vim_printer
|
40
|
+
vim_printer print
|
36
41
|
|
37
42
|
Options:
|
38
43
|
-b, [--base-dir=BASE_DIR] # Base directory
|
39
44
|
# Default: . (current directory)
|
40
45
|
-e, [--exts=one two three] # List of extensions to search for
|
41
|
-
-f, [--non-exts=one two three] # List of
|
42
|
-
-n, [--inc-words=one two three] # List of words to be included in the result
|
43
|
-
-x, [--exc-words=one two three] # List of words to be excluded from the result
|
46
|
+
-f, [--non-exts=one two three] # List of files without extension to search for
|
47
|
+
-n, [--inc-words=one two three] # List of words to be included in the result if any
|
48
|
+
-x, [--exc-words=one two three] # List of words to be excluded from the result if any
|
44
49
|
-i, [--ignore-case], [--no-ignore-case] # Match case insensitively
|
45
50
|
# Default: true
|
46
51
|
-r, [--recursive], [--no-recursive] # Search for files recursively
|
47
52
|
# Default: true
|
53
|
+
-v, [--version], [--no-version] # Display version information
|
48
54
|
-t, [--theme=THEME] # Vim colorscheme to use
|
49
55
|
# Default: default
|
50
|
-
-
|
56
|
+
-c, [--index], [--no-index] # Generate the index.html file for the result
|
57
|
+
# Default: true
|
51
58
|
|
52
|
-
Print
|
59
|
+
Print files to (x)html using Vim
|
53
60
|
EOS
|
54
61
|
end
|
55
62
|
|
@@ -62,32 +69,27 @@ Print the list of files
|
|
62
69
|
# @param [Hash<Symbol, Object>] options the options argument
|
63
70
|
def execute(options = {})
|
64
71
|
input_files = CodeLister.files(options)
|
65
|
-
input_files.delete_if { |file| File.binary?(file.gsub(/^\./,options[:base_dir])) }
|
72
|
+
input_files.delete_if { |file| File.binary?(file.gsub(/^\./, options[:base_dir])) }
|
66
73
|
if input_files.empty?
|
67
74
|
puts "No file found for your option: #{options}"
|
68
75
|
return
|
69
76
|
end
|
70
77
|
|
71
78
|
to_htmls(input_files, options)
|
72
|
-
|
73
|
-
# The generated files is the same as input file but with '.xhtml' appended
|
74
|
-
generated_files = input_files.map do |f|
|
75
|
-
"#{f}.xhtml"
|
76
|
-
end
|
77
|
-
|
79
|
+
generated_files = input_files.map { |f| "#{f}.xhtml" }
|
78
80
|
index_file = "./index.html"
|
79
81
|
IndexHtml.htmlify generated_files,
|
80
82
|
base_dir: options[:base_dir],
|
81
83
|
output: index_file
|
82
|
-
|
83
|
-
|
84
|
-
AgileUtils::FileUtil.tar_gzip_files(generated_files,
|
84
|
+
generated_files << index_file if options[:index]
|
85
|
+
output_file = "vim_printer_#{File.basename(File.expand_path(options[:base_dir]))}.tar.gz"
|
86
|
+
AgileUtils::FileUtil.tar_gzip_files(generated_files, output_file)
|
85
87
|
AgileUtils::FileUtil.delete(generated_files)
|
86
|
-
FileUtils.rm_rf(index_file)
|
87
|
-
puts "Your output file is #{File.absolute_path(
|
88
|
+
FileUtils.rm_rf(index_file) if options[:index]
|
89
|
+
puts "Your output file is '#{File.absolute_path(output_file)}'"
|
88
90
|
end
|
89
91
|
|
90
|
-
# convert multiple files to
|
92
|
+
# convert multiple files to html
|
91
93
|
def to_htmls(files, options = {})
|
92
94
|
FileUtils.chdir(File.expand_path(options[:base_dir]))
|
93
95
|
files.each_with_index do |file, index|
|
@@ -2,10 +2,10 @@
|
|
2
2
|
class File
|
3
3
|
def self.binary?(name)
|
4
4
|
name = File.expand_path(name)
|
5
|
-
|
6
|
-
return false unless
|
5
|
+
my_stat = stat(name)
|
6
|
+
return false unless my_stat.file?
|
7
7
|
open(name) do |file|
|
8
|
-
blk = file.read(
|
8
|
+
blk = file.read(my_stat.blksize)
|
9
9
|
return blk.size == 0 ||
|
10
10
|
blk.count("^ -~", "^\r\n") / blk.size > 0.3 || blk.count("\x00") > 0
|
11
11
|
end
|
data/lib/vim_printer/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vim_printer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Burin Choomnuan
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-06-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|