Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

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