Top Level Namespace

Defined Under Namespace

Modules: Roasted

Instance Method Summary collapse

Instance Method Details

#bundle(source, options = {}) ⇒ Object



21
22
23
# File 'lib/roasted/provider/app/textmate.rb', line 21

def bundle(source, options = {})
  download source, "~/Library/Application Support/TextMate/Bundles", options
end

#download(source, target, options = {}) ⇒ Object



29
30
31
32
33
34
35
36
37
# File 'lib/roasted/provider/app/textmate.rb', line 29

def download(source, target, options = {})
  type = case source
  when /^http/
    :http
  when /^git/
    :git
  end
  self.send("download_#{type}", source, target, options)
end

#download_git(source, target, options = {}) ⇒ Object



61
62
63
64
65
66
67
68
69
70
71
72
# File 'lib/roasted/provider/app/textmate.rb', line 61

def download_git(source, target, options = {})
  target = File.expand_path(target)

  # Prepare target directory
  FileUtils.mkdir_p target

  options[:name] ||= File.basename(source).gsub(".git", "")
    
  Dir.chdir target do
    system "git clone '#{source}' '#{options[:name]}'"
  end
end

#download_http(source, target, options = {}) ⇒ Object



39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/roasted/provider/app/textmate.rb', line 39

def download_http(source, target, options = {})
  target = File.expand_path(target)
  
  # Prepare target directory
  FileUtils.mkdir_p target
  
  tmp = Tempfile.new File.basename(source)
  system "curl -o '#{tmp.path}' '#{source}'"
  
  if options[:checksum]
    checksum = Digest::SHA1.hexdigest(File.read(tmp.path))
    raise "Checksum mismatch, expected #{options[:checksum]}" if checksum != options[:checksum]
  end
  
  case File.extname(source)[1..-1]
  when "zip"
    system "ditto -x -k '#{tmp.path}' '#{target}'"
  else
    raise "Unknown download type: #{source}"
  end
end

#plugin(source, options = {}) ⇒ Object



17
18
19
# File 'lib/roasted/provider/app/textmate.rb', line 17

def plugin(source, options = {})
  download source, "~/Library/Application Support/TextMate/PlugIns", options
end

#theme(source, options = {}) ⇒ Object



25
26
27
# File 'lib/roasted/provider/app/textmate.rb', line 25

def theme(source, options = {})
  download source, "~/Library/Application Support/TextMate/Themes", options
end