touch_action 0.0.1alpha

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 744adb3766b383eb489493a91e3c106e8afcb8d1
4
+ data.tar.gz: ef0af39857d40ca853b20b92b2b702f1d45eb244
5
+ SHA512:
6
+ metadata.gz: 753a4a717c285dde7f3913b437ef9f0f999941ca3a0a978288c1ae7987e0e6bac93970d25ab3fc86f94be049bc7a8dfd754ae6b89b87351750f1a3c76a1ba69b
7
+ data.tar.gz: 9c3ba99c733a8063756a04891c10722bc869de0293690f5d7a45a6465879c525b02b5408984c57bd02e35231b5dee4cf86b0f2f9309ffda94edaf55986f02a24
data/.DS_Store ADDED
Binary file
data/.gitignore ADDED
@@ -0,0 +1,15 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ *.bundle
11
+ *.so
12
+ *.o
13
+ *.a
14
+ mkmf.log
15
+ console
data/CHANGELOG.md ADDED
@@ -0,0 +1,3 @@
1
+ ## v0.0.1.alpha
2
+
3
+ * initial release
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in touch_action.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Ricardo Nacif
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/MIT-LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright 2014 Ricardo Nacif <nacif.ricardo@gmail.com>
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,54 @@
1
+ # TouchAction
2
+
3
+ Adds touch gestures to Watir and Selenium using YUI JS. Very useful when using Appium to test mobile websites.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'touch_action'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ ## WARNING
18
+ It's currently being developed and there are no tests on it. For now, it's only supporting Watir-webdriver.
19
+
20
+ ## Usage
21
+
22
+ ```ruby
23
+ #on the element you want to perform the action, call touch_action(:name_of_method)
24
+ element = @driver.div(:id, 'hit')
25
+ element.touch_action(:swipe)
26
+ ```
27
+ ###Available Gestures
28
+ It's currently supporting the gestures bellow. The hash as second argument is optional (here it's showing the default for each action).
29
+ ```ruby
30
+ element.touch_action(:flick, {axis: 'x', distance: -100, duration: 50}) #flick and swipe are the same
31
+
32
+ element.touch_action(:pinch, {r1: 50, r2: 100})
33
+
34
+ element.touch_action(:tap)
35
+
36
+ element.touch_action(:doubletap)
37
+
38
+ element.touch_action(:press, {hold: 2000})
39
+
40
+ element.touch_action(:move, {xdist: 70, ydist: -50, duration: 2000})
41
+
42
+ element.touch_action(:rotate, {rotation: -75})
43
+
44
+ ```
45
+ For more information about how those methods work, please check the [YUI Documentation](http://yuilibrary.com/yui/docs/event/simulate.html#simulating-touch-gestures).
46
+
47
+
48
+ ## Contributing
49
+
50
+ 1. Fork it ( https://github.com/[my-github-username]/touch_action/fork )
51
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
52
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
53
+ 4. Push to the branch (`git push origin my-new-feature`)
54
+ 5. Create a new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+
data/lib/.DS_Store ADDED
Binary file
Binary file
@@ -0,0 +1,40 @@
1
+
2
+ var element_locator = arguments[0];
3
+
4
+ function loadYui(callback) {
5
+ // Adding the script tag to the head as suggested before
6
+ var head = document.getElementsByTagName('head')[0];
7
+ var script = document.createElement('script');
8
+ script.type = 'text/javascript';
9
+ script.src = "http://yui.yahooapis.com/3.17.2/build/yui/yui-min.js";
10
+
11
+ // Then bind the event to the callback function.
12
+ // There are several events for cross browser compatibility.
13
+ script.onreadystatechange = callback;
14
+ script.onload = callback;
15
+
16
+ // Fire the loading
17
+ head.appendChild(script);
18
+ }
19
+
20
+ var doubletap = function() {
21
+
22
+ YUI().use('node-event-simulate', function(Y) {
23
+
24
+ var node = Y.one(element_locator);
25
+
26
+ node.simulateGesture("doubletap");
27
+
28
+ });
29
+
30
+ };
31
+
32
+
33
+
34
+ if (typeof YUI == 'undefined') {
35
+ loadYui(doubletap);
36
+ } else {
37
+ doubletap();
38
+ };
39
+
40
+
@@ -0,0 +1,44 @@
1
+
2
+ var element_locator = arguments[0];
3
+
4
+ function loadYui(callback) {
5
+ // Adding the script tag to the head as suggested before
6
+ var head = document.getElementsByTagName('head')[0];
7
+ var script = document.createElement('script');
8
+ script.type = 'text/javascript';
9
+ script.src = "http://yui.yahooapis.com/3.17.2/build/yui/yui-min.js";
10
+
11
+ // Then bind the event to the callback function.
12
+ // There are several events for cross browser compatibility.
13
+ script.onreadystatechange = callback;
14
+ script.onload = callback;
15
+
16
+ // Fire the loading
17
+ head.appendChild(script);
18
+ }
19
+
20
+ var flick = function() {
21
+
22
+ YUI().use('node-event-simulate', function(Y) {
23
+
24
+ var node = Y.one(element_locator);
25
+
26
+ node.simulateGesture("flick", {
27
+ axis: "<%=axis%>",
28
+ distance: <%=distance%>,
29
+ duration: <%=duration%>
30
+ });
31
+
32
+ });
33
+
34
+ };
35
+
36
+
37
+
38
+ if (typeof YUI == 'undefined') {
39
+ loadYui(flick);
40
+ } else {
41
+ flick();
42
+ };
43
+
44
+
@@ -0,0 +1,44 @@
1
+
2
+ var element_locator = arguments[0];
3
+
4
+ function loadYui(callback) {
5
+ // Adding the script tag to the head as suggested before
6
+ var head = document.getElementsByTagName('head')[0];
7
+ var script = document.createElement('script');
8
+ script.type = 'text/javascript';
9
+ script.src = "http://yui.yahooapis.com/3.17.2/build/yui/yui-min.js";
10
+
11
+ // Then bind the event to the callback function.
12
+ // There are several events for cross browser compatibility.
13
+ script.onreadystatechange = callback;
14
+ script.onload = callback;
15
+
16
+ // Fire the loading
17
+ head.appendChild(script);
18
+ }
19
+
20
+ var move = function() {
21
+
22
+ YUI().use('node-event-simulate', function(Y) {
23
+
24
+ var node = Y.one(element_locator);
25
+
26
+ node.simulateGesture("move", {
27
+ path: {
28
+ xdist: <%= xdist %>,
29
+ ydist: <%= ydist %>
30
+ } ,
31
+ duration: <%= duration %>
32
+
33
+ });
34
+
35
+ });
36
+
37
+ };
38
+
39
+
40
+ if (typeof YUI == 'undefined') {
41
+ loadYui(move);
42
+ } else {
43
+ move();
44
+ };
@@ -0,0 +1,41 @@
1
+
2
+ var element_locator = arguments[0];
3
+
4
+ function loadYui(callback) {
5
+ // Adding the script tag to the head as suggested before
6
+ var head = document.getElementsByTagName('head')[0];
7
+ var script = document.createElement('script');
8
+ script.type = 'text/javascript';
9
+ script.src = "http://yui.yahooapis.com/3.17.2/build/yui/yui-min.js";
10
+
11
+ // Then bind the event to the callback function.
12
+ // There are several events for cross browser compatibility.
13
+ script.onreadystatechange = callback;
14
+ script.onload = callback;
15
+
16
+ // Fire the loading
17
+ head.appendChild(script);
18
+ }
19
+
20
+ var pinch = function() {
21
+
22
+ YUI().use('node-event-simulate', function(Y) {
23
+
24
+ var node = Y.one(element_locator);
25
+
26
+ //simulate a pinch: "r1" and "r2" are required
27
+ node.simulateGesture("pinch", {
28
+ r1: <%=r1%>, // start circle radius at the center of the node
29
+ r2: <%=r2%> // end circle radius at the center of the node
30
+ });
31
+
32
+ });
33
+
34
+ };
35
+
36
+
37
+ if (typeof YUI == 'undefined') {
38
+ loadYui(pinch);
39
+ } else {
40
+ pinch();
41
+ };
@@ -0,0 +1,41 @@
1
+
2
+ var element_locator = arguments[0];
3
+
4
+ function loadYui(callback) {
5
+ // Adding the script tag to the head as suggested before
6
+ var head = document.getElementsByTagName('head')[0];
7
+ var script = document.createElement('script');
8
+ script.type = 'text/javascript';
9
+ script.src = "http://yui.yahooapis.com/3.17.2/build/yui/yui-min.js";
10
+
11
+ // Then bind the event to the callback function.
12
+ // There are several events for cross browser compatibility.
13
+ script.onreadystatechange = callback;
14
+ script.onload = callback;
15
+
16
+ // Fire the loading
17
+ head.appendChild(script);
18
+ }
19
+
20
+ var press = function() {
21
+
22
+ YUI().use('node-event-simulate', function(Y) {
23
+
24
+ var node = Y.one(element_locator);
25
+
26
+ node.simulateGesture("press", {
27
+ hold: <%=hold%>
28
+ });
29
+
30
+ });
31
+
32
+ };
33
+
34
+
35
+ if (typeof YUI == 'undefined') {
36
+ loadYui(press);
37
+ } else {
38
+ press();
39
+ };
40
+
41
+
@@ -0,0 +1,39 @@
1
+
2
+ var element_locator = arguments[0];
3
+
4
+ function loadYui(callback) {
5
+ // Adding the script tag to the head as suggested before
6
+ var head = document.getElementsByTagName('head')[0];
7
+ var script = document.createElement('script');
8
+ script.type = 'text/javascript';
9
+ script.src = "http://yui.yahooapis.com/3.17.2/build/yui/yui-min.js";
10
+
11
+ // Then bind the event to the callback function.
12
+ // There are several events for cross browser compatibility.
13
+ script.onreadystatechange = callback;
14
+ script.onload = callback;
15
+
16
+ // Fire the loading
17
+ head.appendChild(script);
18
+ }
19
+
20
+ var rotate = function() {
21
+
22
+ YUI().use('node-event-simulate', function(Y) {
23
+
24
+ var node = Y.one(element_locator);
25
+
26
+ node.simulateGesture("rotate", {
27
+ rotation: <%=rotation%>
28
+ });
29
+
30
+ });
31
+
32
+ };
33
+
34
+
35
+ if (typeof YUI == 'undefined') {
36
+ loadYui(rotate);
37
+ } else {
38
+ rotate();
39
+ };
@@ -0,0 +1,40 @@
1
+
2
+ var element_locator = arguments[0];
3
+
4
+ function loadYui(callback) {
5
+ // Adding the script tag to the head as suggested before
6
+ var head = document.getElementsByTagName('head')[0];
7
+ var script = document.createElement('script');
8
+ script.type = 'text/javascript';
9
+ script.src = "http://yui.yahooapis.com/3.17.2/build/yui/yui-min.js";
10
+
11
+ // Then bind the event to the callback function.
12
+ // There are several events for cross browser compatibility.
13
+ script.onreadystatechange = callback;
14
+ script.onload = callback;
15
+
16
+ // Fire the loading
17
+ head.appendChild(script);
18
+ }
19
+
20
+ var tap = function() {
21
+
22
+ YUI().use('node-event-simulate', function(Y) {
23
+
24
+ var node = Y.one(element_locator);
25
+
26
+ node.simulateGesture("tap");
27
+
28
+ });
29
+
30
+ };
31
+
32
+
33
+
34
+ if (typeof YUI == 'undefined') {
35
+ loadYui(tap);
36
+ } else {
37
+ tap();
38
+ };
39
+
40
+
@@ -0,0 +1,3 @@
1
+ module TouchAction
2
+ VERSION = "0.0.1alpha"
3
+ end
@@ -0,0 +1,67 @@
1
+ require 'erb'
2
+ require 'ostruct'
3
+ require "touch_action/version"
4
+ require 'watir-webdriver'
5
+
6
+ module TouchAction
7
+
8
+ def touch_action action, options = {}
9
+ browser.execute_script( send(action.to_s + '_script', options), self )
10
+ end
11
+
12
+ def flick_script options = {}
13
+ default_options = {axis: 'x', distance: -100, duration: 50}
14
+ default_options.merge! options
15
+ flick = File.read(File.expand_path("../touch_action/javascripts/flick.js.erb", __FILE__))
16
+ render_erb(flick, default_options)
17
+ end
18
+
19
+ def pinch_script options = {}
20
+ default_options = {r1: 50, r2: 100}
21
+ default_options.merge! options
22
+ pinch = File.read(File.expand_path("../touch_action/javascripts/pinch.js.erb", __FILE__))
23
+ render_erb(pinch_file.read, default_options)
24
+ end
25
+
26
+ def tap_script
27
+ tap = File.read(File.expand_path("../touch_action/javascripts/tap.js.erb", __FILE__))
28
+ render_erb tap
29
+ end
30
+
31
+ def doubletap_script
32
+ doubletap = File.read(File.expand_path("../touch_action/javascripts/doubletap.js.erb", __FILE__))
33
+ render_erb doubletap
34
+ end
35
+
36
+ def press_script options = {}
37
+ default_options = {hold: 2000}
38
+ default_options.merge! options
39
+ press = File.read(File.expand_path("../touch_action/javascripts/press.js.erb", __FILE__))
40
+ render_erb(press, default_options)
41
+ end
42
+
43
+ def move_script options = {}
44
+ default_options = {xdist: 70, ydist: -50, duration: 2000}
45
+ default_options.merge! options
46
+ move = File.read(File.expand_path("../touch_action/javascripts/move.js.erb", __FILE__))
47
+ render_erb(move, default_options)
48
+ end
49
+
50
+ def rotate_script options = {}
51
+ default_options = {rotation: -75}
52
+ default_options.merge! options
53
+ rotate = File.read(File.expand_path("../touch_action/javascripts/rotate.js.erb", __FILE__))
54
+ render_erb(rotate, default_options)
55
+ end
56
+
57
+ alias_method :swipe_script, :flick_script
58
+
59
+ private
60
+
61
+ def render_erb template, vars = {}
62
+ ERB.new(template).result(OpenStruct.new(vars).instance_eval { binding })
63
+ end
64
+
65
+ end
66
+
67
+ Watir::Element.class_eval { include TouchAction }
@@ -0,0 +1,26 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'touch_action/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "touch_action"
8
+ spec.version = TouchAction::VERSION
9
+ spec.authors = ["Ricardo Nacif"]
10
+ spec.email = ["nacif.ricardo@gmail.com"]
11
+ spec.summary = "Adds touch gestures to Watir and Selenium using YUI JS."
12
+ spec.description = "Adds touch gestures to Watir and Selenium using YUI JS."
13
+ spec.homepage = ""
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_runtime_dependency "watir-webdriver"
22
+
23
+ spec.add_development_dependency "bundler", "~> 1.7"
24
+ spec.add_development_dependency "rake", "~> 10.0"
25
+ spec.add_development_dependency "pry"
26
+ end
metadata ADDED
@@ -0,0 +1,121 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: touch_action
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1alpha
5
+ platform: ruby
6
+ authors:
7
+ - Ricardo Nacif
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-10-03 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: watir-webdriver
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.7'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.7'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '10.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '10.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: pry
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ description: Adds touch gestures to Watir and Selenium using YUI JS.
70
+ email:
71
+ - nacif.ricardo@gmail.com
72
+ executables: []
73
+ extensions: []
74
+ extra_rdoc_files: []
75
+ files:
76
+ - ".DS_Store"
77
+ - ".gitignore"
78
+ - CHANGELOG.md
79
+ - Gemfile
80
+ - LICENSE.txt
81
+ - MIT-LICENSE
82
+ - README.md
83
+ - Rakefile
84
+ - lib/.DS_Store
85
+ - lib/touch_action.rb
86
+ - lib/touch_action/.DS_Store
87
+ - lib/touch_action/javascripts/.DS_Store
88
+ - lib/touch_action/javascripts/doubletap.js.erb
89
+ - lib/touch_action/javascripts/flick.js.erb
90
+ - lib/touch_action/javascripts/move.js.erb
91
+ - lib/touch_action/javascripts/pinch.js.erb
92
+ - lib/touch_action/javascripts/press.js.erb
93
+ - lib/touch_action/javascripts/rotate.js.erb
94
+ - lib/touch_action/javascripts/tap.js.erb
95
+ - lib/touch_action/version.rb
96
+ - touch_action.gemspec
97
+ homepage: ''
98
+ licenses:
99
+ - MIT
100
+ metadata: {}
101
+ post_install_message:
102
+ rdoc_options: []
103
+ require_paths:
104
+ - lib
105
+ required_ruby_version: !ruby/object:Gem::Requirement
106
+ requirements:
107
+ - - ">="
108
+ - !ruby/object:Gem::Version
109
+ version: '0'
110
+ required_rubygems_version: !ruby/object:Gem::Requirement
111
+ requirements:
112
+ - - ">"
113
+ - !ruby/object:Gem::Version
114
+ version: 1.3.1
115
+ requirements: []
116
+ rubyforge_project:
117
+ rubygems_version: 2.2.2
118
+ signing_key:
119
+ specification_version: 4
120
+ summary: Adds touch gestures to Watir and Selenium using YUI JS.
121
+ test_files: []