win32screenshot 4.0.0 → 4.1.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7c6e29c2c5baea6ccc52e0a3988c6f9abb76b83054b38072918d097e21471d67
4
- data.tar.gz: 93ee67cb6debdcf6128b2ebc6ffed4165cd54b119417f625bca2431db0996971
3
+ metadata.gz: 20fb85f0a8a6db55a03ef208225cb7a0f081b704f41abf405b39e63283c2c7ea
4
+ data.tar.gz: bfeb14a87af3452d3bd39b37edfd13733a940657e671e4e038a1ec06775aa858
5
5
  SHA512:
6
- metadata.gz: 3ea409fdeeba7caf2dc68858eb378983641003b9167112b58ae8138cd48789f705c2efa77002295614d75f07a0b75a8e783b8bcb47ccb02e1368e030dbb344b1
7
- data.tar.gz: 313e9d5d815495afe4bd59e04b2603e778494500ce19649812335df18f71fdc966635af43074e6ce71e9f0b5da54436839dad4a02e04cf38556d4320756562a6
6
+ metadata.gz: 75b4b936b11909e01426ee6ae23a8885106c594a8585372e9e8d7cef59c739d0ce5b7369173b1ae28484559637466f2d22774b0d29a487df13dca8011ed1464d
7
+ data.tar.gz: e428a2fdcaa46dd961f351000af951d4c4ffa8f556e1b8b9befb7e09dd99eb7c3412d950f9e4122301d6ebc99009cda805eb7343c0772bb14ac0b152fcd4163c
data/CHANGES.md CHANGED
@@ -1,3 +1,7 @@
1
+ # 4.1.0 2023-02-05
2
+ * Add support for Ruby 3.2 (by @kaiwaredaikon009 via PR #36)
3
+
4
+
1
5
  # 4.0.0 2022-06-18
2
6
  * Add support for taking screenchots of non-native Windows (e.g. Google Chrome).
3
7
  * When taking screenshot of `:desktop` then all monitors will be included if they exist.
@@ -6,14 +10,17 @@
6
10
 
7
11
  Changes done by @bensandland via PR #34.
8
12
 
13
+
9
14
  # 3.1.0 2022-02-05
10
15
  * Update dependencies
11
16
 
17
+
12
18
  # 3.0.0 2019-12-11
13
19
  * Use RAutomation 1.0.0 as its dependency to be able to use newer ffi.
14
20
  * Update bundled ImageMagick to 7.0.9-8.
15
21
  * Update MiniMagick dependency.
16
22
 
23
+
17
24
  # 2.1.0 2016-01-09
18
25
  * Add Image#write! for overwriting images.
19
26
  * Update MiniMagick dependency.
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- win32screenshot (4.0.0)
4
+ win32screenshot (4.1.0)
5
5
  ffi (~> 1.15.0)
6
6
  mini_magick (~> 4.9)
7
7
  rautomation (~> 1.1.0)
@@ -42,4 +42,4 @@ DEPENDENCIES
42
42
  yard
43
43
 
44
44
  BUNDLED WITH
45
- 2.3.3
45
+ 2.3.24
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Win32::Screenshot
2
2
 
3
- * http://github.com/jarmo/win32screenshot
3
+ * http://github.com/jarmo/win32screenshot
4
4
 
5
5
 
6
6
  ## DESCRIPTION
@@ -9,39 +9,45 @@ Capture Screenshots on Windows with Ruby to bmp, gif, jpg or png formats!
9
9
 
10
10
  ## INSTALL
11
11
 
12
- gem install win32screenshot
12
+ ```
13
+ gem install win32screenshot
14
+ ```
13
15
 
14
16
  ## SYNOPSIS
15
17
 
16
- require 'win32/screenshot'
18
+ ```ruby
19
+ require 'win32/screenshot'
17
20
 
18
- # Take a screenshot of the window with the specified title
19
- Win32::Screenshot::Take.of(:window, title: "Windows Internet Explorer").write("image.bmp")
21
+ # Take a screenshot of the window with the specified title
22
+ Win32::Screenshot::Take.of(:window, title: "Windows Internet Explorer").write("image.bmp")
20
23
 
21
- # Take a screenshot of the whole desktop area, including all monitors if multiple are connected
22
- Win32::Screenshot::Take.of(:desktop).write("image.png")
24
+ # Take a screenshot of the whole desktop area, including all monitors if multiple are connected
25
+ Win32::Screenshot::Take.of(:desktop).write("image.png")
23
26
 
24
- # Take a screenshot of the foreground window
25
- Win32::Screenshot::Take.of(:foreground).write("image.png")
27
+ # Take a screenshot of the foreground window
28
+ Win32::Screenshot::Take.of(:foreground).write("image.png")
26
29
 
27
- # Take a screenshot of the foreground window, and writing over previous image if it exists
28
- Win32::Screenshot::Take.of(:foreground).write!("image.png")
30
+ # Take a screenshot of the foreground window, and writing over previous image if it exists
31
+ Win32::Screenshot::Take.of(:foreground).write!("image.png")
29
32
 
30
- # Take a screenshot of the specified window with title matching the regular expression
31
- Win32::Screenshot::Take.of(:window, title: /internet/i).write("image.jpg")
33
+ # Take a screenshot of the specified window with title matching the regular expression
34
+ Win32::Screenshot::Take.of(:window, title: /internet/i).write("image.jpg")
32
35
 
33
- # Take a screenshot of the window with the specified handle
34
- Win32::Screenshot::Take.of(:window, hwnd: 123456).write("image.gif")
36
+ # Take a screenshot of the window with the specified handle
37
+ Win32::Screenshot::Take.of(:window, hwnd: 123456).write("image.gif")
35
38
 
36
- # Take a screenshot of the child window with the specified internal class name
37
- Win32::Screenshot::Take.of(:rautomation, RAutomation::Window.new(hwnd: 123456).
38
- child(class: "Internet Explorer_Server")).write("image.png")
39
+ # Take a screenshot of the child window with the specified internal class name
40
+ Win32::Screenshot::Take.of(
41
+ :rautomation,
42
+ RAutomation::Window.new(hwnd: 123456).child(class: "Internet Explorer_Server")
43
+ ).write("image.png")
39
44
 
40
- # Use the bitmap blob for something else
41
- image = Win32::Screenshot::Take.of(:window, hwnd: 123456)
42
- image.height # => height of the image
43
- image.width # => width of the image
44
- image.bitmap # => bitmap blob
45
+ # Use the bitmap blob for something else
46
+ image = Win32::Screenshot::Take.of(:window, hwnd: 123456)
47
+ image.height # => height of the image
48
+ image.width # => width of the image
49
+ image.bitmap # => bitmap blob
50
+ ```
45
51
 
46
52
  ## Copyright
47
53
 
@@ -1,48 +1,48 @@
1
- module Win32
2
- module Screenshot
3
- # Holds the bitmap data and writes it to the disk
4
- class Image
5
- # [String] raw bitmap blob
6
- attr_reader :bitmap
7
-
8
- # [String] bitmap width
9
- attr_reader :width
10
-
11
- # [String] bitmap height
12
- attr_reader :height
13
-
14
- # Supported output formats
15
- FORMATS = %w{bmp gif jpg png}
16
-
17
- # @private
18
- def initialize(blob, width, height)
19
- @bitmap = blob
20
- @width = width
21
- @height = height
22
- end
23
-
24
- # Writes image to the disk.
25
- # @param [String] file_path writes image to the specified path.
26
- # @raise [RuntimeError] when _file_path_ already exists.
27
- # @raise [RuntimeError] when _file_path_ is not with the supported output {FORMATS} extension.
28
- def write(file_path)
29
- raise "File already exists: #{file_path}!" if File.exists? file_path
30
- write! file_path
31
- end
32
-
33
- #Writes image to disk, writing over existing copy if it exists.
34
- def write!(file_path)
35
- ext = File.extname(file_path)[1..-1]
36
- raise "File '#{file_path}' has to have one of the following extensions: #{FORMATS.join(", ")}" unless ext && FORMATS.include?(ext.downcase)
37
-
38
- if ext.downcase == "bmp"
39
- File.open(file_path, "wb") {|io| io.write @bitmap}
40
- else
41
- image = ::MiniMagick::Image.read @bitmap
42
- image.format ext
43
- image.write file_path
44
- end
45
- end
46
- end
47
- end
48
- end
1
+ module Win32
2
+ module Screenshot
3
+ # Holds the bitmap data and writes it to the disk
4
+ class Image
5
+ # [String] raw bitmap blob
6
+ attr_reader :bitmap
7
+
8
+ # [String] bitmap width
9
+ attr_reader :width
10
+
11
+ # [String] bitmap height
12
+ attr_reader :height
13
+
14
+ # Supported output formats
15
+ FORMATS = %w{bmp gif jpg png}
16
+
17
+ # @private
18
+ def initialize(blob, width, height)
19
+ @bitmap = blob
20
+ @width = width
21
+ @height = height
22
+ end
23
+
24
+ # Writes image to the disk.
25
+ # @param [String] file_path writes image to the specified path.
26
+ # @raise [RuntimeError] when _file_path_ already exists.
27
+ # @raise [RuntimeError] when _file_path_ is not with the supported output {FORMATS} extension.
28
+ def write(file_path)
29
+ raise "File already exists: #{file_path}!" if File.exist? file_path
30
+ write! file_path
31
+ end
32
+
33
+ #Writes image to disk, writing over existing copy if it exists.
34
+ def write!(file_path)
35
+ ext = File.extname(file_path)[1..-1]
36
+ raise "File '#{file_path}' has to have one of the following extensions: #{FORMATS.join(", ")}" unless ext && FORMATS.include?(ext.downcase)
37
+
38
+ if ext.downcase == "bmp"
39
+ File.open(file_path, "wb") {|io| io.write @bitmap}
40
+ else
41
+ image = ::MiniMagick::Image.read @bitmap
42
+ image.format ext
43
+ image.write file_path
44
+ end
45
+ end
46
+ end
47
+ end
48
+ end
@@ -1,5 +1,5 @@
1
1
  module Win32
2
2
  module Screenshot
3
- VERSION = "4.0.0"
3
+ VERSION = "4.1.0"
4
4
  end
5
5
  end
data/spec/spec_helper.rb CHANGED
@@ -20,7 +20,7 @@ module SpecHelper
20
20
  [:long, :long, :int, :int, :int, :int, :int], :bool
21
21
 
22
22
  def save_and_verify_image(img, file=nil)
23
- FileUtils.mkdir @temp_dir unless File.exists?(@temp_dir)
23
+ FileUtils.mkdir @temp_dir unless File.exist?(@temp_dir)
24
24
  file_name = File.join @temp_dir, "#{file}.bmp"
25
25
  img.write file_name
26
26
  expect(img.bitmap[0..1]).to eq('BM')
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: win32screenshot
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.0.0
4
+ version: 4.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jarmo Pertman
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2022-06-18 00:00:00.000000000 Z
12
+ date: 2023-02-05 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: ffi
@@ -145,7 +145,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
145
145
  - !ruby/object:Gem::Version
146
146
  version: '0'
147
147
  requirements: []
148
- rubygems_version: 3.0.3
148
+ rubygems_version: 3.3.24
149
149
  signing_key:
150
150
  specification_version: 4
151
151
  summary: Capture Screenshots on Windows with Ruby to bmp, gif, jpg or png formats.