vagrant-proxyconf 0.2.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore CHANGED
@@ -1,4 +1,6 @@
1
1
  /.bundle
2
+ /.yardoc
2
3
  /Gemfile.lock
4
+ /doc
3
5
  /pkg
4
6
  /tmp
data/.yardopts ADDED
@@ -0,0 +1,6 @@
1
+ --no-private
2
+ --protected
3
+ -
4
+ CHANGELOG.md
5
+ LICENSE.txt
6
+ README.md
data/CHANGELOG.md CHANGED
@@ -1,3 +1,9 @@
1
+ # 0.3.0 / 2013-07-12
2
+
3
+ - Support the [AWS provider](https://github.com/mitchellh/vagrant-aws) ([GH-10][])
4
+ - Support `vagrant rebuild` command of the [Digital Ocean provider](https://github.com/smdahlen/vagrant-digitalocean) ([GH-11][])
5
+ - Do not add the default port to complete URIs (e.g. `http://proxy`) ([GH-9][])
6
+
1
7
  # 0.2.0 / 2013-07-05
2
8
 
3
9
  - Add Apt proxy configuration for FTP URIs ([GH-5][])
@@ -20,3 +26,6 @@
20
26
  [GH-5]: https://github.com/tmatilai/vagrant-proxyconf/issues/5 "Issue 5"
21
27
  [GH-7]: https://github.com/tmatilai/vagrant-proxyconf/issues/7 "Issue 7"
22
28
  [GH-8]: https://github.com/tmatilai/vagrant-proxyconf/issues/8 "Issue 8"
29
+ [GH-9]: https://github.com/tmatilai/vagrant-proxyconf/issues/9 "Issue 9"
30
+ [GH-10]: https://github.com/tmatilai/vagrant-proxyconf/issues/10 "Issue 10"
31
+ [GH-11]: https://github.com/tmatilai/vagrant-proxyconf/issues/11 "Issue 11"
data/Gemfile CHANGED
@@ -2,11 +2,15 @@ source 'https://rubygems.org'
2
2
 
3
3
  gemspec
4
4
 
5
+ gem 'cane', '~> 2.6'
5
6
  gem 'rake'
6
7
  gem 'rspec', '~> 2.11'
8
+ gem 'simplecov', '~> 0.7', :require => false
7
9
  gem 'tailor', '~> 1.2'
8
10
  gem 'vagrant', github: 'mitchellh/vagrant', ref: 'v1.2.2'
9
11
 
10
12
  group :development do
11
13
  gem 'guard-rspec'
14
+ gem 'redcarpet'
15
+ gem 'yard', '~> 0.8'
12
16
  end
data/README.md CHANGED
@@ -1,16 +1,16 @@
1
- # Vagrant Proxy Configuration Plugin
1
+ # Proxy Configuration Plugin for Vagrant
2
2
 
3
3
  <span class="badges">
4
4
  [![Gem Version](https://badge.fury.io/rb/vagrant-proxyconf.png)][gem]
5
5
  [![Build Status](https://travis-ci.org/tmatilai/vagrant-proxyconf.png?branch=master)][travis]
6
6
  [![Dependency Status](https://gemnasium.com/tmatilai/vagrant-proxyconf.png)][gemnasium]
7
7
  [![Code Climate](https://codeclimate.com/github/tmatilai/vagrant-proxyconf.png)][codeclimate]
8
+ </span>
8
9
 
9
10
  [gem]: https://rubygems.org/gems/vagrant-proxyconf
10
11
  [travis]: https://travis-ci.org/tmatilai/vagrant-proxyconf
11
12
  [gemnasium]: https://gemnasium.com/tmatilai/vagrant-proxyconf
12
13
  [codeclimate]: https://codeclimate.com/github/tmatilai/vagrant-proxyconf
13
- </span>
14
14
 
15
15
  A [Vagrant](http://www.vagrantup.com/) plugin that configures the virtual machine to use specified proxies for package managers etc.
16
16
 
@@ -20,9 +20,18 @@ At this state we support:
20
20
 
21
21
  Support is planned for other package managers (at least yum).
22
22
 
23
- ## Installation
23
+ ## Compatibility
24
+
25
+ This plugin requires Vagrant 1.2 or newer ([downloads](http://downloads.vagrantup.com/)).
24
26
 
25
- **Note:** This plugin requires Vagrant v1.2 or newer ([downloads](http://downloads.vagrantup.com/)).
27
+ The plugin is supposed to be compatible with all Vagrant providers. Please file an [issue](https://github.com/tmatilai/vagrant-proxyconf/issues) if this is not the case.
28
+ The following providers are confirmed to work:
29
+ [AWS](https://github.com/mitchellh/vagrant-aws),
30
+ [Digital Ocean](https://github.com/smdahlen/vagrant-digitalocean),
31
+ [VirtualBox](http://docs.vagrantup.com/v2/virtualbox),
32
+ [VMware Fusion](http://docs.vagrantup.com/v2/vmware/index.html).
33
+
34
+ ## Installation
26
35
 
27
36
  Install using standard Vagrant plugin installation method:
28
37
 
@@ -32,6 +41,8 @@ vagrant plugin install vagrant-proxyconf
32
41
 
33
42
  ## Usage
34
43
 
44
+ The plugin hooks itself to `vagrant up`, `vagrant reload` and `vagrant rebuild` commands.
45
+
35
46
  Proxy settings can be configured in Vagrantfile. In the common case that you want to use the same configuration in all Vagrant machines, you can use _$HOME/.vagrant.d/Vagrantfile_ or environment variables. Package manager specific settings are only used on supporting platforms (i.e. Apt configuration on Debian based systems), so there is no harm using global configuration.
36
47
 
37
48
  Project specific Vagrantfile overrides global settings. Environment variables override both.
data/Rakefile CHANGED
@@ -1,8 +1,9 @@
1
1
  require 'bundler/gem_tasks'
2
+ require 'cane/rake_task'
2
3
  require 'rspec/core/rake_task'
3
4
  require 'tailor/rake_task'
4
5
 
5
- task :default => [:test, :tailor]
6
+ task :default => [:test, :quality]
6
7
 
7
8
  # Remove 'install' task as the gem is installed to Vagrant, not to system
8
9
  Rake::Task[:install].clear
@@ -28,6 +29,14 @@ Tailor::RakeTask.new do |task|
28
29
  end
29
30
  end
30
31
 
32
+ Cane::RakeTask.new(:cane) do |task|
33
+ task.style_measure = 100
34
+ task.options[:color] = true
35
+ end
36
+
37
+ desc 'Run all quality tasks'
38
+ task :quality => [:cane, :tailor]
39
+
31
40
  desc "Update gh-pages"
32
41
  task 'gh-pages' do
33
42
  require 'tmpdir'
@@ -40,3 +49,10 @@ task 'gh-pages' do
40
49
  end
41
50
  end
42
51
  end
52
+
53
+ begin
54
+ require 'yard'
55
+ YARD::Rake::YardocTask.new
56
+ rescue LoadError
57
+ # gem not installed on the CI server
58
+ end
@@ -4,6 +4,7 @@ require 'tempfile'
4
4
  module VagrantPlugins
5
5
  module ProxyConf
6
6
  class Action
7
+ # Action for configuring Apt on the guest
7
8
  class ConfigureAptProxy
8
9
  attr_reader :logger
9
10
 
@@ -2,7 +2,9 @@ module VagrantPlugins
2
2
  module ProxyConf
3
3
  module Cap
4
4
  module Debian
5
+ # Capability for Apt proxy configuration
5
6
  module AptProxyConf
7
+ # @return [String] the path to the configuration file
6
8
  def self.apt_proxy_conf(machine)
7
9
  '/etc/apt/apt.conf.d/01proxy'
8
10
  end
@@ -3,14 +3,17 @@ require 'vagrant'
3
3
  module VagrantPlugins
4
4
  module ProxyConf
5
5
  module Config
6
+ # Proxy configuration for Apt
7
+ #
8
+ # @!parse class AptProxy < Vagrant::Plugin::V2::Config; end
6
9
  class AptProxy < Vagrant.plugin('2', :config)
7
- # HTTP proxy for Apt
10
+ # @return [String] the HTTP proxy
8
11
  attr_accessor :http
9
12
 
10
- # HTTPS proxy for Apt
13
+ # @return [String] the HTTPS proxy
11
14
  attr_accessor :https
12
15
 
13
- # FTP proxy for Apt
16
+ # @return [String] the FTP proxy
14
17
  attr_accessor :ftp
15
18
 
16
19
  def initialize
@@ -49,6 +52,9 @@ module VagrantPlugins
49
52
  ConfigValue.new(proto, send(proto.to_sym))
50
53
  end
51
54
 
55
+ # Helper for building configuration lines
56
+ #
57
+ # @api private
52
58
  class ConfigValue
53
59
 
54
60
  attr_reader :proto, :value
@@ -84,7 +90,7 @@ module VagrantPlugins
84
90
  end
85
91
 
86
92
  def suffix
87
- ":#{default_port}" if value !~ %r{:\d+$}
93
+ ":#{default_port}" if value !~ %r{:\d+$} && value !~ %r{/}
88
94
  end
89
95
 
90
96
  def default_port
@@ -2,6 +2,9 @@ require 'vagrant'
2
2
 
3
3
  module VagrantPlugins
4
4
  module ProxyConf
5
+ # Vagrant Plugin class that registers all proxy configs, hooks, etc.
6
+ #
7
+ # @!parse class Plugin < Vagrant::Plugin::V2::Plugin; end
5
8
  class Plugin < Vagrant.plugin('2')
6
9
  # The minimum compatible Vagrant version
7
10
  MIN_VAGRANT_VERSION = '1.2.0'
@@ -35,9 +38,16 @@ module VagrantPlugins
35
38
  proxyconf_action_hook = lambda do |hook|
36
39
  require_relative 'action/configure_apt_proxy'
37
40
  hook.after Vagrant::Action::Builtin::Provision, Action::ConfigureAptProxy
41
+
42
+ # vagrant-aws uses a non-standard provision action
43
+ if VagrantPlugins.const_defined?('AWS')
44
+ hook.after VagrantPlugins::AWS::Action::TimedProvision, Action::ConfigureAptProxy
45
+ end
38
46
  end
39
47
  action_hook 'proxyconf-machine-up', :machine_action_up, &proxyconf_action_hook
40
48
  action_hook 'proxyconf-machine-reload', :machine_action_reload, &proxyconf_action_hook
49
+ # Hook to vagrant-digitalocean's `rebuild` command
50
+ action_hook 'proxyconf-machine-rebuild', :machine_action_rebuild, &proxyconf_action_hook
41
51
  end
42
52
  end
43
53
  end
@@ -1,5 +1,5 @@
1
1
  module VagrantPlugins
2
2
  module ProxyConf
3
- VERSION = '0.2.0'
3
+ VERSION = '0.3.0'
4
4
  end
5
5
  end
data/spec/spec_helper.rb CHANGED
@@ -6,5 +6,11 @@ RSpec.configure do |config|
6
6
  config.tty = true
7
7
  end
8
8
 
9
+ require 'simplecov'
10
+ SimpleCov.start do
11
+ coverage_dir('tmp/coverage')
12
+ add_filter '/spec/'
13
+ end
14
+
9
15
  require 'tempfile'
10
16
  require 'vagrant-proxyconf'
@@ -9,7 +9,8 @@ def conf_line(proto, name, port = 3142)
9
9
  if name == :direct
10
10
  %Q{Acquire::#{proto}::Proxy "DIRECT";\n}
11
11
  else
12
- %Q{Acquire::#{proto}::Proxy "#{proto}://#{name}:#{port}";\n}
12
+ port = ":#{port}" if port
13
+ %Q{Acquire::#{proto}::Proxy "#{proto}://#{name}#{port}";\n}
13
14
  end
14
15
  end
15
16
 
@@ -41,7 +42,13 @@ shared_examples "apt proxy config" do |proto|
41
42
  context "with protocol and name" do
42
43
  subject { config_with(proto => "#{proto}://proxy.foo.tld") }
43
44
  its(:enabled?) { should be_true }
44
- its(:to_s) { should eq conf_line(proto, "proxy.foo.tld") }
45
+ its(:to_s) { should eq conf_line(proto, "proxy.foo.tld", nil) }
46
+ end
47
+
48
+ context "with trailing slash" do
49
+ subject { config_with(proto => "#{proto}://proxy.foo.tld/") }
50
+ its(:enabled?) { should be_true }
51
+ its(:to_s) { should eq conf_line(proto, "proxy.foo.tld/", nil) }
45
52
  end
46
53
 
47
54
  context "with protocol and name and port" do
@@ -0,0 +1,5 @@
1
+ require 'spec_helper'
2
+ require 'vagrant-proxyconf/action/configure_apt_proxy'
3
+
4
+ describe VagrantPlugins::ProxyConf::Action::ConfigureAptProxy do
5
+ end
@@ -0,0 +1,11 @@
1
+ require 'spec_helper'
2
+ require 'vagrant-proxyconf/cap/debian/apt_proxy_conf'
3
+
4
+ describe VagrantPlugins::ProxyConf::Cap::Debian::AptProxyConf do
5
+
6
+ describe '.apt_proxy_conf' do
7
+ let(:subject) { described_class.apt_proxy_conf(double) }
8
+ it { should eq '/etc/apt/apt.conf.d/01proxy' }
9
+ end
10
+
11
+ end
@@ -8,7 +8,7 @@ Gem::Specification.new do |spec|
8
8
  spec.version = VagrantPlugins::ProxyConf::VERSION
9
9
  spec.authors = ["Teemu Matilainen"]
10
10
  spec.email = ["teemu.matilainen@iki.fi"]
11
- spec.description = "A Vagrant Plugin that configures the virtual machine to use proxies"
11
+ spec.description = "A Vagrant plugin that configures the virtual machine to use proxies"
12
12
  spec.summary = spec.description
13
13
  spec.homepage = "http://tmatilai.github.io/vagrant-proxyconf/"
14
14
  spec.license = "MIT"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vagrant-proxyconf
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,9 +9,9 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-07-05 00:00:00.000000000 Z
12
+ date: 2013-07-12 00:00:00.000000000 Z
13
13
  dependencies: []
14
- description: A Vagrant Plugin that configures the virtual machine to use proxies
14
+ description: A Vagrant plugin that configures the virtual machine to use proxies
15
15
  email:
16
16
  - teemu.matilainen@iki.fi
17
17
  executables: []
@@ -20,6 +20,7 @@ extra_rdoc_files: []
20
20
  files:
21
21
  - .gitignore
22
22
  - .travis.yml
23
+ - .yardopts
23
24
  - CHANGELOG.md
24
25
  - Gemfile
25
26
  - Guardfile
@@ -37,6 +38,8 @@ files:
37
38
  - lib/vagrant-proxyconf/version.rb
38
39
  - spec/spec_helper.rb
39
40
  - spec/unit/support/shared/apt_proxy_config.rb
41
+ - spec/unit/vagrant-proxyconf/action/configure_apt_proxy_spec.rb
42
+ - spec/unit/vagrant-proxyconf/cap/debian/apt_proxy_conf_spec.rb
40
43
  - spec/unit/vagrant-proxyconf/config/apt_proxy_spec.rb
41
44
  - spec/unit/vagrant-proxyconf/plugin_spec.rb
42
45
  - vagrant-proxyconf.gemspec
@@ -55,7 +58,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
55
58
  version: '0'
56
59
  segments:
57
60
  - 0
58
- hash: -654121375063372740
61
+ hash: 3198216208626978364
59
62
  required_rubygems_version: !ruby/object:Gem::Requirement
60
63
  none: false
61
64
  requirements:
@@ -64,15 +67,18 @@ required_rubygems_version: !ruby/object:Gem::Requirement
64
67
  version: '0'
65
68
  segments:
66
69
  - 0
67
- hash: -654121375063372740
70
+ hash: 3198216208626978364
68
71
  requirements: []
69
72
  rubyforge_project:
70
73
  rubygems_version: 1.8.23
71
74
  signing_key:
72
75
  specification_version: 3
73
- summary: A Vagrant Plugin that configures the virtual machine to use proxies
76
+ summary: A Vagrant plugin that configures the virtual machine to use proxies
74
77
  test_files:
75
78
  - spec/spec_helper.rb
76
79
  - spec/unit/support/shared/apt_proxy_config.rb
80
+ - spec/unit/vagrant-proxyconf/action/configure_apt_proxy_spec.rb
81
+ - spec/unit/vagrant-proxyconf/cap/debian/apt_proxy_conf_spec.rb
77
82
  - spec/unit/vagrant-proxyconf/config/apt_proxy_spec.rb
78
83
  - spec/unit/vagrant-proxyconf/plugin_spec.rb
84
+ has_rdoc: