|
1 | | -task :build do |
2 | | - title "Building the gem" |
3 | | -end |
4 | | - |
5 | | -require "bundler/gem_tasks" |
6 | | - |
7 | 1 | # Bootstrap task |
8 | 2 | #-----------------------------------------------------------------------------# |
9 | 3 |
|
10 | 4 | desc 'Install dependencies' |
11 | 5 | task :bootstrap do |
12 | | - sh "bundle install" |
| 6 | + if system('which bundle') |
| 7 | + sh "bundle install" |
| 8 | + else |
| 9 | + $stderr.puts red("[!] Please install the bundler gem manually:\n" \ |
| 10 | + ' $ [sudo] gem install bundler') |
| 11 | + exit 1 |
| 12 | + end |
13 | 13 | end |
14 | 14 |
|
| 15 | +begin |
15 | 16 |
|
16 | | -# Release tasks |
17 | | -#-----------------------------------------------------------------------------# |
18 | | - |
19 | | -desc "Build the gem for distribution" |
20 | | -task :release_build => ['ext:clean', 'ext:precompile', :build] |
| 17 | + task :build do |
| 18 | + title "Building the gem" |
| 19 | + end |
21 | 20 |
|
22 | | -desc "Runs the tasks necessary for the release of the gem" |
23 | | -task :pre_release do |
24 | | - title "Running pre-release tasks" |
25 | | - tmp = File.expand_path('../tmp', __FILE__) |
26 | | - sh "rm -rf '#{tmp}'" |
27 | | - Rake::Task[:release_build].invoke |
28 | | -end |
| 21 | + require "bundler/gem_tasks" |
29 | 22 |
|
30 | | -# Always prebuilt for gems! |
31 | | -Rake::Task[:build].enhance [:pre_release] |
| 23 | + # Release tasks |
| 24 | + #-----------------------------------------------------------------------------# |
32 | 25 |
|
33 | | -# Ext Namespace |
34 | | -#-----------------------------------------------------------------------------# |
| 26 | + desc "Build the gem for distribution" |
| 27 | + task :release_build => ['ext:clean', 'ext:precompile', :build] |
35 | 28 |
|
36 | | -namespace :ext do |
37 | | - desc "Clean the ext files" |
38 | | - task :clean do |
39 | | - title "Cleaning extension" |
40 | | - sh "cd ext/xcodeproj && rm -f Makefile *.o *.bundle prebuilt/**/*.o prebuilt/**/*.bundle" |
| 29 | + desc "Runs the tasks necessary for the release of the gem" |
| 30 | + task :pre_release do |
| 31 | + title "Running pre-release tasks" |
| 32 | + tmp = File.expand_path('../tmp', __FILE__) |
| 33 | + sh "rm -rf '#{tmp}'" |
| 34 | + Rake::Task[:release_build].invoke |
41 | 35 | end |
42 | 36 |
|
43 | | - desc "Build the ext" |
44 | | - task :build do |
45 | | - title "Building the extension" |
46 | | - Dir.chdir 'ext/xcodeproj' do |
47 | | - if on_rvm? |
48 | | - sh "CFLAGS='-I#{rvm_ruby_dir}/include' ruby extconf.rb" |
49 | | - else |
50 | | - sh "ruby extconf.rb" |
51 | | - end |
52 | | - sh "make" |
| 37 | + # Always prebuilt for gems! |
| 38 | + Rake::Task[:build].enhance [:pre_release] |
| 39 | + |
| 40 | + # Ext Namespace |
| 41 | + #-----------------------------------------------------------------------------# |
| 42 | + |
| 43 | + namespace :ext do |
| 44 | + desc "Clean the ext files" |
| 45 | + task :clean do |
| 46 | + title "Cleaning extension" |
| 47 | + sh "cd ext/xcodeproj && rm -f Makefile *.o *.bundle prebuilt/**/*.o prebuilt/**/*.bundle" |
53 | 48 | end |
54 | | - end |
55 | 49 |
|
56 | | - desc "Pre-compile the ext for default Ruby on 10.8 and 10.9" |
57 | | - task :precompile do |
58 | | - title "Pre-compiling the extension" |
59 | | - versions = Dir.glob(File.expand_path('../ext/xcodeproj/prebuilt/*darwin*', __FILE__)).sort |
60 | | - versions.each do |version| |
61 | | - Dir.chdir version do |
62 | | - subtitle "#{File.basename(version)}" |
| 50 | + desc "Build the ext" |
| 51 | + task :build do |
| 52 | + title "Building the extension" |
| 53 | + Dir.chdir 'ext/xcodeproj' do |
| 54 | + if on_rvm? |
| 55 | + sh "CFLAGS='-I#{rvm_ruby_dir}/include' ruby extconf.rb" |
| 56 | + else |
| 57 | + sh "ruby extconf.rb" |
| 58 | + end |
63 | 59 | sh "make" |
64 | 60 | end |
65 | 61 | end |
| 62 | + |
| 63 | + desc "Pre-compile the ext for default Ruby on 10.8 and 10.9" |
| 64 | + task :precompile do |
| 65 | + title "Pre-compiling the extension" |
| 66 | + versions = Dir.glob(File.expand_path('../ext/xcodeproj/prebuilt/*darwin*', __FILE__)).sort |
| 67 | + versions.each do |version| |
| 68 | + Dir.chdir version do |
| 69 | + subtitle "#{File.basename(version)}" |
| 70 | + sh "make" |
| 71 | + end |
| 72 | + end |
| 73 | + end |
| 74 | + |
| 75 | + desc "Clean and build the ext" |
| 76 | + task :cleanbuild => [:clean, :build] |
66 | 77 | end |
67 | 78 |
|
68 | | - desc "Clean and build the ext" |
69 | | - task :cleanbuild => [:clean, :build] |
70 | | -end |
| 79 | + # Travis support |
| 80 | + def on_rvm? |
| 81 | + `which ruby`.strip.include?('.rvm') |
| 82 | + end |
71 | 83 |
|
72 | | -# Travis support |
73 | | -def on_rvm? |
74 | | - `which ruby`.strip.include?('.rvm') |
75 | | -end |
| 84 | + def rvm_ruby_dir |
| 85 | + @rvm_ruby_dir ||= File.expand_path('../..', `which ruby`.strip) |
| 86 | + end |
76 | 87 |
|
77 | | -def rvm_ruby_dir |
78 | | - @rvm_ruby_dir ||= File.expand_path('../..', `which ruby`.strip) |
79 | | -end |
| 88 | + #-----------------------------------------------------------------------------# |
80 | 89 |
|
81 | | -#-----------------------------------------------------------------------------# |
| 90 | + namespace :spec do |
| 91 | + desc "Run all specs" |
| 92 | + task :all do |
| 93 | + puts "\n\033[0;32mUsing #{`ruby --version`.chomp}\033[0m" |
| 94 | + Rake::Task["ext:cleanbuild"].invoke |
82 | 95 |
|
83 | | -namespace :spec do |
84 | | - desc "Run all specs" |
85 | | - task :all do |
86 | | - puts "\n\033[0;32mUsing #{`ruby --version`.chomp}\033[0m" |
87 | | - Rake::Task["ext:cleanbuild"].invoke |
| 96 | + title "Running the specs" |
| 97 | + ENV['GENERATE_COVERAGE'] = 'true' |
| 98 | + sh "bundle exec bacon #{FileList['spec/**/*_spec.rb'].join(' ')}" |
| 99 | + end |
88 | 100 |
|
89 | | - title "Running the specs" |
90 | | - ENV['GENERATE_COVERAGE'] = 'true' |
91 | | - sh "bundle exec bacon #{FileList['spec/**/*_spec.rb'].join(' ')}" |
92 | | - end |
| 101 | + desc "Automatically run specs" |
| 102 | + task :kick do |
| 103 | + exec "bundle exec kicker -c" |
| 104 | + end |
93 | 105 |
|
94 | | - desc "Automatically run specs" |
95 | | - task :kick do |
96 | | - exec "bundle exec kicker -c" |
| 106 | + desc "Run single spec" |
| 107 | + task :single, :spec_file do |t, args| |
| 108 | + sh "bundle exec bacon #{args.spec_file}" |
| 109 | + end |
97 | 110 | end |
98 | 111 |
|
99 | | - desc "Run single spec" |
100 | | - task :single, :spec_file do |t, args| |
101 | | - sh "bundle exec bacon #{args.spec_file}" |
102 | | - end |
103 | | -end |
| 112 | + desc "Run all specs" |
| 113 | + task :spec => 'spec:all' |
104 | 114 |
|
105 | | -desc "Run all specs" |
106 | | -task :spec => 'spec:all' |
| 115 | + task :default => :spec |
107 | 116 |
|
108 | | -task :default => :spec |
| 117 | +rescue LoadError |
| 118 | + $stderr.puts red('[!] Some Rake tasks haven been disabled because the ' \ |
| 119 | + 'environment couldn’t be loaded. Be sure to run `rake bootstrap` first.') |
| 120 | +end |
109 | 121 |
|
110 | | -# UI |
| 122 | +# UI Helpers |
111 | 123 | #-----------------------------------------------------------------------------# |
112 | 124 |
|
113 | 125 | # Prints a title. |
|
135 | 147 | def cyan(string) |
136 | 148 | "\n\033[0;36m#{string}\033[0m" |
137 | 149 | end |
| 150 | + |
| 151 | +# Colorizes a string to red. |
| 152 | +# |
| 153 | +def red(string) |
| 154 | + "\033[0;31m#{string}\e[0m" |
| 155 | +end |
0 commit comments