linecook 1.2.1 → 2.0.0

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.
Files changed (61) hide show
  1. data/{History → History.rdoc} +3 -2
  2. data/README.rdoc +93 -0
  3. data/bin/linecook +32 -56
  4. data/bin/linecook_run +19 -6
  5. data/bin/linecook_scp +12 -4
  6. data/doc/vm_setup.rdoc +75 -0
  7. data/lib/linecook.rb +3 -2
  8. data/lib/linecook/attributes.rb +33 -8
  9. data/lib/linecook/command.rb +61 -0
  10. data/lib/linecook/command_set.rb +85 -0
  11. data/lib/linecook/command_utils.rb +20 -0
  12. data/lib/linecook/commands/build.rb +108 -57
  13. data/lib/linecook/commands/compile.rb +181 -0
  14. data/lib/linecook/commands/{helper.rb → compile_helper.rb} +123 -94
  15. data/lib/linecook/commands/run.rb +43 -39
  16. data/lib/linecook/commands/snapshot.rb +24 -24
  17. data/lib/linecook/commands/ssh.rb +7 -7
  18. data/lib/linecook/commands/start.rb +10 -10
  19. data/lib/linecook/commands/state.rb +7 -7
  20. data/lib/linecook/commands/stop.rb +3 -3
  21. data/lib/linecook/commands/{vbox_command.rb → virtual_box_command.rb} +31 -29
  22. data/lib/linecook/cookbook.rb +149 -131
  23. data/lib/linecook/executable.rb +28 -0
  24. data/lib/linecook/package.rb +177 -361
  25. data/lib/linecook/proxy.rb +4 -10
  26. data/lib/linecook/recipe.rb +289 -369
  27. data/lib/linecook/test.rb +114 -98
  28. data/lib/linecook/utils.rb +31 -41
  29. data/lib/linecook/version.rb +2 -6
  30. metadata +120 -68
  31. data/HowTo/Control Virtual Machines +0 -106
  32. data/HowTo/Generate Scripts +0 -268
  33. data/HowTo/Run Scripts +0 -87
  34. data/HowTo/Setup Virtual Machines +0 -76
  35. data/README +0 -117
  36. data/lib/linecook/commands.rb +0 -11
  37. data/lib/linecook/commands/command.rb +0 -58
  38. data/lib/linecook/commands/command_error.rb +0 -12
  39. data/lib/linecook/commands/env.rb +0 -89
  40. data/lib/linecook/commands/init.rb +0 -86
  41. data/lib/linecook/commands/package.rb +0 -57
  42. data/lib/linecook/template.rb +0 -17
  43. data/lib/linecook/test/command_parser.rb +0 -75
  44. data/lib/linecook/test/file_test.rb +0 -197
  45. data/lib/linecook/test/regexp_escape.rb +0 -86
  46. data/lib/linecook/test/shell_test.rb +0 -177
  47. data/lib/linecook/test/shim.rb +0 -71
  48. data/templates/Gemfile +0 -3
  49. data/templates/Rakefile +0 -146
  50. data/templates/_gitignore +0 -4
  51. data/templates/attributes/project_name.rb +0 -3
  52. data/templates/config/ssh +0 -14
  53. data/templates/cookbook +0 -10
  54. data/templates/files/example.txt +0 -1
  55. data/templates/helpers/project_name/echo.erb +0 -4
  56. data/templates/packages/abox.yml +0 -2
  57. data/templates/project_name.gemspec +0 -30
  58. data/templates/recipes/abox.rb +0 -16
  59. data/templates/templates/example.erb +0 -1
  60. data/templates/test/project_name_test.rb +0 -24
  61. data/templates/test/test_helper.rb +0 -14
@@ -1,71 +0,0 @@
1
- require 'test/unit'
2
-
3
- if Object.const_defined?(:MiniTest)
4
- ################################
5
- # MiniTest shims (ruby 1.9)
6
- ################################
7
-
8
- class Test::Unit::TestCase
9
- class << self
10
- # Causes a test suite to be skipped. If a message is given, it will
11
- # print and notify the user the test suite has been skipped.
12
- def skip_test(msg=nil)
13
- @@test_suites.delete(self)
14
- puts "Skipping #{self}#{msg.empty? ? '' : ': ' + msg}"
15
- end
16
- end
17
- end
18
-
19
- # MiniTest renames method_name as name. For backwards compatibility it must
20
- # be added back.
21
- class MiniTest::Unit::TestCase
22
- def method_name
23
- __name__
24
- end
25
- end
26
-
27
- else
28
- ################################
29
- # Test::Unit shims (< ruby 1.9)
30
- ################################
31
- # :stopdoc:
32
- # Implementing skip_test in the original Test::Unit is considerably more
33
- # tricky than in the Mini::Test Test::Unit.
34
- class Test::Unit::TestCase
35
- class << self
36
- alias tap_original_test_case_inherited inherited
37
-
38
- def inherited(child)
39
- super
40
- tap_original_test_case_inherited(child)
41
- child.instance_variable_set(:@skip_messages, [])
42
- child.instance_variable_set(:@run_test_suite, true)
43
- end
44
-
45
- # Causes a test suite to be skipped. If a message is given, it will
46
- # print and notify the user the test suite has been skipped.
47
- def skip_test(msg=nil)
48
- @run_test_suite = false
49
- @skip_messages << msg
50
- end
51
-
52
- alias :original_suite :suite
53
-
54
- # Modifies the default suite method to skip the suit unless
55
- # run_test_suite is true. If the test is skipped, the skip_messages
56
- # will be printed along with the default 'Skipping <Test>' message.
57
- def suite # :nodoc:
58
- if @run_test_suite
59
- original_suite
60
- else
61
- skip_message = @skip_messages.compact.join(', ')
62
- puts "Skipping #{name}#{skip_message.empty? ? '' : ': ' + skip_message}"
63
-
64
- # return an empty test suite of the appropriate name
65
- Test::Unit::TestSuite.new(name)
66
- end
67
- end
68
- end
69
- end
70
- # :startdoc:
71
- end
@@ -1,3 +0,0 @@
1
- # Linecook uses this Gemfile to setup dependencies, if present.
2
- source "http://rubygems.org"
3
- gemspec
@@ -1,146 +0,0 @@
1
- require 'rake'
2
- require 'rake/rdoctask'
3
- require 'rake/gempackagetask'
4
-
5
- #
6
- # Gem tasks
7
- #
8
-
9
- def gemspec
10
- @gemspec ||= begin
11
- gemspec_path = File.expand_path('../<%= project_name %>.gemspec', __FILE__)
12
- eval(File.read(gemspec_path), TOPLEVEL_BINDING)
13
- end
14
- end
15
-
16
- Rake::GemPackageTask.new(gemspec) do |pkg|
17
- pkg.need_tar = true
18
- end
19
-
20
- desc 'Prints the gemspec manifest.'
21
- task :print_manifest do
22
- files = gemspec.files.inject({}) do |files, file|
23
- files[File.expand_path(file)] = [File.exists?(file), file]
24
- files
25
- end
26
-
27
- cookbook_files = Dir.glob('{attributes,files,lib,recipes,templates}/**/*')
28
- cookbook_file = Dir.glob('*')
29
-
30
- (cookbook_files + cookbook_file).each do |file|
31
- next unless File.file?(file)
32
- path = File.expand_path(file)
33
- files[path] = ['', file] unless files.has_key?(path)
34
- end
35
-
36
- # sort and output the results
37
- files.values.sort_by {|exists, file| file }.each do |entry|
38
- puts '%-5s %s' % entry
39
- end
40
- end
41
-
42
- #
43
- # Documentation tasks
44
- #
45
-
46
- desc 'Generate documentation.'
47
- Rake::RDocTask.new(:rdoc) do |rdoc|
48
- spec = gemspec
49
-
50
- rdoc.rdoc_dir = 'rdoc'
51
- rdoc.options.concat(spec.rdoc_options)
52
- rdoc.rdoc_files.include(spec.extra_rdoc_files)
53
-
54
- files = spec.files.select {|file| file =~ /^lib.*\.rb$/}
55
- rdoc.rdoc_files.include( files )
56
- end
57
-
58
- #
59
- # Dependency tasks
60
- #
61
-
62
- desc 'Bundle dependencies'
63
- task :bundle do
64
- output = `bundle check 2>&1`
65
-
66
- unless $?.to_i == 0
67
- puts output
68
- sh "bundle install 2>&1"
69
- puts
70
- end
71
- end
72
-
73
- #
74
- # Linecook Helpers
75
- #
76
-
77
- package = ENV['PACKAGE']
78
- force = (ENV['FORCE'] == 'true')
79
-
80
- desc "build helpers and packages"
81
- task :build => :bundle do
82
- sh "bundle exec linecook build #{force ? '--force ' : nil}#{package}"
83
- end
84
-
85
- desc "run packages"
86
- task :run => :build do
87
- sh "bundle exec linecook run #{package}"
88
- end
89
-
90
- desc "start each vm at CURRENT"
91
- task :start => :bundle do
92
- sh 'bundle exec linecook start --socket --snapshot CURRENT'
93
- end
94
-
95
- desc "snapshot each vm to a new CURRENT"
96
- task :snapshot => :bundle do
97
- sh 'bundle exec linecook snapshot CURRENT'
98
- end
99
-
100
- desc "reset each vm to BASE"
101
- task :reset_base => :bundle do
102
- sh 'bundle exec linecook snapshot --reset BASE'
103
- sh 'bundle exec linecook snapshot CURRENT'
104
- sh 'bundle exec linecook start --socket --snapshot CURRENT'
105
- end
106
-
107
- desc "stop each vm"
108
- task :stop => :bundle do
109
- sh 'bundle exec linecook stop'
110
- end
111
-
112
- #
113
- # Test tasks
114
- #
115
-
116
- desc 'Default: Run tests.'
117
- task :default => :test
118
-
119
- desc 'Run the tests assuming each vm is setup'
120
- task :quicktest => :build do
121
- tests = Dir.glob('test/**/*_test.rb')
122
- tests.delete_if {|test| test =~ /_test\/test_/ }
123
-
124
- if ENV['RCOV'] == 'true'
125
- FileUtils.rm_rf File.expand_path('../coverage', __FILE__)
126
- sh('rcov', '-w', '--text-report', '--exclude', '^/', *tests)
127
- else
128
- sh('ruby', '-w', '-e', 'ARGV.dup.each {|test| load test}', *tests)
129
- end
130
- end
131
-
132
- desc 'Run the tests'
133
- task :test do
134
- begin
135
- Rake::Task["start"].invoke
136
- Rake::Task["quicktest"].invoke
137
- ensure
138
- Rake::Task["stop"].execute(nil)
139
- end
140
- end
141
-
142
- desc 'Run rcov'
143
- task :rcov do
144
- ENV['RCOV'] = 'true'
145
- Rake::Task["test"].invoke
146
- end
@@ -1,4 +0,0 @@
1
- .DS_Store
2
- .bundle
3
- *.gem
4
- /rdoc
@@ -1,3 +0,0 @@
1
- # Define default attributes here. The attrs object is a self-nesting Hash
2
- # (note string keys are usually better than symbols).
3
- attrs['<%= project_name %>']['message'] = 'Hello World'
@@ -1,14 +0,0 @@
1
- # Declare a Host for each package.
2
- Host abox
3
- Port 2220
4
-
5
- # Define defaults here.
6
- Host *
7
- HostName localhost
8
- User linecook
9
- Port 2220
10
- UserKnownHostsFile /dev/null
11
- StrictHostKeyChecking no
12
- IdentitiesOnly yes
13
- ControlMaster auto
14
- ControlPath /tmp/socket-%r@%h:%p
@@ -1,10 +0,0 @@
1
- # Configure the cookbook here.
2
-
3
- # Define directories searched for attributes/recipes/etc.
4
- # paths: ['.']
5
-
6
- # Name the gems added to path - defaults to all marked gems.
7
- # gems: []
8
-
9
- # Adding this file to a gem marks it as a cookbook gem
10
- # (within a gem the contents of this file are ignored)
@@ -1 +0,0 @@
1
- Hello World (from a file)
@@ -1,4 +0,0 @@
1
- Echo a string.
2
- (str)
3
- --
4
- echo "<%= '<' %>%= str %<%= '>' %> (from a helper)"
@@ -1,2 +0,0 @@
1
- # Attributes set in a package file override those in an attributes file.
2
- {}
@@ -1,30 +0,0 @@
1
- # -*- encoding: utf-8 -*-
2
-
3
- Gem::Specification.new do |s|
4
- s.name = '<%= project_name %>'
5
- s.version = '0.0.1'
6
- s.platform = Gem::Platform::RUBY
7
- s.authors = 'TODO: Write your name'
8
- s.email = 'TODO: Write your email address'
9
- s.homepage = ''
10
- s.summary = %q{TODO: Write a gem summary}
11
- s.description = %q{TODO: Write a gem description}
12
- s.rubyforge_project = ''
13
-
14
- s.has_rdoc = true
15
- s.rdoc_options.concat %W{--main README -S -N --title <%= project_name.capitalize %>}
16
-
17
- # add dependencies
18
- s.add_dependency('linecook', '~> <%= Linecook::MAJOR %>.<%= Linecook::MINOR %>')
19
-
20
- # list extra rdoc files here.
21
- s.extra_rdoc_files = %W{
22
- cookbook
23
- }
24
-
25
- # list the files you want to include here.
26
- s.files = %W{
27
- }
28
-
29
- s.require_path = 'lib'
30
- end
@@ -1,16 +0,0 @@
1
- #############################################################################
2
- attributes '<%= project_name %>'
3
- helpers '<%= project_name %>'
4
- #############################################################################
5
-
6
- # Write to the script using write/writeln
7
- writeln '# An example script.'
8
-
9
- # Attributes are available via attrs.
10
- # Helpers are available as methods.
11
- echo attrs['<%= project_name %>']['message']
12
-
13
- # Use file_path and template_path to add files to the package; the return
14
- # value can be treated as a path to the file. For example:
15
- writeln "cat #{file_path('example.txt', 'example_file')}"
16
- writeln "cat #{template_path('example.erb', 'example_template')}"
@@ -1 +0,0 @@
1
- <%= '<' %>%= attrs['<%= project_name %>']['message'] %<%= '>' %> (from a template)
@@ -1,24 +0,0 @@
1
- require File.expand_path('../test_helper', __FILE__)
2
-
3
- class <%= const_name %>Test < Test::Unit::TestCase
4
- include Linecook::Test
5
-
6
- #
7
- # project test (build and run project as written)
8
- #
9
-
10
- no_cleanup
11
-
12
- def test_<%= project_name %>
13
- result, cmd = build_project
14
- assert_equal 0, $?.exitstatus, cmd
15
-
16
- result, cmd = run_project
17
- assert_output_equal %q{
18
- Hello World (from a helper)
19
- Hello World (from a file)
20
- Hello World (from a template)
21
- }, result, cmd
22
- assert_equal 0, $?.exitstatus, cmd
23
- end
24
- end
@@ -1,14 +0,0 @@
1
- require 'rubygems'
2
- require 'bundler'
3
- Bundler.setup
4
-
5
- require 'test/unit'
6
- require 'linecook/test'
7
-
8
- if testcase = ENV['TESTCASE']
9
- ARGV << "--testcase=#{testcase}"
10
- end
11
-
12
- if name = ENV['NAME']
13
- ARGV << "--name=#{name}"
14
- end