delirium 0.1.0 → 0.2.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: 67269f8169e5297e1ce01f90654f13d3d3600d5752052e7a9ad40afb4fd2964c
4
- data.tar.gz: 86fa5f9d3081f44bd6cf91f5b76cf6997e2de9f3bd2ef933fa4df2d264bf2439
3
+ metadata.gz: f82cc3de8c5cd756ef19491f041b3263fc864107866225b22cd21ef77eda1f15
4
+ data.tar.gz: f9bcd42b71058c20269f5e386be9a0a56eaea680fa8e63ff342be8c6ecdbbfb9
5
5
  SHA512:
6
- metadata.gz: 8620f9f3c4a69cf0bf2613be0c52437166129447e9a9c402f920156dbc637b21974c58f87bc17c26081f1506ffbcf64b0ee17a75daeed465fb6e4d3d5b0f4dcb
7
- data.tar.gz: 12a8aa454b49ac7e1b2b1cf2478b03d7cabb451321246d109a4ffec57b52a1f395faf25d7f539e9782d2f7f2a867efb5229d764f48feb8aea11b623e10015a81
6
+ metadata.gz: 04ba47c91ad4ba254db5b6ae3b904010471b2f81b3d633057e58f67c0313a14efae16d052ec6193b824c1d4cc583daa61cd6cb3268f82924c427fe6c457582b4
7
+ data.tar.gz: 79850bcd4098b48b38df6d76e5e73306a4773d8db54a094ff544682ac2c9344f5e05afdaf0155b968e263ec635e6911224dabc64f2bf11e0074178743504af2e
data/.ruby-gemset ADDED
@@ -0,0 +1 @@
1
+ delirium
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 2.5.1
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- delirium (0.1.0)
4
+ delirium (0.2.0)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -26,7 +26,7 @@ PLATFORMS
26
26
  ruby
27
27
 
28
28
  DEPENDENCIES
29
- bundler (~> 1.17)
29
+ bundler (~> 1.16)
30
30
  delirium!
31
31
  rake (~> 10.0)
32
32
  rspec (~> 3.0)
data/delirium.gemspec CHANGED
@@ -21,7 +21,7 @@ Gem::Specification.new do |spec|
21
21
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
22
22
  spec.require_paths = ["lib"]
23
23
 
24
- spec.add_development_dependency "bundler", "~> 1.17"
24
+ spec.add_development_dependency "bundler", "~> 1.16"
25
25
  spec.add_development_dependency "rake", "~> 10.0"
26
26
  spec.add_development_dependency "rspec", "~> 3.0"
27
27
  end
data/lib/delirium.rb CHANGED
@@ -1,6 +1,6 @@
1
- require "delirium/version"
2
-
3
1
  module Delirium
4
2
  class Error < StandardError; end
5
- # Your code goes here...
6
3
  end
4
+
5
+ require_relative "delirium/version"
6
+ require_relative "delirium/platform"
@@ -0,0 +1,21 @@
1
+ module Delirium
2
+ module Platform
3
+ def self.class_for_current_platform
4
+ case RUBY_PLATFORM.downcase
5
+ when /darwin/
6
+ Delirium::Platform::Darwin
7
+ when /linux/
8
+ Delirium::Platform::Linux
9
+ when /cygwin|mswin|mingw|bccwin|wince|emx/
10
+ Delirium::Platform::Windows
11
+ else
12
+ raise Delirium::Error, "Unsupported Platform: #{platform}"
13
+ end
14
+ end
15
+ end
16
+ end
17
+
18
+ require_relative "platform/base"
19
+ require_relative "platform/darwin"
20
+ require_relative "platform/linux"
21
+ require_relative "platform/windows"
@@ -0,0 +1,25 @@
1
+ module Delirium
2
+ module Platform
3
+ class Base
4
+ def initialize
5
+ @mouse = eval "#{self.class.name}::Mouse.new"
6
+ @keyboard = eval "#{self.class.name}::Keyboard.new"
7
+ end
8
+
9
+ def do(device:, action:, params:)
10
+ case device
11
+ when :mouse
12
+ @mouse.send action, params
13
+ when :keyboard
14
+ @keyboard.send action, params
15
+ else
16
+ raise Delirium::Error, "unknown device: #{device}"
17
+ end
18
+ nil
19
+ end
20
+ end
21
+ end
22
+ end
23
+
24
+ require_relative "base/mouse"
25
+ require_relative "base/keyboard"
@@ -0,0 +1,23 @@
1
+ module Delirium
2
+ module Platform
3
+ class Base
4
+ class Keyboard
5
+ def key_press(string_or_symbol)
6
+ raise Delirium::Error, "not implemented"
7
+ end
8
+
9
+ def key_down(string_or_symbol)
10
+ raise Delirium::Error, "not implemented"
11
+ end
12
+
13
+ def key_up(string_or_symbol)
14
+ raise Delirium::Error, "not implemented"
15
+ end
16
+
17
+ def write(string)
18
+ raise Delirium::Error, "not implemented"
19
+ end
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,11 @@
1
+ module Delirium
2
+ module Platform
3
+ class Base
4
+ class Mouse
5
+ def move(params)
6
+ raise Delirium::Error, "not implemented"
7
+ end
8
+ end
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,9 @@
1
+ module Delirium
2
+ module Platform
3
+ class Darwin < Base
4
+ end
5
+ end
6
+ end
7
+
8
+ require_relative "darwin/mouse"
9
+ require_relative "darwin/keyboard"
@@ -0,0 +1,38 @@
1
+ module Delirium
2
+ module Platform
3
+ class Darwin
4
+ class Keyboard < Base::Keyboard
5
+ def key_press(key:)
6
+ case key
7
+ when String
8
+ `cliclick t:#{key}`
9
+ when Symbol
10
+ cliclick_key = case key
11
+ when :cmd
12
+ when :volume_up
13
+ "volume-up"
14
+ when :volume_down
15
+ "volume-down"
16
+ else
17
+ key
18
+ end
19
+
20
+ `cliclick kp:#{cliclick_key}` if cliclick_key
21
+ end
22
+ end
23
+
24
+ def key_down(key:)
25
+ `cliclick kd:#{key}`
26
+ end
27
+
28
+ def key_up(key:)
29
+ `cliclick ku:#{key}`
30
+ end
31
+
32
+ def write(string:)
33
+ `cliclick t:#{string}`
34
+ end
35
+ end
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,11 @@
1
+ module Delirium
2
+ module Platform
3
+ class Darwin
4
+ class Mouse < Base::Mouse
5
+ def move(params)
6
+ `cliclick m:+#{params[:x]},+#{params[:y]}`
7
+ end
8
+ end
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,9 @@
1
+ module Delirium
2
+ module Platform
3
+ class Linux < Base
4
+ end
5
+ end
6
+ end
7
+
8
+ require_relative "linux/mouse"
9
+ require_relative "linux/keyboard"
@@ -0,0 +1,32 @@
1
+ module Delirium
2
+ module Platform
3
+ class Linux
4
+ class Keyboard < Base::Keyboard
5
+ def key_press(key:)
6
+ case key
7
+ when Symbol
8
+ `xdotool type '#{key}'`
9
+ end
10
+ end
11
+
12
+ def key_down(key:)
13
+ case key
14
+ when Symbol
15
+ `xdotool keydown '#{key}'`
16
+ end
17
+ end
18
+
19
+ def key_up(key:)
20
+ case key
21
+ when Symbol
22
+ `xdotool keyup '#{key}'`
23
+ end
24
+ end
25
+
26
+ def write(string:)
27
+ `xdotool type '#{string}'`
28
+ end
29
+ end
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,11 @@
1
+ module Delirium
2
+ module Platform
3
+ class Linux
4
+ class Mouse < Base::Mouse
5
+ def move(params)
6
+ `xdotool`
7
+ end
8
+ end
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,9 @@
1
+ module Delirium
2
+ module Platform
3
+ class Windows < Base
4
+ end
5
+ end
6
+ end
7
+
8
+ require_relative "windows/mouse"
9
+ require_relative "windows/keyboard"
@@ -0,0 +1,28 @@
1
+ module Delirium
2
+ module Platform
3
+ class Windows
4
+ class Keyboard < Base::Keyboard
5
+ def key_press(key:)
6
+ case key
7
+ when Symbol
8
+ `nircmd.exe sendkey #{key} press`
9
+ end
10
+ end
11
+
12
+ def key_down(key:)
13
+ case key
14
+ when Symbol
15
+ `nircmd.exe sendkey #{key} down`
16
+ end
17
+ end
18
+
19
+ def key_up(key:)
20
+ case key
21
+ when Symbol
22
+ `nircmd.exe sendkey #{key} up`
23
+ end
24
+ end
25
+ end
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,11 @@
1
+ module Delirium
2
+ module Platform
3
+ class Windows
4
+ class Mouse < Base::Mouse
5
+ def move(params)
6
+ `nircmd.exe sendmouse #{params}`
7
+ end
8
+ end
9
+ end
10
+ end
11
+ end
@@ -1,3 +1,3 @@
1
1
  module Delirium
2
- VERSION = "0.1.0"
2
+ VERSION = "0.2.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: delirium
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Superbot HQ
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-12-12 00:00:00.000000000 Z
11
+ date: 2018-12-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '1.17'
19
+ version: '1.16'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '1.17'
26
+ version: '1.16'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -60,6 +60,8 @@ extra_rdoc_files: []
60
60
  files:
61
61
  - ".gitignore"
62
62
  - ".rspec"
63
+ - ".ruby-gemset"
64
+ - ".ruby-version"
63
65
  - ".travis.yml"
64
66
  - Gemfile
65
67
  - Gemfile.lock
@@ -70,6 +72,19 @@ files:
70
72
  - bin/setup
71
73
  - delirium.gemspec
72
74
  - lib/delirium.rb
75
+ - lib/delirium/platform.rb
76
+ - lib/delirium/platform/base.rb
77
+ - lib/delirium/platform/base/keyboard.rb
78
+ - lib/delirium/platform/base/mouse.rb
79
+ - lib/delirium/platform/darwin.rb
80
+ - lib/delirium/platform/darwin/keyboard.rb
81
+ - lib/delirium/platform/darwin/mouse.rb
82
+ - lib/delirium/platform/linux.rb
83
+ - lib/delirium/platform/linux/keyboard.rb
84
+ - lib/delirium/platform/linux/mouse.rb
85
+ - lib/delirium/platform/windows.rb
86
+ - lib/delirium/platform/windows/keyboard.rb
87
+ - lib/delirium/platform/windows/mouse.rb
73
88
  - lib/delirium/version.rb
74
89
  homepage: https://github.com/superbot-hq/delirium
75
90
  licenses:
@@ -91,7 +106,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
91
106
  version: '0'
92
107
  requirements: []
93
108
  rubyforge_project:
94
- rubygems_version: 2.7.7
109
+ rubygems_version: 2.7.8
95
110
  signing_key:
96
111
  specification_version: 4
97
112
  summary: desktop selenium