skeleton-ui 0.1.11 → 0.1.12
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/skeleton.rb +3 -1
- data/lib/skeleton/base.rb +1 -1
- data/lib/skeleton/ios.rb +29 -14
- data/lib/skeleton/languages.rb +109 -2
- data/lib/skeleton/version.rb +1 -1
- data/server/server.rb +6 -2
- data/server/skeleton.html +1 -0
- data/server/template.html.erb +4 -4
- 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: 070fce0dd13ee0154db462655d7f86b119ed77e75c0f0810de14ca407802643d
|
4
|
+
data.tar.gz: 937d99a22bed5cca8fcda3346f06cdd93dfcf0b81c10f32666a9f54f32ae960d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 48a760cd677ff3c90110d490a9984f67f10c2bca83c2b8860384c4c9a33c300ad7c500ac8e45bae6e569eaaf814bca06f4c960c88f7e0fa43fa1ebc157233459
|
7
|
+
data.tar.gz: 0dcf69c1ee743eea168c6223537304823ea2f9502d6e30f6e9c20be851edbd9c042ab15a081c1c1bdbce8f00f67de54f08b75d1e53cc2ed33ad4ec7c26d100bf
|
data/lib/skeleton.rb
CHANGED
@@ -39,7 +39,9 @@ module Skeleton
|
|
39
39
|
|
40
40
|
def fill_html
|
41
41
|
language = Language.new
|
42
|
-
%w[ruby java python javascript]
|
42
|
+
languages = %w[ruby java python javascript]
|
43
|
+
languages += %w[swift] if ios?
|
44
|
+
languages.each do |lang|
|
43
45
|
attach_image
|
44
46
|
type = language.type(lang)
|
45
47
|
folder = Base::PAGE_OBJECTS_FOLDER
|
data/lib/skeleton/base.rb
CHANGED
@@ -5,7 +5,6 @@ class Base
|
|
5
5
|
|
6
6
|
def precondition
|
7
7
|
clear
|
8
|
-
FileUtils.rm_rf("#{ROOT_DIR}/server/screenshot.png")
|
9
8
|
FileUtils.mkdir_p(PAGE_OBJECTS_FOLDER)
|
10
9
|
FileUtils.mkdir_p(ATTACHMENTS_FOLDER)
|
11
10
|
rescue
|
@@ -21,6 +20,7 @@ class Base
|
|
21
20
|
def clear
|
22
21
|
FileUtils.rm_rf(PAGE_OBJECTS_FOLDER)
|
23
22
|
FileUtils.rm_rf(ATTACHMENTS_FOLDER)
|
23
|
+
FileUtils.rm_rf("#{ROOT_DIR}/server/screenshot.png")
|
24
24
|
end
|
25
25
|
|
26
26
|
protected
|
data/lib/skeleton/ios.rb
CHANGED
@@ -49,27 +49,30 @@ class IOS < Base
|
|
49
49
|
def create_locator(line)
|
50
50
|
locator_by_id = locator_by_id(line)
|
51
51
|
locator_by_label = locator_by_label(line)
|
52
|
+
type = element_type(line)
|
52
53
|
if !locator_by_id.empty?
|
53
|
-
create_locator_by_id(locator_by_id)
|
54
|
+
create_locator_by_id(locator_by_id, type)
|
54
55
|
elsif !locator_by_label.empty?
|
55
|
-
type = element_type(line)
|
56
56
|
create_locator_by_label(locator_by_label, type)
|
57
57
|
end
|
58
58
|
end
|
59
59
|
|
60
|
-
def create_locator_by_id(locator)
|
60
|
+
def create_locator_by_id(locator, type)
|
61
61
|
method_name = locator.strip
|
62
|
+
locator_hash = { locator => type }
|
62
63
|
code_generation(method_name: method_name,
|
63
64
|
locator_type: ACC_ID,
|
64
|
-
locator_value:
|
65
|
+
locator_value: locator_hash,
|
66
|
+
accessibility_id: true)
|
65
67
|
end
|
66
68
|
|
67
69
|
def create_locator_by_label(text, type)
|
68
70
|
method_name = "#{type}#{increment_locator_id}"
|
69
71
|
locator = "#{LABEL} LIKE '#{text}'"
|
72
|
+
locator_hash = { locator => type }
|
70
73
|
code_generation(method_name: method_name,
|
71
74
|
locator_type: NSPREDICATE,
|
72
|
-
locator_value:
|
75
|
+
locator_value: locator_hash)
|
73
76
|
end
|
74
77
|
|
75
78
|
def create_page_objects
|
@@ -110,23 +113,35 @@ class IOS < Base
|
|
110
113
|
end
|
111
114
|
end
|
112
115
|
|
113
|
-
def code_generation(method_name:,
|
114
|
-
|
116
|
+
def code_generation(method_name:,
|
117
|
+
locator_type:,
|
118
|
+
locator_value:,
|
119
|
+
accessibility_id: false)
|
120
|
+
method_name = "_#{method_name}" if method_name[0] =~ /\d+/
|
121
|
+
snake_style = snake_style(method_name)
|
122
|
+
camel_style = camel_style(method_name)
|
123
|
+
java = @language.java(camel_method_name: camel_style,
|
115
124
|
locator_type: locator_type,
|
116
|
-
locator_value: locator_value)
|
117
|
-
ruby = @language.ruby(snake_method_name: snake_style
|
125
|
+
locator_value: locator_value.keys.first)
|
126
|
+
ruby = @language.ruby(snake_method_name: snake_style,
|
118
127
|
locator_type: locator_type,
|
119
|
-
locator_value: locator_value)
|
120
|
-
python = @language.python(snake_method_name: snake_style
|
128
|
+
locator_value: locator_value.keys.first)
|
129
|
+
python = @language.python(snake_method_name: snake_style,
|
121
130
|
locator_type: locator_type,
|
122
|
-
locator_value: locator_value)
|
123
|
-
js = @language.js(camel_method_name: camel_style
|
131
|
+
locator_value: locator_value.keys.first)
|
132
|
+
js = @language.js(camel_method_name: camel_style,
|
124
133
|
locator_type: locator_type,
|
125
|
-
locator_value: locator_value)
|
134
|
+
locator_value: locator_value.keys.first)
|
135
|
+
xcui_element_type = XCUIElement.types[locator_value.values.first.to_sym]
|
136
|
+
swift = @language.swift(camel_method_name: camel_style,
|
137
|
+
element_type: xcui_element_type,
|
138
|
+
locator_value: locator_value.keys.first,
|
139
|
+
accessibility_id: accessibility_id)
|
126
140
|
save(code: java, format: Language::JAVA)
|
127
141
|
save(code: ruby, format: Language::RUBY)
|
128
142
|
save(code: python, format: Language::PYTHON)
|
129
143
|
save(code: js, format: Language::JAVASCRIPT)
|
144
|
+
save(code: swift, format: Language::SWIFT)
|
130
145
|
end
|
131
146
|
|
132
147
|
def page_source
|
data/lib/skeleton/languages.rb
CHANGED
@@ -3,6 +3,7 @@ class Language
|
|
3
3
|
RUBY = 'rb'.freeze
|
4
4
|
PYTHON = 'py'.freeze
|
5
5
|
JAVASCRIPT = 'js'.freeze
|
6
|
+
SWIFT = 'swift'.freeze
|
6
7
|
|
7
8
|
def java(camel_method_name:, locator_type:, locator_value:)
|
8
9
|
<<~JAVA
|
@@ -20,18 +21,34 @@ class Language
|
|
20
21
|
|
21
22
|
def python(snake_method_name:, locator_type:, locator_value:)
|
22
23
|
<<~PYTHON
|
23
|
-
#{snake_method_name} = driver.#{locator_type[:python]}("#{locator_value})"
|
24
|
+
#{snake_method_name} = self.driver.#{locator_type[:python]}("#{locator_value})"
|
24
25
|
|
25
26
|
PYTHON
|
26
27
|
end
|
27
28
|
|
28
29
|
def js(camel_method_name:, locator_type:, locator_value:)
|
29
30
|
<<~JS
|
30
|
-
#{camel_method_name} = driver.elements("#{locator_type[:javascript]}", "#{locator_value}");
|
31
|
+
let #{camel_method_name} = await driver.elements("#{locator_type[:javascript]}", "#{locator_value}");
|
31
32
|
|
32
33
|
JS
|
33
34
|
end
|
34
35
|
|
36
|
+
def swift(camel_method_name:, element_type:, locator_value:, accessibility_id:)
|
37
|
+
if accessibility_id
|
38
|
+
<<~SWIFT
|
39
|
+
let #{camel_method_name} = app.#{element_type}["#{locator_value}"]
|
40
|
+
|
41
|
+
SWIFT
|
42
|
+
else
|
43
|
+
<<~SWIFT
|
44
|
+
let #{camel_method_name} = app.#{element_type}.matching(
|
45
|
+
NSPredicate(format: #{locator_value})
|
46
|
+
).element
|
47
|
+
|
48
|
+
SWIFT
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
35
52
|
def type(format)
|
36
53
|
case format
|
37
54
|
when 'ruby', 'rb'
|
@@ -42,8 +59,98 @@ class Language
|
|
42
59
|
JAVASCRIPT
|
43
60
|
when 'python', 'py'
|
44
61
|
PYTHON
|
62
|
+
when 'swift'
|
63
|
+
SWIFT
|
45
64
|
else
|
46
65
|
"I haven't this language format"
|
47
66
|
end
|
48
67
|
end
|
68
|
+
end
|
69
|
+
|
70
|
+
class XCUIElement
|
71
|
+
def self.types
|
72
|
+
return {
|
73
|
+
Other: "otherElements",
|
74
|
+
Group: "groups",
|
75
|
+
Window: "windows",
|
76
|
+
Sheet: "sheets",
|
77
|
+
Drawer: "drawers",
|
78
|
+
Alert: "alerts",
|
79
|
+
Dialog: "dialogs",
|
80
|
+
Button: "buttons",
|
81
|
+
RadioButton: "radioButtons",
|
82
|
+
RadioGroup: "radioGroups",
|
83
|
+
CheckBox: "checkBoxes",
|
84
|
+
DisclosureTriangle: "disclosureTriangles",
|
85
|
+
PopUpButton: "popUpButtons",
|
86
|
+
ComboBox: "comboBoxes",
|
87
|
+
MenuButton: "menuButtons",
|
88
|
+
ToolbarButton: "toolbarButtons",
|
89
|
+
Popover: "popovers",
|
90
|
+
Keyboard: "keyboards",
|
91
|
+
Key: "keys",
|
92
|
+
NavigationBar: "navigationBars",
|
93
|
+
TabBar: "tabBars",
|
94
|
+
TabGroup: "tabGroups",
|
95
|
+
Toolbar: "toolbars",
|
96
|
+
StatusBar: "statusBars",
|
97
|
+
Table: "tables",
|
98
|
+
TableRow: "tableRows",
|
99
|
+
TableColumn: "tableColumns",
|
100
|
+
Outline: "outlines",
|
101
|
+
OutlineRow: "outlineRows",
|
102
|
+
Browser: "browsers",
|
103
|
+
CollectionView: "collectionViews",
|
104
|
+
Slider: "sliders",
|
105
|
+
PageIndicator: "pageIndicators",
|
106
|
+
ProgressIndicator: "progressIndicators",
|
107
|
+
ActivityIndicator: "activityIndicators",
|
108
|
+
SegmentedControl: "segmentedControls",
|
109
|
+
Picker: "pickers",
|
110
|
+
PickerWheel: "pickerWheels",
|
111
|
+
Switch: "switches",
|
112
|
+
Toggle: "toggles",
|
113
|
+
Link: "links",
|
114
|
+
Image: "images",
|
115
|
+
Icon: "icons",
|
116
|
+
SearchField: "searchFields",
|
117
|
+
ScrollView: "scrollViews",
|
118
|
+
ScrollBar: "scrollBars",
|
119
|
+
StaticText: "staticTexts",
|
120
|
+
TextField: "textFields",
|
121
|
+
SecureTextField: "secureTextFields",
|
122
|
+
DatePicker: "datePickers",
|
123
|
+
TextView: "textViews",
|
124
|
+
Menu: "menus",
|
125
|
+
MenuItem: "menuItems",
|
126
|
+
MenuBar: "menuBars",
|
127
|
+
MenuBarItem: "menuBarItems",
|
128
|
+
Map: "maps",
|
129
|
+
WebView: "webViews",
|
130
|
+
IncrementArrow: "incrementArrows",
|
131
|
+
DecrementArrow: "decrementArrows",
|
132
|
+
Timeline: "timelines",
|
133
|
+
RatingIndicator: "ratingIndicators",
|
134
|
+
ValueIndicator: "valueIndicators",
|
135
|
+
SplitGroup: "splitGroups",
|
136
|
+
Splitter: "splitters",
|
137
|
+
RelevanceIndicator: "relevanceIndicators",
|
138
|
+
ColorWell: "colorWells",
|
139
|
+
HelpTag: "helpTags",
|
140
|
+
Matte: "mattes",
|
141
|
+
DockItem: "dockItems",
|
142
|
+
Ruler: "rulers",
|
143
|
+
RulerMarker: "rulerMarkers",
|
144
|
+
Grid: "grids",
|
145
|
+
LevelIndicator: "levelIndicators",
|
146
|
+
Cell: "cells",
|
147
|
+
LayoutArea: "layoutAreas",
|
148
|
+
LayoutItem: "layoutItems",
|
149
|
+
Handle: "handles",
|
150
|
+
Stepper: "steppers",
|
151
|
+
Tab: "tabs",
|
152
|
+
TouchBar: "touchBars",
|
153
|
+
StatusItem: "statusItems"
|
154
|
+
}
|
155
|
+
end
|
49
156
|
end
|
data/lib/skeleton/version.rb
CHANGED
data/server/server.rb
CHANGED
@@ -6,8 +6,12 @@ set :port, server_port
|
|
6
6
|
|
7
7
|
File.open("#{Base::ROOT_DIR}/server/port", 'w+') { |f| f.write(server_port) }
|
8
8
|
|
9
|
+
not_found do
|
10
|
+
redirect 'skeleton'
|
11
|
+
end
|
12
|
+
|
9
13
|
get '/' do
|
10
|
-
redirect
|
14
|
+
redirect 'skeleton'
|
11
15
|
end
|
12
16
|
|
13
17
|
get '/:file' do
|
@@ -20,4 +24,4 @@ post '/:file' do
|
|
20
24
|
domain = params[:file].split('.').last
|
21
25
|
file = domain == params[:file] ? "#{domain}.html" : params[:file]
|
22
26
|
send_file "#{Base::ROOT_DIR}/server/#{file}"
|
23
|
-
end
|
27
|
+
end
|
data/server/skeleton.html
CHANGED
data/server/template.html.erb
CHANGED
@@ -13,15 +13,15 @@
|
|
13
13
|
<div class="py-5 text-center">
|
14
14
|
<h2>Skeleton</h2>
|
15
15
|
</div>
|
16
|
-
<div class="row" style="min-height:
|
16
|
+
<div class="row" style="min-height: 666px;">
|
17
17
|
<div class="col-md-4 mb-4">
|
18
|
-
<div class="aside"
|
19
|
-
<div class="aside__img" style="background-image: url(screenshot.png); outline: 1px solid gray;"></div>
|
18
|
+
<div class="aside">
|
19
|
+
<div class="aside__img" style="width:100%; height:100%; background-image: url(screenshot.png); outline: 1px solid gray;"></div>
|
20
20
|
</div>
|
21
21
|
</div>
|
22
22
|
<div class="col-md-8">
|
23
23
|
<h4 class="mb-3">Screen Objects:</h4>
|
24
|
-
<div class="content" id="content" style="max-height:
|
24
|
+
<div class="content" id="content" style="max-height: 666px; overflow-y: auto;">
|
25
25
|
<pre><code><%= @screen_objects %></code></pre>
|
26
26
|
</div>
|
27
27
|
</div>
|
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.1.
|
4
|
+
version: 0.1.12
|
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-08-
|
11
|
+
date: 2018-08-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|