vagrant_filoo 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +61 -0
- data/Gemfile +14 -0
- data/LICENSE +22 -0
- data/README.md +207 -0
- data/Rakefile +5 -0
- data/doc/img_res/filoo_logo.png +0 -0
- data/doc/img_res/filoo_wolke.png +0 -0
- data/example_box/README.md +13 -0
- data/example_box/metadata.json +3 -0
- data/filoo.box +0 -0
- data/lib/vagrant_filoo/action/create_server.rb +51 -0
- data/lib/vagrant_filoo/action/get_images.rb +21 -0
- data/lib/vagrant_filoo/action/is_created.rb +22 -0
- data/lib/vagrant_filoo/action/is_stopped.rb +18 -0
- data/lib/vagrant_filoo/action/message_already_created.rb +16 -0
- data/lib/vagrant_filoo/action/message_not_created.rb +16 -0
- data/lib/vagrant_filoo/action/read_ssh_info.rb +40 -0
- data/lib/vagrant_filoo/action/read_state.rb +65 -0
- data/lib/vagrant_filoo/action/start_instance.rb +48 -0
- data/lib/vagrant_filoo/action/stop_instance.rb +31 -0
- data/lib/vagrant_filoo/action/terminate_instance.rb +24 -0
- data/lib/vagrant_filoo/action/test.rb +2 -0
- data/lib/vagrant_filoo/action.rb +184 -0
- data/lib/vagrant_filoo/cloud_compute.rb +629 -0
- data/lib/vagrant_filoo/config.rb +54 -0
- data/lib/vagrant_filoo/errors.rb +81 -0
- data/lib/vagrant_filoo/plugin.rb +73 -0
- data/lib/vagrant_filoo/provider.rb +52 -0
- data/lib/vagrant_filoo/util/timer.rb +17 -0
- data/lib/vagrant_filoo/version.rb +5 -0
- data/lib/vagrant_filoo.rb +17 -0
- data/locales/en.yml +122 -0
- data/sample_config/Vagrantfile_example +23 -0
- data/spec/spec_helper.rb +0 -0
- data/spec/vagrant_filoo/config_spec.rb +70 -0
- data/templates/metadata.json.erb +3 -0
- data/templates/vagrant-filoo_package_Vagrantfile.erb +5 -0
- data/vagrant_filoo.gemspec +58 -0
- metadata +178 -0
@@ -0,0 +1,81 @@
|
|
1
|
+
require "vagrant"
|
2
|
+
|
3
|
+
module VagrantPlugins
|
4
|
+
module Filoo
|
5
|
+
module Errors
|
6
|
+
|
7
|
+
class InvaildServerParameterError < StandardError
|
8
|
+
def initialize(paramName, paramValue, serverStatus)
|
9
|
+
@paramName = paramName
|
10
|
+
@paramValue = paramValue
|
11
|
+
@serverStatus = serverStatus
|
12
|
+
end
|
13
|
+
|
14
|
+
def paramName
|
15
|
+
return @paramName
|
16
|
+
end
|
17
|
+
|
18
|
+
def paramValue
|
19
|
+
return @paramValue
|
20
|
+
end
|
21
|
+
|
22
|
+
def serverStatus
|
23
|
+
return @serverStatus
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
class VagrantFilooError < Vagrant::Errors::VagrantError
|
28
|
+
error_namespace('vagrant_filoo.errors')
|
29
|
+
end
|
30
|
+
|
31
|
+
class ImagesNotLoaded < VagrantFilooError
|
32
|
+
error_key 'images_not_loaded'
|
33
|
+
end
|
34
|
+
|
35
|
+
class ConfigError < VagrantFilooError
|
36
|
+
error_key('config_error')
|
37
|
+
end
|
38
|
+
|
39
|
+
class UnexpectedStateError < VagrantFilooError
|
40
|
+
error_key(:unexpected_state_error)
|
41
|
+
end
|
42
|
+
|
43
|
+
class FilooApiError < VagrantFilooError
|
44
|
+
error_key(:filoo_api_error)
|
45
|
+
end
|
46
|
+
|
47
|
+
class FilooJobFailedError < VagrantFilooError
|
48
|
+
error_key('filoo_job_failed_error')
|
49
|
+
end
|
50
|
+
|
51
|
+
class FilooJobResultTimeoutError < VagrantFilooError
|
52
|
+
error_key(:filoo_job_result_timeout_error)
|
53
|
+
end
|
54
|
+
|
55
|
+
class StartInstanceTimeout < VagrantFilooError
|
56
|
+
error_key(:start_instance_timeout)
|
57
|
+
end
|
58
|
+
|
59
|
+
class StopInstanceTimeout < VagrantFilooError
|
60
|
+
error_key(:stop_instance_timeout)
|
61
|
+
end
|
62
|
+
|
63
|
+
class CreateInstanceTimeout < VagrantFilooError
|
64
|
+
error_key(:create_instance_timeout)
|
65
|
+
end
|
66
|
+
|
67
|
+
class DeleteInstanceTimeout < VagrantFilooError
|
68
|
+
error_key(:delete_instance_timeout)
|
69
|
+
end
|
70
|
+
|
71
|
+
class RsyncError < VagrantFilooError
|
72
|
+
error_key(:rsync_error)
|
73
|
+
end
|
74
|
+
|
75
|
+
class MkdirError < VagrantFilooError
|
76
|
+
error_key(:mkdir_error)
|
77
|
+
end
|
78
|
+
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
@@ -0,0 +1,73 @@
|
|
1
|
+
begin
|
2
|
+
require 'vagrant'
|
3
|
+
rescue LoadError
|
4
|
+
raise 'The Vagrant Filoo plugin must be run within Vagrant.'
|
5
|
+
end
|
6
|
+
|
7
|
+
# This is a sanity check to make sure no one is attempting to install
|
8
|
+
# this into an early Vagrant version.
|
9
|
+
if Vagrant::VERSION < '0.0.1'
|
10
|
+
raise 'The Vagrant Filoo plugin is only compatible with Vagrant 0.0.1+'
|
11
|
+
end
|
12
|
+
|
13
|
+
module VagrantPlugins
|
14
|
+
module Filoo
|
15
|
+
class Plugin < Vagrant.plugin('2')
|
16
|
+
name 'Filoo'
|
17
|
+
description <<-DESC
|
18
|
+
This plugin installs a provider that allows Vagrant to manage
|
19
|
+
machines in the Filoo infrastructure).
|
20
|
+
DESC
|
21
|
+
|
22
|
+
config(:filoo, :provider) do
|
23
|
+
require_relative 'config'
|
24
|
+
Config
|
25
|
+
end
|
26
|
+
|
27
|
+
provider(:filoo, parallel: true) do
|
28
|
+
# Setup logging and i18n
|
29
|
+
setup_logging
|
30
|
+
setup_i18n
|
31
|
+
|
32
|
+
# Return the provider
|
33
|
+
require_relative 'provider'
|
34
|
+
Provider
|
35
|
+
end
|
36
|
+
|
37
|
+
# This initializes the internationalization strings.
|
38
|
+
def self.setup_i18n
|
39
|
+
I18n.load_path << File.expand_path('locales/en.yml', Filoo.source_root)
|
40
|
+
I18n.reload!
|
41
|
+
end
|
42
|
+
|
43
|
+
# This sets up our log level to be whatever VAGRANT_LOG is.
|
44
|
+
def self.setup_logging
|
45
|
+
require 'log4r'
|
46
|
+
|
47
|
+
level = nil
|
48
|
+
begin
|
49
|
+
level = Log4r.const_get(ENV['VAGRANT_LOG'].upcase)
|
50
|
+
rescue NameError
|
51
|
+
# This means that the logging constant wasn't found,
|
52
|
+
# which is fine. We just keep `level` as `nil`. But
|
53
|
+
# we tell the user.
|
54
|
+
level = nil
|
55
|
+
end
|
56
|
+
|
57
|
+
# Some constants, such as "true" resolve to booleans, so the
|
58
|
+
# above error checking doesn't catch it. This will check to make
|
59
|
+
# sure that the log level is an integer, as Log4r requires.
|
60
|
+
level = nil if !level.is_a?(Integer)
|
61
|
+
|
62
|
+
# Set the logging level on all "vagrant" namespaced
|
63
|
+
# logs as long as we have a valid level.
|
64
|
+
if level
|
65
|
+
logger = Log4r::Logger.new('vagrant_filoo')
|
66
|
+
logger.outputters = Log4r::Outputter.stderr
|
67
|
+
logger.level = level
|
68
|
+
logger = nil
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
require 'log4r'
|
2
|
+
require 'vagrant'
|
3
|
+
require 'vagrant_filoo/action'
|
4
|
+
|
5
|
+
module VagrantPlugins
|
6
|
+
module Filoo
|
7
|
+
class Provider < Vagrant.plugin('2', :provider)
|
8
|
+
def initialize(machine)
|
9
|
+
@machine = machine
|
10
|
+
end
|
11
|
+
|
12
|
+
def action(name)
|
13
|
+
# Attempt to get the action method from the Action class if it
|
14
|
+
# exists, otherwise return nil to show that we don't support the
|
15
|
+
# given action.
|
16
|
+
action_method = "action_#{name}"
|
17
|
+
return Action.send(action_method) if Action.respond_to?(action_method)
|
18
|
+
nil
|
19
|
+
end
|
20
|
+
|
21
|
+
def ssh_info
|
22
|
+
# Run a custom action called "read_ssh_info" which does what it
|
23
|
+
# says and puts the resulting SSH info into the `:machine_ssh_info`
|
24
|
+
# key in the environment.
|
25
|
+
env = @machine.action('read_ssh_info')
|
26
|
+
env[:machine_ssh_info]
|
27
|
+
end
|
28
|
+
|
29
|
+
def state
|
30
|
+
|
31
|
+
# Run a custom action we define called "read_state" which does
|
32
|
+
# what it says. It puts the state in the `:machine_state_id`
|
33
|
+
# key in the environment.
|
34
|
+
env = @machine.action('read_state')
|
35
|
+
|
36
|
+
state_id = env[:machine_state_id]
|
37
|
+
|
38
|
+
# Get the short and long description
|
39
|
+
short = I18n.t("vagrant_filoo.states.short_#{state_id}")
|
40
|
+
long = I18n.t("vagrant_filoo.states.long_#{state_id}")
|
41
|
+
|
42
|
+
# Return the MachineState object
|
43
|
+
Vagrant::MachineState.new(state_id, short, long)
|
44
|
+
end
|
45
|
+
|
46
|
+
def to_s
|
47
|
+
id = @machine.id.nil? ? 'new' : @machine.id
|
48
|
+
"Filoo (#{id})"
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module VagrantPlugins
|
2
|
+
module Filoo
|
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
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require "pathname"
|
2
|
+
require "vagrant_filoo/plugin"
|
3
|
+
|
4
|
+
module VagrantPlugins
|
5
|
+
module Filoo
|
6
|
+
lib_path = Pathname.new(File.expand_path("../vagrant_filoo", __FILE__))
|
7
|
+
autoload :Action, lib_path.join("action")
|
8
|
+
autoload :Errors, lib_path.join("errors")
|
9
|
+
|
10
|
+
# This returns the path to the source of this plugin.
|
11
|
+
#
|
12
|
+
# @return [Pathname]
|
13
|
+
def self.source_root
|
14
|
+
@source_root ||= Pathname.new(File.expand_path("../../", __FILE__))
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
data/locales/en.yml
ADDED
@@ -0,0 +1,122 @@
|
|
1
|
+
---
|
2
|
+
en:
|
3
|
+
vagrant_filoo:
|
4
|
+
already_created: "Server %{id} is already created."
|
5
|
+
already_status: "The machine is already %{status}."
|
6
|
+
config:
|
7
|
+
api_key_required: "An API key is required."
|
8
|
+
invalid_uri: "The value for %{key} is not a valid URI: %{uri}"
|
9
|
+
metadata_must_be_hash: "Metadata must be a hash."
|
10
|
+
public_key_not_found: |-
|
11
|
+
The public key file could not be found. Please make sure
|
12
|
+
you specified a valid path.
|
13
|
+
username_required: "A username is required."
|
14
|
+
creating_image: "Creating image..."
|
15
|
+
deleting_server: "Deleting server..."
|
16
|
+
|
17
|
+
ready: |-
|
18
|
+
Machine is booted and ready for use
|
19
|
+
|
20
|
+
errors:
|
21
|
+
config_error: |-
|
22
|
+
Configuration Error detected.
|
23
|
+
%{message}
|
24
|
+
create_instance_timeout: "Processing job create instance with job id %{job_id} took more than the specified timeout of %{timeout} seconds."
|
25
|
+
delete_instance_timeout: "Processing job delete instance with job id %{job_id} took more than the specified timeout of %{timeout} seconds."
|
26
|
+
filoo_api_error: |-
|
27
|
+
Remote Api Error.
|
28
|
+
Message %{message}
|
29
|
+
Error Code %{code}
|
30
|
+
Description %{description}
|
31
|
+
filoo_job_failed_error: |-
|
32
|
+
The remote processing of filoo job %{job_command} %{job_param} with uuid %{job_id} ended with status failed
|
33
|
+
Message %{message}
|
34
|
+
Command %{job_command}
|
35
|
+
Params %{job_param}
|
36
|
+
Job ID {job_id}
|
37
|
+
filoo_job_result_timeout_error: "The remote processing of filo job with uuid %{job_id} took more than the specified timeout of %{timeout} seconds. "
|
38
|
+
gen_error: |-
|
39
|
+
Configuration Error detected.
|
40
|
+
%{message}
|
41
|
+
images_not_loaded: "The System did not load the available images to check configuration parameter cd_image_name"
|
42
|
+
no_matching_flavor: |-
|
43
|
+
No matching flavor was found! Please check your flavor setting
|
44
|
+
to make sure you have a valid flavor chosen.
|
45
|
+
no_matching_image: |-
|
46
|
+
No matching image was found! Please check your image setting to
|
47
|
+
make sure you have a valid image chosen.
|
48
|
+
rsync_error: |-
|
49
|
+
There was an error when attemping to rsync a share folder.
|
50
|
+
Please inspect the error message below for more info.
|
51
|
+
|
52
|
+
Host path: %{hostpath}
|
53
|
+
Guest path: %{guestpath}
|
54
|
+
Error: %{stderr}
|
55
|
+
start_instance_timeout: "Processing job start instance with job id %{job_id} took more than the specified timeout of %{timeout} seconds. "
|
56
|
+
stop_instance_timeout: "Processing job stop instance with job id %{job_id} took more than the specified timeout of %{timeout} seconds."
|
57
|
+
|
58
|
+
unexpected_state_error: |-
|
59
|
+
The Maschine transitioned to an unexpected state.
|
60
|
+
state: '%{state}'.
|
61
|
+
Message %{message}
|
62
|
+
Description %{description}
|
63
|
+
Resource %{resource}
|
64
|
+
|
65
|
+
Run `vagrant status`
|
66
|
+
to find out what can be done about this state, or `vagrant destroy`
|
67
|
+
if you want to start over.
|
68
|
+
|
69
|
+
finding_flavor: "Finding flavor for server..."
|
70
|
+
finding_image: "Finding image for server..."
|
71
|
+
image_ready: "Image created"
|
72
|
+
launching_server: "Launching a server with the following settings..."
|
73
|
+
not_created: "The server hasn't been created yet. Run `vagrant up` first."
|
74
|
+
ready: "The server is ready!"
|
75
|
+
rsync_folder: "Rsyncing folder: %{hostpath} => %{guestpath}"
|
76
|
+
states:
|
77
|
+
long_deleted: "The Filoo instance is deleted."
|
78
|
+
long_disabled: "Filoo instance disabled"
|
79
|
+
long_not_activated: "The Filoo instance is not activated."
|
80
|
+
long_not_created: "The Filoo instance is not created. Run `vagrant up` to create it."
|
81
|
+
long_processing_autoinstall: "The Filoo instance is processing autoinstall."
|
82
|
+
long_running: |-
|
83
|
+
The Filoo instance is running. To stop this machine, you can run
|
84
|
+
`vagrant halt`. To destroy the machine, you can run `vagrant destroy`.
|
85
|
+
long_stopped: "The Filoo instance is stopped. Run `vagrant up` to start it."
|
86
|
+
long_unknown: "The State of the Filoo instance ist unknown"
|
87
|
+
short_deleted: deleted
|
88
|
+
short_disabled: disabled
|
89
|
+
short_not_activated: "not activated"
|
90
|
+
short_not_created: "not created"
|
91
|
+
short_processing_autoinstall: "processing autoinstall"
|
92
|
+
short_running: running
|
93
|
+
short_stopped: stopped
|
94
|
+
short_unknown: unknown
|
95
|
+
sync_folders: |-
|
96
|
+
Rackspace support for Vagrant 1.3 has been deprecated. Please
|
97
|
+
upgrade to the latest version of vagrant for continued support.
|
98
|
+
waiting_for_build: "Waiting for the server to be built..."
|
99
|
+
waiting_for_communicator: "Waiting for %{communicator} to become available at %{address}..."
|
100
|
+
waiting_for_rackconnect: "Waiting for RackConnect to complete..."
|
101
|
+
warn_insecure_ssh: |-
|
102
|
+
Warning! By not specifying a custom public/private keypair,
|
103
|
+
Vagrant is defaulting to use the insecure keypair that ships with
|
104
|
+
Vagrant. While this isn't much of a big deal for local development,
|
105
|
+
this is quite insecure for remote servers. Please specify a custom
|
106
|
+
public/private keypair.
|
107
|
+
warn_insecure_winrm: |-
|
108
|
+
Warning! Vagrant is using plaintext communication for WinRM. While
|
109
|
+
this isn't much of a big deal for local development, this is quite
|
110
|
+
insecure for remote servers. Please configure WinRM to use SSL.
|
111
|
+
warn_networks: |-
|
112
|
+
Warning! The Rackspace provider doesn't support any of the Vagrant
|
113
|
+
high-level network configurations (`config.vm.network`). They
|
114
|
+
will be silently ignored.
|
115
|
+
waiting_for_ssh: |-
|
116
|
+
Waiting for SSH to become available...
|
117
|
+
warn_winrm_password: |-
|
118
|
+
Warning! Vagrant has no way to store the Administrator password generated
|
119
|
+
by Rackspace for later use with WinRM. Please configure Vagrant to use
|
120
|
+
the same value for the winrm password and the Rackspace admin_password so
|
121
|
+
Vagrant will be able to connect via WinRM.
|
122
|
+
will_not_destroy: "The server will not be deleted."
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# -*- mode: ruby -*-
|
2
|
+
# vi: set ft=ruby :
|
3
|
+
|
4
|
+
Vagrant.configure("2") do |config|
|
5
|
+
config.vm.box = "filoo"
|
6
|
+
config.vm.provider :filoo do |filoo|
|
7
|
+
|
8
|
+
filoo.filoo_api_key = "your filoo api access key"
|
9
|
+
# or to use environment variable uncomment this
|
10
|
+
#filoo.filoo_api_key = ENV['FILOO_API_KEY']
|
11
|
+
|
12
|
+
filoo.filoo_api_entry_point = "https://api.filoo.de/api/v1"
|
13
|
+
# or to use environment variable uncomment this
|
14
|
+
#filoo.filoo_api_entry_point = ENV['FILOO_API_ENTTRY_POINT']
|
15
|
+
|
16
|
+
filoo.cd_image_name = "Debian 7.7 - 64bit"
|
17
|
+
filoo.type = "dynamic"
|
18
|
+
filoo.cpu = 1
|
19
|
+
filoo.ram = 128
|
20
|
+
filoo.hdd = 10
|
21
|
+
filoo.additional_nic = true #defaults to false
|
22
|
+
end
|
23
|
+
end
|
data/spec/spec_helper.rb
ADDED
File without changes
|
@@ -0,0 +1,70 @@
|
|
1
|
+
require "vagrant_filoo/config"
|
2
|
+
require 'rspec/its'
|
3
|
+
|
4
|
+
describe VagrantPlugins::Filoo::Config do
|
5
|
+
let(:instance) { described_class.new }
|
6
|
+
|
7
|
+
# Ensure tests are not affected by Filoo credential environment variables
|
8
|
+
before :each do
|
9
|
+
ENV.stub(:[] => nil)
|
10
|
+
end
|
11
|
+
|
12
|
+
describe "defaults" do
|
13
|
+
subject do
|
14
|
+
instance.tap do |o|
|
15
|
+
puts(o.inspect)
|
16
|
+
o.finalize!
|
17
|
+
end
|
18
|
+
end
|
19
|
+
its("filoo_api_key") { should be_nil }
|
20
|
+
its("filoo_api_entry_point") { should be_nil }
|
21
|
+
end
|
22
|
+
|
23
|
+
|
24
|
+
describe "overriding defaults" do
|
25
|
+
# I typically don't meta-program in tests, but this is a very
|
26
|
+
# simple boilerplate test, so I cut corners here. It just sets
|
27
|
+
# each of these attributes to "foo" in isolation, and reads the value
|
28
|
+
# and asserts the proper result comes back out.
|
29
|
+
[:filoo_api_key].each do |attribute|
|
30
|
+
|
31
|
+
it "should not default #{attribute} if overridden" do
|
32
|
+
instance.send("#{attribute}=".to_sym, "foo")
|
33
|
+
instance.finalize!
|
34
|
+
instance.send(attribute).should == "foo"
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
describe "getting credentials from environment" do
|
40
|
+
context "without FILOO credential environment variables" do
|
41
|
+
subject do
|
42
|
+
instance.tap do |o|
|
43
|
+
o.finalize!
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
its("filoo_api_key") { should be_nil }
|
48
|
+
|
49
|
+
end
|
50
|
+
|
51
|
+
context "with Filoo credential and entry point environment variables" do
|
52
|
+
before :each do
|
53
|
+
ENV.stub(:[]).with("FILOO_API_KEY").and_return("filoo_api_key")
|
54
|
+
ENV.stub(:[]).with("FILOO_API_ENTRY_POINT").and_return("http://example.com")
|
55
|
+
end
|
56
|
+
|
57
|
+
subject do
|
58
|
+
instance.tap do |o|
|
59
|
+
o.finalize!
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
its("filoo_api_key") { should == "filoo_api_key" }
|
64
|
+
its("filoo_api_entry_point") { should == "filoo_api_entry_point" }
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
|
69
|
+
|
70
|
+
end
|
@@ -0,0 +1,58 @@
|
|
1
|
+
$:.unshift File.expand_path("../lib", __FILE__)
|
2
|
+
require "vagrant_filoo/version"
|
3
|
+
|
4
|
+
Gem::Specification.new do |s|
|
5
|
+
s.name = "vagrant_filoo"
|
6
|
+
s.version = VagrantPlugins::Filoo::VERSION
|
7
|
+
s.platform = Gem::Platform::RUBY
|
8
|
+
s.authors = "Stefan heuer"
|
9
|
+
s.email = "stefan.heuer@huf-group.com"
|
10
|
+
s.summary = "Enables Vagrant to manage machines in Filoo infrastructure."
|
11
|
+
s.description = "Enables Vagrant to manage machines in Filoo infrastructure."
|
12
|
+
|
13
|
+
s.required_rubygems_version = ">= 1.3.6"
|
14
|
+
s.rubyforge_project = "vagrant_filoo"
|
15
|
+
|
16
|
+
s.add_runtime_dependency "rest-client", "~> 1.6.0"
|
17
|
+
s.add_development_dependency "rake"
|
18
|
+
s.add_development_dependency "rspec", "~> 2.12"
|
19
|
+
s.add_development_dependency "rspec-its"
|
20
|
+
s.add_development_dependency "rspec-mocks"
|
21
|
+
s.add_development_dependency "ci_reporter", "~> 1.9.1"
|
22
|
+
s.add_development_dependency "test-unit", "~> 2.5.5"
|
23
|
+
|
24
|
+
# The following block of code determines the files that should be included
|
25
|
+
# in the gem. It does this by reading all the files in the directory where
|
26
|
+
# this gemspec is, and parsing out the ignored files from the gitignore.
|
27
|
+
# Note that the entire gitignore(5) syntax is not supported, specifically
|
28
|
+
# the "!" syntax, but it should mostly work correctly.
|
29
|
+
root_path = File.dirname(__FILE__)
|
30
|
+
all_files = Dir.chdir(root_path) { Dir.glob("**/{*,.*}") }
|
31
|
+
all_files.reject! { |file| [".", ".."].include?(File.basename(file)) }
|
32
|
+
gitignore_path = File.join(root_path, ".gitignore")
|
33
|
+
gitignore = File.readlines(gitignore_path)
|
34
|
+
gitignore.map! { |line| line.chomp.strip }
|
35
|
+
gitignore.reject! { |line| line.empty? || line =~ /^(#|!)/ }
|
36
|
+
|
37
|
+
unignored_files = all_files.reject do |file|
|
38
|
+
# Ignore any directories, the gemspec only cares about files
|
39
|
+
next true if File.directory?(file)
|
40
|
+
|
41
|
+
# Ignore any paths that match anything in the gitignore. We do
|
42
|
+
# two tests here:
|
43
|
+
#
|
44
|
+
# - First, test to see if the entire path matches the gitignore.
|
45
|
+
# - Second, match if the basename does, this makes it so that things
|
46
|
+
# like '.DS_Store' will match sub-directories too (same behavior
|
47
|
+
# as git).
|
48
|
+
#
|
49
|
+
gitignore.any? do |ignore|
|
50
|
+
File.fnmatch(ignore, file, File::FNM_PATHNAME) ||
|
51
|
+
File.fnmatch(ignore, File.basename(file), File::FNM_PATHNAME)
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
s.files = unignored_files
|
56
|
+
s.executables = unignored_files.map { |f| f[/^bin\/(.*)/, 1] }.compact
|
57
|
+
s.require_path = 'lib'
|
58
|
+
end
|