From 325173d5bd3b92da7d175fd0a9a43b3f8e21905a Mon Sep 17 00:00:00 2001 From: Julian Tescher Date: Sat, 6 Jun 2015 14:17:29 -0700 Subject: [PATCH] Add support for Ivy --- docs/buckets/ivy.md | 13 +++++++++++++ docs/template.html | 1 + lib/vagrant-cachier/bucket.rb | 1 + lib/vagrant-cachier/bucket/ivy.rb | 21 +++++++++++++++++++++ lib/vagrant-cachier/cap/linux/ivy_path.rb | 20 ++++++++++++++++++++ lib/vagrant-cachier/capabilities.rb | 5 +++++ 6 files changed, 61 insertions(+) create mode 100644 docs/buckets/ivy.md create mode 100644 lib/vagrant-cachier/bucket/ivy.rb create mode 100644 lib/vagrant-cachier/cap/linux/ivy_path.rb diff --git a/docs/buckets/ivy.md b/docs/buckets/ivy.md new file mode 100644 index 0000000..1aa13c1 --- /dev/null +++ b/docs/buckets/ivy.md @@ -0,0 +1,13 @@ +# [Ivy](http://ant.apache.org/ivy/) + +Compatible with probably any type of linux guest distro, will cache guests' +`$HOME/.ivy2/cache` if sbt is detected. + +To manually enable it: + +```ruby +Vagrant.configure("2") do |config| + config.vm.box = 'some-box-with-sbt-installed' + config.cache.enable :ivy +end +``` diff --git a/docs/template.html b/docs/template.html index 06b1eca..b563041 100644 --- a/docs/template.html +++ b/docs/template.html @@ -94,6 +94,7 @@
  • npm
  • RubyGems
  • rvm
  • +
  • Ivy
  • Yum
  • Zypper
  • diff --git a/lib/vagrant-cachier/bucket.rb b/lib/vagrant-cachier/bucket.rb index ac4e76b..bbdad45 100644 --- a/lib/vagrant-cachier/bucket.rb +++ b/lib/vagrant-cachier/bucket.rb @@ -101,3 +101,4 @@ require_relative "bucket/bower" require_relative "bucket/npm" require_relative "bucket/zypper" require_relative "bucket/generic" +require_relative "bucket/ivy" diff --git a/lib/vagrant-cachier/bucket/ivy.rb b/lib/vagrant-cachier/bucket/ivy.rb new file mode 100644 index 0000000..5a804ee --- /dev/null +++ b/lib/vagrant-cachier/bucket/ivy.rb @@ -0,0 +1,21 @@ +module VagrantPlugins + module Cachier + class Bucket + class Ivy < Bucket + def self.capability + :ivy_path + end + + def install + if guest.capability?(:ivy_path) + if ivy_path = guest.capability(:ivy_path) + user_symlink(ivy_path) + end + else + @env[:ui].info I18n.t('vagrant_cachier.skipping_bucket', bucket: 'Ivy') + end + end + end + end + end +end diff --git a/lib/vagrant-cachier/cap/linux/ivy_path.rb b/lib/vagrant-cachier/cap/linux/ivy_path.rb new file mode 100644 index 0000000..092a31b --- /dev/null +++ b/lib/vagrant-cachier/cap/linux/ivy_path.rb @@ -0,0 +1,20 @@ +module VagrantPlugins + module Cachier + module Cap + module Linux + module IvyPath + def self.ivy_path(machine) + ivy_path = nil + machine.communicate.tap do |comm| + return unless comm.test('which sbt') + comm.execute 'echo $HOME' do |buffer, output| + ivy_path = output.chomp if buffer == :stdout + end + end + return "#{ivy_path}/.ivy2/cache" + end + end + end + end + end +end diff --git a/lib/vagrant-cachier/capabilities.rb b/lib/vagrant-cachier/capabilities.rb index 277ff37..cd71f7f 100644 --- a/lib/vagrant-cachier/capabilities.rb +++ b/lib/vagrant-cachier/capabilities.rb @@ -26,6 +26,11 @@ module VagrantPlugins Cap::Linux::BowerPath end + guest_capability 'linux', 'ivy_path' do + require_relative 'cap/linux/ivy_path' + Cap::Linux::IvyPath + end + guest_capability 'linux', 'chef_file_cache_path' do require_relative 'cap/linux/chef_file_cache_path' Cap::Linux::ChefFileCachePath