Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

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