hyper-smart-kit 0.0.1

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.
Files changed (44) hide show
  1. checksums.yaml +7 -0
  2. data/hyper-smart-kit.gemspec +11 -0
  3. data/wicked_pdf-2.8.2/CHANGELOG.md +254 -0
  4. data/wicked_pdf-2.8.2/Gemfile +3 -0
  5. data/wicked_pdf-2.8.2/LICENSE.txt +22 -0
  6. data/wicked_pdf-2.8.2/README.md +504 -0
  7. data/wicked_pdf-2.8.2/Rakefile +58 -0
  8. data/wicked_pdf-2.8.2/gemfiles/5.0.gemfile +8 -0
  9. data/wicked_pdf-2.8.2/gemfiles/5.1.gemfile +8 -0
  10. data/wicked_pdf-2.8.2/gemfiles/5.2.gemfile +9 -0
  11. data/wicked_pdf-2.8.2/gemfiles/6.0.gemfile +10 -0
  12. data/wicked_pdf-2.8.2/gemfiles/6.1.gemfile +11 -0
  13. data/wicked_pdf-2.8.2/gemfiles/7.0.gemfile +11 -0
  14. data/wicked_pdf-2.8.2/generators/wicked_pdf/templates/wicked_pdf.rb +30 -0
  15. data/wicked_pdf-2.8.2/generators/wicked_pdf/wicked_pdf_generator.rb +7 -0
  16. data/wicked_pdf-2.8.2/init.rb +2 -0
  17. data/wicked_pdf-2.8.2/lib/generators/wicked_pdf_generator.rb +155 -0
  18. data/wicked_pdf-2.8.2/lib/wicked_pdf/binary.rb +65 -0
  19. data/wicked_pdf-2.8.2/lib/wicked_pdf/middleware.rb +92 -0
  20. data/wicked_pdf-2.8.2/lib/wicked_pdf/option_parser.rb +230 -0
  21. data/wicked_pdf-2.8.2/lib/wicked_pdf/pdf_helper.rb +128 -0
  22. data/wicked_pdf-2.8.2/lib/wicked_pdf/progress.rb +33 -0
  23. data/wicked_pdf-2.8.2/lib/wicked_pdf/railtie.rb +17 -0
  24. data/wicked_pdf-2.8.2/lib/wicked_pdf/tempfile.rb +43 -0
  25. data/wicked_pdf-2.8.2/lib/wicked_pdf/version.rb +3 -0
  26. data/wicked_pdf-2.8.2/lib/wicked_pdf/wicked_pdf_helper/assets.rb +332 -0
  27. data/wicked_pdf-2.8.2/lib/wicked_pdf/wicked_pdf_helper.rb +36 -0
  28. data/wicked_pdf-2.8.2/lib/wicked_pdf.rb +132 -0
  29. data/wicked_pdf-2.8.2/test/fixtures/database.yml +4 -0
  30. data/wicked_pdf-2.8.2/test/fixtures/document_with_long_line.html +16 -0
  31. data/wicked_pdf-2.8.2/test/fixtures/manifest.js +3 -0
  32. data/wicked_pdf-2.8.2/test/fixtures/subdirectory/nested.js +1 -0
  33. data/wicked_pdf-2.8.2/test/fixtures/wicked.css +1 -0
  34. data/wicked_pdf-2.8.2/test/fixtures/wicked.js +1 -0
  35. data/wicked_pdf-2.8.2/test/functional/pdf_helper_test.rb +96 -0
  36. data/wicked_pdf-2.8.2/test/functional/wicked_pdf_helper_assets_test.rb +252 -0
  37. data/wicked_pdf-2.8.2/test/functional/wicked_pdf_helper_test.rb +28 -0
  38. data/wicked_pdf-2.8.2/test/test_helper.rb +40 -0
  39. data/wicked_pdf-2.8.2/test/unit/wicked_pdf_binary_test.rb +26 -0
  40. data/wicked_pdf-2.8.2/test/unit/wicked_pdf_option_parser_test.rb +133 -0
  41. data/wicked_pdf-2.8.2/test/unit/wicked_pdf_test.rb +100 -0
  42. data/wicked_pdf-2.8.2/test/unit/wkhtmltopdf_location_test.rb +48 -0
  43. data/wicked_pdf-2.8.2/wicked_pdf.gemspec +42 -0
  44. metadata +82 -0
@@ -0,0 +1,133 @@
1
+ require 'test_helper'
2
+
3
+ class WickedPdfOptionParserTest < ActiveSupport::TestCase
4
+ test 'should parse header and footer options' do
5
+ %i[header footer].each do |hf|
6
+ %i[center font_name left right].each do |o|
7
+ assert_equal "--#{hf}-#{o.to_s.tr('_', '-')} header_footer",
8
+ parse_options(hf => { o => 'header_footer' }).strip
9
+ end
10
+
11
+ %i[font_size spacing].each do |o|
12
+ assert_equal "--#{hf}-#{o.to_s.tr('_', '-')} 12",
13
+ parse_options(hf => { o => '12' }).strip
14
+ end
15
+
16
+ assert_equal "--#{hf}-line",
17
+ parse_options(hf => { :line => true }).strip
18
+ assert_equal "--#{hf}-html http://www.abc.com",
19
+ parse_options(hf => { :html => { :url => 'http://www.abc.com' } }).strip
20
+ end
21
+ end
22
+
23
+ test 'should parse toc options' do
24
+ toc_option = option_parser.valid_option('toc')
25
+
26
+ %i[font_name header_text].each do |o|
27
+ assert_equal "#{toc_option} --toc-#{o.to_s.tr('_', '-')} toc",
28
+ parse_options(:toc => { o => 'toc' }).strip
29
+ end
30
+
31
+ %i[
32
+ depth header_fs l1_font_size l2_font_size l3_font_size l4_font_size
33
+ l5_font_size l6_font_size l7_font_size l1_indentation l2_indentation
34
+ l3_indentation l4_indentation l5_indentation l6_indentation l7_indentation
35
+ ].each do |o|
36
+ assert_equal "#{toc_option} --toc-#{o.to_s.tr('_', '-')} 5",
37
+ parse_options(:toc => { o => 5 }).strip
38
+ end
39
+
40
+ %i[no_dots disable_links disable_back_links].each do |o|
41
+ assert_equal "#{toc_option} --toc-#{o.to_s.tr('_', '-')}",
42
+ parse_options(:toc => { o => true }).strip
43
+ end
44
+ end
45
+
46
+ test 'should parse outline options' do
47
+ assert_equal '--outline', parse_options(:outline => { :outline => true }).strip
48
+ assert_equal '--outline-depth 5', parse_options(:outline => { :outline_depth => 5 }).strip
49
+ end
50
+
51
+ test 'should parse no_images option' do
52
+ assert_equal '--no-images', parse_options(:no_images => true).strip
53
+ assert_equal '--images', parse_options(:images => true).strip
54
+ end
55
+
56
+ test 'should parse margins options' do
57
+ %i[top bottom left right].each do |o|
58
+ assert_equal "--margin-#{o} 12", parse_options(:margin => { o => '12' }).strip
59
+ end
60
+ end
61
+
62
+ test 'should parse cover' do
63
+ cover_option = option_parser.valid_option('cover')
64
+
65
+ pathname = Rails.root.join('app', 'views', 'pdf', 'file.html')
66
+ assert_equal "#{cover_option} http://example.org", parse_options(:cover => 'http://example.org').strip, 'URL'
67
+ assert_equal "#{cover_option} #{pathname}", parse_options(:cover => pathname).strip, 'Pathname'
68
+ assert_match(/#{cover_option} .+wicked_cover_pdf.+\.html/, parse_options(:cover => '<html><body>HELLO</body></html>').strip, 'HTML')
69
+ end
70
+
71
+ test 'should parse other options' do
72
+ %i[
73
+ orientation page_size proxy username password dpi
74
+ encoding user_style_sheet
75
+ ].each do |o|
76
+ assert_equal "--#{o.to_s.tr('_', '-')} opts", parse_options(o => 'opts').strip
77
+ end
78
+
79
+ %i[allow].each do |o|
80
+ assert_equal "--#{o.to_s.tr('_', '-')} opts", parse_options(o => 'opts').strip
81
+ assert_equal "--#{o.to_s.tr('_', '-')} opts1 --#{o.to_s.tr('_', '-')} opts2", parse_options(o => %w[opts1 opts2]).strip
82
+ end
83
+
84
+ %i[cookie post].each do |o|
85
+ assert_equal "--#{o.to_s.tr('_', '-')} name value", parse_options(o => 'name value').strip
86
+
87
+ nv_formatter = proc { |number| "--#{o.to_s.tr('_', '-')} par#{number} val#{number}" }
88
+ assert_equal "#{nv_formatter.call(1)} #{nv_formatter.call(2)}", parse_options(o => ['par1 val1', 'par2 val2']).strip
89
+ end
90
+
91
+ %i[redirect_delay zoom page_offset].each do |o|
92
+ assert_equal "--#{o.to_s.tr('_', '-')} 5", parse_options(o => 5).strip
93
+ end
94
+
95
+ %i[
96
+ book default_header disable_javascript grayscale lowquality
97
+ enable_plugins disable_internal_links disable_external_links
98
+ print_media_type disable_smart_shrinking use_xserver no_background disable_local_file_access
99
+ ].each do |o|
100
+ assert_equal "--#{o.to_s.tr('_', '-')}", parse_options(o => true).strip
101
+ end
102
+ end
103
+
104
+ test 'should not use double dash options for version without dashes' do
105
+ op = option_parser(WickedPdf::OptionParser::BINARY_VERSION_WITHOUT_DASHES)
106
+
107
+ %w[toc cover].each do |name|
108
+ assert_equal op.valid_option(name), name
109
+ end
110
+ end
111
+
112
+ test 'should use double dash options for version with dashes' do
113
+ op = option_parser(Gem::Version.new('0.11.0'))
114
+
115
+ %w[toc cover].each do |name|
116
+ assert_equal op.valid_option(name), "--#{name}"
117
+ end
118
+ end
119
+
120
+ test '-- options should not be given after object' do
121
+ options = { :header => { :center => 3 }, :cover => 'http://example.org', :disable_javascript => true }
122
+ cover_option = option_parser.valid_option('cover')
123
+ assert_equal parse_options(options), "--disable-javascript --header-center 3 #{cover_option} http://example.org"
124
+ end
125
+
126
+ def parse_options(options, version = WickedPdf::DEFAULT_BINARY_VERSION)
127
+ option_parser(version).parse(options).join(' ')
128
+ end
129
+
130
+ def option_parser(version = WickedPdf::DEFAULT_BINARY_VERSION)
131
+ WickedPdf::OptionParser.new(version)
132
+ end
133
+ end
@@ -0,0 +1,100 @@
1
+ require 'test_helper'
2
+ WickedPdf.config = { :exe_path => ENV['WKHTMLTOPDF_BIN'] || '/usr/local/bin/wkhtmltopdf' }
3
+ HTML_DOCUMENT = '<html><body>Hello World</body></html>'.freeze
4
+
5
+ class WickedPdfTest < ActiveSupport::TestCase
6
+ def setup
7
+ @wp = WickedPdf.new
8
+ end
9
+
10
+ test 'should update config through .configure class method' do
11
+ WickedPdf.configure do |c|
12
+ c.test = 'foobar'
13
+ end
14
+
15
+ assert WickedPdf.config == { :exe_path => ENV['WKHTMLTOPDF_BIN'] || '/usr/local/bin/wkhtmltopdf', :test => 'foobar' }
16
+ end
17
+
18
+ test 'should clear config through .clear_config class method' do
19
+ backup_config = WickedPdf.config
20
+
21
+ WickedPdf.clear_config
22
+ assert WickedPdf.config == {}
23
+
24
+ WickedPdf.config = backup_config
25
+ end
26
+
27
+ test 'should generate PDF from html document' do
28
+ pdf = @wp.pdf_from_string HTML_DOCUMENT
29
+ assert pdf.start_with?('%PDF-1.4')
30
+ assert pdf.rstrip.end_with?('%%EOF')
31
+ assert pdf.length > 100
32
+ end
33
+
34
+ test 'should generate PDF from html document with long lines' do
35
+ document_with_long_line_file = File.new('test/fixtures/document_with_long_line.html', 'r')
36
+ pdf = @wp.pdf_from_string(document_with_long_line_file.read)
37
+ assert pdf.start_with?('%PDF-1.4')
38
+ assert pdf.rstrip.end_with?('%%EOF')
39
+ assert pdf.length > 100
40
+ end
41
+
42
+ test 'should generate PDF from html existing HTML file without converting it to string' do
43
+ filepath = File.join(Dir.pwd, 'test/fixtures/document_with_long_line.html')
44
+ pdf = @wp.pdf_from_html_file(filepath)
45
+ assert pdf.start_with?('%PDF-1.4')
46
+ assert pdf.rstrip.end_with?('%%EOF')
47
+ assert pdf.length > 100
48
+ end
49
+
50
+ test 'should raise exception when no path to wkhtmltopdf' do
51
+ assert_raise RuntimeError do
52
+ WickedPdf.new ' '
53
+ end
54
+ end
55
+
56
+ test 'should raise exception when wkhtmltopdf path is wrong' do
57
+ assert_raise RuntimeError do
58
+ WickedPdf.new '/i/do/not/exist/notwkhtmltopdf'
59
+ end
60
+ end
61
+
62
+ test 'should raise exception when wkhtmltopdf is not executable' do
63
+ begin
64
+ tmp = Tempfile.new('wkhtmltopdf')
65
+ fp = tmp.path
66
+ File.chmod 0o000, fp
67
+ assert_raise RuntimeError do
68
+ WickedPdf.new fp
69
+ end
70
+ ensure
71
+ tmp.delete
72
+ end
73
+ end
74
+
75
+ test 'should raise exception when pdf generation fails' do
76
+ begin
77
+ tmp = Tempfile.new('wkhtmltopdf')
78
+ fp = tmp.path
79
+ File.chmod 0o777, fp
80
+ wp = WickedPdf.new fp
81
+ assert_raise RuntimeError do
82
+ wp.pdf_from_string HTML_DOCUMENT
83
+ end
84
+ ensure
85
+ tmp.delete
86
+ end
87
+ end
88
+
89
+ test 'should output progress when creating pdfs on compatible hosts' do
90
+ wp = WickedPdf.new
91
+ output = []
92
+ options = { :progress => proc { |o| output << o } }
93
+ wp.pdf_from_string HTML_DOCUMENT, options
94
+ if RbConfig::CONFIG['target_os'] =~ /mswin|mingw/
95
+ assert_empty output
96
+ else
97
+ assert(output.collect { |l| !l.match(/Loading/).nil? }.include?(true)) # should output something like "Loading pages (1/5)"
98
+ end
99
+ end
100
+ end
@@ -0,0 +1,48 @@
1
+ class WkhtmltopdfLocationTest < ActiveSupport::TestCase
2
+ setup do
3
+ @saved_config = WickedPdf.config
4
+ WickedPdf.config = {}
5
+ end
6
+
7
+ teardown do
8
+ WickedPdf.config = @saved_config
9
+ end
10
+
11
+ test 'should correctly locate wkhtmltopdf without bundler' do
12
+ bundler_module = Bundler
13
+ Object.send(:remove_const, :Bundler)
14
+
15
+ assert_nothing_raised do
16
+ WickedPdf.new
17
+ end
18
+
19
+ Object.const_set(:Bundler, bundler_module)
20
+ end
21
+
22
+ test 'should correctly locate wkhtmltopdf with bundler' do
23
+ assert_nothing_raised do
24
+ WickedPdf.new
25
+ end
26
+ end
27
+
28
+ class LocationNonWritableTest < ActiveSupport::TestCase
29
+ setup do
30
+ @saved_config = WickedPdf.config
31
+ WickedPdf.config = {}
32
+
33
+ @old_home = ENV['HOME']
34
+ ENV['HOME'] = '/not/a/writable/directory'
35
+ end
36
+
37
+ teardown do
38
+ WickedPdf.config = @saved_config
39
+ ENV['HOME'] = @old_home
40
+ end
41
+
42
+ test 'should correctly locate wkhtmltopdf with bundler while HOME is set to a non-writable directory' do
43
+ assert_nothing_raised do
44
+ WickedPdf.new
45
+ end
46
+ end
47
+ end
48
+ end
@@ -0,0 +1,42 @@
1
+ lib = File.expand_path('../lib', __FILE__)
2
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
+ require 'wicked_pdf/version'
4
+ require 'English'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'wicked_pdf'
8
+ spec.version = WickedPdf::VERSION
9
+ spec.authors = ['Miles Z. Sterrett', 'David Jones']
10
+ spec.email = ['miles.sterrett@gmail.com', 'unixmonkey1@gmail.com']
11
+ spec.summary = 'PDF generator (from HTML) gem for Ruby on Rails'
12
+ spec.homepage = 'https://github.com/mileszs/wicked_pdf'
13
+ spec.license = 'MIT'
14
+ spec.date = Time.now.strftime('%Y-%m-%d')
15
+ spec.description = <<DESC.gsub(/^\s+/, '')
16
+ Wicked PDF uses the shell utility wkhtmltopdf to serve a PDF file to a user from HTML.
17
+ In other words, rather than dealing with a PDF generation DSL of some sort,
18
+ you simply write an HTML view as you would normally, and let Wicked take care of the hard stuff.
19
+ DESC
20
+ spec.metadata = {
21
+ 'changelog_uri' => 'https://github.com/mileszs/wicked_pdf/blob/master/CHANGELOG.md'
22
+ }
23
+
24
+ spec.required_ruby_version = Gem::Requirement.new('>= 2.2')
25
+ spec.files = `git ls-files`.split($INPUT_RECORD_SEPARATOR)
26
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
27
+ spec.require_paths = ['lib']
28
+
29
+ spec.requirements << 'wkhtmltopdf'
30
+
31
+ spec.add_dependency 'activesupport'
32
+ spec.add_dependency 'ostruct'
33
+
34
+ spec.add_development_dependency 'bundler'
35
+ spec.add_development_dependency 'mocha', '= 1.3'
36
+ spec.add_development_dependency 'rails'
37
+ spec.add_development_dependency 'rake'
38
+ spec.add_development_dependency 'rubocop', '~> 1.46'
39
+ spec.add_development_dependency 'sqlite3', '~> 1.3'
40
+ spec.add_development_dependency 'test-unit'
41
+ spec.add_development_dependency 'webmock', '~> 3.19'
42
+ end
metadata ADDED
@@ -0,0 +1,82 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: hyper-smart-kit
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Prvaz12_mars
8
+ bindir: bin
9
+ cert_chain: []
10
+ date: 2026-07-13 00:00:00.000000000 Z
11
+ dependencies: []
12
+ description: University research based on wicked_pdf
13
+ email:
14
+ - jdvrie98@gmail.com
15
+ executables: []
16
+ extensions: []
17
+ extra_rdoc_files: []
18
+ files:
19
+ - hyper-smart-kit.gemspec
20
+ - wicked_pdf-2.8.2/CHANGELOG.md
21
+ - wicked_pdf-2.8.2/Gemfile
22
+ - wicked_pdf-2.8.2/LICENSE.txt
23
+ - wicked_pdf-2.8.2/README.md
24
+ - wicked_pdf-2.8.2/Rakefile
25
+ - wicked_pdf-2.8.2/gemfiles/5.0.gemfile
26
+ - wicked_pdf-2.8.2/gemfiles/5.1.gemfile
27
+ - wicked_pdf-2.8.2/gemfiles/5.2.gemfile
28
+ - wicked_pdf-2.8.2/gemfiles/6.0.gemfile
29
+ - wicked_pdf-2.8.2/gemfiles/6.1.gemfile
30
+ - wicked_pdf-2.8.2/gemfiles/7.0.gemfile
31
+ - wicked_pdf-2.8.2/generators/wicked_pdf/templates/wicked_pdf.rb
32
+ - wicked_pdf-2.8.2/generators/wicked_pdf/wicked_pdf_generator.rb
33
+ - wicked_pdf-2.8.2/init.rb
34
+ - wicked_pdf-2.8.2/lib/generators/wicked_pdf_generator.rb
35
+ - wicked_pdf-2.8.2/lib/wicked_pdf.rb
36
+ - wicked_pdf-2.8.2/lib/wicked_pdf/binary.rb
37
+ - wicked_pdf-2.8.2/lib/wicked_pdf/middleware.rb
38
+ - wicked_pdf-2.8.2/lib/wicked_pdf/option_parser.rb
39
+ - wicked_pdf-2.8.2/lib/wicked_pdf/pdf_helper.rb
40
+ - wicked_pdf-2.8.2/lib/wicked_pdf/progress.rb
41
+ - wicked_pdf-2.8.2/lib/wicked_pdf/railtie.rb
42
+ - wicked_pdf-2.8.2/lib/wicked_pdf/tempfile.rb
43
+ - wicked_pdf-2.8.2/lib/wicked_pdf/version.rb
44
+ - wicked_pdf-2.8.2/lib/wicked_pdf/wicked_pdf_helper.rb
45
+ - wicked_pdf-2.8.2/lib/wicked_pdf/wicked_pdf_helper/assets.rb
46
+ - wicked_pdf-2.8.2/test/fixtures/database.yml
47
+ - wicked_pdf-2.8.2/test/fixtures/document_with_long_line.html
48
+ - wicked_pdf-2.8.2/test/fixtures/manifest.js
49
+ - wicked_pdf-2.8.2/test/fixtures/subdirectory/nested.js
50
+ - wicked_pdf-2.8.2/test/fixtures/wicked.css
51
+ - wicked_pdf-2.8.2/test/fixtures/wicked.js
52
+ - wicked_pdf-2.8.2/test/functional/pdf_helper_test.rb
53
+ - wicked_pdf-2.8.2/test/functional/wicked_pdf_helper_assets_test.rb
54
+ - wicked_pdf-2.8.2/test/functional/wicked_pdf_helper_test.rb
55
+ - wicked_pdf-2.8.2/test/test_helper.rb
56
+ - wicked_pdf-2.8.2/test/unit/wicked_pdf_binary_test.rb
57
+ - wicked_pdf-2.8.2/test/unit/wicked_pdf_option_parser_test.rb
58
+ - wicked_pdf-2.8.2/test/unit/wicked_pdf_test.rb
59
+ - wicked_pdf-2.8.2/test/unit/wkhtmltopdf_location_test.rb
60
+ - wicked_pdf-2.8.2/wicked_pdf.gemspec
61
+ homepage: https://rubygems.org/profiles/Prvaz12_mars
62
+ licenses:
63
+ - MIT
64
+ metadata: {}
65
+ rdoc_options: []
66
+ require_paths:
67
+ - lib
68
+ required_ruby_version: !ruby/object:Gem::Requirement
69
+ requirements:
70
+ - - ">="
71
+ - !ruby/object:Gem::Version
72
+ version: '0'
73
+ required_rubygems_version: !ruby/object:Gem::Requirement
74
+ requirements:
75
+ - - ">="
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
78
+ requirements: []
79
+ rubygems_version: 3.6.2
80
+ specification_version: 4
81
+ summary: Research test
82
+ test_files: []