vagrant-butter 0.0.2 → 0.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/.gitignore CHANGED
@@ -15,3 +15,5 @@ spec/reports
15
15
  test/tmp
16
16
  test/version_tmp
17
17
  tmp
18
+ .rvmrc
19
+ .rbx/
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2011 Fletcher Nichol
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md CHANGED
@@ -1,14 +1,30 @@
1
- # vagrant-butter
1
+ # <a name="title"></a> vagrant-butter
2
2
 
3
- ## Install
3
+ ## <a name="installation"></a> Installation
4
+
5
+ Using Vagrant installed from package:
6
+
7
+ ```sh
8
+ vagrant gem install vagrant-butter
9
+ ```
10
+
11
+ Using Vagrant installed as a gem:
4
12
 
5
13
  ```sh
6
14
  gem install vagrant-butter
7
15
  ```
8
16
 
9
- ## Helpers
17
+ ## <a name="middleware"></a> Middleware
10
18
 
11
- ### local_ip
19
+ #### <a name="middleware-sethostname"></a> SetHostName
20
+
21
+ Sets a default host name based on the directory containing your
22
+ `Vagrantfile`. For example a project in `/tmp/vagrant/chef-testing`
23
+ will set the host name to `chef-testing.vagrantup.com`.
24
+
25
+ ## <a name="helpers"></a> Helpers
26
+
27
+ ### <a name="helpers-localip"></a> local_ip
12
28
 
13
29
  #### Usage
14
30
 
@@ -16,12 +32,41 @@ gem install vagrant-butter
16
32
  include Vagrant::Butter::Helpers
17
33
  ```
18
34
 
19
- ## Patches and Support
35
+ ## <a name="patches"></a> Patches
20
36
 
21
- ### SuSE Halting and Setting Hostname
37
+ ### <a name="patches-suse"></a> SuSE Halting and Setting Hostname
22
38
 
23
39
  #### Usage
24
40
 
25
41
  ```ruby
26
42
  require 'vagrant/butter/systems/suse'
27
43
  ```
44
+
45
+ ## <a name="development"></a> Development
46
+
47
+ * Source hosted at [GitHub][repo]
48
+ * Report issues/questions/feature requests on [GitHub Issues][issues]
49
+
50
+ Pull requests are very welcome! Make sure your patches are well tested.
51
+ Ideally create a topic branch for every separate change you make. For
52
+ example:
53
+
54
+ 1. Fork the repo
55
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
56
+ 3. Commit your changes (`git commit -am 'Added some feature'`)
57
+ 4. Push to the branch (`git push origin my-new-feature`)
58
+ 5. Create new Pull Request
59
+
60
+ ## <a name="authors"></a> Authors
61
+
62
+ Created and maintained by [Fletcher Nichol][fnichol] (<fnichol@nichol.ca>)
63
+
64
+ ## <a name="license"></a> License
65
+
66
+ MIT (see [LICENSE][license])
67
+
68
+ [license]: https://github.com/fnichol/vagrant-butter/blob/master/LICENSE
69
+ [fnichol]: https://github.com/fnichol
70
+ [repo]: https://github.com/fnichol/vagrant-butter
71
+ [issues]: https://github.com/fnichol/vagrant-butter/issues
72
+ [contributors]: https://github.com/fnichol/vagrant-butter/contributors
data/Rakefile CHANGED
@@ -1,2 +1,12 @@
1
1
  #!/usr/bin/env rake
2
2
  require 'bundler/gem_tasks'
3
+
4
+ require 'rake/testtask'
5
+
6
+ Rake::TestTask.new do |t|
7
+ t.libs.push "lib"
8
+ t.test_files = FileList['spec/**/*_spec.rb']
9
+ t.verbose = true
10
+ end
11
+
12
+ task :default => 'test'
@@ -1,3 +1,4 @@
1
1
  # coding: utf-8
2
2
 
3
+ require 'vagrant/butter/action/vm/set_host_name'
3
4
  require 'vagrant/butter/helpers'
@@ -0,0 +1,27 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ module Vagrant
4
+ module Butter
5
+ module Action
6
+ module VM
7
+ class SetHostName
8
+ def initialize(app, env)
9
+ @app = app
10
+ end
11
+
12
+ def call(env)
13
+ if env[:vm].config.vm.host_name.nil?
14
+ host = File.basename(env[:vm].env.root_path).gsub(/_/, '-')
15
+ env[:vm].config.vm.host_name = "#{host}.vagrantup.com"
16
+ end
17
+
18
+ @app.call(env)
19
+ end
20
+ end
21
+ end
22
+ end
23
+ end
24
+ end
25
+
26
+ Vagrant.actions[:start].
27
+ insert_before(Vagrant::Action::VM::HostName, Vagrant::Butter::Action::VM::SetHostName)
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Vagrant
4
4
  module Butter
5
- VERSION = "0.0.2"
5
+ VERSION = "0.0.3"
6
6
  end
7
7
  end
@@ -0,0 +1,48 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require 'minitest/autorun'
3
+ require 'mocha'
4
+ require 'vagrant'
5
+ require 'vagrant/butter/action/vm/set_host_name'
6
+
7
+ describe Vagrant::Butter::Action::VM::SetHostName do
8
+ include Vagrant::TestHelpers
9
+
10
+ let(:middleware) { Vagrant::Butter::Action::VM::SetHostName.new(@app, @env) }
11
+ let(:host_name) { @env["vm"].config.vm.host_name }
12
+
13
+ def stub_root_path!(path)
14
+ @env[:vm].env.stubs(:root_path).returns(Pathname.new(path))
15
+ end
16
+
17
+ before do
18
+ @app, @env = action_env
19
+ end
20
+
21
+ it "invokes the next middleware" do
22
+ @app.expects(:call).with(@env).once
23
+
24
+ middleware.call(@env)
25
+ end
26
+
27
+ it "sets host name to the current working directory name" do
28
+ stub_root_path! "/tmp/vagrant/myhost"
29
+ middleware.call(@env)
30
+
31
+ host_name.must_equal "myhost.vagrantup.com"
32
+ end
33
+
34
+ it "replaces underscores with dashes" do
35
+ stub_root_path! "/vagrants/the_dude_app_1"
36
+ middleware.call(@env)
37
+
38
+ host_name.must_equal "the-dude-app-1.vagrantup.com"
39
+ end
40
+
41
+ it "uses the host name from a Vagrantfile over default" do
42
+ stub_root_path! "/tmp/vagrant/fuzzypants"
43
+ @env[:vm].config.vm.host_name = "buzzkill.example.com"
44
+ middleware.call(@env)
45
+
46
+ host_name.must_equal "buzzkill.example.com"
47
+ end
48
+ end
@@ -15,5 +15,8 @@ Gem::Specification.new do |gem|
15
15
  gem.require_paths = ['lib']
16
16
  gem.version = Vagrant::Butter::VERSION
17
17
 
18
- gem.add_dependency "vagrant", "~> 0"
18
+ gem.add_dependency "vagrant", "~> 1.0.0"
19
+
20
+ gem.add_development_dependency "minitest", "~> 2.12.0"
21
+ gem.add_development_dependency "mocha"
19
22
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vagrant-butter
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,19 +9,41 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-02-05 00:00:00.000000000 Z
12
+ date: 2012-04-09 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: vagrant
16
- requirement: &2157134260 !ruby/object:Gem::Requirement
16
+ requirement: &70191129620780 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
20
20
  - !ruby/object:Gem::Version
21
- version: '0'
21
+ version: 1.0.0
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *2157134260
24
+ version_requirements: *70191129620780
25
+ - !ruby/object:Gem::Dependency
26
+ name: minitest
27
+ requirement: &70191129620280 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ~>
31
+ - !ruby/object:Gem::Version
32
+ version: 2.12.0
33
+ type: :development
34
+ prerelease: false
35
+ version_requirements: *70191129620280
36
+ - !ruby/object:Gem::Dependency
37
+ name: mocha
38
+ requirement: &70191129619880 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ! '>='
42
+ - !ruby/object:Gem::Version
43
+ version: '0'
44
+ type: :development
45
+ prerelease: false
46
+ version_requirements: *70191129619880
25
47
  description: Smooth out Vagrantfiles with some common helpers and shims
26
48
  email:
27
49
  - fnichol@nichol.ca
@@ -31,13 +53,16 @@ extra_rdoc_files: []
31
53
  files:
32
54
  - .gitignore
33
55
  - Gemfile
56
+ - LICENSE
34
57
  - README.md
35
58
  - Rakefile
36
59
  - lib/vagrant-butter.rb
60
+ - lib/vagrant/butter/action/vm/set_host_name.rb
37
61
  - lib/vagrant/butter/helpers.rb
38
62
  - lib/vagrant/butter/systems/suse.rb
39
63
  - lib/vagrant/butter/version.rb
40
64
  - lib/vagrant_init.rb
65
+ - spec/vagrant/butter/action/vm/set_host_name_spec.rb
41
66
  - vagrant-butter.gemspec
42
67
  homepage: https://github.com/fnichol/vagrant-butter#readme
43
68
  licenses: []
@@ -53,7 +78,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
53
78
  version: '0'
54
79
  segments:
55
80
  - 0
56
- hash: -3594635565780566737
81
+ hash: -4045232948945146367
57
82
  required_rubygems_version: !ruby/object:Gem::Requirement
58
83
  none: false
59
84
  requirements:
@@ -62,11 +87,12 @@ required_rubygems_version: !ruby/object:Gem::Requirement
62
87
  version: '0'
63
88
  segments:
64
89
  - 0
65
- hash: -3594635565780566737
90
+ hash: -4045232948945146367
66
91
  requirements: []
67
92
  rubyforge_project:
68
- rubygems_version: 1.8.10
93
+ rubygems_version: 1.8.17
69
94
  signing_key:
70
95
  specification_version: 3
71
96
  summary: Smooth out Vagrantfiles with some common helpers and shims
72
- test_files: []
97
+ test_files:
98
+ - spec/vagrant/butter/action/vm/set_host_name_spec.rb