-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
165 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
name: Ruby | ||
|
||
on: | ||
push: | ||
branches: [ "main" ] | ||
pull_request: | ||
branches: [ "main" ] | ||
|
||
jobs: | ||
test: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Set up Ruby | ||
uses: ruby/setup-ruby@ec02537da5712d66d4d50a0f33b7eb52773b5ed1 | ||
with: | ||
ruby-version: '3.1' | ||
- name: Install dependencies | ||
run: bundle install | ||
- name: Run cops | ||
run: bundle exec rubocop |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# frozen_string_literal: true | ||
|
||
source 'https://rubygems.org' | ||
|
||
gemspec | ||
|
||
gem 'rubocop' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
PATH | ||
remote: . | ||
specs: | ||
boaw (0.0.2) | ||
|
||
GEM | ||
remote: https://rubygems.org/ | ||
specs: | ||
ast (2.4.2) | ||
json (2.6.3) | ||
language_server-protocol (3.17.0.3) | ||
parallel (1.23.0) | ||
parser (3.2.2.4) | ||
ast (~> 2.4.1) | ||
racc | ||
racc (1.7.2) | ||
rainbow (3.1.1) | ||
regexp_parser (2.8.2) | ||
rexml (3.2.6) | ||
rubocop (1.57.2) | ||
json (~> 2.3) | ||
language_server-protocol (>= 3.17.0) | ||
parallel (~> 1.10) | ||
parser (>= 3.2.2.4) | ||
rainbow (>= 2.2.2, < 4.0) | ||
regexp_parser (>= 1.8, < 3.0) | ||
rexml (>= 3.2.5, < 4.0) | ||
rubocop-ast (>= 1.28.1, < 2.0) | ||
ruby-progressbar (~> 1.7) | ||
unicode-display_width (>= 2.4.0, < 3.0) | ||
rubocop-ast (1.30.0) | ||
parser (>= 3.2.1.0) | ||
ruby-progressbar (1.13.0) | ||
unicode-display_width (2.5.0) | ||
|
||
PLATFORMS | ||
x86_64-linux | ||
|
||
DEPENDENCIES | ||
boaw! | ||
rubocop | ||
|
||
BUNDLED WITH | ||
2.4.20 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#!/usr/bin/env ruby | ||
# frozen_string_literal: true | ||
|
||
require 'bundler/setup' | ||
require 'boaw' | ||
|
||
require 'irb' | ||
IRB.start(__FILE__) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#!/usr/bin/env bash | ||
set -euo pipefail | ||
IFS=$'\n\t' | ||
set -vx | ||
|
||
bundle install |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# frozen_string_literal: true | ||
|
||
require_relative 'lib/boaw/version' | ||
|
||
Gem::Specification.new do |s| | ||
s.name = 'boaw' | ||
s.version = Boaw::VERSION | ||
s.summary = 'Mouse manipulation library' | ||
s.description = 'The library will allow you to create auto-clickers for Unix systems' | ||
s.authors = ['Kirill Leonov'] | ||
s.email = '[email protected]' | ||
s.files = Dir.glob('lib/**/*') | ||
s.homepage = 'https://github.com/leonovk/boaw' | ||
s.license = 'MIT' | ||
s.required_ruby_version = '>= 3.1.0' | ||
s.metadata['homepage_uri'] = s.homepage | ||
s.metadata['source_code_uri'] = s.homepage | ||
s.metadata['documentation_uri'] = s.homepage | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# frozen_string_literal: true | ||
|
||
require_relative 'xdotool/adapter' | ||
|
||
# Main class | ||
class Boaw | ||
attr_reader :adapter | ||
|
||
def initialize | ||
@adapter = Xdotool::Adapter.new | ||
end | ||
|
||
def position | ||
adapter.position | ||
end | ||
|
||
def left_click(position) | ||
adapter.left_click(position) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# frozen_string_literal: true | ||
|
||
class Boaw | ||
VERSION = '0.0.2' | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# frozen_string_literal: true | ||
|
||
module Xdotool | ||
# Xdotool adapter for mouse control | ||
class Adapter | ||
def position | ||
system('xdotool getmouselocation>temp.txt') | ||
|
||
current_position = parse_position | ||
|
||
{ | ||
x: current_position['x'].to_i, | ||
y: current_position['y'].to_i | ||
} | ||
end | ||
|
||
def left_click(position) | ||
system("xdotool mousemove #{position[:x]} #{position[:y]} click 1") | ||
end | ||
|
||
private | ||
|
||
def parse_position | ||
file = File.open('./temp.txt', 'r') | ||
position = file.gets.scan(/(\w+):(\d+)/).to_h | ||
file.close | ||
delete_temp_file | ||
position | ||
end | ||
|
||
def delete_temp_file | ||
File.delete('./temp.txt') | ||
end | ||
end | ||
end |