skeleton-ui 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: b0eafc40c32b9e41f9bc72d7ee34a4cccfa079d4f1ce26c2e0b3d71029f1071f
4
+ data.tar.gz: 17ccda940c71c289d6d1a7d84e6ce0fa455967f3a55f5c4a3dca0f01d71059ca
5
+ SHA512:
6
+ metadata.gz: 53ba9ca28c4747f6beb058271737122a30badeac37bb29166daea620457218ad3c4064db9c7f3040e82152230cd10c9ffc39346f969470cf00e34da14881a8aa
7
+ data.tar.gz: 6ada05132319443502cf72a80d3ee4e6ca9cf2c724fecbc770f1e7e307a88280ed17e7d62db8e45ec6cbc1cfae69eede274a2dbf9aa1e0c7212bc97d96a332e2
data/.gitignore ADDED
@@ -0,0 +1,7 @@
1
+ .DS_Store
2
+ *.xcodeproj
3
+ *.xcworkspace
4
+ /PageObjects/
5
+ /attach/
6
+ /Attachments/
7
+ /XCResults/
@@ -0,0 +1,74 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to making participation in our project and
7
+ our community a harassment-free experience for everyone, regardless of age, body
8
+ size, disability, ethnicity, gender identity and expression, level of experience,
9
+ nationality, personal appearance, race, religion, or sexual identity and
10
+ orientation.
11
+
12
+ ## Our Standards
13
+
14
+ Examples of behavior that contributes to creating a positive environment
15
+ include:
16
+
17
+ * Using welcoming and inclusive language
18
+ * Being respectful of differing viewpoints and experiences
19
+ * Gracefully accepting constructive criticism
20
+ * Focusing on what is best for the community
21
+ * Showing empathy towards other community members
22
+
23
+ Examples of unacceptable behavior by participants include:
24
+
25
+ * The use of sexualized language or imagery and unwelcome sexual attention or
26
+ advances
27
+ * Trolling, insulting/derogatory comments, and personal or political attacks
28
+ * Public or private harassment
29
+ * Publishing others' private information, such as a physical or electronic
30
+ address, without explicit permission
31
+ * Other conduct which could reasonably be considered inappropriate in a
32
+ professional setting
33
+
34
+ ## Our Responsibilities
35
+
36
+ Project maintainers are responsible for clarifying the standards of acceptable
37
+ behavior and are expected to take appropriate and fair corrective action in
38
+ response to any instances of unacceptable behavior.
39
+
40
+ Project maintainers have the right and responsibility to remove, edit, or
41
+ reject comments, commits, code, wiki edits, issues, and other contributions
42
+ that are not aligned to this Code of Conduct, or to ban temporarily or
43
+ permanently any contributor for other behaviors that they deem inappropriate,
44
+ threatening, offensive, or harmful.
45
+
46
+ ## Scope
47
+
48
+ This Code of Conduct applies both within project spaces and in public spaces
49
+ when an individual is representing the project or its community. Examples of
50
+ representing a project or community include using an official project e-mail
51
+ address, posting via an official social media account, or acting as an appointed
52
+ representative at an online or offline event. Representation of a project may be
53
+ further defined and clarified by project maintainers.
54
+
55
+ ## Enforcement
56
+
57
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
+ reported by contacting the project team at a.alterpesotskiy@corp.mail.ru. All
59
+ complaints will be reviewed and investigated and will result in a response that
60
+ is deemed necessary and appropriate to the circumstances. The project team is
61
+ obligated to maintain confidentiality with regard to the reporter of an incident.
62
+ Further details of specific enforcement policies may be posted separately.
63
+
64
+ Project maintainers who do not follow or enforce the Code of Conduct in good
65
+ faith may face temporary or permanent repercussions as determined by other
66
+ members of the project's leadership.
67
+
68
+ ## Attribution
69
+
70
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
+ available at [http://contributor-covenant.org/version/1/4][version]
72
+
73
+ [homepage]: http://contributor-covenant.org
74
+ [version]: http://contributor-covenant.org/version/1/4/
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source "https://rubygems.org"
2
+
3
+ git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
4
+
5
+ # Specify your gem's dependencies in skeleton.gemspec
6
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,28 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ skeleton (0.0.1)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ colorize (0.8.1)
10
+ fileutils (1.0.2)
11
+ mini_portile2 (2.3.0)
12
+ nokogiri (1.8.2)
13
+ mini_portile2 (~> 2.3.0)
14
+ rake (12.3.0)
15
+
16
+ PLATFORMS
17
+ ruby
18
+
19
+ DEPENDENCIES
20
+ bundler (~> 1.16)
21
+ colorize (~> 0.8.1)
22
+ fileutils
23
+ nokogiri (~> 1.8.2)
24
+ rake (~> 12.3.0)
25
+ skeleton!
26
+
27
+ BUNDLED WITH
28
+ 1.16.1
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2018 forqa
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,32 @@
1
+ # skeleton
2
+ CLI for fast generating multi language page objects from iOS and Android screens.
3
+
4
+
5
+ Prerequisites:
6
+ --------
7
+
8
+ #### Android
9
+ - Install [SDK Tools](http://developer.android.com/sdk/installing/index.html?pkg=tools).
10
+ - SDK tools are added to your $PATH. [OSX](https://stackoverflow.com/posts/19764254/revisions)
11
+ - Enable [USB Debugging](https://www.kingoapp.com/root-tutorials/how-to-enable-usb-debugging-mode-on-android.htm) on your device(s).
12
+
13
+ #### iOS
14
+ - Install [Xcode](https://developer.apple.com/xcode/download/).
15
+ - Install [Xcode Command Line Tools](http://railsapps.github.io/xcode-command-line-tools.html).
16
+ - For real devices you need to sign skeleton in xcodeproj ([like appium](https://github.com/appium/appium-xcuitest-driver/blob/master/docs/real-device-config.md)).
17
+
18
+ Installation:
19
+ ------
20
+ $ git clone https://github.com/forqa/skeleton.git
21
+ $ gem install bundler
22
+ $ cd skeleton && bundle install
23
+
24
+ Usage:
25
+ ------
26
+ $ ruby skeleton.rb -h
27
+
28
+ ## License
29
+
30
+ A tool is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
31
+
32
+
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+ task :default => :spec
@@ -0,0 +1,46 @@
1
+ //
2
+ // AppDelegate.swift
3
+ // Skeleton
4
+ //
5
+ // Created by a.alterpesotskiy on 12/03/2018.
6
+ // Copyright © 2018 forqa. All rights reserved.
7
+ //
8
+
9
+ import UIKit
10
+
11
+ @UIApplicationMain
12
+ class AppDelegate: UIResponder, UIApplicationDelegate {
13
+
14
+ var window: UIWindow?
15
+
16
+
17
+ func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
18
+ // Override point for customization after application launch.
19
+ return true
20
+ }
21
+
22
+ func applicationWillResignActive(_ application: UIApplication) {
23
+ // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
24
+ // Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game.
25
+ }
26
+
27
+ func applicationDidEnterBackground(_ application: UIApplication) {
28
+ // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
29
+ // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
30
+ }
31
+
32
+ func applicationWillEnterForeground(_ application: UIApplication) {
33
+ // Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background.
34
+ }
35
+
36
+ func applicationDidBecomeActive(_ application: UIApplication) {
37
+ // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
38
+ }
39
+
40
+ func applicationWillTerminate(_ application: UIApplication) {
41
+ // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
42
+ }
43
+
44
+
45
+ }
46
+
@@ -0,0 +1,93 @@
1
+ {
2
+ "images" : [
3
+ {
4
+ "idiom" : "iphone",
5
+ "size" : "20x20",
6
+ "scale" : "2x"
7
+ },
8
+ {
9
+ "idiom" : "iphone",
10
+ "size" : "20x20",
11
+ "scale" : "3x"
12
+ },
13
+ {
14
+ "idiom" : "iphone",
15
+ "size" : "29x29",
16
+ "scale" : "2x"
17
+ },
18
+ {
19
+ "idiom" : "iphone",
20
+ "size" : "29x29",
21
+ "scale" : "3x"
22
+ },
23
+ {
24
+ "idiom" : "iphone",
25
+ "size" : "40x40",
26
+ "scale" : "2x"
27
+ },
28
+ {
29
+ "idiom" : "iphone",
30
+ "size" : "40x40",
31
+ "scale" : "3x"
32
+ },
33
+ {
34
+ "idiom" : "iphone",
35
+ "size" : "60x60",
36
+ "scale" : "2x"
37
+ },
38
+ {
39
+ "idiom" : "iphone",
40
+ "size" : "60x60",
41
+ "scale" : "3x"
42
+ },
43
+ {
44
+ "idiom" : "ipad",
45
+ "size" : "20x20",
46
+ "scale" : "1x"
47
+ },
48
+ {
49
+ "idiom" : "ipad",
50
+ "size" : "20x20",
51
+ "scale" : "2x"
52
+ },
53
+ {
54
+ "idiom" : "ipad",
55
+ "size" : "29x29",
56
+ "scale" : "1x"
57
+ },
58
+ {
59
+ "idiom" : "ipad",
60
+ "size" : "29x29",
61
+ "scale" : "2x"
62
+ },
63
+ {
64
+ "idiom" : "ipad",
65
+ "size" : "40x40",
66
+ "scale" : "1x"
67
+ },
68
+ {
69
+ "idiom" : "ipad",
70
+ "size" : "40x40",
71
+ "scale" : "2x"
72
+ },
73
+ {
74
+ "idiom" : "ipad",
75
+ "size" : "76x76",
76
+ "scale" : "1x"
77
+ },
78
+ {
79
+ "idiom" : "ipad",
80
+ "size" : "76x76",
81
+ "scale" : "2x"
82
+ },
83
+ {
84
+ "idiom" : "ipad",
85
+ "size" : "83.5x83.5",
86
+ "scale" : "2x"
87
+ }
88
+ ],
89
+ "info" : {
90
+ "version" : 1,
91
+ "author" : "xcode"
92
+ }
93
+ }
@@ -0,0 +1,25 @@
1
+ <?xml version="1.0" encoding="UTF-8" standalone="no"?>
2
+ <document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="13122.16" systemVersion="17A277" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="01J-lp-oVM">
3
+ <dependencies>
4
+ <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="13104.12"/>
5
+ <capability name="Safe area layout guides" minToolsVersion="9.0"/>
6
+ <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
7
+ </dependencies>
8
+ <scenes>
9
+ <!--View Controller-->
10
+ <scene sceneID="EHf-IW-A2E">
11
+ <objects>
12
+ <viewController id="01J-lp-oVM" sceneMemberID="viewController">
13
+ <view key="view" contentMode="scaleToFill" id="Ze5-6b-2t3">
14
+ <rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
15
+ <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
16
+ <color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
17
+ <viewLayoutGuide key="safeArea" id="6Tk-OE-BBY"/>
18
+ </view>
19
+ </viewController>
20
+ <placeholder placeholderIdentifier="IBFirstResponder" id="iYj-Kq-Ea1" userLabel="First Responder" sceneMemberID="firstResponder"/>
21
+ </objects>
22
+ <point key="canvasLocation" x="53" y="375"/>
23
+ </scene>
24
+ </scenes>
25
+ </document>
@@ -0,0 +1,24 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="13122.16" systemVersion="17A277" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="BYZ-38-t0r">
3
+ <dependencies>
4
+ <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="13104.12"/>
5
+ <capability name="Safe area layout guides" minToolsVersion="9.0"/>
6
+ <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
7
+ </dependencies>
8
+ <scenes>
9
+ <!--View Controller-->
10
+ <scene sceneID="tne-QT-ifu">
11
+ <objects>
12
+ <viewController id="BYZ-38-t0r" customClass="ViewController" customModuleProvider="target" sceneMemberID="viewController">
13
+ <view key="view" contentMode="scaleToFill" id="8bC-Xf-vdC">
14
+ <rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
15
+ <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
16
+ <color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
17
+ <viewLayoutGuide key="safeArea" id="6Tk-OE-BBY"/>
18
+ </view>
19
+ </viewController>
20
+ <placeholder placeholderIdentifier="IBFirstResponder" id="dkx-z0-nzr" sceneMemberID="firstResponder"/>
21
+ </objects>
22
+ </scene>
23
+ </scenes>
24
+ </document>
@@ -0,0 +1,45 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3
+ <plist version="1.0">
4
+ <dict>
5
+ <key>CFBundleDevelopmentRegion</key>
6
+ <string>$(DEVELOPMENT_LANGUAGE)</string>
7
+ <key>CFBundleExecutable</key>
8
+ <string>$(EXECUTABLE_NAME)</string>
9
+ <key>CFBundleIdentifier</key>
10
+ <string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
11
+ <key>CFBundleInfoDictionaryVersion</key>
12
+ <string>6.0</string>
13
+ <key>CFBundleName</key>
14
+ <string>$(PRODUCT_NAME)</string>
15
+ <key>CFBundlePackageType</key>
16
+ <string>APPL</string>
17
+ <key>CFBundleShortVersionString</key>
18
+ <string>1.0</string>
19
+ <key>CFBundleVersion</key>
20
+ <string>1</string>
21
+ <key>LSRequiresIPhoneOS</key>
22
+ <true/>
23
+ <key>UILaunchStoryboardName</key>
24
+ <string>LaunchScreen</string>
25
+ <key>UIMainStoryboardFile</key>
26
+ <string>Main</string>
27
+ <key>UIRequiredDeviceCapabilities</key>
28
+ <array>
29
+ <string>armv7</string>
30
+ </array>
31
+ <key>UISupportedInterfaceOrientations</key>
32
+ <array>
33
+ <string>UIInterfaceOrientationPortrait</string>
34
+ <string>UIInterfaceOrientationLandscapeLeft</string>
35
+ <string>UIInterfaceOrientationLandscapeRight</string>
36
+ </array>
37
+ <key>UISupportedInterfaceOrientations~ipad</key>
38
+ <array>
39
+ <string>UIInterfaceOrientationPortrait</string>
40
+ <string>UIInterfaceOrientationPortraitUpsideDown</string>
41
+ <string>UIInterfaceOrientationLandscapeLeft</string>
42
+ <string>UIInterfaceOrientationLandscapeRight</string>
43
+ </array>
44
+ </dict>
45
+ </plist>
@@ -0,0 +1,25 @@
1
+ //
2
+ // ViewController.swift
3
+ // Skeleton
4
+ //
5
+ // Created by a.alterpesotskiy on 12/03/2018.
6
+ // Copyright © 2018 forqa. All rights reserved.
7
+ //
8
+
9
+ import UIKit
10
+
11
+ class ViewController: UIViewController {
12
+
13
+ override func viewDidLoad() {
14
+ super.viewDidLoad()
15
+ // Do any additional setup after loading the view, typically from a nib.
16
+ }
17
+
18
+ override func didReceiveMemoryWarning() {
19
+ super.didReceiveMemoryWarning()
20
+ // Dispose of any resources that can be recreated.
21
+ }
22
+
23
+
24
+ }
25
+
@@ -0,0 +1,22 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3
+ <plist version="1.0">
4
+ <dict>
5
+ <key>CFBundleDevelopmentRegion</key>
6
+ <string>$(DEVELOPMENT_LANGUAGE)</string>
7
+ <key>CFBundleExecutable</key>
8
+ <string>$(EXECUTABLE_NAME)</string>
9
+ <key>CFBundleIdentifier</key>
10
+ <string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
11
+ <key>CFBundleInfoDictionaryVersion</key>
12
+ <string>6.0</string>
13
+ <key>CFBundleName</key>
14
+ <string>$(PRODUCT_NAME)</string>
15
+ <key>CFBundlePackageType</key>
16
+ <string>BNDL</string>
17
+ <key>CFBundleShortVersionString</key>
18
+ <string>1.0</string>
19
+ <key>CFBundleVersion</key>
20
+ <string>1</string>
21
+ </dict>
22
+ </plist>
@@ -0,0 +1,28 @@
1
+ //
2
+ // SkeletonUITests.swift
3
+ // SkeletonUITests
4
+ //
5
+ // Created by a.alterpesotskiy on 12/03/2018.
6
+ // Copyright © 2018 forqa. All rights reserved.
7
+ //
8
+
9
+ import XCTest
10
+
11
+ let app = XCUIApplication(bundleIdentifier: ProcessInfo.processInfo.environment["bundle_id"]!)
12
+
13
+ class SkeletonUITests: XCTestCase {
14
+
15
+ func testMe() {
16
+ app.activate()
17
+ sleep(1)
18
+ print("start_grep_tag")
19
+ print(app.debugDescription)
20
+ print("end_grep_tag")
21
+ let screenshot = app.windows.firstMatch.screenshot()
22
+ let attachment = XCTAttachment(screenshot: screenshot)
23
+ attachment.lifetime = .keepAlways
24
+ attachment.name = "skeleton"
25
+ add(attachment)
26
+ }
27
+
28
+ }
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "skeleton"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start(__FILE__)
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
data/lib/skeleton.rb ADDED
@@ -0,0 +1,79 @@
1
+ require 'optparse'
2
+ require 'fileutils'
3
+ require 'nokogiri'
4
+ require 'logger'
5
+ require 'colorize'
6
+ require_relative 'skeleton/version'
7
+ require_relative 'skeleton/base'
8
+ require_relative 'skeleton/ios'
9
+ require_relative 'skeleton/android'
10
+
11
+ module Skeleton
12
+ class Skeleton
13
+
14
+ attr_accessor :platform, :udid, :bundle_id
15
+
16
+ def initialize(options)
17
+ self.platform = options[:platform]
18
+ self.udid = options[:udid]
19
+ self.bundle_id = options[:bundle_id]
20
+ @driver = ios? ? IOS.new(options) : Android.new(options)
21
+ end
22
+
23
+ def platform=(platform)
24
+ platform.nil? || platform.downcase!
25
+ if platform != 'ios' && platform != 'android'
26
+ raise 'Set platform, ios or android [-p arg]'
27
+ end
28
+ @platform = platform
29
+ end
30
+
31
+ def udid=(udid)
32
+ if udid.nil?
33
+ raise 'Not set udid [-u arg]'
34
+ end
35
+ @udid = udid
36
+ end
37
+
38
+ def bundle_id=(bundle_id)
39
+ if @platform == 'ios' && bundle_id.nil?
40
+ raise 'Not set bundle_id [-b arg]'
41
+ end
42
+ @bundle_id = bundle_id
43
+ end
44
+
45
+ def start
46
+ @driver.precondition
47
+ @driver.skeletoner
48
+ @driver.log.info("#{Dir.pwd}/#{Base::PAGE_OBJECTS_FOLDER}/. 😍")
49
+ end
50
+
51
+ def ios?
52
+ @platform == 'ios'
53
+ end
54
+
55
+ def android?
56
+ @platform == 'android'
57
+ end
58
+ end
59
+
60
+ options = {}
61
+ ARGV.options do |opts|
62
+ opts.on('-u',
63
+ '--udid=val',
64
+ 'Set device udid',
65
+ String) { |val| options[:udid] = val }
66
+ opts.on('-p',
67
+ '--platform=val',
68
+ 'Set device platform',
69
+ String) { |val| options[:platform] = val }
70
+ opts.on('-b',
71
+ '--bundle=val',
72
+ 'Set bundleId for your app [required for iOS]',
73
+ String) { |val| options[:bundle_id] = val }
74
+ opts.parse!
75
+ end
76
+
77
+ skeleton = Skeleton.new(options)
78
+ skeleton.start
79
+ end
@@ -0,0 +1,91 @@
1
+ class Android < Base
2
+ RESOURCE_ID = {
3
+ java: 'resource-id',
4
+ ruby: 'resource-id'
5
+ }
6
+ CONTENT_DESC = {
7
+ java: 'content-desc',
8
+ ruby: 'content-desc'
9
+ }
10
+ TEXT = 'text'
11
+ ID = 'id'
12
+ XPATH = 'xpath'
13
+ CLASS = 'class'
14
+
15
+ attr_accessor :platform, :udid, :bundle_id, :ios_sim
16
+
17
+ def initialize(options)
18
+ self.platform = options[:platform]
19
+ self.udid = options[:udid]
20
+ end
21
+
22
+ def skeletoner
23
+ create_page_objects
24
+ save_screenshot
25
+ save(page_source)
26
+ end
27
+
28
+ private
29
+
30
+ def create_locator_by_resouce_id(line)
31
+ method_name = line[RESOURCE_ID]
32
+ method_name.slice!(/.*id\//)
33
+ code_generation(method_name, ID, line[RESOURCE_ID])
34
+ end
35
+
36
+ def create_locator_by_content_desc(line)
37
+ method_name = "#{line[CLASS]}#{increment_locator_id}"
38
+ method_name.slice!(/.*\./)
39
+ locator = "//#{line[CLASS]}[@#{CONTENT_DESC}='#{line[CONTENT_DESC]}']"
40
+ code_generation(method_name, XPATH, locator)
41
+ end
42
+
43
+ def create_locator_by_text(line)
44
+ method_name = "#{line[CLASS]}#{increment_locator_id}"
45
+ method_name.slice!(/.*\./)
46
+ locator = "//#{line[CLASS]}[@#{TEXT}='#{line[TEXT]}'"
47
+ code_generation(method_name, XPATH, locator)
48
+ end
49
+
50
+ def create_locator(line)
51
+ if !line[RESOURCE_ID].empty?
52
+ create_locator_by_resouce_id(line)
53
+ elsif !line[CONTENT_DESC].empty?
54
+ create_locator_by_content_desc(line)
55
+ elsif !line[TEXT].empty?
56
+ create_locator_by_text(line)
57
+ end
58
+ end
59
+
60
+ def create_page_objects
61
+ page_source_html = Nokogiri::HTML.parse(page_source)
62
+ page_source_html.css('node').each { |line| create_locator(line) }
63
+ end
64
+
65
+ def code_generation(method_name, locator_type, value)
66
+ java = java(method_name, locator_type, value)
67
+ save(java, format: Language::JAVA)
68
+
69
+ # ADD OTHER LANGUAGES HERE
70
+ end
71
+
72
+ def save(code, format: 'xml')
73
+ file_path = "#{PAGE_OBJECTS_FOLDER}/#{@platform}_#{TIMESTAMP}.#{format}"
74
+ File.open(file_path, 'a') { |f| f.write(code) }
75
+ end
76
+
77
+ def page_source
78
+ unless @page_source
79
+ dump = `adb -s #{@udid} shell uiautomator dump | egrep -o '/.*?xml'`
80
+ @page_source = `adb -s #{@udid} shell cat #{dump}`
81
+ end
82
+ @page_source
83
+ end
84
+
85
+ def save_screenshot
86
+ file_name = "#{@platform}_#{TIMESTAMP}.png"
87
+ `adb -s #{@udid} shell screencap -p /sdcard/#{file_name}`
88
+ `adb -s #{@udid} pull /sdcard/#{file_name} #{ATTACHMENTS_FOLDER}/`
89
+ `adb -s #{@udid} shell rm /sdcard/#{file_name}`
90
+ end
91
+ end
@@ -0,0 +1,98 @@
1
+ require_relative 'languages.rb'
2
+
3
+ class Base
4
+ include Language
5
+
6
+ ROOT_DIR = File.expand_path('..', Dir.pwd)
7
+ PAGE_OBJECTS_FOLDER = "#{ROOT_DIR}/PageObjects"
8
+ ATTACHMENTS_FOLDER = "#{ROOT_DIR}/Attachments"
9
+ TIMESTAMP = (Time.now.to_f * 1000).to_i
10
+
11
+ def precondition
12
+ create_logger
13
+ FileUtils.mkdir_p(PAGE_OBJECTS_FOLDER)
14
+ FileUtils.mkdir_p(ATTACHMENTS_FOLDER)
15
+ end
16
+
17
+ def log
18
+ if @log.nil?
19
+ create_logger
20
+ end
21
+ @log
22
+ end
23
+
24
+ def skeletoner
25
+ end
26
+
27
+ protected
28
+
29
+ def create_logger
30
+ @log = Logger.new(STDOUT)
31
+ @log.level = Logger::INFO
32
+ @log.formatter = proc do |severity, datetime, progname, msg|
33
+ "[#{severity}] #{datetime}: " + "#{msg}\n".colorize(:light_cyan)
34
+ end
35
+ end
36
+
37
+ def snake_style(method_name)
38
+ method_name.each_char.with_index do |char, char_i|
39
+ method_name[char_i] =
40
+ if /[ -!$%^&*()+|~=`{}\[\]:";'<>?,.\/]/.match(method_name[char_i])
41
+ '_'
42
+ elsif /[A-Z]/.match(method_name[char_i])
43
+ if method_name[char_i - 1] != '_'
44
+ "_#{method_name[char_i]}"
45
+ else
46
+ method_name[char_i]
47
+ end
48
+ else
49
+ method_name[char_i]
50
+ end
51
+ end
52
+ method_name.squeeze('_').downcase
53
+ end
54
+
55
+ def camel_style(method_name)
56
+ space_i = 0
57
+ method_name[0] = method_name[0].downcase
58
+ method_name.each_char.with_index do |char, char_i|
59
+ if /[ -!$%^&*()_+|~=`{}\[\]:";'<>?,.\/]/.match(char)
60
+ method_name[char_i - space_i] = ''
61
+ method_name[char_i - space_i] = method_name[char_i - space_i].capitalize
62
+ space_i += 1
63
+ end
64
+ end
65
+ end
66
+
67
+ def increment_locator_id
68
+ @locator_index = @locator_index.nil? ? 1 : @locator_index + 1
69
+ end
70
+
71
+ def java(method_name, locator_type, value)
72
+ <<~JAVA
73
+ By #{camel_style(method_name)}() {
74
+ return MobileBy.#{locator_type[:java]}("#{value}");
75
+ }
76
+
77
+ JAVA
78
+ end
79
+
80
+ def ruby(method_name, locator_type, value)
81
+ <<~RUBY
82
+ def #{snake_style(method_name)}
83
+ return :#{locator_type[:ruby]}, "#{value}"
84
+ end
85
+
86
+ RUBY
87
+ end
88
+
89
+ def screenshot
90
+ end
91
+
92
+ def page_source
93
+ end
94
+
95
+ def code_generation
96
+ end
97
+
98
+ end
@@ -0,0 +1,138 @@
1
+ class IOS < Base
2
+ ACC_ID = {
3
+ java: :AccessibilityId,
4
+ ruby: :accessibility_id
5
+ }
6
+ NSPREDICATE = {
7
+ java: :iOSNsPredicateString,
8
+ ruby: :predicate
9
+ }
10
+ IDENTIFIER = 'identifier'
11
+ LABEL = 'label'
12
+ XCRESULTS_FOLDER = "#{File.expand_path('..', Dir.pwd)}/XCResults"
13
+
14
+ attr_accessor :platform, :udid, :bundle_id
15
+
16
+ def initialize(options)
17
+ self.platform = options[:platform]
18
+ self.udid = options[:udid]
19
+ self.bundle_id = options[:bundle_id]
20
+ end
21
+
22
+ def skeletoner
23
+ log.info('We starting to skeleton your screen 🚀')
24
+ check_udid
25
+ page_source
26
+ create_page_objects
27
+ save_screenshot
28
+ save(page_source)
29
+ log.info('We successfully skeletoned your screen 👻')
30
+ end
31
+
32
+ private
33
+
34
+ def create_locator(line)
35
+ locator_by_id = locator_by_id(line)
36
+ locator_by_label = locator_by_label(line)
37
+ if !locator_by_id.empty?
38
+ create_locator_by_id(locator_by_id)
39
+ elsif !locator_by_label.empty?
40
+ type = element_type(line)
41
+ create_locator_by_label(locator_by_label, type)
42
+ end
43
+ end
44
+
45
+ def create_locator_by_id(locator)
46
+ method_name = locator.strip
47
+ code_generation(method_name, ACC_ID, locator)
48
+ end
49
+
50
+ def create_locator_by_label(locator, type)
51
+ method_name = "#{type}#{increment_locator_id}"
52
+ locator = "#{LABEL} like '#{locator}'"
53
+ code_generation(method_name, NSPREDICATE, locator)
54
+ end
55
+
56
+ def create_page_objects
57
+ log.info('Generation page objects for your awesome language 💪')
58
+ page_source.each_line do |line|
59
+ break if line.include?(' StatusBar, ')
60
+ next if line.include?('Application, ')
61
+ create_locator(line)
62
+ end
63
+ end
64
+
65
+ def element_type(line)
66
+ line_first_word = line.split.first
67
+ line_first_word.nil? ? '' : line_first_word.chomp(',')
68
+ end
69
+
70
+ def locator_by_id(line)
71
+ locator = /#{IDENTIFIER}: '(.*?)'/.match(line)
72
+ locator.nil? ? '' : locator[1]
73
+ end
74
+
75
+ def locator_by_label(line)
76
+ locator = /#{LABEL}: '(.*?)'/.match(line)
77
+ locator.nil? ? '' : locator[1]
78
+ end
79
+
80
+ def code_generation(method_name, locator_type, value)
81
+ java = java(method_name, locator_type, value)
82
+ ruby = ruby(method_name, locator_type, value)
83
+
84
+ save(java, format: Language::JAVA)
85
+ save(ruby, format: Language::RUBY)
86
+ end
87
+
88
+ def page_source
89
+ if @page_source.nil?
90
+ log.info('Getting screen source tree ⚒')
91
+ FileUtils.rm_rf(XCRESULTS_FOLDER)
92
+ start_grep, end_grep = 'start_grep_tag', 'end_grep_tag'
93
+ ios_arch = @simulator ? 'iOS Simulator' : 'iOS'
94
+ @page_source = `xcodebuild test \
95
+ -project #{ROOT_DIR}/Skeleton.xcodeproj \
96
+ -scheme Skeleton \
97
+ -destination 'platform=#{ios_arch},id=#{@udid}' \
98
+ -resultBundlePath #{XCRESULTS_FOLDER} \
99
+ bundle_id="#{@bundle_id}" | \
100
+ awk '/#{start_grep}/,/#{end_grep}/'`
101
+ @page_source.slice!(start_grep)
102
+ @page_source.slice!(end_grep)
103
+ if @page_source.empty?
104
+ log.fatal('Something went wrong. Try to sign Skeleton ' \
105
+ 'and to trust it in the iOS settings.')
106
+ Process.exit(1)
107
+ end
108
+ log.info('Successfully getting Screen Source Tree 🔥')
109
+ end
110
+ @page_source
111
+ end
112
+
113
+ def check_udid
114
+ if @simulator.nil?
115
+ log.info('Checking iOS UDID 👨‍💻')
116
+ simulators = `xcrun simctl list`
117
+ @simulator = simulators.include?(@udid)
118
+ if !@simulator && !`instruments -s devices`.include?("[#{@udid}]")
119
+ log.fatal("No such devices with UDID: #{@udid}")
120
+ Process.exit(1)
121
+ end
122
+ end
123
+ end
124
+
125
+ def save(code, format: 'xml')
126
+ file_path = "#{PAGE_OBJECTS_FOLDER}/#{@platform}_#{TIMESTAMP}.#{format}"
127
+ File.open(file_path, 'a') { |f| f.write(code) }
128
+ end
129
+
130
+ def save_screenshot
131
+ log.info('Saving screenshot 📷')
132
+ png_path = "#{XCRESULTS_FOLDER}/Attachments/*.png"
133
+ new_path = "#{ATTACHMENTS_FOLDER}/#{@platform}_#{TIMESTAMP}.png"
134
+ screenshots = Dir[png_path].collect { |png| File.expand_path(png) }
135
+ FileUtils.cp(screenshots[0], new_path)
136
+ FileUtils.rm_rf(XCRESULTS_FOLDER)
137
+ end
138
+ end
@@ -0,0 +1,5 @@
1
+ module Language
2
+ JAVA = 'java'
3
+ RUBY = 'rb'
4
+ PYTHON = 'py'
5
+ end
@@ -0,0 +1,3 @@
1
+ module Skeleton
2
+ VERSION = "0.0.1"
3
+ end
data/skeleton.gemspec ADDED
@@ -0,0 +1,37 @@
1
+
2
+ lib = File.expand_path("../lib", __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require "skeleton/version"
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "skeleton-ui"
8
+ spec.version = Skeleton::VERSION
9
+ spec.authors = ["a.alterpesotskiy"]
10
+ spec.email = ["33gri@bk.ru"]
11
+
12
+ spec.summary = %q{CLI for fast generating multi language page objects from iOS and Android screens.}
13
+ spec.homepage = "https://github.com/forqa/skeleton"
14
+ spec.license = "MIT"
15
+
16
+ # Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
17
+ # to allow pushing to a single host or delete this section to allow pushing to any host.
18
+ if spec.respond_to?(:metadata)
19
+ spec.metadata["allowed_push_host"] = "https://rubygems.org"
20
+ else
21
+ raise "RubyGems 2.0 or newer is required to protect against " \
22
+ "public gem pushes."
23
+ end
24
+
25
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
26
+ f.match(%r{^(test|spec|features)/})
27
+ end
28
+ spec.bindir = "exe"
29
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
30
+ spec.require_paths = ["lib"]
31
+
32
+ spec.add_development_dependency "bundler", "~> 1.16"
33
+ spec.add_development_dependency "rake", "~> 12.3.0"
34
+ spec.add_development_dependency "colorize", "~> 0.8.1"
35
+ spec.add_development_dependency "nokogiri", "~> 1.8.2"
36
+ spec.add_development_dependency "fileutils"
37
+ end
metadata ADDED
@@ -0,0 +1,144 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: skeleton-ui
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - a.alterpesotskiy
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2018-03-26 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.16'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.16'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: 12.3.0
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: 12.3.0
41
+ - !ruby/object:Gem::Dependency
42
+ name: colorize
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: 0.8.1
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: 0.8.1
55
+ - !ruby/object:Gem::Dependency
56
+ name: nokogiri
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: 1.8.2
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: 1.8.2
69
+ - !ruby/object:Gem::Dependency
70
+ name: fileutils
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ description:
84
+ email:
85
+ - 33gri@bk.ru
86
+ executables: []
87
+ extensions: []
88
+ extra_rdoc_files: []
89
+ files:
90
+ - ".gitignore"
91
+ - CODE_OF_CONDUCT.md
92
+ - Gemfile
93
+ - Gemfile.lock
94
+ - LICENSE.txt
95
+ - README.md
96
+ - Rakefile
97
+ - Skeleton.xcodeproj/project.pbxproj
98
+ - Skeleton.xcodeproj/project.xcworkspace/contents.xcworkspacedata
99
+ - Skeleton.xcodeproj/project.xcworkspace/xcuserdata/a.alterpesotskiy.xcuserdatad/UserInterfaceState.xcuserstate
100
+ - Skeleton.xcodeproj/xcshareddata/xcschemes/Skeleton.xcscheme
101
+ - Skeleton/AppDelegate.swift
102
+ - Skeleton/Assets.xcassets/AppIcon.appiconset/Contents.json
103
+ - Skeleton/Base.lproj/LaunchScreen.storyboard
104
+ - Skeleton/Base.lproj/Main.storyboard
105
+ - Skeleton/Info.plist
106
+ - Skeleton/ViewController.swift
107
+ - SkeletonUITests/Info.plist
108
+ - SkeletonUITests/SkeletonUITests.swift
109
+ - bin/console
110
+ - bin/setup
111
+ - lib/skeleton.rb
112
+ - lib/skeleton/android.rb
113
+ - lib/skeleton/base.rb
114
+ - lib/skeleton/ios.rb
115
+ - lib/skeleton/languages.rb
116
+ - lib/skeleton/version.rb
117
+ - skeleton.gemspec
118
+ homepage: https://github.com/forqa/skeleton
119
+ licenses:
120
+ - MIT
121
+ metadata:
122
+ allowed_push_host: https://rubygems.org
123
+ post_install_message:
124
+ rdoc_options: []
125
+ require_paths:
126
+ - lib
127
+ required_ruby_version: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - ">="
130
+ - !ruby/object:Gem::Version
131
+ version: '0'
132
+ required_rubygems_version: !ruby/object:Gem::Requirement
133
+ requirements:
134
+ - - ">="
135
+ - !ruby/object:Gem::Version
136
+ version: '0'
137
+ requirements: []
138
+ rubyforge_project:
139
+ rubygems_version: 2.7.3
140
+ signing_key:
141
+ specification_version: 4
142
+ summary: CLI for fast generating multi language page objects from iOS and Android
143
+ screens.
144
+ test_files: []