Permalink
Browse files

Add simple command executer.

  • Loading branch information...
1 parent 71fc2bb commit eed0a91fcb3396016b186814cb92ae5025da078d @alloy alloy committed Sep 17, 2011
View
1 TODO
@@ -0,0 +1 @@
+* Check exit statuses of commands performed and raise when necessary.
View
@@ -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'
View
@@ -6,6 +6,7 @@ class Informative < StandardError
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 Xcode
end
autoload :Pathname, 'pathname'
- autoload :Executioner, 'executioner'
end
class Pathname
@@ -40,6 +40,7 @@ def self.banner
def self.options
" --help Show help information\n" +
+ " --silent Print nothing\n" +
" --verbose Print more information while working"
end
@@ -59,6 +60,7 @@ def self.run(*argv)
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
@@ -1,4 +1,3 @@
-require 'executioner'
require 'fileutils'
module Pod
@@ -23,7 +22,7 @@ def self.banner
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 @@ def initialize(pod_root, url, options)
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 @@ def download_tag
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
@@ -0,0 +1,13 @@
+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
View
@@ -1,5 +1,4 @@
require 'spec_helper/temporary_directory'
-require 'executioner'
module SpecHelper
def self.tmp_repos_path
@@ -16,7 +15,7 @@ def tmp_master_repo_path
tmp_repos_path + 'master'
end
- include Executioner
+ extend Pod::Executable
executable :git
alias_method :git_super, :git

0 comments on commit eed0a91

Please sign in to comment.