boaw 0.0.2 → 0.0.3

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
2
  SHA256:
3
- metadata.gz: b7888bcff81bb35a03e6c4e756fa14fbdf8bb4afdc09955aa769d4267776c41c
4
- data.tar.gz: 9abf00d8b7287c7dc0b68a3658ad1a2ca36294c0fc7e69680c70b5a1d37e927f
3
+ metadata.gz: 59af16dc6f343753d59681d0a13cc206620babc84c0396bce97d5e59017a3558
4
+ data.tar.gz: 0ed2d61b4bd9e8092541d582b909eecf2798c1a12ad11d67891da2729149739b
5
5
  SHA512:
6
- metadata.gz: 5586887d3fc18a6b5d14db1a379fb3e34821a65f0bf8fcede9aaab182801ee093b50bb5c7d7d0f008954b9e2739d1961f6ab42de5ee35c172bd16c522319710a
7
- data.tar.gz: c7c470bc142556f9022061d4f8592a2781e40050f375538a4647cba610e2cc6088a5ea117aee832de4bf3eb82060f659676494cdfce101bf67543d74fba8d6a3
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.2'
4
+ VERSION = '0.0.3'
5
5
  end
data/lib/boaw.rb CHANGED
@@ -2,10 +2,8 @@
2
2
 
3
3
  require_relative 'xdotool/adapter'
4
4
 
5
- # Main class
5
+ # The main class from which work with the program begins
6
6
  class Boaw
7
- attr_reader :adapter
8
-
9
7
  def initialize
10
8
  @adapter = Xdotool::Adapter.new
11
9
  end
@@ -17,4 +15,12 @@ class Boaw
17
15
  def left_click(position)
18
16
  adapter.left_click(position)
19
17
  end
18
+
19
+ def right_click(position)
20
+ adapter.right_click(position)
21
+ end
22
+
23
+ private
24
+
25
+ attr_reader :adapter
20
26
  end
@@ -1,35 +1,22 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require_relative 'position_parser'
4
+
3
5
  module Xdotool
4
6
  # Xdotool adapter for mouse control
5
7
  class Adapter
6
8
  def position
7
- system('xdotool getmouselocation>temp.txt')
8
-
9
- current_position = parse_position
9
+ output = IO.popen('xdotool getmouselocation', &:read)
10
10
 
11
- {
12
- x: current_position['x'].to_i,
13
- y: current_position['y'].to_i
14
- }
11
+ PositionParser.parse(output)
15
12
  end
16
13
 
17
14
  def left_click(position)
18
- system("xdotool mousemove #{position[:x]} #{position[:y]} click 1")
19
- end
20
-
21
- private
22
-
23
- def parse_position
24
- file = File.open('./temp.txt', 'r')
25
- position = file.gets.scan(/(\w+):(\d+)/).to_h
26
- file.close
27
- delete_temp_file
28
- position
15
+ Kernel.system("xdotool mousemove #{position[:x]} #{position[:y]} click 1")
29
16
  end
30
17
 
31
- def delete_temp_file
32
- File.delete('./temp.txt')
18
+ def right_click(position)
19
+ Kernel.system("xdotool mousemove #{position[:x]} #{position[:y]} click 3")
33
20
  end
34
21
  end
35
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.2
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
@@ -19,6 +19,7 @@ files:
19
19
  - lib/boaw.rb
20
20
  - lib/boaw/version.rb
21
21
  - lib/xdotool/adapter.rb
22
+ - lib/xdotool/position_parser.rb
22
23
  homepage: https://github.com/leonovk/boaw
23
24
  licenses:
24
25
  - MIT
@@ -41,7 +42,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
41
42
  - !ruby/object:Gem::Version
42
43
  version: '0'
43
44
  requirements: []
44
- rubygems_version: 3.4.20
45
+ rubygems_version: 3.4.21
45
46
  signing_key:
46
47
  specification_version: 4
47
48
  summary: Mouse manipulation library