Skip to content

Commit 104ad6d

Browse files
authored
Merge pull request #5 from TheSoftwareDesignLab/v2
Version 1.0.5
2 parents deb8c13 + 9ff3920 commit 104ad6d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+2550
-444
lines changed

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
11
/kraken-mobile-*.gem
22
/example
33
/Gemfile.lock
4+
.byebug_history
5+
.DS_Store
6+
/features
7+
/test_servers

bin/kraken-mobile

Lines changed: 55 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -1,91 +1,79 @@
11
#!/usr/bin/env ruby
22

3-
require File.join(File.dirname(__FILE__), "kraken-mobile-helpers")
4-
require File.join(File.dirname(__FILE__), "kraken-mobile-setup")
5-
require File.join(File.dirname(__FILE__), "kraken-mobile-calabash-android")
6-
$LOAD_PATH << File.expand_path("../../lib", __FILE__)
7-
require 'kraken-mobile'
3+
require File.join(File.dirname(__FILE__), 'kraken_mobile_helpers')
4+
require File.join(File.dirname(__FILE__), 'kraken_mobile_setup')
5+
require File.join(File.dirname(__FILE__), 'kraken_mobile_calabash_android')
6+
$LOAD_PATH << File.expand_path('../lib', __dir__)
7+
require 'kraken_mobile'
88
require 'kraken-mobile/constants'
99

1010
#-------------------------------
1111
# AGV reader helper
1212
#-------------------------------
1313

14-
def read_specified_runner
15-
runner_command = ARGV.select { |arg| arg.include?("--runner=") }.first
16-
if runner_command
17-
formatted_runner_command = runner_command.strip.downcase
18-
formatted_runner_command.slice!("--runner=")
19-
formatted_runner_command
20-
end
21-
end
14+
def read_configuration
15+
configuration_command = ARGV.select do |arg|
16+
arg.include?('--configuration=')
17+
end.first
18+
return if configuration_command.nil?
2219

23-
def read_specified_protocol
24-
protocol_command = ARGV.select { |arg| arg.include?("--protocol=") }.first
25-
if protocol_command
26-
formatted_protocol_command = protocol_command.strip.downcase
27-
formatted_protocol_command.slice!("--protocol=")
28-
if KrakenMobile::Constants::SUPPORTED_PROTOCOLS.include?(formatted_protocol_command)
29-
formatted_protocol_command
30-
else # Protocol not supported.
31-
raise "Specified protocol not supported."
32-
end
33-
else # If protocol not specified use file based as default.
34-
KrakenMobile::Constants::FILE_PROTOCOL
35-
end
20+
configuration_command = configuration_command.strip.downcase
21+
configuration_command.slice!('--configuration=')
22+
configuration_command
3623
end
3724

38-
def read_configuration
39-
configuration_command = ARGV.select { |arg| arg.include?("--configuration=") }.first
40-
if configuration_command
41-
configuration_command = configuration_command.strip.downcase
42-
configuration_command.slice!("--configuration=")
43-
configuration_command
44-
end
25+
def read_user_entered_properties_path
26+
properties_command = ARGV.select { |arg| arg.include?('--properties=') }.first
27+
return if properties_command.nil?
28+
29+
properties_command = properties_command.strip.downcase
30+
properties_command.slice!('--properties=')
31+
properties_command
4532
end
4633

47-
def read_properties
48-
properties_command = ARGV.select { |arg| arg.include?("--properties=") }.first
49-
if properties_command
50-
properties_command = properties_command.strip.downcase
51-
properties_command.slice!("--properties=")
52-
properties_command
53-
end
34+
#-------------------------------
35+
# Helpers
36+
#-------------------------------
37+
38+
def user_entered_apk_path
39+
return nil if ARGV.first.nil?
40+
41+
first_argument = ARGV.first
42+
return nil if first_argument.start_with?('--') # Is argument parameter not apk
43+
44+
File.expand_path(first_argument)
5445
end
5546

5647
#-------------------------------
5748
# Command reader
5849
#-------------------------------
5950

60-
if ARGV.length == 0
61-
print_usage
51+
if ARGV.length.zero?
52+
print_usage
6253
else
6354
cmd = ARGV.shift
6455
case cmd
65-
when 'version'
66-
require 'kraken-mobile/version'
67-
puts KrakenMobile::VERSION
68-
when 'devices'
69-
require 'kraken-mobile/helpers/devices_helper/manager'
70-
print_devices
71-
when 'setup'
72-
kraken_setup
73-
else
74-
runner_command = read_specified_runner()
75-
protocol = read_specified_protocol()
76-
configuration = read_configuration()
77-
properties = read_properties()
78-
if runner_command
79-
case runner_command
80-
when KrakenMobile::Constants::CALABASH_ANDROID
81-
require File.join(File.dirname(__FILE__), "kraken-mobile-calabash-android")
82-
handle_calabash_android(cmd, protocol, configuration, properties)
83-
else
84-
raise "Specified runner not supported."
85-
end
86-
else # If runner not specified use calabash android as default.
87-
require File.join(File.dirname(__FILE__), "kraken-mobile-calabash-android")
88-
handle_calabash_android(cmd, protocol, configuration, properties)
89-
end
56+
when 'version'
57+
require 'kraken-mobile/version'
58+
puts KrakenMobile::VERSION
59+
when 'devices'
60+
require 'kraken-mobile/helpers/devices_helper/manager'
61+
print_devices
62+
when 'setup'
63+
KrakenSetup.new.run
64+
when 'gen'
65+
scaffold_folder_structure
66+
when 'resign'
67+
require 'calabash-android/helpers'
68+
puts 'Resigning APK with Calabash-Android'
69+
ensure_apk_is_specified
70+
resign_apk(user_entered_apk_path)
71+
when 'run'
72+
require File.join(File.dirname(__FILE__), 'kraken_mobile_calabash_android')
73+
configuration = read_configuration
74+
user_entered_properties_path = read_user_entered_properties_path
75+
handle_calabash_android(configuration, user_entered_properties_path)
76+
else
77+
print_usage
9078
end
9179
end

bin/kraken-mobile-calabash-android.rb

Lines changed: 0 additions & 85 deletions
This file was deleted.

bin/kraken-mobile-generate.rb

Lines changed: 0 additions & 19 deletions
This file was deleted.

bin/kraken-mobile-helpers.rb

Lines changed: 0 additions & 48 deletions
This file was deleted.

bin/kraken-mobile-setup.rb

Lines changed: 0 additions & 50 deletions
This file was deleted.

0 commit comments

Comments
 (0)