Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

errors for xdotool #4

Merged
merged 1 commit into from
Nov 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
boaw (0.0.3)
boaw (0.1.0)

GEM
remote: https://rubygems.org/
Expand Down
2 changes: 1 addition & 1 deletion lib/boaw/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# frozen_string_literal: true

class Boaw
VERSION = '0.0.3'
VERSION = '0.1.0'
end
6 changes: 6 additions & 0 deletions lib/xdotool/adapter.rb
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
# frozen_string_literal: true

require_relative 'position_parser'
require_relative 'base_error'

module Xdotool
# Xdotool adapter for mouse control
class Adapter
def initialize
result = Kernel.system('xdotool')
raise BaseError if result.nil?
end

def position
output = IO.popen('xdotool getmouselocation', &:read)

Expand Down
10 changes: 10 additions & 0 deletions lib/xdotool/base_error.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# frozen_string_literal: true

module Xdotool
# default error
class BaseError < StandardError
def message
'не удалось инициализировать модуль xdotool'
end
end
end
2 changes: 1 addition & 1 deletion test/lib/boaw/version_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@

class VersionTest < Minitest::Test
def test_version
assert_equal '0.0.3', Boaw::VERSION
assert_equal '0.1.0', Boaw::VERSION
end
end
7 changes: 6 additions & 1 deletion test/lib/boaw_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,12 @@
class BoawTest < Minitest::Test
def setup
@mock_adapter = Minitest::Mock.new
@boaw = Boaw.new
mock_kernel = Minitest::Mock.new

Kernel.stub(:system, true, mock_kernel) do
@boaw = Boaw.new
end

@boaw.instance_variable_set(:@adapter, @mock_adapter)
@position = { x: 1, y: 2 }
end
Expand Down
7 changes: 6 additions & 1 deletion test/lib/xdotool/adapter_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,12 @@ module Xdotool
class AdapterTest < Minitest::Test
def setup
@position = { x: 1, y: 2 }
@adapter = Adapter.new

mock_kernel = Minitest::Mock.new

Kernel.stub(:system, true, mock_kernel) do
@adapter = Adapter.new
end
end

def test_left_click
Expand Down
1 change: 1 addition & 0 deletions test/test_helper.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# frozen_string_literal: true

require 'byebug'
require_relative '../lib/boaw'
require_relative '../lib/boaw/version'
require_relative '../lib/xdotool/position_parser'
Expand Down