vagrant-hp 0.1.0 → 0.1.1
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 +59 -59
- data/CHANGELOG.md +6 -3
- data/Gemfile +10 -10
- data/LICENSE +9 -0
- data/README.md +172 -167
- data/Rakefile +21 -21
- data/example_box/README.md +13 -13
- data/example_box/Vagrantfile +7 -7
- data/example_box/metadata.json +3 -3
- data/lib/vagrant-hp.rb +18 -18
- data/lib/vagrant-hp/action.rb +110 -110
- data/lib/vagrant-hp/action/connect_hp.rb +54 -54
- data/lib/vagrant-hp/action/create_server.rb +124 -121
- data/lib/vagrant-hp/action/delete_server.rb +30 -30
- data/lib/vagrant-hp/action/halt_server.rb +30 -30
- data/lib/vagrant-hp/action/is_created.rb +23 -23
- data/lib/vagrant-hp/action/is_running.rb +23 -23
- data/lib/vagrant-hp/action/message_already_created.rb +21 -21
- data/lib/vagrant-hp/action/message_not_created.rb +21 -21
- data/lib/vagrant-hp/action/read_ssh_info.rb +51 -51
- data/lib/vagrant-hp/action/read_state.rb +43 -43
- data/lib/vagrant-hp/action/sync_folders.rb +63 -63
- data/lib/vagrant-hp/action/timed_provision.rb +27 -27
- data/lib/vagrant-hp/action/warn_networks.rb +24 -24
- data/lib/vagrant-hp/config.rb +159 -157
- data/lib/vagrant-hp/errors.rb +24 -24
- data/lib/vagrant-hp/plugin.rb +78 -78
- data/lib/vagrant-hp/provider.rb +55 -55
- data/lib/vagrant-hp/util/timer.rb +17 -17
- data/lib/vagrant-hp/version.rb +10 -10
- data/locales/en.yml +91 -91
- data/spec/vagrant-hp/config_spec.rb +42 -42
- data/vagrant-hp.gemspec +59 -59
- metadata +4 -3
data/lib/vagrant-hp/provider.rb
CHANGED
@@ -1,55 +1,55 @@
|
|
1
|
-
#
|
2
|
-
# Author:: Mohit Sethi (<mohit@sethis.in>)
|
3
|
-
# Copyright:: Copyright (c) 2013 Mohit Sethi.
|
4
|
-
#
|
5
|
-
|
6
|
-
require "log4r"
|
7
|
-
require "vagrant"
|
8
|
-
|
9
|
-
module VagrantPlugins
|
10
|
-
module HP
|
11
|
-
class Provider < Vagrant.plugin("2", :provider)
|
12
|
-
def initialize(machine)
|
13
|
-
@machine = machine
|
14
|
-
end
|
15
|
-
|
16
|
-
def action(name)
|
17
|
-
# Attempt to get the action method from the Action class if it
|
18
|
-
# exists, otherwise return nil to show that we don't support the
|
19
|
-
# given action.
|
20
|
-
action_method = "action_#{name}"
|
21
|
-
return Action.send(action_method) if Action.respond_to?(action_method)
|
22
|
-
nil
|
23
|
-
end
|
24
|
-
|
25
|
-
def ssh_info
|
26
|
-
# Run a custom action called "read_ssh_info" which does what it
|
27
|
-
# says and puts the resulting SSH info into the `:machine_ssh_info`
|
28
|
-
# key in the environment.
|
29
|
-
env = @machine.action("read_ssh_info")
|
30
|
-
env[:machine_ssh_info]
|
31
|
-
end
|
32
|
-
|
33
|
-
def state
|
34
|
-
# Run a custom action we define called "read_state" which does
|
35
|
-
# what it says. It puts the state in the `:machine_state_id`
|
36
|
-
# key in the environment.
|
37
|
-
env = @machine.action("read_state")
|
38
|
-
|
39
|
-
state_id = env[:machine_state_id]
|
40
|
-
|
41
|
-
# Get the short and long description
|
42
|
-
short = I18n.t("vagrant_hp.states.short_#{state_id.to_s.downcase}")
|
43
|
-
long = I18n.t("vagrant_hp.states.long_#{state_id.to_s.downcase}")
|
44
|
-
|
45
|
-
# Return the MachineState object
|
46
|
-
Vagrant::MachineState.new(state_id, short, long)
|
47
|
-
end
|
48
|
-
|
49
|
-
def to_s
|
50
|
-
id = @machine.id.nil? ? "new" : @machine.id
|
51
|
-
"HP (#{id})"
|
52
|
-
end
|
53
|
-
end
|
54
|
-
end
|
55
|
-
end
|
1
|
+
#
|
2
|
+
# Author:: Mohit Sethi (<mohit@sethis.in>)
|
3
|
+
# Copyright:: Copyright (c) 2013 Mohit Sethi.
|
4
|
+
#
|
5
|
+
|
6
|
+
require "log4r"
|
7
|
+
require "vagrant"
|
8
|
+
|
9
|
+
module VagrantPlugins
|
10
|
+
module HP
|
11
|
+
class Provider < Vagrant.plugin("2", :provider)
|
12
|
+
def initialize(machine)
|
13
|
+
@machine = machine
|
14
|
+
end
|
15
|
+
|
16
|
+
def action(name)
|
17
|
+
# Attempt to get the action method from the Action class if it
|
18
|
+
# exists, otherwise return nil to show that we don't support the
|
19
|
+
# given action.
|
20
|
+
action_method = "action_#{name}"
|
21
|
+
return Action.send(action_method) if Action.respond_to?(action_method)
|
22
|
+
nil
|
23
|
+
end
|
24
|
+
|
25
|
+
def ssh_info
|
26
|
+
# Run a custom action called "read_ssh_info" which does what it
|
27
|
+
# says and puts the resulting SSH info into the `:machine_ssh_info`
|
28
|
+
# key in the environment.
|
29
|
+
env = @machine.action("read_ssh_info")
|
30
|
+
env[:machine_ssh_info]
|
31
|
+
end
|
32
|
+
|
33
|
+
def state
|
34
|
+
# Run a custom action we define called "read_state" which does
|
35
|
+
# what it says. It puts the state in the `:machine_state_id`
|
36
|
+
# key in the environment.
|
37
|
+
env = @machine.action("read_state")
|
38
|
+
|
39
|
+
state_id = env[:machine_state_id]
|
40
|
+
|
41
|
+
# Get the short and long description
|
42
|
+
short = I18n.t("vagrant_hp.states.short_#{state_id.to_s.downcase}")
|
43
|
+
long = I18n.t("vagrant_hp.states.long_#{state_id.to_s.downcase}")
|
44
|
+
|
45
|
+
# Return the MachineState object
|
46
|
+
Vagrant::MachineState.new(state_id, short, long)
|
47
|
+
end
|
48
|
+
|
49
|
+
def to_s
|
50
|
+
id = @machine.id.nil? ? "new" : @machine.id
|
51
|
+
"HP (#{id})"
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
@@ -1,17 +1,17 @@
|
|
1
|
-
module VagrantPlugins
|
2
|
-
module HP
|
3
|
-
module Util
|
4
|
-
class Timer
|
5
|
-
# A basic utility method that times the execution of the given
|
6
|
-
# block and returns it.
|
7
|
-
def self.time
|
8
|
-
start_time = Time.now.to_f
|
9
|
-
yield
|
10
|
-
end_time = Time.now.to_f
|
11
|
-
|
12
|
-
end_time - start_time
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
1
|
+
module VagrantPlugins
|
2
|
+
module HP
|
3
|
+
module Util
|
4
|
+
class Timer
|
5
|
+
# A basic utility method that times the execution of the given
|
6
|
+
# block and returns it.
|
7
|
+
def self.time
|
8
|
+
start_time = Time.now.to_f
|
9
|
+
yield
|
10
|
+
end_time = Time.now.to_f
|
11
|
+
|
12
|
+
end_time - start_time
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
data/lib/vagrant-hp/version.rb
CHANGED
@@ -1,10 +1,10 @@
|
|
1
|
-
#
|
2
|
-
# Author:: Mohit Sethi (<mohit@sethis.in>)
|
3
|
-
# Copyright:: Copyright (c) 2013 Mohit Sethi.
|
4
|
-
#
|
5
|
-
|
6
|
-
module VagrantPlugins
|
7
|
-
module HP
|
8
|
-
VERSION = "0.1.
|
9
|
-
end
|
10
|
-
end
|
1
|
+
#
|
2
|
+
# Author:: Mohit Sethi (<mohit@sethis.in>)
|
3
|
+
# Copyright:: Copyright (c) 2013 Mohit Sethi.
|
4
|
+
#
|
5
|
+
|
6
|
+
module VagrantPlugins
|
7
|
+
module HP
|
8
|
+
VERSION = "0.1.1"
|
9
|
+
end
|
10
|
+
end
|
data/locales/en.yml
CHANGED
@@ -1,91 +1,91 @@
|
|
1
|
-
en:
|
2
|
-
vagrant_hp:
|
3
|
-
already_created: |-
|
4
|
-
The machine is already created.
|
5
|
-
launching_server: |-
|
6
|
-
Launching a server with the following settings...
|
7
|
-
launch_no_keypair: |-
|
8
|
-
Warning! You didn't specify a keypair to launch your instance with.
|
9
|
-
This can sometimes result in not being able to access your instance.
|
10
|
-
launch_vpc_warning: |-
|
11
|
-
Warning! You're launching this instance into a VPC without an
|
12
|
-
elastic IP. Please verify you're properly connected to a VPN so
|
13
|
-
you can access this machine, otherwise Vagrant will not be able
|
14
|
-
to SSH into it.
|
15
|
-
not_created: |-
|
16
|
-
Instance is not created. Please run `vagrant up` first.
|
17
|
-
ready: |-
|
18
|
-
Machine is booted and ready for use!
|
19
|
-
rsync_folder: |-
|
20
|
-
Rsyncing folder: %{hostpath} => %{guestpath}
|
21
|
-
terminating: |-
|
22
|
-
Terminating the instance...
|
23
|
-
waiting_for_build: |-
|
24
|
-
Waiting for the server to be built...
|
25
|
-
waiting_for_ready: |-
|
26
|
-
Waiting for instance to become "ready"...
|
27
|
-
waiting_for_ssh: |-
|
28
|
-
Waiting for SSH to become available...
|
29
|
-
warn_networks: |-
|
30
|
-
Warning! The HP provider doesn't support any of the Vagrant
|
31
|
-
high-level network configurations (`config.vm.network`). They
|
32
|
-
will be silently ignored.
|
33
|
-
deleting_server: |-
|
34
|
-
"Attemping to delete server on HP Cloud"
|
35
|
-
finding_flavor: |-
|
36
|
-
Finding flavor for server...
|
37
|
-
finding_image: |-
|
38
|
-
Finding image for server...
|
39
|
-
|
40
|
-
default:
|
41
|
-
ssh_username_default: |-
|
42
|
-
No ssh_username provided, using "vagrant" as ssh_username
|
43
|
-
|
44
|
-
config:
|
45
|
-
access_key_required: |-
|
46
|
-
An access key is required, please specify via "access_key_id"
|
47
|
-
image_required: |-
|
48
|
-
An image is required, please specify via "image=<IMAGE_ID>" or "image=<IMAGE-NAME>"
|
49
|
-
ssh_private_key_path: |-
|
50
|
-
A private key is required, please specify via "ssh_private_key_path"
|
51
|
-
secret_key_required: |-
|
52
|
-
A secret key is required, please specify via "secret_key"
|
53
|
-
keypair_name_required: |-
|
54
|
-
A keypair name is required, please specify via "keypair_name".
|
55
|
-
tenant_id_required: |-
|
56
|
-
A tenant id is required, please specify via "tenant_id"
|
57
|
-
|
58
|
-
errors:
|
59
|
-
fog_error: |-
|
60
|
-
There was an error talking to HP. The error message is shown
|
61
|
-
below:
|
62
|
-
|
63
|
-
%{message}
|
64
|
-
rsync_error: |-
|
65
|
-
There was an error when attemping to rsync a share folder.
|
66
|
-
Please inspect the error message below for more info.
|
67
|
-
|
68
|
-
Host path: %{hostpath}
|
69
|
-
Guest path: %{guestpath}
|
70
|
-
Error: %{stderr}
|
71
|
-
|
72
|
-
states:
|
73
|
-
short_active: |-
|
74
|
-
active
|
75
|
-
long_active: |-
|
76
|
-
The server is up and running. Run `vagrant ssh` to access it.
|
77
|
-
short_build: |-
|
78
|
-
building
|
79
|
-
long_build: |-
|
80
|
-
The server is currently being built. You must wait for this to
|
81
|
-
complete before you can access it. You can delete the server, however,
|
82
|
-
by running `vagrant destroy`.
|
83
|
-
short_error: |-
|
84
|
-
error
|
85
|
-
long_error: |-
|
86
|
-
The server is in an erroneous state. Destroy the machine with
|
87
|
-
`vagrant destroy`.
|
88
|
-
short_not_created: |-
|
89
|
-
not created
|
90
|
-
long_not_created: |-
|
91
|
-
The server is not created. Run `vagrant up` to create it.
|
1
|
+
en:
|
2
|
+
vagrant_hp:
|
3
|
+
already_created: |-
|
4
|
+
The machine is already created.
|
5
|
+
launching_server: |-
|
6
|
+
Launching a server with the following settings...
|
7
|
+
launch_no_keypair: |-
|
8
|
+
Warning! You didn't specify a keypair to launch your instance with.
|
9
|
+
This can sometimes result in not being able to access your instance.
|
10
|
+
launch_vpc_warning: |-
|
11
|
+
Warning! You're launching this instance into a VPC without an
|
12
|
+
elastic IP. Please verify you're properly connected to a VPN so
|
13
|
+
you can access this machine, otherwise Vagrant will not be able
|
14
|
+
to SSH into it.
|
15
|
+
not_created: |-
|
16
|
+
Instance is not created. Please run `vagrant up` first.
|
17
|
+
ready: |-
|
18
|
+
Machine is booted and ready for use!
|
19
|
+
rsync_folder: |-
|
20
|
+
Rsyncing folder: %{hostpath} => %{guestpath}
|
21
|
+
terminating: |-
|
22
|
+
Terminating the instance...
|
23
|
+
waiting_for_build: |-
|
24
|
+
Waiting for the server to be built...
|
25
|
+
waiting_for_ready: |-
|
26
|
+
Waiting for instance to become "ready"...
|
27
|
+
waiting_for_ssh: |-
|
28
|
+
Waiting for SSH to become available...
|
29
|
+
warn_networks: |-
|
30
|
+
Warning! The HP provider doesn't support any of the Vagrant
|
31
|
+
high-level network configurations (`config.vm.network`). They
|
32
|
+
will be silently ignored.
|
33
|
+
deleting_server: |-
|
34
|
+
"Attemping to delete server on HP Cloud"
|
35
|
+
finding_flavor: |-
|
36
|
+
Finding flavor for server...
|
37
|
+
finding_image: |-
|
38
|
+
Finding image for server...
|
39
|
+
|
40
|
+
default:
|
41
|
+
ssh_username_default: |-
|
42
|
+
No ssh_username provided, using "vagrant" as ssh_username
|
43
|
+
|
44
|
+
config:
|
45
|
+
access_key_required: |-
|
46
|
+
An access key is required, please specify via "access_key_id"
|
47
|
+
image_required: |-
|
48
|
+
An image is required, please specify via "image=<IMAGE_ID>" or "image=<IMAGE-NAME>"
|
49
|
+
ssh_private_key_path: |-
|
50
|
+
A private key is required, please specify via "ssh_private_key_path"
|
51
|
+
secret_key_required: |-
|
52
|
+
A secret key is required, please specify via "secret_key"
|
53
|
+
keypair_name_required: |-
|
54
|
+
A keypair name is required, please specify via "keypair_name".
|
55
|
+
tenant_id_required: |-
|
56
|
+
A tenant id is required, please specify via "tenant_id"
|
57
|
+
|
58
|
+
errors:
|
59
|
+
fog_error: |-
|
60
|
+
There was an error talking to HP. The error message is shown
|
61
|
+
below:
|
62
|
+
|
63
|
+
%{message}
|
64
|
+
rsync_error: |-
|
65
|
+
There was an error when attemping to rsync a share folder.
|
66
|
+
Please inspect the error message below for more info.
|
67
|
+
|
68
|
+
Host path: %{hostpath}
|
69
|
+
Guest path: %{guestpath}
|
70
|
+
Error: %{stderr}
|
71
|
+
|
72
|
+
states:
|
73
|
+
short_active: |-
|
74
|
+
active
|
75
|
+
long_active: |-
|
76
|
+
The server is up and running. Run `vagrant ssh` to access it.
|
77
|
+
short_build: |-
|
78
|
+
building
|
79
|
+
long_build: |-
|
80
|
+
The server is currently being built. You must wait for this to
|
81
|
+
complete before you can access it. You can delete the server, however,
|
82
|
+
by running `vagrant destroy`.
|
83
|
+
short_error: |-
|
84
|
+
error
|
85
|
+
long_error: |-
|
86
|
+
The server is in an erroneous state. Destroy the machine with
|
87
|
+
`vagrant destroy`.
|
88
|
+
short_not_created: |-
|
89
|
+
not created
|
90
|
+
long_not_created: |-
|
91
|
+
The server is not created. Run `vagrant up` to create it.
|
@@ -1,42 +1,42 @@
|
|
1
|
-
require "vagrant-hp/config"
|
2
|
-
|
3
|
-
describe VagrantPlugins::HP::Config do
|
4
|
-
let(:instance) { described_class.new }
|
5
|
-
|
6
|
-
describe "defaults" do
|
7
|
-
subject do
|
8
|
-
instance.tap do |o|
|
9
|
-
o.finalize!
|
10
|
-
end
|
11
|
-
end
|
12
|
-
|
13
|
-
its("access_key") { should be_nil }
|
14
|
-
its("tenant_id") { should be_nil }
|
15
|
-
its("availability_zone") { should == "az1" }
|
16
|
-
its("image") { should be_nil }
|
17
|
-
its("keypair_name") { should be_nil }
|
18
|
-
its("secret_key") { should be_nil }
|
19
|
-
its("ssh_private_key_path") { should be_nil }
|
20
|
-
its("ssh_username") { should be_nil }
|
21
|
-
its("flavor") { should == "standard.small" }
|
22
|
-
its("tenant_id") { should be_nil }
|
23
|
-
its("server_name") { should be_nil }
|
24
|
-
end
|
25
|
-
|
26
|
-
describe "overriding defaults" do
|
27
|
-
# I typically don't meta-program in tests, but this is a very
|
28
|
-
# simple boilerplate test, so I cut corners here. It just sets
|
29
|
-
# each of these attributes to "foo" in isolation, and reads the value
|
30
|
-
# and asserts the proper result comes back out.
|
31
|
-
[:access_key, :tenant_id, :availability_zone, :image,
|
32
|
-
:keypair_name,:secret_key,:ssh_private_key_path,:ssh_username,
|
33
|
-
:flavor,:tenant_id,:server_name].each do |attribute|
|
34
|
-
|
35
|
-
it "should not default #{attribute} if overridden" do
|
36
|
-
instance.send("#{attribute}=".to_sym, "foo")
|
37
|
-
instance.finalize!
|
38
|
-
instance.send(attribute).should == "foo"
|
39
|
-
end
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|
1
|
+
require "vagrant-hp/config"
|
2
|
+
|
3
|
+
describe VagrantPlugins::HP::Config do
|
4
|
+
let(:instance) { described_class.new }
|
5
|
+
|
6
|
+
describe "defaults" do
|
7
|
+
subject do
|
8
|
+
instance.tap do |o|
|
9
|
+
o.finalize!
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
its("access_key") { should be_nil }
|
14
|
+
its("tenant_id") { should be_nil }
|
15
|
+
its("availability_zone") { should == "az1" }
|
16
|
+
its("image") { should be_nil }
|
17
|
+
its("keypair_name") { should be_nil }
|
18
|
+
its("secret_key") { should be_nil }
|
19
|
+
its("ssh_private_key_path") { should be_nil }
|
20
|
+
its("ssh_username") { should be_nil }
|
21
|
+
its("flavor") { should == "standard.small" }
|
22
|
+
its("tenant_id") { should be_nil }
|
23
|
+
its("server_name") { should be_nil }
|
24
|
+
end
|
25
|
+
|
26
|
+
describe "overriding defaults" do
|
27
|
+
# I typically don't meta-program in tests, but this is a very
|
28
|
+
# simple boilerplate test, so I cut corners here. It just sets
|
29
|
+
# each of these attributes to "foo" in isolation, and reads the value
|
30
|
+
# and asserts the proper result comes back out.
|
31
|
+
[:access_key, :tenant_id, :availability_zone, :image,
|
32
|
+
:keypair_name,:secret_key,:ssh_private_key_path,:ssh_username,
|
33
|
+
:flavor,:tenant_id,:server_name].each do |attribute|
|
34
|
+
|
35
|
+
it "should not default #{attribute} if overridden" do
|
36
|
+
instance.send("#{attribute}=".to_sym, "foo")
|
37
|
+
instance.finalize!
|
38
|
+
instance.send(attribute).should == "foo"
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
data/vagrant-hp.gemspec
CHANGED
@@ -1,59 +1,59 @@
|
|
1
|
-
$:.unshift File.expand_path("../lib", __FILE__)
|
2
|
-
require "vagrant-hp/version"
|
3
|
-
|
4
|
-
Gem::Specification.new do |s|
|
5
|
-
s.name = "vagrant-hp"
|
6
|
-
s.version = VagrantPlugins::HP::VERSION
|
7
|
-
s.platform = Gem::Platform::RUBY
|
8
|
-
s.authors = "Mohit Sethi"
|
9
|
-
s.email = "mohit@sethis.in"
|
10
|
-
s.homepage = "http://github.com/mohitsethi/vagrant-hp"
|
11
|
-
s.summary = "Enables Vagrant to manage machines on HP Cloud."
|
12
|
-
s.description = "Enables Vagrant to manage machines on HP Cloud."
|
13
|
-
|
14
|
-
s.required_rubygems_version = ">= 1.3.6"
|
15
|
-
s.rubyforge_project = "vagrant-hp"
|
16
|
-
|
17
|
-
s.add_runtime_dependency "fog", "~> 1.10.0"
|
18
|
-
|
19
|
-
s.add_development_dependency "rake"
|
20
|
-
s.add_development_dependency "rspec-core", "~> 2.12.2"
|
21
|
-
s.add_development_dependency "rspec-expectations", "~> 2.12.1"
|
22
|
-
s.add_development_dependency "rspec-mocks", "~> 2.12.1"
|
23
|
-
s.add_development_dependency "rubygems-bundler"
|
24
|
-
|
25
|
-
# The following block of code determines the files that should be included
|
26
|
-
# in the gem. It does this by reading all the files in the directory where
|
27
|
-
# this gemspec is, and parsing out the ignored files from the gitignore.
|
28
|
-
# Note that the entire gitignore(5) syntax is not supported, specifically
|
29
|
-
# the "!" syntax, but it should mostly work correctly.
|
30
|
-
root_path = File.dirname(__FILE__)
|
31
|
-
all_files = Dir.chdir(root_path) { Dir.glob("**/{*,.*}") }
|
32
|
-
all_files.reject! { |file| [".", ".."].include?(File.basename(file)) }
|
33
|
-
gitignore_path = File.join(root_path, ".gitignore")
|
34
|
-
gitignore = File.readlines(gitignore_path)
|
35
|
-
gitignore.map! { |line| line.chomp.strip }
|
36
|
-
gitignore.reject! { |line| line.empty? || line =~ /^(#|!)/ }
|
37
|
-
|
38
|
-
unignored_files = all_files.reject do |file|
|
39
|
-
# Ignore any directories, the gemspec only cares about files
|
40
|
-
next true if File.directory?(file)
|
41
|
-
|
42
|
-
# Ignore any paths that match anything in the gitignore. We do
|
43
|
-
# two tests here:
|
44
|
-
#
|
45
|
-
# - First, test to see if the entire path matches the gitignore.
|
46
|
-
# - Second, match if the basename does, this makes it so that things
|
47
|
-
# like '.DS_Store' will match sub-directories too (same behavior
|
48
|
-
# as git).
|
49
|
-
#
|
50
|
-
gitignore.any? do |ignore|
|
51
|
-
File.fnmatch(ignore, file, File::FNM_PATHNAME) ||
|
52
|
-
File.fnmatch(ignore, File.basename(file), File::FNM_PATHNAME)
|
53
|
-
end
|
54
|
-
end
|
55
|
-
|
56
|
-
s.files = unignored_files
|
57
|
-
s.executables = unignored_files.map { |f| f[/^bin\/(.*)/, 1] }.compact
|
58
|
-
s.require_path = 'lib'
|
59
|
-
end
|
1
|
+
$:.unshift File.expand_path("../lib", __FILE__)
|
2
|
+
require "vagrant-hp/version"
|
3
|
+
|
4
|
+
Gem::Specification.new do |s|
|
5
|
+
s.name = "vagrant-hp"
|
6
|
+
s.version = VagrantPlugins::HP::VERSION
|
7
|
+
s.platform = Gem::Platform::RUBY
|
8
|
+
s.authors = "Mohit Sethi"
|
9
|
+
s.email = "mohit@sethis.in"
|
10
|
+
s.homepage = "http://github.com/mohitsethi/vagrant-hp"
|
11
|
+
s.summary = "Enables Vagrant to manage machines on HP Cloud."
|
12
|
+
s.description = "Enables Vagrant to manage machines on HP Cloud."
|
13
|
+
|
14
|
+
s.required_rubygems_version = ">= 1.3.6"
|
15
|
+
s.rubyforge_project = "vagrant-hp"
|
16
|
+
|
17
|
+
s.add_runtime_dependency "fog", "~> 1.10.0"
|
18
|
+
|
19
|
+
s.add_development_dependency "rake"
|
20
|
+
s.add_development_dependency "rspec-core", "~> 2.12.2"
|
21
|
+
s.add_development_dependency "rspec-expectations", "~> 2.12.1"
|
22
|
+
s.add_development_dependency "rspec-mocks", "~> 2.12.1"
|
23
|
+
s.add_development_dependency "rubygems-bundler"
|
24
|
+
|
25
|
+
# The following block of code determines the files that should be included
|
26
|
+
# in the gem. It does this by reading all the files in the directory where
|
27
|
+
# this gemspec is, and parsing out the ignored files from the gitignore.
|
28
|
+
# Note that the entire gitignore(5) syntax is not supported, specifically
|
29
|
+
# the "!" syntax, but it should mostly work correctly.
|
30
|
+
root_path = File.dirname(__FILE__)
|
31
|
+
all_files = Dir.chdir(root_path) { Dir.glob("**/{*,.*}") }
|
32
|
+
all_files.reject! { |file| [".", ".."].include?(File.basename(file)) }
|
33
|
+
gitignore_path = File.join(root_path, ".gitignore")
|
34
|
+
gitignore = File.readlines(gitignore_path)
|
35
|
+
gitignore.map! { |line| line.chomp.strip }
|
36
|
+
gitignore.reject! { |line| line.empty? || line =~ /^(#|!)/ }
|
37
|
+
|
38
|
+
unignored_files = all_files.reject do |file|
|
39
|
+
# Ignore any directories, the gemspec only cares about files
|
40
|
+
next true if File.directory?(file)
|
41
|
+
|
42
|
+
# Ignore any paths that match anything in the gitignore. We do
|
43
|
+
# two tests here:
|
44
|
+
#
|
45
|
+
# - First, test to see if the entire path matches the gitignore.
|
46
|
+
# - Second, match if the basename does, this makes it so that things
|
47
|
+
# like '.DS_Store' will match sub-directories too (same behavior
|
48
|
+
# as git).
|
49
|
+
#
|
50
|
+
gitignore.any? do |ignore|
|
51
|
+
File.fnmatch(ignore, file, File::FNM_PATHNAME) ||
|
52
|
+
File.fnmatch(ignore, File.basename(file), File::FNM_PATHNAME)
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
s.files = unignored_files
|
57
|
+
s.executables = unignored_files.map { |f| f[/^bin\/(.*)/, 1] }.compact
|
58
|
+
s.require_path = 'lib'
|
59
|
+
end
|