Dhalang 0.6.5 → 0.7.0

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.
data/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dhalang",
3
- "version": "0.6.4",
3
+ "version": "0.7.0",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "directories": {
@@ -20,6 +20,6 @@
20
20
  },
21
21
  "homepage": "https://github.com/NielsSteensma/Dhalang#readme",
22
22
  "dependencies": {
23
- "puppeteer": "^13.3.2"
23
+ "puppeteer": "^22.5.0"
24
24
  }
25
25
  }
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: Dhalang
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.5
4
+ version: 0.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Niels Steensma
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-06-10 00:00:00.000000000 Z
11
+ date: 2024-04-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -80,15 +80,16 @@ dependencies:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
82
  version: '3.0'
83
- description:
83
+ description:
84
84
  email:
85
85
  - nielssteensma@yahoo.nl
86
86
  executables: []
87
87
  extensions: []
88
88
  extra_rdoc_files: []
89
89
  files:
90
+ - ".github/workflows/build.yml"
91
+ - ".github/workflows/publish.yml"
90
92
  - ".gitignore"
91
- - ".travis.yml"
92
93
  - Dhalang.gemspec
93
94
  - Gemfile
94
95
  - Gemfile.lock
@@ -96,14 +97,17 @@ files:
96
97
  - README.md
97
98
  - Rakefile
98
99
  - lib/Dhalang.rb
100
+ - lib/Dhalang/configuration.rb
99
101
  - lib/Dhalang/error.rb
100
102
  - lib/Dhalang/file_utils.rb
101
- - lib/Dhalang/puppeteer.rb
103
+ - lib/Dhalang/node_script_invoker.rb
102
104
  - lib/Dhalang/url_utils.rb
103
105
  - lib/Dhalang/version.rb
104
106
  - lib/PDF.rb
107
+ - lib/Scraper.rb
105
108
  - lib/Screenshot.rb
106
109
  - lib/js/dhalang.js
110
+ - lib/js/html-scraper.js
107
111
  - lib/js/pdf-generator.js
108
112
  - lib/js/screenshot-generator.js
109
113
  - package-lock.json
@@ -112,7 +116,7 @@ homepage: https://github.com/NielsSteensma/Dhalang
112
116
  licenses:
113
117
  - MIT
114
118
  metadata: {}
115
- post_install_message:
119
+ post_install_message:
116
120
  rdoc_options: []
117
121
  require_paths:
118
122
  - lib
@@ -127,8 +131,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
127
131
  - !ruby/object:Gem::Version
128
132
  version: '0'
129
133
  requirements: []
130
- rubygems_version: 3.0.8
131
- signing_key:
134
+ rubygems_version: 3.3.7
135
+ signing_key:
132
136
  specification_version: 4
133
137
  summary: Ruby wrapper for Puppeteer. Generate screenshots and PDF's from HTML!
134
138
  test_files: []
data/.travis.yml DELETED
@@ -1,21 +0,0 @@
1
- language: ruby
2
- node_js:
3
- - node
4
- rvm:
5
- - 2.6
6
- addons:
7
- chrome: stable
8
- before_install:
9
- - nvm install v15.0.1
10
- install:
11
- - bundle install
12
- - npm install
13
- script: bundle exec rake spec
14
- deploy:
15
- provider: rubygems
16
- gemspec: Dhalang.gemspec
17
- api_key:
18
- secure: PMiaYF8Xtyyl9Kuhf9WwDRaUzUcqbe430DF8Rwk2qYM1oI8eiYbESswHVavAnrT+ZLKZVzp0+avXJ1TFjoz2tHBa7YVmmz76+RvECozwBXFVofK0GX8c6PVZTuuHgoanr1RVv0KTJOZXs5Aa+372Er31ESuwaaRPU2y/d8aotxtoe7MUoVle67S7Z28H53jwDCut54WFq6hKi+gNO/B+7y/e2efPgrqSktHxaPDGcaUaX9v8fAYBJgAulJLYMeRj+m7IQccajIjppr7vWDE1m9XEDAK71i3EZis96/z+KexB2bo3+Qc+TvpTWP5NeKw61uhtPn9HU4+XCaOV8Vz0e6PH2JfS82h333BcSifXjcFb9iQU8aEMpSpcjraUvvvu8JZepUUO//vtGEJLyOJ0L4f9XiUPhQ15OYjBsJ2ADFdNcqyFeASDuLoeKbAQrWunyTStb+wFrr5TzAoQp9ItZbEt6eHaI6WSd4qhJfzqU7NOzE06Ns03J1jMdmzMxREl8ENJFle65fQouQfRnfcZTS6qW7UX/7YZUiMw60Cpa15qHW+92glCkOuiZUhr4D999ejqMFY5Jd3tHGVBX0/1MWc2jl0fPk2/fueA/YW8xLd3xKP9p0KhbqWZhiMxIct5w718nfOLuSoL1VLJRImj4HAKmoCFKP4RE+1Vl95UwEY=
19
- on:
20
- branch: master
21
- tags: true
@@ -1,97 +0,0 @@
1
- module Dhalang
2
- # Contains common logic for interacting with Puppeteer.
3
- class Puppeteer
4
- NODE_MODULES_PATH = Dir.pwd + '/node_modules/'.freeze
5
- private_constant :NODE_MODULES_PATH
6
-
7
- USER_OPTIONS = {
8
- navigationTimeout: 10000,
9
- printToPDFTimeout: 0, # unlimited
10
- navigationWaitUntil: 'load',
11
- navigationWaitForSelector: '',
12
- navigationWaitForXPath: '',
13
- userAgent: '',
14
- isHeadless: true,
15
- viewPort: '',
16
- httpAuthenticationCredentials: '',
17
- isAutoHeight: false,
18
- chromeOptions: []
19
- }
20
- private_constant :USER_OPTIONS
21
-
22
- DEFAULT_PDF_OPTIONS = {
23
- scale: 1,
24
- displayHeaderFooter: false,
25
- headerTemplate: '',
26
- footerTemplate: '',
27
- headerTemplateFile: '',
28
- footerTemplateFile: '',
29
- printBackground: true,
30
- landscape: false,
31
- pageRanges: '',
32
- format: 'A4',
33
- width: '',
34
- height: '',
35
- margin: { top: 36, right: 36, bottom: 20, left: 36 },
36
- preferCSSPageSize: true,
37
- omitBackground: false
38
- }
39
- private_constant :DEFAULT_PDF_OPTIONS
40
-
41
- DEFAULT_SCREENSHOT_OPTIONS = {
42
- fullPage: true,
43
- clip: nil,
44
- omitBackground: false
45
- }
46
- private_constant :DEFAULT_SCREENSHOT_OPTIONS
47
-
48
- DEFAULT_JPEG_OPTIONS = {
49
- quality: 100
50
- }
51
- private_constant :DEFAULT_JPEG_OPTIONS
52
-
53
-
54
- # Launches a new Node process, executing the (Puppeteer) script under the given script_path.
55
- #
56
- # @param [String] page_url The url to pass to the goTo method of Puppeteer.
57
- # @param [String] script_path The absolute path of the JS script to execute.
58
- # @param [String] temp_file_path The absolute path of the temp file to use to write any actions from Puppeteer.
59
- # @param [String] temp_file_extension The extension of the temp file.
60
- # @param [Object] options Set of options to use, configurable by the user.
61
- def self.visit(page_url, script_path, temp_file_path, temp_file_extension, options)
62
- configuration = create_configuration(page_url, script_path, temp_file_path, temp_file_extension, options)
63
-
64
- command = "node #{script_path} #{Shellwords.escape(configuration)}"
65
-
66
- Open3.popen2e(command) do |_stdin, stdouterr, wait|
67
- return nil if wait.value.success?
68
-
69
- output = stdouterr.read.strip
70
- output = nil if output == ''
71
- message = output || "Exited with status #{wait.value.exitstatus}"
72
- raise DhalangError, message
73
- end
74
- end
75
-
76
-
77
- # Returns a JSON string with the configuration to use within the Puppeteer script.
78
- #
79
- # @param [String] page_url The url to pass to the goTo method of Puppeteer.
80
- # @param [String] script_path The absolute path of the JS script to execute.
81
- # @param [String] temp_file_path The absolute path of the temp file to use to write any actions from Puppeteer.
82
- # @param [String] temp_file_extension The extension of the temp file.
83
- # @param [Hash] options Set of options to use, configurable by the user.
84
- private_class_method def self.create_configuration(page_url, script_path, temp_file_path, temp_file_extension, options)
85
- {
86
- webPageUrl: page_url,
87
- tempFilePath: temp_file_path,
88
- puppeteerPath: NODE_MODULES_PATH,
89
- imageType: temp_file_extension,
90
- userOptions: USER_OPTIONS.map { |option, value| [option, options.has_key?(option) ? options[option] : value]}.to_h,
91
- pdfOptions: DEFAULT_PDF_OPTIONS.map { |option, value| [option, options.has_key?(option) ? options[option] : value] }.to_h,
92
- screenshotOptions: DEFAULT_SCREENSHOT_OPTIONS.map { |option, value| [option, options.has_key?(option) ? options[option] : value] }.to_h,
93
- jpegOptions: DEFAULT_JPEG_OPTIONS.map { |option, value| [option, options.has_key?(option) ? options[option] : value] }.to_h
94
- }.to_json
95
- end
96
- end
97
- end