cova 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/bin/cova +10 -5
- data/lib/cova.rb +12 -312
- data/lib/covaio.rb +116 -0
- data/lib/covalog.rb +50 -0
- data/lib/covamain.rb +176 -0
- metadata +10 -7
    
        data/bin/cova
    CHANGED
    
    | @@ -1,9 +1,14 @@ | |
| 1 1 | 
             
            #!/usr/bin/env ruby
         | 
| 2 2 |  | 
| 3 | 
            -
            require  | 
| 4 | 
            -
             | 
| 5 | 
            -
            require  | 
| 6 | 
            -
            require  | 
| 7 | 
            -
            require  | 
| 3 | 
            +
            require 'rubygems'
         | 
| 4 | 
            +
             | 
| 5 | 
            +
            require 'logger'
         | 
| 6 | 
            +
            require 'colorize'
         | 
| 7 | 
            +
            require 'fileutils'
         | 
| 8 | 
            +
            require 'thor'
         | 
| 9 | 
            +
            require 'cocoapods'
         | 
| 10 | 
            +
            require 'covalog'
         | 
| 11 | 
            +
            require 'covaio'
         | 
| 12 | 
            +
            require 'covamain'
         | 
| 8 13 |  | 
| 9 14 | 
             
            Cova.start
         | 
    
        data/lib/cova.rb
    CHANGED
    
    | @@ -1,312 +1,12 @@ | |
| 1 | 
            -
             | 
| 2 | 
            -
             | 
| 3 | 
            -
             | 
| 4 | 
            -
             | 
| 5 | 
            -
             | 
| 6 | 
            -
             | 
| 7 | 
            -
             | 
| 8 | 
            -
             | 
| 9 | 
            -
             | 
| 10 | 
            -
             | 
| 11 | 
            -
             | 
| 12 | 
            -
             | 
| 13 | 
            -
            	  	def _info(msg)
         | 
| 14 | 
            -
            	  		puts
         | 
| 15 | 
            -
            	  		puts msg.blue
         | 
| 16 | 
            -
            	  		puts
         | 
| 17 | 
            -
            	  	end
         | 
| 18 | 
            -
             | 
| 19 | 
            -
            	  	def _ok
         | 
| 20 | 
            -
            	  		print "[ ".black
         | 
| 21 | 
            -
            	  		print "OK".green
         | 
| 22 | 
            -
            	  		print " ]".black
         | 
| 23 | 
            -
            	  		puts
         | 
| 24 | 
            -
            	  	end
         | 
| 25 | 
            -
             | 
| 26 | 
            -
            	  	def _error
         | 
| 27 | 
            -
            	  		print "[".black
         | 
| 28 | 
            -
            	  		print "FAIL".red
         | 
| 29 | 
            -
            	  		print "]".black
         | 
| 30 | 
            -
            	  		puts
         | 
| 31 | 
            -
            	  	end
         | 
| 32 | 
            -
            	  		
         | 
| 33 | 
            -
            	  	def _success
         | 
| 34 | 
            -
            	  		puts
         | 
| 35 | 
            -
            	  		print "=".black * 9
         | 
| 36 | 
            -
            	  		print " SUCCESS ".green
         | 
| 37 | 
            -
            	  		puts "=".black * 9
         | 
| 38 | 
            -
            	  		puts
         | 
| 39 | 
            -
            	  	end
         | 
| 40 | 
            -
             | 
| 41 | 
            -
            	  	def _fail
         | 
| 42 | 
            -
            	  		puts
         | 
| 43 | 
            -
            	  		print "=".black * 8
         | 
| 44 | 
            -
            	  		print " FAILED ".red
         | 
| 45 | 
            -
            	  		puts "=".black * 8
         | 
| 46 | 
            -
            	  		puts
         | 
| 47 | 
            -
            	  	end
         | 
| 48 | 
            -
             | 
| 49 | 
            -
            	  	def _start(msg)
         | 
| 50 | 
            -
            	  		puts
         | 
| 51 | 
            -
            	  		print "=".black * 3
         | 
| 52 | 
            -
            	  		print " " + msg.black + " "
         | 
| 53 | 
            -
            	  		puts "=".black * 3
         | 
| 54 | 
            -
            	  		puts
         | 
| 55 | 
            -
            	  	end
         | 
| 56 | 
            -
             | 
| 57 | 
            -
            	  	def _cmd(cmd)
         | 
| 58 | 
            -
            			pipe = IO.popen(cmd)
         | 
| 59 | 
            -
            			puts cmd.blue
         | 
| 60 | 
            -
            			while (line = pipe.gets)
         | 
| 61 | 
            -
            			  print line.black		
         | 
| 62 | 
            -
            			end
         | 
| 63 | 
            -
            	  	end
         | 
| 64 | 
            -
             | 
| 65 | 
            -
            	  	def _covadir
         | 
| 66 | 
            -
            			File.expand_path("~/.cova")
         | 
| 67 | 
            -
            	  	end
         | 
| 68 | 
            -
             | 
| 69 | 
            -
            	  	def _covamodsdir
         | 
| 70 | 
            -
            			user_home_dir = File.expand_path("~/.cocoapods/cova")
         | 
| 71 | 
            -
            	  	end
         | 
| 72 | 
            -
             | 
| 73 | 
            -
            	  	def _builddir
         | 
| 74 | 
            -
            			File.expand_path("~/Library/Developer/Xcode/DerivedData")
         | 
| 75 | 
            -
            	  	end
         | 
| 76 | 
            -
             | 
| 77 | 
            -
            	  	def _init
         | 
| 78 | 
            -
            		  	user_home_dir = File.expand_path("~")
         | 
| 79 | 
            -
            		  	cova_dir = user_home_dir + "/.cova"
         | 
| 80 | 
            -
            		  	cocoapods_cova_dir = user_home_dir + "/.cocoapods/cova"
         | 
| 81 | 
            -
             | 
| 82 | 
            -
            		  	_start "Initializing Cova"
         | 
| 83 | 
            -
             | 
| 84 | 
            -
            	  		if File.directory?(cova_dir)
         | 
| 85 | 
            -
            			  	_msg "Cleaning up previous installation"
         | 
| 86 | 
            -
            			  	FileUtils.rm_r cova_dir, :force => true	  	
         | 
| 87 | 
            -
            			  	if File.directory?(cova_dir)
         | 
| 88 | 
            -
            			  		_error
         | 
| 89 | 
            -
            		  			_fail
         | 
| 90 | 
            -
            			  		exit
         | 
| 91 | 
            -
            			  	else
         | 
| 92 | 
            -
            			  		_ok
         | 
| 93 | 
            -
            			  		if File.directory?(cocoapods_cova_dir)
         | 
| 94 | 
            -
            				  		_msg "Cleaning Cova Mods"
         | 
| 95 | 
            -
            				  		FileUtils.rm_r cocoapods_cova_dir
         | 
| 96 | 
            -
            				  		if File.directory?(cocoapods_cova_dir)
         | 
| 97 | 
            -
            				  			_error
         | 
| 98 | 
            -
            				  			_fail
         | 
| 99 | 
            -
            				  			exit
         | 
| 100 | 
            -
            				  		else
         | 
| 101 | 
            -
            				  			_ok
         | 
| 102 | 
            -
            				  		end
         | 
| 103 | 
            -
            				  	end	
         | 
| 104 | 
            -
            				end
         | 
| 105 | 
            -
            	  		end
         | 
| 106 | 
            -
             | 
| 107 | 
            -
            		  	_msg "Preparing to install Cova in #{cova_dir}"
         | 
| 108 | 
            -
            	  		FileUtils.mkdir cova_dir
         | 
| 109 | 
            -
            	  		if File.directory?(cova_dir)
         | 
| 110 | 
            -
            	  			_ok
         | 
| 111 | 
            -
            				FileUtils.cd cova_dir
         | 
| 112 | 
            -
              				_cmd ("git clone #{XCTOOL_REPO}")
         | 
| 113 | 
            -
              				if File.directory?(cova_dir + "/xctool")
         | 
| 114 | 
            -
            	  				_cmd ("git clone #{COVA_REPO}")
         | 
| 115 | 
            -
            	  				if File.directory?(cova_dir + "/cova")
         | 
| 116 | 
            -
            	  					_cmd "pod repo add cova #{COVA_MODS_REPO}"
         | 
| 117 | 
            -
            		  				if File.directory?(cocoapods_cova_dir)
         | 
| 118 | 
            -
            		  					status
         | 
| 119 | 
            -
            			  				_success
         | 
| 120 | 
            -
            			  				puts
         | 
| 121 | 
            -
            			  				puts "Congrats! Cove is now installed. Enjoy Cova and build the next great app sensation!".green
         | 
| 122 | 
            -
            			  				puts
         | 
| 123 | 
            -
            			  				puts "For more info visit the homepage: http://cova.io".black
         | 
| 124 | 
            -
            			  				puts
         | 
| 125 | 
            -
            		  				else
         | 
| 126 | 
            -
            			  				_msg "Could not create Cova Mods home"
         | 
| 127 | 
            -
            			  				_error
         | 
| 128 | 
            -
            			  				_error
         | 
| 129 | 
            -
            		  					exit
         | 
| 130 | 
            -
            		  				end
         | 
| 131 | 
            -
            		  			else
         | 
| 132 | 
            -
            		  				_msg "cova did not clone correctly"
         | 
| 133 | 
            -
            		  				_error
         | 
| 134 | 
            -
            						_fail
         | 
| 135 | 
            -
            		  				exit		  				
         | 
| 136 | 
            -
            		  			end
         | 
| 137 | 
            -
            	  			else
         | 
| 138 | 
            -
            	  				_msg "xctool did not clone correctly"
         | 
| 139 | 
            -
            	  				_error
         | 
| 140 | 
            -
            					_fail
         | 
| 141 | 
            -
            	  				exit
         | 
| 142 | 
            -
              				end	
         | 
| 143 | 
            -
            	  		else
         | 
| 144 | 
            -
            	  			_error
         | 
| 145 | 
            -
            	  			_fail
         | 
| 146 | 
            -
            	  			exit
         | 
| 147 | 
            -
            	  		end
         | 
| 148 | 
            -
            	  	end
         | 
| 149 | 
            -
             | 
| 150 | 
            -
            	  	def _build
         | 
| 151 | 
            -
            	  		_start "Building"
         | 
| 152 | 
            -
            	  		if File.exist?('cova.xcworkspace')
         | 
| 153 | 
            -
            				_cmd (_covadir + "/xctool/xctool.sh -workspace cova.xcworkspace -scheme cova -configuration Debug -sdk iphonesimulator")
         | 
| 154 | 
            -
            				_success
         | 
| 155 | 
            -
            			else
         | 
| 156 | 
            -
            				_msg "Expecting cova.xcworkspace"
         | 
| 157 | 
            -
            				_error
         | 
| 158 | 
            -
            				_fail
         | 
| 159 | 
            -
            				exit
         | 
| 160 | 
            -
            			end	
         | 
| 161 | 
            -
            	  	end
         | 
| 162 | 
            -
             | 
| 163 | 
            -
            	  	def _buildall
         | 
| 164 | 
            -
            			_start "Building with dependencies"
         | 
| 165 | 
            -
            	     	_msg "Looking for Podfile"
         | 
| 166 | 
            -
                	 	if File.exist?('Podfile')
         | 
| 167 | 
            -
                 			_ok
         | 
| 168 | 
            -
                 			_cmd "pod install"
         | 
| 169 | 
            -
                 			_build
         | 
| 170 | 
            -
            			else
         | 
| 171 | 
            -
            				_error
         | 
| 172 | 
            -
            				_msg "Expecting Podfile"
         | 
| 173 | 
            -
            				_error
         | 
| 174 | 
            -
            				_fail
         | 
| 175 | 
            -
            				exit
         | 
| 176 | 
            -
            			end	
         | 
| 177 | 
            -
            	  	end
         | 
| 178 | 
            -
             | 
| 179 | 
            -
            	  end
         | 
| 180 | 
            -
             | 
| 181 | 
            -
            	  desc 'status', 'Checks the status of a Cova installation'
         | 
| 182 | 
            -
            	  def status
         | 
| 183 | 
            -
            	  	_start "Checking if Cova is installed"
         | 
| 184 | 
            -
            	  	cova_dir = _covadir
         | 
| 185 | 
            -
            	  	if File.directory?(cova_dir)
         | 
| 186 | 
            -
            	  		_msg "Found Cova in #{cova_dir}"
         | 
| 187 | 
            -
            	  		_ok
         | 
| 188 | 
            -
            	  	else
         | 
| 189 | 
            -
            	  		puts "Expecting Cova in #{cova_dir} not found".red
         | 
| 190 | 
            -
            	  		_fail
         | 
| 191 | 
            -
            	  		return false
         | 
| 192 | 
            -
            	  	end
         | 
| 193 | 
            -
             | 
| 194 | 
            -
            	  	cova_mods_dir = _covamodsdir
         | 
| 195 | 
            -
            	  	if File.directory?(cova_mods_dir)
         | 
| 196 | 
            -
            	  		_msg "Found Cova Mods in #{cova_mods_dir}"
         | 
| 197 | 
            -
            	  		_ok
         | 
| 198 | 
            -
            	  		_success
         | 
| 199 | 
            -
            	  	else
         | 
| 200 | 
            -
            	  		puts "Expected Cova Mods in #{cova_mods_dir} not found".red
         | 
| 201 | 
            -
            	  		return false
         | 
| 202 | 
            -
            	  	end
         | 
| 203 | 
            -
             | 
| 204 | 
            -
            	  	return true
         | 
| 205 | 
            -
            	  end
         | 
| 206 | 
            -
             | 
| 207 | 
            -
            	  desc 'uninstall', 'Completely uninstalls Cova'
         | 
| 208 | 
            -
            	  def uninstall
         | 
| 209 | 
            -
             | 
| 210 | 
            -
            	  	_start "Uninstalling Cova"
         | 
| 211 | 
            -
             | 
| 212 | 
            -
            		cova_dir = _covadir
         | 
| 213 | 
            -
            		_msg "Removing Cova from #{cova_dir}"
         | 
| 214 | 
            -
            		FileUtils.rm_r cova_dir, :force => true
         | 
| 215 | 
            -
            	  	if File.directory?(cova_dir)
         | 
| 216 | 
            -
            	  		_error
         | 
| 217 | 
            -
            			_fail
         | 
| 218 | 
            -
            	  		exit
         | 
| 219 | 
            -
            	  	else
         | 
| 220 | 
            -
            	  		_ok
         | 
| 221 | 
            -
            	  	end
         | 
| 222 | 
            -
             | 
| 223 | 
            -
            	  	cova_mods_dir = _covamodsdir
         | 
| 224 | 
            -
            		_msg "Removing Cova Mods from #{cova_mods_dir}"
         | 
| 225 | 
            -
            		FileUtils.rm_r cova_mods_dir, :force => true	  		
         | 
| 226 | 
            -
            	  	if File.directory?(cova_mods_dir)
         | 
| 227 | 
            -
            	  		_error
         | 
| 228 | 
            -
            			_fail
         | 
| 229 | 
            -
            	  		exit
         | 
| 230 | 
            -
            	  	else
         | 
| 231 | 
            -
            	  		_ok
         | 
| 232 | 
            -
            		  	_success
         | 
| 233 | 
            -
            	  	end
         | 
| 234 | 
            -
            	  end
         | 
| 235 | 
            -
             | 
| 236 | 
            -
            	  desc 'install', 'Installs Cova from scratch'
         | 
| 237 | 
            -
            	  option :force, :type => :boolean, :aliases => :f
         | 
| 238 | 
            -
            	  def install
         | 
| 239 | 
            -
            	  	user_home_dir = File.expand_path("~")
         | 
| 240 | 
            -
            	  	cova_dir = user_home_dir + "/.cova"
         | 
| 241 | 
            -
             | 
| 242 | 
            -
            	  	if File.directory?(cova_dir)
         | 
| 243 | 
            -
            	  		if  options[:force]
         | 
| 244 | 
            -
            		  		_init
         | 
| 245 | 
            -
            		  	else
         | 
| 246 | 
            -
            		  		_info "Cova is already installed. Run install -f to force a re-install"		  		
         | 
| 247 | 
            -
            		  	end
         | 
| 248 | 
            -
            	  	else
         | 
| 249 | 
            -
            	  		_init
         | 
| 250 | 
            -
            	  	end
         | 
| 251 | 
            -
            	  end
         | 
| 252 | 
            -
             | 
| 253 | 
            -
                  desc 'create NAME', 'Creates a new Cova app'
         | 
| 254 | 
            -
            	  option :build, :type => :boolean, :aliases => :b
         | 
| 255 | 
            -
                  def create (name)
         | 
| 256 | 
            -
             | 
| 257 | 
            -
                  		_start "Creating app #{name}"
         | 
| 258 | 
            -
             | 
| 259 | 
            -
                  		if status
         | 
| 260 | 
            -
              				app_home = File.expand_path("./#{name}")
         | 
| 261 | 
            -
            				if File.directory?(app_home)
         | 
| 262 | 
            -
            					_msg "Cannot create directory #{app_home} as it already exists"
         | 
| 263 | 
            -
            					_error
         | 
| 264 | 
            -
            					_fail
         | 
| 265 | 
            -
            					exit
         | 
| 266 | 
            -
            				end
         | 
| 267 | 
            -
             | 
| 268 | 
            -
              				_msg "Creating app home in #{app_home}"
         | 
| 269 | 
            -
              				FileUtils.mkdir app_home
         | 
| 270 | 
            -
            				if File.directory?(app_home)
         | 
| 271 | 
            -
              					_ok
         | 
| 272 | 
            -
              					_msg "Adding Xcode project"
         | 
| 273 | 
            -
              					cova_dir = _covadir
         | 
| 274 | 
            -
             | 
| 275 | 
            -
              					FileUtils.cp_r cova_dir + "/cova/ios/xcode-template", app_home + "/ios"
         | 
| 276 | 
            -
              					if File.directory?(app_home + "/ios/cova")
         | 
| 277 | 
            -
            						_ok
         | 
| 278 | 
            -
            				      	 if  options[:build]
         | 
| 279 | 
            -
            				      		FileUtils.cd app_home + "/ios"
         | 
| 280 | 
            -
            							_buildall
         | 
| 281 | 
            -
             						 else
         | 
| 282 | 
            -
             					      	_success
         | 
| 283 | 
            -
             						 end
         | 
| 284 | 
            -
            					else
         | 
| 285 | 
            -
            						_error
         | 
| 286 | 
            -
            						_fail
         | 
| 287 | 
            -
            						_exit
         | 
| 288 | 
            -
            					end  						
         | 
| 289 | 
            -
              				else
         | 
| 290 | 
            -
              					_error
         | 
| 291 | 
            -
            					_fail
         | 
| 292 | 
            -
              					exit
         | 
| 293 | 
            -
              			    end
         | 
| 294 | 
            -
              			else
         | 
| 295 | 
            -
              				_msg "Cova not installed. Run install -f to install it"
         | 
| 296 | 
            -
              				_error
         | 
| 297 | 
            -
              				_fail
         | 
| 298 | 
            -
              				exit
         | 
| 299 | 
            -
              			end
         | 
| 300 | 
            -
                  end
         | 
| 301 | 
            -
             | 
| 302 | 
            -
                 desc 'build', 'Builds an existing Cova app'
         | 
| 303 | 
            -
            	 option :dependencies, :type => :boolean, :aliases => :d
         | 
| 304 | 
            -
                 def build
         | 
| 305 | 
            -
                 	if  options[:dependencies]
         | 
| 306 | 
            -
            	     	_buildall
         | 
| 307 | 
            -
            		else
         | 
| 308 | 
            -
            			_build
         | 
| 309 | 
            -
            		end
         | 
| 310 | 
            -
                 end
         | 
| 311 | 
            -
             | 
| 312 | 
            -
            end
         | 
| 1 | 
            +
            require 'rubygems'
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            require 'logger'
         | 
| 4 | 
            +
            require 'colorize'
         | 
| 5 | 
            +
            require 'fileutils'
         | 
| 6 | 
            +
            require 'thor'
         | 
| 7 | 
            +
            require 'cocoapods'
         | 
| 8 | 
            +
            require 'covalog'
         | 
| 9 | 
            +
            require 'covaio'
         | 
| 10 | 
            +
            require 'covamain'
         | 
| 11 | 
            +
             | 
| 12 | 
            +
            Cova.start
         | 
    
        data/lib/covaio.rb
    ADDED
    
    | @@ -0,0 +1,116 @@ | |
| 1 | 
            +
            module CovaIO
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            		def _io_init
         | 
| 4 | 
            +
            			@dir_user_home 			= File.expand_path("~")
         | 
| 5 | 
            +
            			@dir_cova_home 			= File.expand_path("~/.cova")
         | 
| 6 | 
            +
            			@dir_cova_mods_home 	= File.expand_path("~/.cocoapods/cova")
         | 
| 7 | 
            +
            			@dir_cocoapods_home 	= File.expand_path("~/.cocoapods")
         | 
| 8 | 
            +
            			@dir_xctool_home 		= File.expand_path("~/.cova/xctool")
         | 
| 9 | 
            +
            			@dir_xcode_build_home 	= File.expand_path("~/Library/Developer/Xcode/DerivedData")
         | 
| 10 | 
            +
            			@dir_cova_apps_home 	= File.expand_path("~/.cova/apps")
         | 
| 11 | 
            +
             | 
| 12 | 
            +
            			@repo_cova 				= "git://github.com/dancali/cova.git"
         | 
| 13 | 
            +
            			@repo_cova_mods			= "git://github.com/dancali/cova-mods.git"
         | 
| 14 | 
            +
            			@repo_xctool			= "git://github.com/facebook/xctool.git"
         | 
| 15 | 
            +
            		end
         | 
| 16 | 
            +
             | 
| 17 | 
            +
            		def _io_exec(cmd)
         | 
| 18 | 
            +
            			pipe = IO.popen(cmd)
         | 
| 19 | 
            +
            			puts cmd.blue
         | 
| 20 | 
            +
            			while (line = pipe.gets)
         | 
| 21 | 
            +
            			  print line.black		
         | 
| 22 | 
            +
            			end
         | 
| 23 | 
            +
            		end
         | 
| 24 | 
            +
             | 
| 25 | 
            +
            		def _io_exec_xctool(cmd="build", config="Debug", sdk="iphonesimulator")
         | 
| 26 | 
            +
            			_io_exec @dir_xctool_home + "/xctool.sh -workspace cova.xcworkspace -scheme cova -configuration #{config} -sdk #{sdk} #{cmd}"
         | 
| 27 | 
            +
            		end
         | 
| 28 | 
            +
             | 
| 29 | 
            +
            		def _io_pod_add_repo(name, repo)
         | 
| 30 | 
            +
            			_io_exec("pod repo add #{name} #{repo}")
         | 
| 31 | 
            +
            			return _io_isdir(@dir_cocoapods_home + "/" + name)
         | 
| 32 | 
            +
            		end
         | 
| 33 | 
            +
             | 
| 34 | 
            +
            		def _io_isdir(dir,expected=true)
         | 
| 35 | 
            +
            			_log_line (expected ? "Expecting #{dir} to exist" : "Ensuring #{dir} does not exist")
         | 
| 36 | 
            +
            			if File.directory?(dir)
         | 
| 37 | 
            +
            				expected ? _log_line_ok : _log_line_error
         | 
| 38 | 
            +
            		  		return true
         | 
| 39 | 
            +
            		  	end		  	
         | 
| 40 | 
            +
             | 
| 41 | 
            +
            		  	if expected
         | 
| 42 | 
            +
            			  	_log_line_error
         | 
| 43 | 
            +
            			else
         | 
| 44 | 
            +
            				_log_line_ok
         | 
| 45 | 
            +
            			end
         | 
| 46 | 
            +
            		  	return false
         | 
| 47 | 
            +
            		end
         | 
| 48 | 
            +
             | 
| 49 | 
            +
            		def _io_isfile(file,expected=true)
         | 
| 50 | 
            +
            			_log_line (expected ? "Expecting #{file} to exist" : "Ensuring #{file} does not exist")
         | 
| 51 | 
            +
            			if File.exist?(file)
         | 
| 52 | 
            +
            				expected ? _log_line_ok : _log_line_error
         | 
| 53 | 
            +
            		  		return true
         | 
| 54 | 
            +
            		  	end		  	
         | 
| 55 | 
            +
             | 
| 56 | 
            +
            		  	if expected
         | 
| 57 | 
            +
            			  	_log_line_error
         | 
| 58 | 
            +
            			else
         | 
| 59 | 
            +
            				_log_line_ok
         | 
| 60 | 
            +
            			end
         | 
| 61 | 
            +
            		  	return false
         | 
| 62 | 
            +
            		end
         | 
| 63 | 
            +
             | 
| 64 | 
            +
            		def _io_app_exists(name)
         | 
| 65 | 
            +
            			return File.directory?(@dir_cova_apps_home + "/" + name)
         | 
| 66 | 
            +
            		end
         | 
| 67 | 
            +
             | 
| 68 | 
            +
            		def _io_ls(dir)
         | 
| 69 | 
            +
            			Dir.foreach(dir) {|entry| puts "#{entry}" unless (entry =='.' || entry == '..') }
         | 
| 70 | 
            +
            		end
         | 
| 71 | 
            +
             | 
| 72 | 
            +
            		def _io_clone_repo (repo, dir)
         | 
| 73 | 
            +
            			pwd = Dir.pwd
         | 
| 74 | 
            +
            			Dir.chdir(dir)
         | 
| 75 | 
            +
            			_io_exec "git clone #{repo}"
         | 
| 76 | 
            +
            			Dir.chdir(pwd)
         | 
| 77 | 
            +
            			return _io_isdir(dir + "/" + File.basename(repo, ".*"))
         | 
| 78 | 
            +
            		end
         | 
| 79 | 
            +
             | 
| 80 | 
            +
            		def _io_rmdir(dir)
         | 
| 81 | 
            +
            			_log_line "Removing #{dir}"
         | 
| 82 | 
            +
            			if File.directory?(dir)
         | 
| 83 | 
            +
            				`rm -rf #{dir}`
         | 
| 84 | 
            +
            			  	if File.directory?(dir)
         | 
| 85 | 
            +
            			  		_log_line_error
         | 
| 86 | 
            +
            			  		return false
         | 
| 87 | 
            +
            				end
         | 
| 88 | 
            +
            			end
         | 
| 89 | 
            +
            			_log_line_ok
         | 
| 90 | 
            +
            			return true
         | 
| 91 | 
            +
            		end
         | 
| 92 | 
            +
             | 
| 93 | 
            +
            		def _io_lndir(src, targ)
         | 
| 94 | 
            +
            			if _io_isdir src and not _io_isdir targ, false
         | 
| 95 | 
            +
            				`ln -s #{src} #{targ}`
         | 
| 96 | 
            +
            				return _io_isdir targ
         | 
| 97 | 
            +
            			end
         | 
| 98 | 
            +
             | 
| 99 | 
            +
            			return false
         | 
| 100 | 
            +
            		end
         | 
| 101 | 
            +
             | 
| 102 | 
            +
            		def _io_cpdir(src, targ)
         | 
| 103 | 
            +
            			if _io_isdir src and not _io_isdir targ, false
         | 
| 104 | 
            +
            				`cp -r #{src} #{targ}`
         | 
| 105 | 
            +
            				return _io_isdir targ
         | 
| 106 | 
            +
            			end
         | 
| 107 | 
            +
            			return false
         | 
| 108 | 
            +
            		end
         | 
| 109 | 
            +
             | 
| 110 | 
            +
            		def _io_mkdir(dir)
         | 
| 111 | 
            +
            			_log_line "Creating #{dir}"
         | 
| 112 | 
            +
            			`mkdir #{dir}`
         | 
| 113 | 
            +
            			File.directory?(dir) ? _log_line_ok : _log_line_error
         | 
| 114 | 
            +
            			return File.directory?(dir)
         | 
| 115 | 
            +
            		end
         | 
| 116 | 
            +
            end
         | 
    
        data/lib/covalog.rb
    ADDED
    
    | @@ -0,0 +1,50 @@ | |
| 1 | 
            +
            module CovaLog
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            	def _log_line(msg)
         | 
| 4 | 
            +
            		print msg.black + "  ...  "
         | 
| 5 | 
            +
            	end
         | 
| 6 | 
            +
             | 
| 7 | 
            +
            	def _log_line_ok
         | 
| 8 | 
            +
            		print "[ ".black
         | 
| 9 | 
            +
            		print "OK".green
         | 
| 10 | 
            +
            		print " ]".black
         | 
| 11 | 
            +
            		puts
         | 
| 12 | 
            +
            	end
         | 
| 13 | 
            +
             | 
| 14 | 
            +
            	def _log_line_error
         | 
| 15 | 
            +
            		print "[".black
         | 
| 16 | 
            +
            		print "FAIL".red
         | 
| 17 | 
            +
            		print "]".black
         | 
| 18 | 
            +
            		puts
         | 
| 19 | 
            +
            	end
         | 
| 20 | 
            +
            		
         | 
| 21 | 
            +
            	def _log_info(msg)
         | 
| 22 | 
            +
            		puts
         | 
| 23 | 
            +
            		puts msg.blue
         | 
| 24 | 
            +
            		puts
         | 
| 25 | 
            +
            	end
         | 
| 26 | 
            +
             | 
| 27 | 
            +
            	def _log_block_start(msg)
         | 
| 28 | 
            +
            		puts
         | 
| 29 | 
            +
            		print "=".black * 3
         | 
| 30 | 
            +
            		print " " + msg.black + " "
         | 
| 31 | 
            +
            		puts "=".black * 3
         | 
| 32 | 
            +
            		puts
         | 
| 33 | 
            +
            	end
         | 
| 34 | 
            +
             | 
| 35 | 
            +
            	def _log_block_success
         | 
| 36 | 
            +
            		puts
         | 
| 37 | 
            +
            		print "=".black * 9
         | 
| 38 | 
            +
            		print " SUCCESS ".green
         | 
| 39 | 
            +
            		puts "=".black * 9
         | 
| 40 | 
            +
            		puts
         | 
| 41 | 
            +
            	end
         | 
| 42 | 
            +
             | 
| 43 | 
            +
            	def _log_block_error
         | 
| 44 | 
            +
            		puts
         | 
| 45 | 
            +
            		print "=".black * 8
         | 
| 46 | 
            +
            		print " FAILED ".red
         | 
| 47 | 
            +
            		puts "=".black * 8
         | 
| 48 | 
            +
            		puts
         | 
| 49 | 
            +
            	end
         | 
| 50 | 
            +
            end
         | 
    
        data/lib/covamain.rb
    ADDED
    
    | @@ -0,0 +1,176 @@ | |
| 1 | 
            +
            class Cova < Thor
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            	include CovaLog
         | 
| 4 | 
            +
            	include CovaIO
         | 
| 5 | 
            +
             | 
| 6 | 
            +
            	def initialize(*args)
         | 
| 7 | 
            +
            	  super
         | 
| 8 | 
            +
            	  _io_init
         | 
| 9 | 
            +
            	end
         | 
| 10 | 
            +
             | 
| 11 | 
            +
            	desc 'status', 'Checks the status of a Cova installation'
         | 
| 12 | 
            +
            	def status
         | 
| 13 | 
            +
            	   _log_block_start "Checking if Cova is installed"
         | 
| 14 | 
            +
            	   if _io_isdir(@dir_cova_home) and _io_isdir(@dir_cova_mods_home)
         | 
| 15 | 
            +
            	   		_log_block_success
         | 
| 16 | 
            +
            	   		return true
         | 
| 17 | 
            +
            	   end
         | 
| 18 | 
            +
            	   _log_block_error
         | 
| 19 | 
            +
            	   _cova_prompt_install
         | 
| 20 | 
            +
            	   return false
         | 
| 21 | 
            +
            	end
         | 
| 22 | 
            +
             | 
| 23 | 
            +
            	desc 'uninstall', 'Completely uninstalls Cova'
         | 
| 24 | 
            +
            	def uninstall
         | 
| 25 | 
            +
            	   _log_block_start "Uninstalling Cova"
         | 
| 26 | 
            +
            	   _io_rmdir(@dir_cova_home)
         | 
| 27 | 
            +
            	   _io_rmdir(@dir_cova_mods_home)
         | 
| 28 | 
            +
            	   if _io_isdir(@dir_cova_home, false) or _io_isdir(@dir_cova_mods_home, false)
         | 
| 29 | 
            +
            	   		_log_block_error
         | 
| 30 | 
            +
            	   		return false
         | 
| 31 | 
            +
            	   end
         | 
| 32 | 
            +
            	   _log_block_success
         | 
| 33 | 
            +
            	   return true
         | 
| 34 | 
            +
            	end
         | 
| 35 | 
            +
             | 
| 36 | 
            +
            	desc 'install', 'Installs Cova from scratch'
         | 
| 37 | 
            +
            	def install
         | 
| 38 | 
            +
            	  _log_block_start "Installing Cova"
         | 
| 39 | 
            +
             | 
| 40 | 
            +
            	  if _io_isdir(@dir_cova_home, false) or _io_isdir(@dir_cova_mods_home, false)
         | 
| 41 | 
            +
            		  _log_info "It looks like Cova is already installed. Please uninstall it first before installing again."	  	 
         | 
| 42 | 
            +
            		  _log_block_error
         | 
| 43 | 
            +
            		  return false
         | 
| 44 | 
            +
            	  end
         | 
| 45 | 
            +
             | 
| 46 | 
            +
            	  if _io_mkdir @dir_cova_home and _io_mkdir @dir_cova_apps_home
         | 
| 47 | 
            +
            	  	  if _io_clone_repo @repo_xctool, @dir_cova_home and _io_clone_repo @repo_cova, @dir_cova_home
         | 
| 48 | 
            +
            	  	  	  _io_pod_add_repo "cova", @repo_cova_mods
         | 
| 49 | 
            +
            		  	  _log_block_success
         | 
| 50 | 
            +
            		  	  puts
         | 
| 51 | 
            +
              			  puts "Congrats! Cove is now installed. Enjoy and build the next great app sensation!".green
         | 
| 52 | 
            +
              			  puts
         | 
| 53 | 
            +
              			  puts "For more info check out http://cova.io".black
         | 
| 54 | 
            +
              			  puts
         | 
| 55 | 
            +
            		  	  return true
         | 
| 56 | 
            +
            		  end
         | 
| 57 | 
            +
            	  end
         | 
| 58 | 
            +
             | 
| 59 | 
            +
            	  _log_block_error
         | 
| 60 | 
            +
            	  return false
         | 
| 61 | 
            +
            	end
         | 
| 62 | 
            +
             | 
| 63 | 
            +
            	desc 'list', 'List all exisiting apps'
         | 
| 64 | 
            +
            	def list
         | 
| 65 | 
            +
            		if not _cova_installed
         | 
| 66 | 
            +
            			_cova_prompt_install
         | 
| 67 | 
            +
            			return false
         | 
| 68 | 
            +
            		end
         | 
| 69 | 
            +
             | 
| 70 | 
            +
            		_io_ls @dir_cova_apps_home
         | 
| 71 | 
            +
            		return true
         | 
| 72 | 
            +
                end
         | 
| 73 | 
            +
             | 
| 74 | 
            +
            	desc 'find NAME', 'Looks for an app'
         | 
| 75 | 
            +
            	def find(name)
         | 
| 76 | 
            +
            		if not _cova_installed
         | 
| 77 | 
            +
            			_cova_prompt_install
         | 
| 78 | 
            +
            			return false
         | 
| 79 | 
            +
            		end
         | 
| 80 | 
            +
             | 
| 81 | 
            +
            		_log_line "Searching for app #{name}"
         | 
| 82 | 
            +
            		if _io_app_exists name
         | 
| 83 | 
            +
            			_log_line_ok
         | 
| 84 | 
            +
            			return true
         | 
| 85 | 
            +
            		end
         | 
| 86 | 
            +
             | 
| 87 | 
            +
            		_log_line_error
         | 
| 88 | 
            +
            		return false
         | 
| 89 | 
            +
                end
         | 
| 90 | 
            +
             | 
| 91 | 
            +
            	desc 'create [-b] NAME', 'Creates a new Cova app (-b to build it including tests)'
         | 
| 92 | 
            +
            	option :build, :type => :boolean, :aliases => :b
         | 
| 93 | 
            +
                def create (name)
         | 
| 94 | 
            +
             | 
| 95 | 
            +
            		if not _cova_installed
         | 
| 96 | 
            +
            			_cova_prompt_install
         | 
| 97 | 
            +
            			return false
         | 
| 98 | 
            +
            		end
         | 
| 99 | 
            +
             | 
| 100 | 
            +
                  	appname = name.strip.delete(' ')
         | 
| 101 | 
            +
                  	_log_block_start "Creating Cova app #{appname}"
         | 
| 102 | 
            +
                  	dir = Dir.pwd + "/" + appname
         | 
| 103 | 
            +
             | 
| 104 | 
            +
                  	if _io_isdir dir, false or _io_app_exists appname or not _io_mkdir dir or not _io_lndir dir, @dir_cova_apps_home + "/" + appname
         | 
| 105 | 
            +
                  		_log_block_error
         | 
| 106 | 
            +
                  		return false
         | 
| 107 | 
            +
                  	end
         | 
| 108 | 
            +
             | 
| 109 | 
            +
                  	if _io_cpdir @dir_cova_home + "/cova/ios/xcode-template", dir + "/ios"
         | 
| 110 | 
            +
                  		if options[:build]
         | 
| 111 | 
            +
            		    	Dir.chdir(@dir_cova_apps_home + "/" + name + "/ios")
         | 
| 112 | 
            +
            		     	if not _cova_build_dependencies
         | 
| 113 | 
            +
            		     		_log_line "Attempted to build the app dependencies"
         | 
| 114 | 
            +
            		     		_log_line_error
         | 
| 115 | 
            +
            	    	 		return false
         | 
| 116 | 
            +
            	     		end
         | 
| 117 | 
            +
                  			
         | 
| 118 | 
            +
            				_io_exec_xctool "test"
         | 
| 119 | 
            +
                  			return true
         | 
| 120 | 
            +
                  		end
         | 
| 121 | 
            +
             | 
| 122 | 
            +
                	  	_log_block_success
         | 
| 123 | 
            +
            	      	return true
         | 
| 124 | 
            +
                  	end
         | 
| 125 | 
            +
             | 
| 126 | 
            +
            		_log_block_error
         | 
| 127 | 
            +
                  	return false
         | 
| 128 | 
            +
                end
         | 
| 129 | 
            +
             | 
| 130 | 
            +
                desc 'build [-d][-t] NAME', 'Builds an app (-d to build dependencies, -t to build and run tests)'
         | 
| 131 | 
            +
            	option :dependencies, :type => :boolean, :aliases => :d
         | 
| 132 | 
            +
            	option :tests, :type => :boolean, :aliases => :t
         | 
| 133 | 
            +
                def build (name)
         | 
| 134 | 
            +
                	if not _cova_installed
         | 
| 135 | 
            +
            			_cova_prompt_install
         | 
| 136 | 
            +
            			return false
         | 
| 137 | 
            +
            		end
         | 
| 138 | 
            +
             | 
| 139 | 
            +
                	if not _io_app_exists name
         | 
| 140 | 
            +
                		_log_line "App #{name} does not exist"
         | 
| 141 | 
            +
                		_log_line_error
         | 
| 142 | 
            +
                		return false
         | 
| 143 | 
            +
                	end
         | 
| 144 | 
            +
             | 
| 145 | 
            +
                	Dir.chdir(@dir_cova_apps_home + "/" + name + "/ios")
         | 
| 146 | 
            +
            		_log_block_start "Building app #{name}"
         | 
| 147 | 
            +
                 	if options[:dependencies] or not _io_isfile "cova.xcworkspace" or not _io_isdir "Pods"
         | 
| 148 | 
            +
            	     	if not _cova_build_dependencies
         | 
| 149 | 
            +
            	     		_log_block_error
         | 
| 150 | 
            +
            	     		return false
         | 
| 151 | 
            +
            	     	end
         | 
| 152 | 
            +
            		end
         | 
| 153 | 
            +
             | 
| 154 | 
            +
            		_io_exec_xctool (options[:tests] ? "test" : "build")
         | 
| 155 | 
            +
                end
         | 
| 156 | 
            +
             | 
| 157 | 
            +
                no_commands do
         | 
| 158 | 
            +
             | 
| 159 | 
            +
                	def _cova_prompt_install
         | 
| 160 | 
            +
            		   _log_info "Looks like Cova is not installed yet. Please run [cova install] now"
         | 
| 161 | 
            +
                	end
         | 
| 162 | 
            +
             | 
| 163 | 
            +
                	def _cova_installed
         | 
| 164 | 
            +
                		return (File.directory?(@dir_cova_home) and File.directory?(@dir_cova_mods_home))
         | 
| 165 | 
            +
                	end
         | 
| 166 | 
            +
             | 
| 167 | 
            +
                	def _cova_build_dependencies
         | 
| 168 | 
            +
            			if not _io_isfile "Podfile"
         | 
| 169 | 
            +
            				return false
         | 
| 170 | 
            +
            			end
         | 
| 171 | 
            +
             | 
| 172 | 
            +
            			_io_exec "pod install"
         | 
| 173 | 
            +
            	     	return (_io_isfile "cova.xcworkspace" and _io_isdir "Pods")
         | 
| 174 | 
            +
                	end
         | 
| 175 | 
            +
            	end
         | 
| 176 | 
            +
            end
         | 
    
        metadata
    CHANGED
    
    | @@ -1,13 +1,13 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification 
         | 
| 2 2 | 
             
            name: cova
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version 
         | 
| 4 | 
            -
              hash:  | 
| 4 | 
            +
              hash: 25
         | 
| 5 5 | 
             
              prerelease: 
         | 
| 6 6 | 
             
              segments: 
         | 
| 7 7 | 
             
              - 0
         | 
| 8 8 | 
             
              - 1
         | 
| 9 | 
            -
              -  | 
| 10 | 
            -
              version: 0.1. | 
| 9 | 
            +
              - 1
         | 
| 10 | 
            +
              version: 0.1.1
         | 
| 11 11 | 
             
            platform: ruby
         | 
| 12 12 | 
             
            authors: 
         | 
| 13 13 | 
             
            - Dan Calinescu
         | 
| @@ -15,10 +15,10 @@ autorequire: | |
| 15 15 | 
             
            bindir: bin
         | 
| 16 16 | 
             
            cert_chain: []
         | 
| 17 17 |  | 
| 18 | 
            -
            date: 2013-05- | 
| 18 | 
            +
            date: 2013-05-26 00:00:00 Z
         | 
| 19 19 | 
             
            dependencies: 
         | 
| 20 20 | 
             
            - !ruby/object:Gem::Dependency 
         | 
| 21 | 
            -
              name:  | 
| 21 | 
            +
              name: logger
         | 
| 22 22 | 
             
              prerelease: false
         | 
| 23 23 | 
             
              requirement: &id001 !ruby/object:Gem::Requirement 
         | 
| 24 24 | 
             
                none: false
         | 
| @@ -46,7 +46,7 @@ dependencies: | |
| 46 46 | 
             
              type: :runtime
         | 
| 47 47 | 
             
              version_requirements: *id002
         | 
| 48 48 | 
             
            - !ruby/object:Gem::Dependency 
         | 
| 49 | 
            -
              name:  | 
| 49 | 
            +
              name: colorize
         | 
| 50 50 | 
             
              prerelease: false
         | 
| 51 51 | 
             
              requirement: &id003 !ruby/object:Gem::Requirement 
         | 
| 52 52 | 
             
                none: false
         | 
| @@ -60,7 +60,7 @@ dependencies: | |
| 60 60 | 
             
              type: :runtime
         | 
| 61 61 | 
             
              version_requirements: *id003
         | 
| 62 62 | 
             
            - !ruby/object:Gem::Dependency 
         | 
| 63 | 
            -
              name:  | 
| 63 | 
            +
              name: xcodeproj
         | 
| 64 64 | 
             
              prerelease: false
         | 
| 65 65 | 
             
              requirement: &id004 !ruby/object:Gem::Requirement 
         | 
| 66 66 | 
             
                none: false
         | 
| @@ -83,6 +83,9 @@ extra_rdoc_files: [] | |
| 83 83 |  | 
| 84 84 | 
             
            files: 
         | 
| 85 85 | 
             
            - lib/cova.rb
         | 
| 86 | 
            +
            - lib/covaio.rb
         | 
| 87 | 
            +
            - lib/covalog.rb
         | 
| 88 | 
            +
            - lib/covamain.rb
         | 
| 86 89 | 
             
            - bin/cova
         | 
| 87 90 | 
             
            homepage: http://cova.io
         | 
| 88 91 | 
             
            licenses: 
         |