Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 248 lines (214 sloc) 6.644 kb
0910111 Chad Humphries Initial Rake tasks for dev environment setup
spicycode authored
1 require 'rake'
2 require 'fileutils'
3 require 'pathname'
4
62fa3d2 The top-level Rakefile requires Bundler awareness.
Austin Ziegler authored
5 UsingBundler = !!ENV['BUNDLE_GEMFILE']
6
46c6ca2 David Chelimsky hit rspec-expectations first (now a dep of rspec-core)
dchelimsky authored
7 Projects = ['rspec-expectations', 'rspec-mocks', 'rspec-core', 'rspec', 'rspec-rails']
57125ad Chad Humphries Making the dev repo more useful (see below)
spicycode authored
8 BaseRspecPath = Pathname.new(Dir.pwd)
9 ReposPath = BaseRspecPath.join('repos')
10
2d0425f David Chelimsky fix bundle install task for rspec-rails repo
dchelimsky authored
11 def run_command(command, opts={})
12 projects = if opts[:except]
13 Projects - [opts[:except]].flatten
14 elsif opts[:only]
15 [opts[:only]].flatten
16 else
17 Projects
18 end
19 projects.each do |dir|
20 next if [opts[:except]].flatten.compact.include?(dir)
1617460 Chad Humphries Dev setup complete
spicycode authored
21 path = ReposPath.join(dir)
22 FileUtils.cd(path) do
96179f6 David Chelimsky Another attempt to make the output cleaner
dchelimsky authored
23 puts "="*50
9ca1363 David Chelimsky path.to_s for 1.9.1
dchelimsky authored
24 puts "# " + path.to_s.sub(/#{File.dirname(__FILE__)}\//,'')
96179f6 David Chelimsky Another attempt to make the output cleaner
dchelimsky authored
25 puts "# " + command
26 puts "-"*40
edcd0c4 David Chelimsky rescue when exceptions are thrown in any project (so the command can run...
dchelimsky authored
27 begin
28 sh command
29 rescue Exception => e
30 puts e.backtrace
31 end
96179f6 David Chelimsky Another attempt to make the output cleaner
dchelimsky authored
32 puts
0910111 Chad Humphries Initial Rake tasks for dev environment setup
spicycode authored
33 end
34 end
35 end
36
afb6214 David Chelimsky add task to release gem
dchelimsky authored
37 def each_project
38 Projects.each do |project|
f8aec05 David Chelimsky add authors script
dchelimsky authored
39 Dir.chdir("repos/#{project}") do
81e8f46 David Chelimsky tweak rake tasks
dchelimsky authored
40 puts "="*50
41 puts "# #{project}"
42 puts "-"*40
43 yield project
44 puts
45 end
afb6214 David Chelimsky add task to release gem
dchelimsky authored
46 end
47 end
48
0910111 Chad Humphries Initial Rake tasks for dev environment setup
spicycode authored
49 task :make_repos_directory do
50 FileUtils.mkdir_p ReposPath
51 end
52
97418dc David Chelimsky add task to run arbitrary commands against all repos
dchelimsky authored
53 desc "run an arbitrary command against all repos"
54 task :run, :command do |t, args|
55 run_command args[:command]
56 end
57
674eba9 Chad Humphries Restructured dev rake task, and added gem management utilities
spicycode authored
58 namespace :gem do
ace3a2a David Chelimsky get write_version task working again
dchelimsky authored
59 desc "Write out a new version constant for each project. You must supply VERSION"
b3a8290 David Chelimsky parameterize write_version task
dchelimsky authored
60 task :write_version, :version do |t, args|
61 raise("You must supply VERSION") unless args[:version]
674eba9 Chad Humphries Restructured dev rake task, and added gem management utilities
spicycode authored
62 Projects.each do |project|
005e57d Myron Marston Remove dependency on jeweler.
myronmarston authored
63 file = Dir.chdir("repos/#{project}") { File.expand_path(`git ls-files **/version.rb`.chomp) }
64 current_content = File.read(file)
65 new_content = current_content.gsub(/STRING = ['"][^'"]+['"]/, "STRING = '#{args[:version]}'")
66
b3a8290 David Chelimsky parameterize write_version task
dchelimsky authored
67 puts "Writing out version #{args[:version]} for #{project}"
afb6214 David Chelimsky add task to release gem
dchelimsky authored
68 File.open(file, "w") { |f| f.write(new_content) }
674eba9 Chad Humphries Restructured dev rake task, and added gem management utilities
spicycode authored
69 end
70 end
71
72 desc "Build gems"
8a0e85d David Chelimsky don't run gemspec for build
dchelimsky authored
73 task :build => [:clean_pkg_directories] do
48fe01e David Chelimsky cleaner rake file thanks to jeweler updates
dchelimsky authored
74 run_command "rake build"
674eba9 Chad Humphries Restructured dev rake task, and added gem management utilities
spicycode authored
75 end
76
77 task :clean_pkg_directories do
78 run_command "rm -rf pkg"
79 end
80
afb6214 David Chelimsky add task to release gem
dchelimsky authored
81 desc "Tag each repo, push the tags, push the gems"
ac2970b David Chelimsky use bundler's release task
dchelimsky authored
82 task :release do
83 run_command("rake release")
afb6214 David Chelimsky add task to release gem
dchelimsky authored
84 end
85
674eba9 Chad Humphries Restructured dev rake task, and added gem management utilities
spicycode authored
86 desc "Install all gems locally"
eb0d64d David Chelimsky install task already builds
dchelimsky authored
87 task :install do
8e09d8f David Chelimsky no sudo
dchelimsky authored
88 run_command "rake install"
674eba9 Chad Humphries Restructured dev rake task, and added gem management utilities
spicycode authored
89 end
90
91 desc "Uninstall gems locally"
92 task :uninstall do
41ca177 David Chelimsky fix uninstall
dchelimsky authored
93 Projects.each do |project|
94 path = ReposPath.join(project)
95 FileUtils.cd(path) do
f8aec05 David Chelimsky add authors script
dchelimsky authored
96 system "gem uninstall --all --executables --ignore-dependencies #{project}"
41ca177 David Chelimsky fix uninstall
dchelimsky authored
97 end
98 end
fb619a4 Chad Humphries Updating the readme and adding a gemcutter task
spicycode authored
99 end
57125ad Chad Humphries Making the dev repo more useful (see below)
spicycode authored
100 end
101
674eba9 Chad Humphries Restructured dev rake task, and added gem management utilities
spicycode authored
102 namespace :dev do
103 desc "Pair dev, you must supply the PAIR1, PAIR2 arguments"
104 task :pair do
105 raise("You must supply PAIR1, and PAIR2 to pair dev") unless ENV['PAIR1'] && ENV['PAIR2']
106 run_command "pair #{ENV['PAIR1']} #{ENV['PAIR2']}"
107 end
108
109 desc "Solo dev, removes any git pair markers"
110 task :solo do
111 run_command "pair"
112 end
113 end
0910111 Chad Humphries Initial Rake tasks for dev environment setup
spicycode authored
114
674eba9 Chad Humphries Restructured dev rake task, and added gem management utilities
spicycode authored
115 namespace :git do
888480d Greg Hurrell Do "bundle:unlock" when running "git:pull" task
wincent authored
116 { :status => nil, :push => nil, :reset => '--hard', :diff => nil }.each do |command, options|
0910111 Chad Humphries Initial Rake tasks for dev environment setup
spicycode authored
117 desc "git #{command} on all the repos"
118 task command => :clone do
119 run_command "git #{command} #{options}".strip
120 end
121 end
122
888480d Greg Hurrell Do "bundle:unlock" when running "git:pull" task
wincent authored
123 desc 'git pull on all the repos'
be04734 David Chelimsky no need to unlock bundles every pull
dchelimsky authored
124 task :pull => [:clone] do
888480d Greg Hurrell Do "bundle:unlock" when running "git:pull" task
wincent authored
125 run_command "git pull --rebase"
126 end
127
08713c4 David Chelimsky rake task to check out versions in the repos
dchelimsky authored
128 desc 'git checkout repos'
129 task :checkout, :version do |t, args|
130 raise("rake git:checkout[VERSION]") unless args[:version]
131 run_command "git checkout #{args[:version]}"
132 end
133
0910111 Chad Humphries Initial Rake tasks for dev environment setup
spicycode authored
134 task :st => :status
6c651ea David Chelimsky alias rake git:pull with git:update
dchelimsky authored
135 task :update => :pull
0910111 Chad Humphries Initial Rake tasks for dev environment setup
spicycode authored
136
137 desc "git clone all the repos the first time"
138 task :clone => :make_repos_directory do
d3acc1c David Chelimsky fix 'rake git:clone'
dchelimsky authored
139 url_prefix = `git config --get remote.origin.url`[%r{(^.*)/rspec-dev}, 1]
a8f1bb5 Glenn Vanderburg Modify Rakefile to work with current dev repo clone URL, rather than har...
glv authored
140
0910111 Chad Humphries Initial Rake tasks for dev environment setup
spicycode authored
141 FileUtils.cd(ReposPath) do
674eba9 Chad Humphries Restructured dev rake task, and added gem management utilities
spicycode authored
142 Projects.each do |repo|
0910111 Chad Humphries Initial Rake tasks for dev environment setup
spicycode authored
143 unless File.exists?(repo)
ca48a0b Greg Hurrell Add .git to the clone URLs.
wincent authored
144 system "git clone #{url_prefix}/#{repo}.git"
0910111 Chad Humphries Initial Rake tasks for dev environment setup
spicycode authored
145 end
146 end
147 end
f1116cc David Chelimsky .... but don't clone what's already there
dchelimsky authored
148
0910111 Chad Humphries Initial Rake tasks for dev environment setup
spicycode authored
149 end
674eba9 Chad Humphries Restructured dev rake task, and added gem management utilities
spicycode authored
150
151 desc "git commit all the repos with the same commit message"
c40c2f8 David Chelimsky update git:commit task to use rake args
dchelimsky authored
152 task :commit, :message do |t, args|
153 raise("You must supply a message to git:commit:\n\n rake git:commit[\"this is the commit message\"]\n\n") unless args[:message]
154 run_command "git commit -am '#{args[:message]}'"
674eba9 Chad Humphries Restructured dev rake task, and added gem management utilities
spicycode authored
155 end
0910111 Chad Humphries Initial Rake tasks for dev environment setup
spicycode authored
156 end
1617460 Chad Humphries Dev setup complete
spicycode authored
157
158 task :clobber do
507cebb David Chelimsky rake clobber runs against repos instead of clobbering them
dchelimsky authored
159 run_command "rake clobber"
1617460 Chad Humphries Dev setup complete
spicycode authored
160 end
161
78e0925 David Chelimsky updated dev environment relies on bundler
dchelimsky authored
162 namespace :bundle do
962b3c2 David Chelimsky rake tasks
dchelimsky authored
163 desc "unlock the gem bundles"
78e0925 David Chelimsky updated dev environment relies on bundler
dchelimsky authored
164 task :unlock do
165 sh "find . -name 'Gemfile.lock' | xargs rm"
166 end
962b3c2 David Chelimsky rake tasks
dchelimsky authored
167
168 desc "install the gem bundles"
169 task :install do
96554e1 David Chelimsky install bundler as part of 'rake setup'
dchelimsky authored
170 `gem install bundler` unless `gem list`.split("\n").detect {|g| g =~ /^bundler/}
cfedf22 David Chelimsky include --binstubs in bundle install commands
dchelimsky authored
171 `bundle install --binstubs`
5104c3c David Chelimsky Fix bin/rake setup
dchelimsky authored
172 Bundler.with_clean_env do
cfedf22 David Chelimsky include --binstubs in bundle install commands
dchelimsky authored
173 run_command 'bundle install --binstubs --gemfile ./Gemfile', :except => 'rspec-rails'
6330de2 Justin Ko Use latest Rails version.
justinko authored
174 run_command 'thor version:use 3.2.2', :only => 'rspec-rails'
5104c3c David Chelimsky Fix bin/rake setup
dchelimsky authored
175 end
962b3c2 David Chelimsky rake tasks
dchelimsky authored
176 end
78e0925 David Chelimsky updated dev environment relies on bundler
dchelimsky authored
177 end
178
8d04e3c install:bundle -> bundle:install in :setup task
Jean-Daniel Guyot authored
179 task :setup => ["git:clone", "bundle:install"]
7dd4146 David Chelimsky much simpler setup
dchelimsky authored
180
bd9bf1b David Chelimsky update the readme
dchelimsky authored
181 task :default do
62fa3d2 The top-level Rakefile requires Bundler awareness.
Austin Ziegler authored
182 if UsingBundler
183 Bundler.with_clean_env do
184 ENV.delete 'BUNDLE_GEMFILE'
185 run_command 'bin/rake'
186 end
187 else
188 run_command 'rake'
189 end
bd9bf1b David Chelimsky update the readme
dchelimsky authored
190 end
f8aec05 David Chelimsky add authors script
dchelimsky authored
191
bb592b2 David Chelimsky dev: add rake task to build rdoc for all 3 repos in one
dchelimsky authored
192 namespace :doc do
193 desc "generate docs"
194 task :generate do
195 Dir.chdir("repos") do
196 sh "ln -s rspec-core/README.md RSpecCore.md" unless test ?f, "RSpecCore.md"
197 sh "ln -s rspec-expectations/README.md RSpecExpectations.md" unless test ?f, "RSpecExpectations.md"
198 sh "ln -s rspec-mocks/README.md RSpecMocks.md" unless test ?f, "RSpecMocks.md"
b0ae1f1 David Chelimsky add rails docs
dchelimsky authored
199 sh "ln -s rspec-rails/README.md RSpecRails.md" unless test ?f, "RSpecRails.md"
bb592b2 David Chelimsky dev: add rake task to build rdoc for all 3 repos in one
dchelimsky authored
200 sh "yardoc"
201 sh "rm RSpecCore.md"
202 sh "rm RSpecExpectations.md"
203 sh "rm RSpecMocks.md"
b0ae1f1 David Chelimsky add rails docs
dchelimsky authored
204 sh "rm RSpecRails.md"
205 sh %q|ruby -pi.bak -e "gsub(/Documentation by YARD \d+\.\d+\.\d+/, 'RSpec 2.8')" doc/_index.html|
206 sh %q|ruby -pi.bak -e "gsub(/<h1 class=\"alphaindex\">Alphabetic Index<\/h1>/, '')" doc/_index.html|
207 sh "cp doc/_index.html doc/index.html"
bb592b2 David Chelimsky dev: add rake task to build rdoc for all 3 repos in one
dchelimsky authored
208 end
209 end
210
211 desc "clobber generated docs"
212 task :clobber do
213 Dir.chdir("repos") do
214 sh "rm -rf .yardoc"
215 sh "rm -rf doc"
216 end
217 end
218
219 desc "publish generated docs"
220 task :publish do
221 Dir.chdir("repos") do
222 `rsync -av --delete doc david@davidchelimsky.net:/www/api.rspec.info`
223 end
224 end
225 end
226
227 task :rdoc => ["doc:clobber", "doc:generate"]
228
715dc42 David Chelimsky contributors
dchelimsky authored
229 task :contributors do
f8aec05 David Chelimsky add authors script
dchelimsky authored
230 logs = Projects.inject("") do |logs, dir|
231 path = ReposPath.join(dir)
232 FileUtils.cd(path) do
233 logs << `git log`
234 end
235 logs
236 end
2d0425f David Chelimsky fix bundle install task for rspec-rails repo
dchelimsky authored
237 authors = logs.split("\n").grep(/^Author/).
f8aec05 David Chelimsky add authors script
dchelimsky authored
238 map{|l| l.sub(/Author: /,'')}.
239 map{|l| l.split('<').first}.
240 map{|l| l.split('and')}.flatten.
241 map{|l| l.split('+')}.flatten.
242 map{|l| l.split(',')}.flatten.
243 map{|l| l.strip}.
2d0425f David Chelimsky fix bundle install task for rspec-rails repo
dchelimsky authored
244 uniq.compact.reject{|n| n == ""}.sort
715dc42 David Chelimsky contributors
dchelimsky authored
245 puts "#{authors.count} contributors: "
2d0425f David Chelimsky fix bundle install task for rspec-rails repo
dchelimsky authored
246 puts authors.compact.join(", ")
f8aec05 David Chelimsky add authors script
dchelimsky authored
247 end
Something went wrong with that request. Please try again.