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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: cbd789fcae0b1e9a87bcbaf2a4cfd857e3f9530f
4
- data.tar.gz: 995d1ba8d9cd25dc87f2bac42a5a46a0122f9430
2
+ SHA256:
3
+ metadata.gz: 4120208812063b2c15e8f852419151082d9251c4d080ac7df3855e896b231b0f
4
+ data.tar.gz: dc516f9d6248afa54017097b1ce7950ec0c15bb6ee481a30e3b1df688250c2d6
5
5
  SHA512:
6
- metadata.gz: 5e2226893a3293c0de832211e1694a133103286d8f949eb17b93423107ee4f461b614c89d428f8d165132edc51cbeeea6f41deb41ba707e359411f56890ebbd0
7
- data.tar.gz: 4ec7dc0b1fdbe3b5013f79ed566fcd3b62b6bbe8f5e19e6a439d61d7cfa3428149df56d8db8ee22f93c3fc444ab80e5101b42b4e15b5835413ac0251db7d792b
6
+ metadata.gz: 9f35129540fc4441a1e9250892c1bc69aa1f29b516619cc292277e8168071257d0227f523705ac60d11c8d105e5b91021c790b2ed01b6e65c85b93459b97a12b
7
+ data.tar.gz: 54d6d8e1460e739d75d1627cee51417861459cc5f090fdc27127895bfa6a07834cc91e2509b2f71f8439492301dd91a831958b3da555ce7b2d80966534b24e0e
data/.gitignore CHANGED
@@ -1,6 +1,4 @@
1
1
  *.blacklist.yml
2
2
  *.gem
3
- *.swp
4
- .DS_Store
5
3
  .bundle
6
4
  pkg/*
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- code2pdf (0.4.1)
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.1)
27
+ pry (0.11.3)
28
28
  coderay (~> 1.1.0)
29
29
  method_source (~> 0.9.0)
30
- rake (12.1.0)
31
- rouge (3.0.0)
32
- rspec (3.6.0)
33
- rspec-core (~> 3.6.0)
34
- rspec-expectations (~> 3.6.0)
35
- rspec-mocks (~> 3.6.0)
36
- rspec-core (3.6.0)
37
- rspec-support (~> 3.6.0)
38
- rspec-expectations (3.6.0)
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.6.0)
41
- rspec-mocks (3.6.0)
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.6.0)
44
- rspec-support (3.6.0)
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.15.4
61
+ 1.16.1
@@ -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
@@ -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(lib)
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.has_key?(:from) || params[:from].nil?
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.has_key?(:to) || params[:to].nil?
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.exists?(@except) && invalid_blacklist?
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.has_key?(:directories) || !@blacklist.has_key?(:files)
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.exists?(dir) && FileTest.directory?(dir)
75
+ File.exist?(dir) && FileTest.directory?(dir)
76
76
  end
77
77
 
78
78
  def valid_file?(file)
79
- File.exists?(file) && FileTest.file?(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 %x(file #{file}) !~ /text/
104
+ if `file #{file}` !~ /text/
105
105
  content << "<color rgb='777777'>[binary]</color>"
106
106
  else
107
- f.each_line.with_index do |line_content, line_number|
108
- content << line_content
109
- end
107
+ f.each_line { |line_content| content << line_content }
110
108
  end
111
109
  end
112
110
  content
@@ -1,3 +1,3 @@
1
1
  module Code2pdf
2
- VERSION = '0.4.1'.freeze
2
+ VERSION = '0.4.2'.freeze
3
3
  end
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.1
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: 2017-10-17 00:00:00.000000000 Z
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.6.13
185
+ rubygems_version: 2.7.3
186
186
  signing_key:
187
187
  specification_version: 4
188
188
  summary: Convert your source code to PDF