freighthop 0.0.5 → 0.0.6

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/Vagrantfile CHANGED
@@ -22,13 +22,13 @@ Vagrant.configure('2') do |config|
22
22
 
23
23
  node_config.vm.provider :vmware_fusion do |v|
24
24
  v.vmx['displayName'] = Freighthop.hostname
25
- v.vmx['memsize'] = 2048
26
- v.vmx['numvcpus'] = 4
25
+ v.vmx['memsize'] = Freighthop.ram
26
+ v.vmx['numvcpus'] = Freighthop.cpus
27
27
  end
28
28
 
29
29
  node_config.vm.provider :virtualbox do |v|
30
- v.customize ['modifyvm', :id, '--memory', '2048']
31
- v.customize ['modifyvm', :id, '--cpus', '4']
30
+ v.customize ['modifyvm', :id, '--memory', Freighthop.ram]
31
+ v.customize ['modifyvm', :id, '--cpus', Freighthop.cpus]
32
32
  end
33
33
 
34
34
  node_config.vm.synced_folder(
data/bin/fh CHANGED
@@ -1,46 +1,80 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- FREIGHTHOP_VARGANT_DOTFILE_PATH = File.expand_path('~/.freighthop.d/vagrant')
4
- FREIGHTHOP_VARGANT_CWD = File.expand_path(File.dirname(__FILE__))
3
+ FREIGHTHOP_VAGRANT_DOTFILE_PATH = File.expand_path('~/.freighthop.d/vagrant')
4
+ FREIGHTHOP_VAGRANT_CWD = File.expand_path(File.dirname(__FILE__))
5
5
 
6
- unless File.directory?(FREIGHTHOP_VARGANT_DOTFILE_PATH)
6
+ unless File.directory?(FREIGHTHOP_VAGRANT_DOTFILE_PATH)
7
7
  require 'fileutils'
8
- FileUtils.mkdir_p(FREIGHTHOP_VARGANT_DOTFILE_PATH)
8
+ FileUtils.mkdir_p(FREIGHTHOP_VAGRANT_DOTFILE_PATH)
9
9
  end
10
10
 
11
- ENV['VAGRANT_DOTFILE_PATH'] = FREIGHTHOP_VARGANT_DOTFILE_PATH
12
- ENV['VAGRANT_CWD'] = FREIGHTHOP_VARGANT_CWD
11
+ ENV['VAGRANT_DOTFILE_PATH'] = FREIGHTHOP_VAGRANT_DOTFILE_PATH
12
+ ENV['VAGRANT_CWD'] = FREIGHTHOP_VAGRANT_CWD
13
13
 
14
14
  PROJECT_NAME = File.basename(Dir.pwd)
15
15
  PROJECT_DIR = "/srv/#{PROJECT_NAME}"
16
16
 
17
- def vagrant_ssh(cmd)
18
- %Q(/usr/bin/vagrant ssh -c 'sudo /bin/bash -l -c "cd #{PROJECT_DIR}; #{cmd}"')
19
- end
17
+ def print_usage
18
+ puts <<USAGETEXT
19
+ NAME
20
+ fh - freighthop's friendly helper
21
+
22
+ DESCRIPTION
23
+ The fh command is used to interact with a freighthop-managed vm from the root
24
+ of your project directory.
25
+
26
+ SYNOPSIS
27
+ fh <COMMAND> [args...]
28
+
29
+ COMMANDS
30
+ up - boot freighthop vm
31
+ halt - shutdown freighthop vm
32
+ destroy - shutdown and delete vm
33
+ provision - rerun provisioning on a booted freighthop vm
34
+ reload - restart freighthop vm (picks up new config changes)
35
+ status - check the current status of the freighthop vm
36
+ ssh - opens a root shell inside the project dir of the freighthop vm
37
+ (other) - see below
38
+ help - this help
39
+
40
+ PASSTHROUGH TO VM
41
+ Anything that does not match the above list will be passed through to the
42
+ freighthop vm.
43
+
44
+ The command will be run in a bash shell, as root, from inside the shared
45
+ project directory.
46
+
47
+ This allows you to specify relative commands like ./script/server and expect
48
+ them to behave properly.
20
49
 
21
- def console_command
22
- if File.exist?('./bin/rails')
23
- './bin/rails console'
24
- elsif File.exist?('./script/console')
25
- './script/console'
26
- else
27
- './script/rails console'
28
- end
50
+ EXAMPLES
51
+ Install gem dependencies:
52
+ fh bundle install
53
+
54
+ Start a Rails 4 server:
55
+ fh ./bin/rails server
56
+
57
+ Run a ruby test:
58
+ fh ruby -Itest test/unit/object_test.rb
59
+
60
+ Install leiningen dependencies:
61
+ fh lein deps
62
+
63
+ Run a ring server:
64
+ fh lein ring server-headless
65
+ USAGETEXT
29
66
  end
30
67
 
31
68
  subcommand, *rest = ARGV
32
69
  case subcommand
33
- when 'run' then
34
- `vagrant ssh-config > /tmp/freighthop.ssh-config`
35
- exec %Q(ssh -t -F /tmp/freighthop.ssh-config #{PROJECT_NAME} 'cd #{PROJECT_DIR}; sudo /bin/bash -l -c "#{rest.join(' ')}"')
36
- when 'console' then
37
- `vagrant ssh-config > /tmp/freighthop.ssh-config`
38
- exec %Q(ssh -t -F /tmp/freighthop.ssh-config #{PROJECT_NAME} 'sudo /bin/bash -l -c "cd #{PROJECT_DIR}; #{console_command} #{rest.join(' ')}"')
39
- when 'rake' then
40
- exec vagrant_ssh("bundle exec rake #{rest.join(' ')}")
70
+ when 'help' then
71
+ print_usage
72
+ when 'up', 'halt', 'destroy', 'provision', 'reload', 'status' then
73
+ exec %Q(vagrant #{subcommand} #{rest.join(' ')})
41
74
  when 'ssh' then
42
75
  `vagrant ssh-config > /tmp/freighthop.ssh-config`
43
76
  exec %Q(ssh -t -F /tmp/freighthop.ssh-config #{PROJECT_NAME} 'cd #{PROJECT_DIR}; sudo /bin/bash -l -i')
44
77
  else
45
- exec "/usr/bin/vagrant #{ARGV.join(' ')}"
78
+ `vagrant ssh-config > /tmp/freighthop.ssh-config`
79
+ exec %Q(ssh -t -F /tmp/freighthop.ssh-config #{PROJECT_NAME} 'cd #{PROJECT_DIR}; sudo /bin/bash -l -c "#{rest.unshift(subcommand).join(' ')}"')
46
80
  end
@@ -1,3 +1,3 @@
1
1
  module Freighthop
2
- VERSION = "0.0.5"
2
+ VERSION = "0.0.6"
3
3
  end
data/lib/freighthop.rb CHANGED
@@ -48,6 +48,14 @@ module Freighthop
48
48
  ]
49
49
  end
50
50
  end
51
+
52
+ def cpus
53
+ Freighthop::Config.fetch('freighthop::cpus', 2)
54
+ end
55
+
56
+ def ram
57
+ Freighthop::Config.fetch('freighthop::ram', 1024)
58
+ end
51
59
  end
52
60
  end
53
61
 
@@ -18,5 +18,6 @@ class freighthop::packages(
18
18
 
19
19
  package { $packages:
20
20
  ensure => installed,
21
+ require => Apt::Ppa[$ppas]
21
22
  }
22
23
  }
@@ -2,9 +2,9 @@ class freighthop::params {
2
2
  $database_flavors = []
3
3
  $databases = []
4
4
  $database_users = []
5
- $packages = ['git-core']
5
+ $packages = []
6
6
  $ppas = []
7
- $languages = ['ruby']
7
+ $languages = []
8
8
  $ruby_version = '1.9.3-p392'
9
9
  $app_name = $::hostname
10
10
  $app_root = "/srv/${app_name}"
@@ -18,5 +18,6 @@ class freighthop::packages(
18
18
 
19
19
  package { $packages:
20
20
  ensure => installed,
21
+ require => Apt::Ppa[$ppas]
21
22
  }
22
23
  }
@@ -2,9 +2,9 @@ class freighthop::params {
2
2
  $database_flavors = []
3
3
  $databases = []
4
4
  $database_users = []
5
- $packages = ['git-core']
5
+ $packages = []
6
6
  $ppas = []
7
- $languages = ['ruby']
7
+ $languages = []
8
8
  $ruby_version = '1.9.3-p392'
9
9
  $app_name = $::hostname
10
10
  $app_root = "/srv/${app_name}"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: freighthop
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-09-26 00:00:00.000000000 Z
12
+ date: 2013-09-30 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler
@@ -650,18 +650,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
650
650
  - - ! '>='
651
651
  - !ruby/object:Gem::Version
652
652
  version: '0'
653
- segments:
654
- - 0
655
- hash: -2753549700317476048
656
653
  required_rubygems_version: !ruby/object:Gem::Requirement
657
654
  none: false
658
655
  requirements:
659
656
  - - ! '>='
660
657
  - !ruby/object:Gem::Version
661
658
  version: '0'
662
- segments:
663
- - 0
664
- hash: -2753549700317476048
665
659
  requirements: []
666
660
  rubyforge_project:
667
661
  rubygems_version: 1.8.23
@@ -670,3 +664,4 @@ specification_version: 3
670
664
  summary: ! 'Vagrant on Rails: quickly spin up a Vagrant VM to serve your rack-compatible
671
665
  app.'
672
666
  test_files: []
667
+ has_rdoc: