Class: Guard::Runner
- Inherits:
-
Object
- Object
- Guard::Runner
- Defined in:
- lib/guard/calabash-ios/runner.rb
Instance Attribute Summary collapse
-
#bundle_path ⇒ Object
Returns the value of attribute bundle_path.
-
#config ⇒ Object
Returns the value of attribute config.
-
#device ⇒ Object
Returns the value of attribute device.
-
#project ⇒ Object
Returns the value of attribute project.
-
#sdk ⇒ Object
Returns the value of attribute sdk.
-
#target ⇒ Object
Returns the value of attribute target.
Instance Method Summary collapse
- #command(features) ⇒ Object
- #init_bundle_path(options) ⇒ Object
- #init_config(options) ⇒ Object
- #init_device(options) ⇒ Object
- #init_project(options) ⇒ Object
- #init_sdk(options) ⇒ Object
- #init_target(options) ⇒ Object
-
#initialize(options) ⇒ Runner
constructor
A new instance of Runner.
- #run(features) ⇒ Object
Constructor Details
#initialize(options) ⇒ Runner
Returns a new instance of Runner.
9 10 11 12 13 14 15 16 |
# File 'lib/guard/calabash-ios/runner.rb', line 9 def initialize() self.sdk = init_sdk() self.device = init_device() self.project = init_project() self.target = init_target() self.config = init_config() self.bundle_path = init_bundle_path() end |
Instance Attribute Details
#bundle_path ⇒ Object
Returns the value of attribute bundle_path.
3 4 5 |
# File 'lib/guard/calabash-ios/runner.rb', line 3 def bundle_path @bundle_path end |
#config ⇒ Object
Returns the value of attribute config.
8 9 10 |
# File 'lib/guard/calabash-ios/runner.rb', line 8 def config @config end |
#device ⇒ Object
Returns the value of attribute device.
5 6 7 |
# File 'lib/guard/calabash-ios/runner.rb', line 5 def device @device end |
#project ⇒ Object
Returns the value of attribute project.
6 7 8 |
# File 'lib/guard/calabash-ios/runner.rb', line 6 def project @project end |
#sdk ⇒ Object
Returns the value of attribute sdk.
4 5 6 |
# File 'lib/guard/calabash-ios/runner.rb', line 4 def sdk @sdk end |
#target ⇒ Object
Returns the value of attribute target.
7 8 9 |
# File 'lib/guard/calabash-ios/runner.rb', line 7 def target @target end |
Instance Method Details
#command(features) ⇒ Object
81 82 83 84 85 86 87 88 89 90 91 |
# File 'lib/guard/calabash-ios/runner.rb', line 81 def command(features) if features.kind_of? Array features = features.join(' ') end cmd = [] cmd << "APP_BUNDLE_PATH='#{self.bundle_path}'" cmd << "OS=#{self.sdk}" cmd << "DEVICE=#{self.device}" cmd << "cucumber #{features} --require features" cmd.join ' ' end |
#init_bundle_path(options) ⇒ Object
93 94 95 96 97 98 99 100 101 |
# File 'lib/guard/calabash-ios/runner.rb', line 93 def init_bundle_path() path = [] path << "#{Dir::pwd}/DerivedData/" path << "#{self.project}/" path << "Build/Products/" path << "#{self.config}-iphonesimulator/" path << "#{self.target}.app" path.join end |
#init_config(options) ⇒ Object
50 51 52 53 54 55 56 |
# File 'lib/guard/calabash-ios/runner.rb', line 50 def init_config() if [:config].nil? "Debug" else [:config] end end |
#init_device(options) ⇒ Object
27 28 29 30 31 32 33 34 |
# File 'lib/guard/calabash-ios/runner.rb', line 27 def init_device() devices = [:iphone, :ipad] if devices.include? [:device] [:device] else :iphone end end |
#init_project(options) ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/guard/calabash-ios/runner.rb', line 36 def init_project() if [:project].nil? xproject = Dir.glob("*.xcodeproj").first if xproject xproject.gsub(".xcodeproj","") else UI.info "Could not find project" nil end else [:project] end end |
#init_sdk(options) ⇒ Object
18 19 20 21 22 23 24 25 |
# File 'lib/guard/calabash-ios/runner.rb', line 18 def init_sdk() sdks = [:ios4, :ios5] if sdks.include? [:sdk] [:sdk] else :ios5 end end |
#init_target(options) ⇒ Object
58 59 60 61 62 63 64 |
# File 'lib/guard/calabash-ios/runner.rb', line 58 def init_target() if [:target].nil? "#{self.project}-cal" else [:target] end end |
#run(features) ⇒ Object
66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/guard/calabash-ios/runner.rb', line 66 def run(features) unless File.exists? self.bundle_path.to_s UI.info "Could not run Calabash. \n'#{self.bundle_path}' not found." return false end if features.eql?("features") or features.empty? = "Run all features" else features = features.join(' ') if features.kind_of? Array = "Run #{features}" end UI.info system(command(features)) end |