boaw 0.0.2 → 0.1.0

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: ce2bc4bae1fef75c28ea59cb3b7691c32b3e3bf933eebf08342596dfbedf54a1
4
+ data.tar.gz: 83ef9f64f397aa3afdfd0810cd0985c99f65fdbb30c79f348b195f0ba114a29a
5
5
  SHA512:
6
- metadata.gz: 5586887d3fc18a6b5d14db1a379fb3e34821a65f0bf8fcede9aaab182801ee093b50bb5c7d7d0f008954b9e2739d1961f6ab42de5ee35c172bd16c522319710a
7
- data.tar.gz: c7c470bc142556f9022061d4f8592a2781e40050f375538a4647cba610e2cc6088a5ea117aee832de4bf3eb82060f659676494cdfce101bf67543d74fba8d6a3
6
+ metadata.gz: 39334c482e475042fb7ddbfecf3cfb428c62285d05fda65c78c1fcad6af53ab9d84e6dfb7a7bd6563149c3c889ffb5c95b6b356847229d366c91ef981f7fba19
7
+ data.tar.gz: 6d5390889608eb0659f2b6e466dada0a8894d0cf481610bc7f9fabec79e551f20ee92c86a3467894338937344e5bf1182a59b25e99233e8e7f1f33ccd6f53ff9
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.1.0'
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,28 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require_relative 'position_parser'
4
+ require_relative 'base_error'
5
+
3
6
  module Xdotool
4
7
  # Xdotool adapter for mouse control
5
8
  class Adapter
6
- def position
7
- system('xdotool getmouselocation>temp.txt')
9
+ def initialize
10
+ result = Kernel.system('xdotool')
11
+ raise BaseError if result.nil?
12
+ end
8
13
 
9
- current_position = parse_position
14
+ def position
15
+ output = IO.popen('xdotool getmouselocation', &:read)
10
16
 
11
- {
12
- x: current_position['x'].to_i,
13
- y: current_position['y'].to_i
14
- }
17
+ PositionParser.parse(output)
15
18
  end
16
19
 
17
20
  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
21
+ Kernel.system("xdotool mousemove #{position[:x]} #{position[:y]} click 1")
29
22
  end
30
23
 
31
- def delete_temp_file
32
- File.delete('./temp.txt')
24
+ def right_click(position)
25
+ Kernel.system("xdotool mousemove #{position[:x]} #{position[:y]} click 3")
33
26
  end
34
27
  end
35
28
  end
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Xdotool
4
+ # default error
5
+ class BaseError < StandardError
6
+ def message
7
+ 'не удалось инициализировать модуль xdotool'
8
+ end
9
+ end
10
+ 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.1.0
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-03 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,8 @@ files:
19
19
  - lib/boaw.rb
20
20
  - lib/boaw/version.rb
21
21
  - lib/xdotool/adapter.rb
22
+ - lib/xdotool/base_error.rb
23
+ - lib/xdotool/position_parser.rb
22
24
  homepage: https://github.com/leonovk/boaw
23
25
  licenses:
24
26
  - MIT
@@ -41,7 +43,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
41
43
  - !ruby/object:Gem::Version
42
44
  version: '0'
43
45
  requirements: []
44
- rubygems_version: 3.4.20
46
+ rubygems_version: 3.4.21
45
47
  signing_key:
46
48
  specification_version: 4
47
49
  summary: Mouse manipulation library