Skip to content

Commit

Permalink
added git:src:install task and more 'how to develop new tasks' info i…
Browse files Browse the repository at this point in the history
…n README
  • Loading branch information
drnic committed Aug 19, 2008
1 parent a85cbd9 commit dcc0457
Show file tree
Hide file tree
Showing 4 changed files with 81 additions and 2 deletions.
17 changes: 17 additions & 0 deletions README.markdown
Expand Up @@ -56,6 +56,23 @@ So, to create a task `foo:bar:baz`, you'll need to add a folder `foo/bar` and cr
end
end

### Installing individual tasks/files

The `rake install` task can selectively install only tasks/files that you are working on, rather than all the files in your repository, using either the `ONLY_FILES` or `ONLY_TASKS` environment variable.

For example, to restrict `rake install` to only re-install a task `foo:bar:baz` you can either use:

rake install ONLY_FILES=foo/bar/baz.sake
rake install ONLY_TASKS=foo:bar:baz

The values can be comma-separated lists.

So for iterative install & run development you could run the install task and the sake task via the same command line:

rake install ONLY_TASKS=foo:bar:baz && sake foo:bar:baz --trace

The optional `--trace` runs sake in trace mode so useful stacktrace information is given as necessary.

### TextMate users

The latest [Ruby.tmbundle](http://github.com/drnic/ruby-tmbundle) on github includes a `task` command that generates the above namespace/task snippet based on the path + file name. That is, inside the `foo/bar/baz.sake` file, make sure your grammar is 'Ruby' or 'Ruby on Rails' and then type "task" and press TAB. The above snippet will be generated ready for you to specify your task.
Expand Down
8 changes: 6 additions & 2 deletions Rakefile
@@ -1,9 +1,13 @@
desc "Install sake tasks, uninstalling any pre-existing tasks first"
desc "Install sake tasks, uninstalling any pre-existing tasks first; can pass ONLY_FILES and ONLY_TASKS env vars"
task :install do
task_files = Dir['**/*.sake']
only_files = ENV['ONLY_FILES'] && ENV['ONLY_FILES'].split(',')
only_tasks = ENV['ONLY_TASKS'] && ENV['ONLY_TASKS'].split(',')
task_files.sort.map do |task_file|
next if only_files && !only_files.include?(task_file)
sake_task = task_file.gsub('/', ':').gsub('.sake','')
puts `sake -u #{sake_task}`
next if only_tasks && !only_tasks.include?(sake_task)
`sake -u #{sake_task}`
puts `sake -i #{task_file}`
end
end
Expand Down
37 changes: 37 additions & 0 deletions git/src/install.sake
@@ -0,0 +1,37 @@
namespace 'git' do
namespace 'src' do
desc "Downloads and installs latest version of git"
task :install => "git:src:latest_version" do
download_url = ENV['GIT_DOWNLOAD_URL']
git_package = File.basename(download_url)
git_src_folder = git_package.gsub(/.tar.gz/, '')
target_base_folder = '/usr/local'
usr_src_folder = File.join(target_base_folder, 'src')
require "fileutils"
FileUtils.mkdir_p usr_src_folder
FileUtils.chdir usr_src_folder do
if File.exists?(git_package)
puts "File #{git_package} already downloaded, skipping download..."
else
`wget #{download_url}`
end

if File.exists?(git_src_folder)
puts "Removing existing #{git_src_folder} source"
FileUtils.rm_rf git_src_folder
end

puts "Unpacking #{git_src_folder}"
`tar xfv #{git_package}`

FileUtils.chdir git_src_folder do
puts "Installing to #{target_base_folder}"
sh "make prefix=#{target_base_folder} all"
sh "sudo make prefix=#{target_base_folder} install all"
end
end

puts "Run 'sake git:manpages:install' to install manpages for #{`git --version`}"
end
end
end
21 changes: 21 additions & 0 deletions git/src/latest_version.sake
@@ -0,0 +1,21 @@
namespace 'git' do
namespace 'src' do
task :latest_version do
require "rubygems"
begin
gem 'hpricot'
require 'hpricot'
rescue LoadError
puts "REQUIREMENT: Hpricot"
puts "Installation: sudo gem install hpricot"
exit
end
require "open-uri"
doc = open('http://git.or.cz/').read
if download_url = doc.match(%r{http://kernel.org/pub/software/scm/git/git-([\d.]+).tar.gz})
ENV['GIT_DOWNLOAD_URL'] = download_url[0]
puts "Current git src version: #{$1}"
end
end
end
end

0 comments on commit dcc0457

Please sign in to comment.