Skip to content

Commit

Permalink
Release first working v0.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
rdsubhas committed Aug 13, 2014
1 parent e0bbd11 commit 8e5d0e7
Show file tree
Hide file tree
Showing 9 changed files with 177 additions and 28 deletions.
148 changes: 148 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,151 @@
# Created by http://www.gitignore.io

### Linux ###
*~

# KDE directory preferences
.directory


### Windows ###
# Windows image file caches
Thumbs.db
ehthumbs.db

# Folder config file
Desktop.ini

# Recycle Bin used on file shares
$RECYCLE.BIN/

# Windows Installer files
*.cab
*.msi
*.msm
*.msp


### OSX ###
.DS_Store
.AppleDouble
.LSOverride

# Icon must end with two \r
Icon


# Thumbnails
._*

# Files that might appear on external disk
.Spotlight-V100
.Trashes

# Directories potentially created on remote AFP share
.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk


### vim ###
[._]*.s[a-w][a-z]
[._]s[a-w][a-z]
*.un~
Session.vim
.netrwhist
*~


### SublimeText ###
# workspace files are user-specific
*.sublime-workspace

# project files should be checked into the repository, unless a significant
# proportion of contributors will probably not be using SublimeText
# *.sublime-project

#sftp configuration file
sftp-config.json


### RubyMine ###
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm

## Directory-based project format
.idea/
# if you remove the above rule, at least ignore user-specific stuff:
# .idea/workspace.xml
# .idea/tasks.xml
# and these sensitive or high-churn files:
# .idea/dataSources.ids
# .idea/dataSources.xml
# .idea/sqlDataSources.xml
# .idea/dynamic.xml

## File-based project format
*.ipr
*.iml
*.iws

## Additional for IntelliJ
out/

# generated by mpeltonen/sbt-idea plugin
.idea_modules/

# generated by JIRA plugin
atlassian-ide-plugin.xml

# generated by Crashlytics plugin (for Android Studio and Intellij)
com_crashlytics_export_strings.xml


### Vagrant ###
.vagrant/


### Ruby ###
*.gem
*.rbc
/.config
/coverage/
/InstalledFiles
/pkg/
/spec/reports/
/test/tmp/
/test/version_tmp/
/tmp/

## Specific to RubyMotion:
.dat*
.repl_history
build/

## Documentation cache and generated files:
/.yardoc/
/_yardoc/
/doc/
/rdoc/

## Environment normalisation:
/.bundle/
/lib/bundler/man/

# for a library or gem, you might want to ignore these files since the code is
# intended to run in multiple environments; otherwise, check them in:
# Gemfile.lock
# .ruby-version
# .ruby-gemset

# unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
.rvmrc

###
### Custom ignores
###

*.gem
*.rbc
.bundle
Expand Down
1 change: 1 addition & 0 deletions .ruby-gemset
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
vagrant-faster
1 change: 1 addition & 0 deletions .ruby-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
2.1.2
12 changes: 0 additions & 12 deletions .travis.yml

This file was deleted.

4 changes: 4 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,7 @@ gemspec
group :development do
gem "vagrant", git: "https://github.com/mitchellh/vagrant.git"
end

group :plugins do
gem "vagrant-faster", path: "."
end
9 changes: 9 additions & 0 deletions Vagrantfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# -*- mode: ruby -*-
# vi: set ft=ruby :

# Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
VAGRANTFILE_API_VERSION = "2"

Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.box = "yungsang/boot2docker"
end
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
module Vagrant
module Faster
class Middleware
class Action
def initialize(app, env)
@app = app
@env = env
end

def call(env)
@env = env
vm = env[:vm] || env[:machine]
vm = env[:vm] || env[:machine]

cpus, mem = optimal_settings
if cpus > 0 && mem > 0
puts "[vagrant-faster] Setting CPUs: #{cpus} and Memory: #{mem}"
vm.cpus = cpus
vm.memory = memory
env[:ui].warn "[vagrant-faster] Setting CPUs: #{cpus}, Memory: #{mem}"
vm.provider_config.customizations << ["pre-boot", ["modifyvm", :id, "--memory", mem]]
vm.provider_config.customizations << ["pre-boot", ["modifyvm", :id, "--cpus", cpus]]
else
puts "[vagrant-faster] was unable to detect optimal settings for your machine"
env[:ui].warn "[vagrant-faster] was unable to detect optimal settings for your machine"
end

@app.call env
end

def optimal_settings
Expand All @@ -40,7 +40,7 @@ def optimal_settings
mem = mem / 4 if mem > 2048
rescue; end

cpus, mem
[ cpus, mem ]
end
end
end
Expand Down
9 changes: 4 additions & 5 deletions lib/vagrant/faster/plugin.rb
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
module Vagrant
module Faster
class Plugin
class Plugin < Vagrant.plugin('2')
name 'vagrant-faster'
description 'Make VMs faster by allocating more Memory/CPU based on your machine capacity'

action_hook 'faster' do |hook|
require_relative './middleware'
puts "[vagrant-faster] hook"
hook.before VagrantPlugins::ProviderVirtualBox::Action::Boot, Vagrant::Faster::Middleware
action_hook 'faster', :machine_action_up do |hook|
require_relative './action'
hook.before VagrantPlugins::ProviderVirtualBox::Action::Customize, Vagrant::Faster::Action
end
end
end
Expand Down
3 changes: 1 addition & 2 deletions vagrant-faster.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)

Gem::Specification.new do |spec|
spec.name = "vagrant-faster"
spec.version = "0.0.3"
spec.version = "#{spec.version}-alpha-#{ENV['TRAVIS_BUILD_NUMBER']}" if ENV['TRAVIS']
spec.version = "0.1.0"

spec.authors = ["rdsubhas"]
spec.email = ["[email protected]"]
Expand Down

0 comments on commit 8e5d0e7

Please sign in to comment.