code2pdf 0.4.1 → 0.4.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.gitignore +0 -2
- data/Gemfile.lock +16 -16
- data/bin/code2pdf +7 -1
- data/code2pdf.gemspec +2 -2
- data/lib/code2pdf/convert_to_pdf.rb +9 -11
- data/lib/code2pdf/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 4120208812063b2c15e8f852419151082d9251c4d080ac7df3855e896b231b0f
|
4
|
+
data.tar.gz: dc516f9d6248afa54017097b1ce7950ec0c15bb6ee481a30e3b1df688250c2d6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9f35129540fc4441a1e9250892c1bc69aa1f29b516619cc292277e8168071257d0227f523705ac60d11c8d105e5b91021c790b2ed01b6e65c85b93459b97a12b
|
7
|
+
data.tar.gz: 54d6d8e1460e739d75d1627cee51417861459cc5f090fdc27127895bfa6a07834cc91e2509b2f71f8439492301dd91a831958b3da555ce7b2d80966534b24e0e
|
data/.gitignore
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
code2pdf (0.4.
|
4
|
+
code2pdf (0.4.2)
|
5
5
|
pdfkit
|
6
6
|
rouge
|
7
7
|
wkhtmltopdf-binary
|
@@ -24,24 +24,24 @@ GEM
|
|
24
24
|
ruby-rc4
|
25
25
|
ttfunk
|
26
26
|
pdfkit (0.8.2)
|
27
|
-
pry (0.11.
|
27
|
+
pry (0.11.3)
|
28
28
|
coderay (~> 1.1.0)
|
29
29
|
method_source (~> 0.9.0)
|
30
|
-
rake (12.
|
31
|
-
rouge (3.
|
32
|
-
rspec (3.
|
33
|
-
rspec-core (~> 3.
|
34
|
-
rspec-expectations (~> 3.
|
35
|
-
rspec-mocks (~> 3.
|
36
|
-
rspec-core (3.
|
37
|
-
rspec-support (~> 3.
|
38
|
-
rspec-expectations (3.
|
30
|
+
rake (12.3.0)
|
31
|
+
rouge (3.1.0)
|
32
|
+
rspec (3.7.0)
|
33
|
+
rspec-core (~> 3.7.0)
|
34
|
+
rspec-expectations (~> 3.7.0)
|
35
|
+
rspec-mocks (~> 3.7.0)
|
36
|
+
rspec-core (3.7.1)
|
37
|
+
rspec-support (~> 3.7.0)
|
38
|
+
rspec-expectations (3.7.0)
|
39
39
|
diff-lcs (>= 1.2.0, < 2.0)
|
40
|
-
rspec-support (~> 3.
|
41
|
-
rspec-mocks (3.
|
40
|
+
rspec-support (~> 3.7.0)
|
41
|
+
rspec-mocks (3.7.0)
|
42
42
|
diff-lcs (>= 1.2.0, < 2.0)
|
43
|
-
rspec-support (~> 3.
|
44
|
-
rspec-support (3.
|
43
|
+
rspec-support (~> 3.7.0)
|
44
|
+
rspec-support (3.7.0)
|
45
45
|
ruby-rc4 (0.1.5)
|
46
46
|
ttfunk (1.5.1)
|
47
47
|
wkhtmltopdf-binary (0.12.3.1)
|
@@ -58,4 +58,4 @@ DEPENDENCIES
|
|
58
58
|
rspec
|
59
59
|
|
60
60
|
BUNDLED WITH
|
61
|
-
1.
|
61
|
+
1.16.1
|
data/bin/code2pdf
CHANGED
@@ -13,6 +13,12 @@ optparse = OptionParser.new do |opts|
|
|
13
13
|
exit
|
14
14
|
end
|
15
15
|
|
16
|
+
opts.on('-v', '--version', 'Display version') do
|
17
|
+
require 'code2pdf/version'
|
18
|
+
puts Code2pdf::VERSION
|
19
|
+
exit
|
20
|
+
end
|
21
|
+
|
16
22
|
if ARGV.size < 1
|
17
23
|
puts opts
|
18
24
|
exit 1
|
@@ -27,7 +33,7 @@ rescue OptionParser::InvalidOption => exception
|
|
27
33
|
end
|
28
34
|
|
29
35
|
PATH = ARGV[0].gsub(/\/$/, '')
|
30
|
-
BLACK_LIST_YAML_FILE = "#{PATH}/.code2pdf"
|
36
|
+
BLACK_LIST_YAML_FILE = "#{PATH}/.code2pdf".freeze
|
31
37
|
|
32
38
|
filename = "#{PATH.gsub(/(\.|\/)/, '_')}.pdf"
|
33
39
|
ConvertToPDF.new from: PATH, to: filename, except: BLACK_LIST_YAML_FILE
|
data/code2pdf.gemspec
CHANGED
@@ -10,8 +10,8 @@ Gem::Specification.new do |gem|
|
|
10
10
|
gem.required_ruby_version = '>= 2.0.0'
|
11
11
|
gem.files = `git ls-files`.split("\n")
|
12
12
|
gem.test_files = `git ls-files -- {spec}/*`.split("\n")
|
13
|
-
gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
14
|
-
gem.require_paths = %w
|
13
|
+
gem.executables = `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) }
|
14
|
+
gem.require_paths = %w[lib]
|
15
15
|
|
16
16
|
gem.add_dependency 'pdfkit'
|
17
17
|
gem.add_dependency 'wkhtmltopdf-binary'
|
@@ -1,19 +1,19 @@
|
|
1
1
|
class ConvertToPDF
|
2
2
|
PDF_OPTIONS = {
|
3
3
|
page_size: 'A4'
|
4
|
-
}
|
4
|
+
}.freeze
|
5
5
|
|
6
6
|
def initialize(params = {})
|
7
|
-
if !params.
|
7
|
+
if !params.key?(:from) || params[:from].nil?
|
8
8
|
raise ArgumentError.new 'where is the codebase you want to convert to PDF?'
|
9
9
|
elsif !valid_directory?(params[:from])
|
10
10
|
raise LoadError.new "#{params[:from]} not found"
|
11
|
-
elsif !params.
|
11
|
+
elsif !params.key?(:to) || params[:to].nil?
|
12
12
|
raise ArgumentError.new 'where should I save the generated pdf file?'
|
13
13
|
else
|
14
14
|
@from, @to, @except = params[:from], params[:to], params[:except].to_s
|
15
15
|
|
16
|
-
if File.
|
16
|
+
if File.exist?(@except) && invalid_blacklist?
|
17
17
|
raise LoadError.new "#{@except} is not a valid blacklist YAML file"
|
18
18
|
end
|
19
19
|
|
@@ -58,7 +58,7 @@ class ConvertToPDF
|
|
58
58
|
|
59
59
|
@blacklist = YAML.load_file(@except)
|
60
60
|
|
61
|
-
!@blacklist.
|
61
|
+
!@blacklist.key?(:directories) || !@blacklist.key?(:files)
|
62
62
|
end
|
63
63
|
|
64
64
|
def in_directory_blacklist?(item_path)
|
@@ -72,11 +72,11 @@ class ConvertToPDF
|
|
72
72
|
end
|
73
73
|
|
74
74
|
def valid_directory?(dir)
|
75
|
-
File.
|
75
|
+
File.exist?(dir) && FileTest.directory?(dir)
|
76
76
|
end
|
77
77
|
|
78
78
|
def valid_file?(file)
|
79
|
-
File.
|
79
|
+
File.exist?(file) && FileTest.file?(file)
|
80
80
|
end
|
81
81
|
|
82
82
|
def read_files(path = nil)
|
@@ -101,12 +101,10 @@ class ConvertToPDF
|
|
101
101
|
|
102
102
|
content = ''
|
103
103
|
File.open(file, 'r') do |f|
|
104
|
-
if
|
104
|
+
if `file #{file}` !~ /text/
|
105
105
|
content << "<color rgb='777777'>[binary]</color>"
|
106
106
|
else
|
107
|
-
f.each_line
|
108
|
-
content << line_content
|
109
|
-
end
|
107
|
+
f.each_line { |line_content| content << line_content }
|
110
108
|
end
|
111
109
|
end
|
112
110
|
content
|
data/lib/code2pdf/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: code2pdf
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Lucas Caton
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-01-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: pdfkit
|
@@ -182,7 +182,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
182
182
|
version: '0'
|
183
183
|
requirements: []
|
184
184
|
rubyforge_project:
|
185
|
-
rubygems_version: 2.
|
185
|
+
rubygems_version: 2.7.3
|
186
186
|
signing_key:
|
187
187
|
specification_version: 4
|
188
188
|
summary: Convert your source code to PDF
|