boaw 0.0.1 → 0.0.3

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: a66c674c62720be3972467caf3322c8cca2611d8166735e22cff118782721c95
4
- data.tar.gz: 6ac808cdea27a87d871068aded16b6a57d077444c0c2296b09f15e752e84044b
3
+ metadata.gz: 59af16dc6f343753d59681d0a13cc206620babc84c0396bce97d5e59017a3558
4
+ data.tar.gz: 0ed2d61b4bd9e8092541d582b909eecf2798c1a12ad11d67891da2729149739b
5
5
  SHA512:
6
- metadata.gz: a9f05b107e3482e21f4561cfbbad1783106cf5acd150dbea742959297f3a42f47e5c903478b2bc86ca17e3c7ddbd5130b0cc4f1598cf3e09733b280ad8abe66e
7
- data.tar.gz: 52967893a3236e1fe2dc61475d5a79aecc4281dab7be2adb8caccb1066450c6b29f427e9125e2cec565c8d01f293a0c7cd428a9d4c1205aadf114dfb090bee7d
6
+ metadata.gz: fc3fe7aeff65cb2930fdc8309d40da9be4a4668afb12f5378ade1df484b0f843c57801d7a33147c7eeeba46bf5d619fb844b2b287ba09274509c386bd317f78a
7
+ data.tar.gz: 6effb5c40dc2a889771d4c58bfe6c24f244a4ceae9d998f115ac1c56cbb90ad52b1054787b6f3fe5bb5780447a6011e373b87994c4b00fabb73db4bb0d42c381
data/lib/boaw/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class Boaw
4
- VERSION = '0.0.1'
4
+ VERSION = '0.0.3'
5
5
  end
data/lib/boaw.rb CHANGED
@@ -1,8 +1,26 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Main class
3
+ require_relative 'xdotool/adapter'
4
+
5
+ # The main class from which work with the program begins
4
6
  class Boaw
5
- def hello
6
- 'dsa'
7
+ def initialize
8
+ @adapter = Xdotool::Adapter.new
9
+ end
10
+
11
+ def position
12
+ adapter.position
13
+ end
14
+
15
+ def left_click(position)
16
+ adapter.left_click(position)
7
17
  end
18
+
19
+ def right_click(position)
20
+ adapter.right_click(position)
21
+ end
22
+
23
+ private
24
+
25
+ attr_reader :adapter
8
26
  end
@@ -0,0 +1,22 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'position_parser'
4
+
5
+ module Xdotool
6
+ # Xdotool adapter for mouse control
7
+ class Adapter
8
+ def position
9
+ output = IO.popen('xdotool getmouselocation', &:read)
10
+
11
+ PositionParser.parse(output)
12
+ end
13
+
14
+ def left_click(position)
15
+ Kernel.system("xdotool mousemove #{position[:x]} #{position[:y]} click 1")
16
+ end
17
+
18
+ def right_click(position)
19
+ Kernel.system("xdotool mousemove #{position[:x]} #{position[:y]} click 3")
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Xdotool
4
+ # coordinate position parser from Xdotool
5
+ class PositionParser
6
+ def self.parse(position)
7
+ hash_position = position.scan(/(\w+):(\d+)/).to_h
8
+
9
+ {
10
+ x: hash_position['x'].to_i,
11
+ y: hash_position['y'].to_i
12
+ }
13
+ end
14
+ end
15
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: boaw
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kirill Leonov
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-11-01 00:00:00.000000000 Z
11
+ date: 2023-11-02 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: The library will allow you to create auto-clickers for Unix systems
14
14
  email: leonov7632@gmail.com
@@ -18,6 +18,8 @@ extra_rdoc_files: []
18
18
  files:
19
19
  - lib/boaw.rb
20
20
  - lib/boaw/version.rb
21
+ - lib/xdotool/adapter.rb
22
+ - lib/xdotool/position_parser.rb
21
23
  homepage: https://github.com/leonovk/boaw
22
24
  licenses:
23
25
  - MIT
@@ -40,7 +42,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
40
42
  - !ruby/object:Gem::Version
41
43
  version: '0'
42
44
  requirements: []
43
- rubygems_version: 3.4.20
45
+ rubygems_version: 3.4.21
44
46
  signing_key:
45
47
  specification_version: 4
46
48
  summary: Mouse manipulation library