forked from CocoaPods/cocoapods-downloader
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRakefile
136 lines (113 loc) · 3.61 KB
/
Rakefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
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
# Bootstrap
#-----------------------------------------------------------------------------#
desc 'Initializes your working copy to run the specs'
task :bootstrap do
if system('which bundle')
title 'Installing gems'
`bundle install`
else
$stderr.puts "\033[0;31m" \
"[!] Please install the bundler gem manually:\n" \
" $ [sudo] gem install bundler" \
"\e[0m"
exit 1
end
end
begin
require 'bundler/gem_tasks'
task :default => :spec
# Spec
#-----------------------------------------------------------------------------#
desc 'Run specs'
task :spec => 'fixtures:unpack_fixture_tarballs' do
title 'Running Unit Tests'
files = FileList['spec/**/*_spec.rb'].shuffle.join(' ')
sh "bundle exec bacon #{files}"
Rake::Task['rubocop'].invoke
end
# Fixtures
#-----------------------------------------------------------------------------#
namespace :fixtures do
desc 'Rebuild all the fixture tarballs'
task :rebuild_fixture_tarballs do
title 'Rebuilding fixtures'
tarballs = FileList['spec/fixtures/**/*.tar.gz']
tarballs.each do |tarball|
basename = File.basename(tarball)
sh "cd #{File.dirname(tarball)} && rm #{basename} && env COPYFILE_DISABLE=1 tar -zcf #{basename} #{basename[0..-8]}"
end
end
desc 'Unpacks all the fixture tarballs'
task :unpack_fixture_tarballs do
title 'Unpacking fixtures'
tarballs = FileList['spec/fixtures/**/*.tar.gz']
tarballs.each do |tarball|
basename = File.basename(tarball)
Dir.chdir(File.dirname(tarball)) do
sh "rm -rf #{basename[0..-8]} && tar zxf #{basename}"
end
end
end
desc 'Removes the stored VCR fixture'
task :clean_vcr do
sh 'rm -f spec/fixtures/vcr/tarballs.yml'
end
end
# Travis
#-----------------------------------------------------------------------------#
namespace :travis do
task :setup do
title 'Configuring Travis'
sh 'sudo apt-get install subversion'
sh "env CFLAGS='-I#{rvm_ruby_dir}/include' bundle install --without debugging documentation"
if ENV['TRAVIS']
sh "git config --global user.name 'CI'"
sh "git config --global user.email '[email protected]'"
end
end
end
def rvm_ruby_dir
@rvm_ruby_dir ||= File.expand_path('../..', `which ruby`.strip)
end
# Print options
#-----------------------------------------------------------------------------#
desc 'Print the options of the various downloaders'
task :print_options do
title 'Downloaders options'
$LOAD_PATH.unshift File.expand_path('../lib', __FILE__)
require 'cocoapods-downloader'
include Pod::Downloader
Pod::Downloader.downloader_class_by_key.each do |key, klass|
puts "#{key}: #{klass.options * ', '}"
end
end
# Rubocop
#-----------------------------------------------------------------------------#
desc 'Checks code style'
task :rubocop do
title 'Checking code style'
if RUBY_VERSION >= '1.9.3'
require 'rubocop'
cli = Rubocop::CLI.new
result = cli.run
abort('RuboCop failed!') unless result == 0
else
puts '[!] Ruby > 1.9 is required to run style checks'
end
end
rescue LoadError
$stderr.puts "\033[0;31m" \
'[!] Some Rake tasks haven been disabled because the environment' \
' couldn’t be loaded. Be sure to run `rake bootstrap` first.' \
"\e[0m"
end
# Helpers
#-----------------------------------------------------------------------------#
def title(title)
cyan_title = "\033[0;36m#{title}\033[0m"
puts
puts '-' * 80
puts cyan_title
puts '-' * 80
puts
end