skeleton-ui 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +2 -4
- data/lib/skeleton/android.rb +14 -12
- data/lib/skeleton/base.rb +1 -18
- data/lib/skeleton/languages.rb +18 -0
- data/lib/skeleton/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b1b6b686064be02b7c71259fe6a6c027c67d22ef4ac3aa3e7cda5c87afc09943
|
4
|
+
data.tar.gz: a3b5cb8fdc94d7631dcf0c66a4ceff2607bf4ad753ede0492c98d8d41fe4a9c0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ddc95d6c494fcbb9237bcdd70725f6340a2b31dc01baf5356ed2e232c7612f0553bd65695e90d70d11269f56d23233b93bb05858503945f0a3d15e4423357944
|
7
|
+
data.tar.gz: 872b9f5c315da8e087b632a835b55df717cf38db55251f3c04a9f435b7ae2f00e6479da4d94838af82a3189abb728d08f746d2e1a895e54944df6052b666b8b8
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -17,13 +17,11 @@ Prerequisites:
|
|
17
17
|
|
18
18
|
Installation:
|
19
19
|
------
|
20
|
-
$
|
21
|
-
$ gem install bundler
|
22
|
-
$ cd skeleton && bundle install
|
20
|
+
$ gem install skeleton-ui
|
23
21
|
|
24
22
|
Usage:
|
25
23
|
------
|
26
|
-
$
|
24
|
+
$ skeleton -h
|
27
25
|
|
28
26
|
## License
|
29
27
|
|
data/lib/skeleton/android.rb
CHANGED
@@ -1,15 +1,9 @@
|
|
1
1
|
class Android < Base
|
2
|
-
RESOURCE_ID =
|
3
|
-
|
4
|
-
ruby: 'resource-id'
|
5
|
-
}
|
6
|
-
CONTENT_DESC = {
|
7
|
-
java: 'content-desc',
|
8
|
-
ruby: 'content-desc'
|
9
|
-
}
|
2
|
+
RESOURCE_ID = 'resource-id'
|
3
|
+
CONTENT_DESC = 'content-desc'
|
10
4
|
TEXT = 'text'
|
11
|
-
ID =
|
12
|
-
XPATH =
|
5
|
+
ID = { java: :id }
|
6
|
+
XPATH = { java: :xpath }
|
13
7
|
CLASS = 'class'
|
14
8
|
|
15
9
|
attr_accessor :platform, :udid, :bundle_id, :ios_sim
|
@@ -20,9 +14,11 @@ class Android < Base
|
|
20
14
|
end
|
21
15
|
|
22
16
|
def skeletoner
|
17
|
+
log.info('We starting to skeleton your screen 🚀')
|
23
18
|
create_page_objects
|
24
19
|
save_screenshot
|
25
20
|
save(page_source)
|
21
|
+
log.info('We successfully skeletoned your screen 👻')
|
26
22
|
end
|
27
23
|
|
28
24
|
private
|
@@ -58,6 +54,7 @@ class Android < Base
|
|
58
54
|
end
|
59
55
|
|
60
56
|
def create_page_objects
|
57
|
+
log.info('Generation page objects for your awesome language 💪')
|
61
58
|
page_source_html = Nokogiri::HTML.parse(page_source)
|
62
59
|
page_source_html.css('node').each { |line| create_locator(line) }
|
63
60
|
end
|
@@ -65,8 +62,6 @@ class Android < Base
|
|
65
62
|
def code_generation(method_name, locator_type, value)
|
66
63
|
java = java(method_name, locator_type, value)
|
67
64
|
save(java, format: Language::JAVA)
|
68
|
-
|
69
|
-
# ADD OTHER LANGUAGES HERE
|
70
65
|
end
|
71
66
|
|
72
67
|
def save(code, format: 'xml')
|
@@ -76,13 +71,20 @@ class Android < Base
|
|
76
71
|
|
77
72
|
def page_source
|
78
73
|
unless @page_source
|
74
|
+
log.info('Getting screen source tree ⚒')
|
79
75
|
dump = `adb -s #{@udid} shell uiautomator dump | egrep -o '/.*?xml'`
|
80
76
|
@page_source = `adb -s #{@udid} shell cat #{dump}`
|
77
|
+
if @page_source.empty?
|
78
|
+
log.fatal('Something went wrong.') # FIXME
|
79
|
+
Process.exit(1)
|
80
|
+
end
|
81
|
+
log.info('Successfully getting Screen Source Tree 🔥')
|
81
82
|
end
|
82
83
|
@page_source
|
83
84
|
end
|
84
85
|
|
85
86
|
def save_screenshot
|
87
|
+
log.info('Saving screenshot 📷')
|
86
88
|
file_name = "#{@platform}_#{TIMESTAMP}.png"
|
87
89
|
`adb -s #{@udid} shell screencap -p /sdcard/#{file_name}`
|
88
90
|
`adb -s #{@udid} pull /sdcard/#{file_name} #{ATTACHMENTS_FOLDER}/`
|
data/lib/skeleton/base.rb
CHANGED
@@ -3,6 +3,7 @@ require_relative 'languages.rb'
|
|
3
3
|
class Base
|
4
4
|
include Language
|
5
5
|
|
6
|
+
# ROOT_DIR_FOR_DEBUG = File.expand_path('..', Dir.pwd)
|
6
7
|
ROOT_DIR = "#{`gem environment gemdir`.strip}" \
|
7
8
|
"/gems/skeleton-ui-#{Skeleton::VERSION}"
|
8
9
|
PAGE_OBJECTS_FOLDER = "#{ROOT_DIR}/PageObjects"
|
@@ -69,24 +70,6 @@ class Base
|
|
69
70
|
@locator_index = @locator_index.nil? ? 1 : @locator_index + 1
|
70
71
|
end
|
71
72
|
|
72
|
-
def java(method_name, locator_type, value)
|
73
|
-
<<~JAVA
|
74
|
-
By #{camel_style(method_name)}() {
|
75
|
-
return MobileBy.#{locator_type[:java]}("#{value}");
|
76
|
-
}
|
77
|
-
|
78
|
-
JAVA
|
79
|
-
end
|
80
|
-
|
81
|
-
def ruby(method_name, locator_type, value)
|
82
|
-
<<~RUBY
|
83
|
-
def #{snake_style(method_name)}
|
84
|
-
return :#{locator_type[:ruby]}, "#{value}"
|
85
|
-
end
|
86
|
-
|
87
|
-
RUBY
|
88
|
-
end
|
89
|
-
|
90
73
|
def screenshot
|
91
74
|
end
|
92
75
|
|
data/lib/skeleton/languages.rb
CHANGED
@@ -2,4 +2,22 @@ module Language
|
|
2
2
|
JAVA = 'java'
|
3
3
|
RUBY = 'rb'
|
4
4
|
PYTHON = 'py'
|
5
|
+
|
6
|
+
def java(method_name, locator_type, value)
|
7
|
+
<<~JAVA
|
8
|
+
By #{camel_style(method_name)}() {
|
9
|
+
return MobileBy.#{locator_type[:java]}("#{value}");
|
10
|
+
}
|
11
|
+
|
12
|
+
JAVA
|
13
|
+
end
|
14
|
+
|
15
|
+
def ruby(method_name, locator_type, value)
|
16
|
+
<<~RUBY
|
17
|
+
def #{snake_style(method_name)}
|
18
|
+
return :#{locator_type[:ruby]}, "#{value}"
|
19
|
+
end
|
20
|
+
|
21
|
+
RUBY
|
22
|
+
end
|
5
23
|
end
|
data/lib/skeleton/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: skeleton-ui
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- a.alterpesotskiy
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-03-
|
11
|
+
date: 2018-03-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|