Commit eed0a91f authored by Eloy Duran's avatar Eloy Duran

Add simple command executer.

parent 71fc2bbf
* Check exit statuses of commands performed and raise when necessary.
......@@ -2,7 +2,7 @@
dependency 'SSZipArchive', '>= 1'
#dependency 'ASIHTTPRequest', '1.8'
#dependency 'ASIWebPageRequest', '= 1.8'
dependency 'ASIWebPageRequest', '= 1.8'
# is part of ASIHTTPRequest 1.8 and 1.8.1
dependency 'Reachability' #, '>= 2.0'
......
......@@ -6,6 +6,7 @@ module Pod
autoload :Config, 'cocoa_pods/config'
autoload :Dependency, 'cocoa_pods/dependency'
autoload :Downloader, 'cocoa_pods/downloader'
autoload :Executable, 'cocoa_pods/executable'
autoload :Installer, 'cocoa_pods/installer'
autoload :Resolver, 'cocoa_pods/resolver'
autoload :Source, 'cocoa_pods/source'
......@@ -19,7 +20,6 @@ module Pod
end
autoload :Pathname, 'pathname'
autoload :Executioner, 'executioner'
end
class Pathname
......
......@@ -40,6 +40,7 @@ module Pod
def self.options
" --help Show help information\n" +
" --silent Print nothing\n" +
" --verbose Print more information while working"
end
......@@ -59,6 +60,7 @@ module Pod
def self.parse(*argv)
argv = ARGV.new(argv)
show_help = argv.option('--help')
Config.instance.silent = argv.option('--silent')
Config.instance.verbose = argv.option('--verbose')
command_class = case argv.shift_argument
......
require 'executioner'
require 'fileutils'
module Pod
......@@ -23,7 +22,7 @@ module Pod
Changes the current working dir to the local spec-repo `NAME'.}
end
include Executioner
extend Executable
executable :git
def initialize(argv)
......
......@@ -16,11 +16,7 @@ module Pod
end
class Git < Downloader
require 'executioner'
include Executioner
# TODO make Executioner:
# * not raise when there's output to either stdout/stderr, but check exit status
# * sync output
extend Executable
executable :git
def download
......@@ -38,16 +34,16 @@ module Pod
Dir.chdir(@pod_root) do
git "init"
git "remote add origin '#{@url}'"
git "fetch origin tags/#{@options[:tag]} 2>&1"
git "fetch origin tags/#{@options[:tag]}"
git "reset --hard FETCH_HEAD"
git "checkout -b activated-pod-commit 2>&1"
git "checkout -b activated-pod-commit"
end
end
def download_commit
git "clone '#{@url}' '#{@pod_root}'"
Dir.chdir(@pod_root) do
git "checkout -b activated-pod-commit #{@options[:commit]} 2>&1"
git "checkout -b activated-pod-commit #{@options[:commit]}"
end
end
......
module Pod
module Executable
def executable(name)
define_method(name) do |command|
if Config.instance.verbose?
`#{name} #{command} 1>&2`
else
`#{name} #{command} 2> /dev/null`
end
end
end
end
end
require 'spec_helper/temporary_directory'
require 'executioner'
module SpecHelper
def self.tmp_repos_path
......@@ -16,7 +15,7 @@ module SpecHelper
tmp_repos_path + 'master'
end
include Executioner
extend Pod::Executable
executable :git
alias_method :git_super, :git
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment