Class: Frank::CLI
- Inherits:
-
Thor
- Object
- Thor
- Frank::CLI
- Includes:
- Thor::Actions
- Defined in:
- lib/frank-cucumber/cli.rb
Constant Summary collapse
- WITHOUT_SERVER =
"without-cocoa-http-server"
- WITHOUT_ASYNC_SOCKET =
"without-cocoa-async-socket"
- WITHOUT_LUMBERJACK =
"without-cocoa-lumberjack"
- XCODEBUILD_OPTIONS =
%w{workspace project scheme target configuration}
- WITHOUT_DEPS =
'without-dependencies'
Class Method Summary collapse
Instance Method Summary collapse
- #build(*args) ⇒ Object
- #build_and_launch ⇒ Object
- #console ⇒ Object
- #inspect ⇒ Object
- #launch ⇒ Object
- #setup ⇒ Object
- #skeleton ⇒ Object
- #update ⇒ Object
Class Method Details
.source_root ⇒ Object
17 18 19 |
# File 'lib/frank-cucumber/cli.rb', line 17 def self.source_root File.join( File.dirname(__FILE__), '..','..','frank-skeleton' ) end |
Instance Method Details
#build(*args) ⇒ Object
76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 |
# File 'lib/frank-cucumber/cli.rb', line 76 def build(*args) clean = !['noclean'] use_plugins = !['no-plugins'] exclude_dependencies = [WITHOUT_DEPS] || [] in_root do unless File.directory? 'Frank' if yes? "You don't appear to have set up a Frank directory for this project. Would you like me to set that up now? Type 'y' or 'yes' if so." invoke :skeleton else say "OK, in that case there's not much I can do for now. Whenever you change your mind and want to get your project setup with Frank simply run `frank setup` from the root of your project directory." say "Bye bye for now!" exit 11 end end end static_bundle = 'frank_static_resources.bundle' if clean remove_dir build_output_dir end build_steps = 'build' if clean build_steps = 'clean ' + build_steps end plugins = use_plugins ? gather_plugins : [] say "Detected plugins: #{plugins.map {|p| p.name}.join(', ')}" unless plugins.empty? say "Excluding plugin dependencies: #{exclude_dependencies.join(', ')}" unless exclude_dependencies.empty? plugins.each {|plugin| plugin.write_xcconfig(exclude_dependencies)} xcconfig_data = Frank::Plugins::Plugin.generate_core_xcconfig(plugins) xcconfig_file = 'Frank/frank.xcconfig' File.open(xcconfig_file,'w') {|f| f.write(xcconfig_data) } extra_opts = XCODEBUILD_OPTIONS.map{ |o| "-#{o} \"#{[o]}\"" if [o] and (o != "target" or ['workspace'] == nil)}.compact.join(' ') # If there is a scheme specified we don't want to inject the default configuration # If there is a configuration specified, we also do not want to inject the default configuration if ['scheme'] || ['configuration'] separate_configuration_option = "" else separate_configuration_option = "-configuration Debug" end xcodebuild_args = args.join(" ") if ['mac'] run %Q|xcodebuild -xcconfig #{xcconfig_file} #{build_steps} #{extra_opts} #{separate_configuration_option} DEPLOYMENT_LOCATION=YES DSTROOT="#{build_output_dir}" FRANK_LIBRARY_SEARCH_PATHS="#{frank_lib_search_paths}" #{xcodebuild_args}| else extra_opts += " -arch #{['arch']}" run %Q|xcodebuild -xcconfig #{xcconfig_file} #{build_steps} #{extra_opts} #{separate_configuration_option} -sdk iphonesimulator ONLY_ACTIVE_ARCH=NO DEPLOYMENT_LOCATION=YES DSTROOT="#{build_output_dir}" FRANK_LIBRARY_SEARCH_PATHS="#{frank_lib_search_paths}" #{xcodebuild_args}| end exit $?.exitstatus if not $?.success? app = Dir.glob("#{build_output_dir}/*.app").delete_if { |x| x =~ /\/#{app_bundle_name}$/ } app = app.first FileUtils.cp_r("#{app}/.", frankified_app_dir) if ['mac'] in_root do FileUtils.cp_r( File.join( 'Frank',static_bundle), File.join( frankified_app_dir, "Contents", "Resources", static_bundle ) ) end else fix_frankified_apps_bundle_identifier in_root do FileUtils.cp_r( File.join( 'Frank',static_bundle), File.join( frankified_app_dir, static_bundle ) ) end end end |
#build_and_launch ⇒ Object
162 163 164 165 |
# File 'lib/frank-cucumber/cli.rb', line 162 def build_and_launch invoke :build invoke :launch end |
#console ⇒ Object
210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 |
# File 'lib/frank-cucumber/cli.rb', line 210 def console # TODO: check whether app is running (using ps or similar), and launch it if it's not begin require 'pry' rescue LoadError say 'The Frank console requires the pry gem.' say 'Simply run `sudo gem install pry` (the `sudo` bit might be optional), and then try again. Thanks!' exit 41 end Frank::Cucumber::FrankHelper.use_shelley_from_now_on console = Frank::Console.new Frank::Cucumber::FrankHelper.test_on_physical_device_via_bonjour if [:bonjour] Frank::Cucumber::FrankHelper.server_base_url = [:server] if [:server] if console.check_for_running_app console.pry end end |
#inspect ⇒ Object
202 203 204 205 |
# File 'lib/frank-cucumber/cli.rb', line 202 def inspect # TODO: check whether app is running (using ps or similar), and launch it if it's not run 'open http://localhost:37265' end |
#launch ⇒ Object
170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 |
# File 'lib/frank-cucumber/cli.rb', line 170 def launch $DEBUG = [:debug] launcher = case [:idiom].downcase when 'iphone' SimLauncher::DirectClient.for_iphone_app( frankified_app_dir ) when 'ipad' SimLauncher::DirectClient.for_ipad_app( frankified_app_dir ) else say "idiom must be either iphone or ipad. You supplied '#{[:idiom]}'", :red exit 10 end in_root do unless File.exists? frankified_app_dir say "A Frankified version of the app doesn't appear to have been built. Building one now" say "..." invoke :build end if built_product_is_mac_app( frankified_app_dir ) launcher = Frank::MacLauncher.new( frankified_app_dir ) say "LAUNCHING APP..." else say "LAUNCHING IN THE SIMULATOR..." end launcher.relaunch end end |
#setup ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/frank-cucumber/cli.rb', line 37 def setup @libs = %w(Shelley CocoaAsyncSocket CocoaLumberjack CocoaHTTPServer Frank) @libsMac = %w(ShelleyMac CocoaAsyncSocketMac CocoaLumberjackMac CocoaHTTPServerMac FrankMac) @libs -= %w(CocoaHTTPServer) if [WITHOUT_SERVER] @libsMac -= %w(CocoaHTTPServerMac) if [WITHOUT_SERVER] @libs -= %w(CocoaAsyncSocket) if [WITHOUT_ASYNC_SOCKET] @libsMac -= %w(CocoaAsyncSocketMac) if [WITHOUT_ASYNC_SOCKET] @libs -= %w(CocoaLumberjack) if [WITHOUT_LUMBERJACK] @libsMac -= %w(CocoaLumberjackMac) if [WITHOUT_LUMBERJACK] directory ".", "Frank" Frankifier.frankify!( File.('.'), :build_config => [:build_configuration], :target => [:target], :project => [:project] ) end |
#skeleton ⇒ Object
23 24 25 |
# File 'lib/frank-cucumber/cli.rb', line 23 def skeleton invoke :setup end |
#update ⇒ Object
53 54 55 56 57 58 59 60 61 62 |
# File 'lib/frank-cucumber/cli.rb', line 53 def update %w{libFrank.a libCocoaAsyncSocket.a libCocoaLumberjack.a libCocoaHTTPServer.a libShelley.a libFrankMac.a libShelleyMac.a libCocoaAsyncSocketMac.a libCocoaLumberjackMac.a libCocoaHTTPServerMac.a}.each do |f| copy_file f, File.join( 'Frank', f ), :force => true end directory( 'frank_static_resources.bundle', 'Frank/frank_static_resources.bundle', :force => true ) if yes? "\nOne or more static libraries may have been updated. For these changes to take effect the 'frankified_build' directory must be cleaned. Would you like me to do that now? Type 'y' or 'yes' to delete the contents of frankified_build." remove_file('Frank/frankified_build') end end |