machines 0.5.4 → 0.5.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (93) hide show
  1. data/.yardopts +7 -1
  2. data/CHANGELOG.md +16 -4
  3. data/INSTALL.md +3 -0
  4. data/LICENSE +1 -2
  5. data/README.md +47 -28
  6. data/Rakefile +0 -8
  7. data/TODO.md +66 -59
  8. data/bin/machines +1 -2
  9. data/lib/machines.rb +16 -1
  10. data/lib/machines/app_settings.rb +1 -1
  11. data/lib/machines/cloud_machine.rb +1 -1
  12. data/lib/machines/command.rb +0 -2
  13. data/lib/machines/commandline.rb +23 -29
  14. data/lib/machines/commands/checks.rb +67 -0
  15. data/lib/machines/commands/configuration.rb +50 -0
  16. data/lib/machines/commands/database.rb +18 -0
  17. data/lib/machines/commands/file_operations.rb +105 -0
  18. data/lib/machines/commands/installation.rb +184 -0
  19. data/lib/machines/commands/questions.rb +16 -0
  20. data/lib/machines/commands/services.rb +26 -0
  21. data/lib/machines/core.rb +55 -25
  22. data/lib/machines/logger.rb +0 -2
  23. data/lib/machines/named_buffer.rb +7 -6
  24. data/lib/machines/version.rb +1 -1
  25. data/lib/packages/awstats.rb +2 -2
  26. data/lib/packages/docky.rb +0 -1
  27. data/lib/packages/dwm.rb +5 -0
  28. data/lib/packages/nginx_logrotate.rb +2 -2
  29. data/lib/packages/timezone.rb +2 -4
  30. data/lib/template/Machinesfile +2 -1
  31. data/lib/template/config.yml +3 -0
  32. data/spec/lib/machines/app_settings_spec.rb +13 -12
  33. data/spec/lib/machines/cloud_machine_spec.rb +9 -8
  34. data/spec/lib/machines/commandline_spec.rb +69 -90
  35. data/spec/lib/machines/{checks_spec.rb → commands/checks_spec.rb} +1 -1
  36. data/spec/lib/machines/{configuration_spec.rb → commands/configuration_spec.rb} +2 -3
  37. data/spec/lib/machines/{database_spec.rb → commands/database_spec.rb} +4 -10
  38. data/spec/lib/machines/{file_operations_spec.rb → commands/file_operations_spec.rb} +3 -7
  39. data/spec/lib/machines/{installation_spec.rb → commands/installation_spec.rb} +10 -4
  40. data/spec/lib/machines/{questions_spec.rb → commands/questions_spec.rb} +1 -3
  41. data/spec/lib/machines/{services_spec.rb → commands/services_spec.rb} +1 -4
  42. data/spec/lib/machines/core_spec.rb +81 -65
  43. data/spec/lib/packages/abiword_spec.rb +1 -5
  44. data/spec/lib/packages/amazon_mp3_spec.rb +0 -4
  45. data/spec/lib/packages/awstats_spec.rb +3 -4
  46. data/spec/lib/packages/base_spec.rb +0 -1
  47. data/spec/lib/packages/chrome_spec.rb +0 -4
  48. data/spec/lib/packages/cruisecontrol_spec.rb +1 -2
  49. data/spec/lib/packages/dependencies_spec.rb +1 -2
  50. data/spec/lib/packages/docky_spec.rb +0 -4
  51. data/spec/lib/packages/dotfiles_spec.rb +5 -4
  52. data/spec/lib/packages/dwm_spec.rb +23 -0
  53. data/spec/lib/packages/file_roller_spec.rb +1 -5
  54. data/spec/lib/packages/firefox_spec.rb +0 -4
  55. data/spec/lib/packages/gedit_spec.rb +1 -5
  56. data/spec/lib/packages/git_spec.rb +0 -4
  57. data/spec/lib/packages/gmate_spec.rb +1 -5
  58. data/spec/lib/packages/gnome_spec.rb +0 -4
  59. data/spec/lib/packages/gnumeric_spec.rb +1 -5
  60. data/spec/lib/packages/hosts_spec.rb +0 -1
  61. data/spec/lib/packages/load_machines_spec.rb +16 -15
  62. data/spec/lib/packages/monit_spec.rb +0 -1
  63. data/spec/lib/packages/mysql_spec.rb +1 -3
  64. data/spec/lib/packages/nginx_logrotate_spec.rb +17 -18
  65. data/spec/lib/packages/nginx_spec.rb +0 -1
  66. data/spec/lib/packages/openbox_spec.rb +0 -4
  67. data/spec/lib/packages/passenger_nginx_spec.rb +0 -1
  68. data/spec/lib/packages/passenger_spec.rb +0 -1
  69. data/spec/lib/packages/postfix_spec.rb +1 -5
  70. data/spec/lib/packages/questions_spec.rb +3 -4
  71. data/spec/lib/packages/rbenv_spec.rb +1 -4
  72. data/spec/lib/packages/rvm_spec.rb +1 -4
  73. data/spec/lib/packages/save_machines_spec.rb +0 -1
  74. data/spec/lib/packages/slim_spec.rb +1 -2
  75. data/spec/lib/packages/sqlserver_spec.rb +0 -4
  76. data/spec/lib/packages/timezone_spec.rb +2 -3
  77. data/spec/lib/packages/unison_spec.rb +1 -2
  78. data/spec/lib/packages/virtualbox_guest_spec.rb +0 -4
  79. data/spec/lib/packages/virtualbox_spec.rb +1 -2
  80. data/spec/lib/packages/webapps_spec.rb +1 -3
  81. data/spec/spec_helper.rb +59 -61
  82. data/spec/support/minitest.rb +4 -62
  83. metadata +27 -28
  84. data/lib/machines/base.rb +0 -13
  85. data/lib/machines/checks.rb +0 -63
  86. data/lib/machines/configuration.rb +0 -49
  87. data/lib/machines/database.rb +0 -17
  88. data/lib/machines/file_operations.rb +0 -104
  89. data/lib/machines/installation.rb +0 -171
  90. data/lib/machines/machinesfile.rb +0 -25
  91. data/lib/machines/questions.rb +0 -15
  92. data/lib/machines/services.rb +0 -24
  93. data/spec/lib/machines/machinesfile_spec.rb +0 -34
@@ -1,25 +0,0 @@
1
- module Machines
2
- module Machinesfile
3
- def package name
4
- if name == 'Machinesfile'
5
- error = 'Cannot find Machinesfile. Use `machines generate` to create a template.'
6
- else
7
- error = "Cannot find custom or built-in package #{name}."
8
- end
9
- package = load_and_eval File.join('packages', "#{name}.rb")
10
- package ||= load_and_eval File.join($conf.application_dir, 'packages', "#{name}.rb")
11
- package || raise(LoadError, error, caller)
12
- end
13
-
14
- private
15
- def load_and_eval package_name
16
- if File.exists?(package_name)
17
- eval(File.read(package_name), nil, "eval: #{package_name}")
18
- true
19
- else
20
- false
21
- end
22
- end
23
- end
24
- end
25
-
@@ -1,15 +0,0 @@
1
- module Machines
2
- module Questions
3
- def enter_password(type, confirm = true)
4
- begin
5
- password = ask("Enter #{type} password: ") { |question| question.echo = false }
6
- break unless confirm
7
- password_confirmation = ask('Confirm the password: ') { |question| question.echo = false }
8
- say "Passwords do not match, please re-enter" unless password == password_confirmation
9
- end while password != password_confirmation
10
- $conf.passwords << password if $conf.passwords && password.size > 4 && password != 'password'
11
- password
12
- end
13
- end
14
- end
15
-
@@ -1,24 +0,0 @@
1
- module Machines
2
- module Services
3
- # Stop a daemon
4
- def stop daemon
5
- Command.new("service #{daemon} stop", check_daemon(daemon, false))
6
- end
7
-
8
- # Start a daemon
9
- # @param [String] daemon Name of the service to start
10
- # @param [Hash] options
11
- # @option options [Boolean] :check Set to false to disable the check (e.g. start hostname, :check => false)
12
- def start daemon, options = {}
13
- check = options[:check] || check_daemon(daemon)
14
- Command.new("service #{daemon} start", check)
15
- end
16
-
17
- # Restart a daemon
18
- # @param [String] daemon Name of the service to restart
19
- def restart daemon
20
- Command.new("service #{daemon} restart", check_daemon(daemon))
21
- end
22
- end
23
- end
24
-
@@ -1,34 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe 'Machinesfile' do
4
- include Machines::Machinesfile
5
-
6
- describe 'package' do
7
- it 'raises specific error when failing to load Machinesfile' do
8
- File.expects(:read).never
9
- lambda{ package 'Machinesfile' }.must_raise LoadError, /Cannot find Machinesfile/
10
- end
11
-
12
- it 'loads custom package when it exists' do
13
- custom_package = "packages/custom_package.rb"
14
- FileUtils.mkdir_p File.dirname(custom_package)
15
- FileUtils.touch custom_package
16
- File.expects(:read).with(custom_package).returns ''
17
- package :custom_package
18
- end
19
-
20
- it 'loads built-in package when no custom package' do
21
- builtin_package = "#{$conf.application_dir}/packages/builtin_package.rb"
22
- FileUtils.mkdir_p File.dirname(builtin_package)
23
- FileUtils.touch builtin_package
24
- File.expects(:read).with(builtin_package).returns ''
25
- package :builtin_package
26
- end
27
-
28
- it 'raises when no custom and no built-in package' do
29
- File.expects(:read).never
30
- lambda { package :builtin_package}.must_raise LoadError, /Cannot find .* package builtin_package/
31
- end
32
- end
33
- end
34
-