linecook 1.1.0 → 1.2.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.
- data/History +7 -0
- data/lib/linecook/commands/build.rb +6 -6
- data/lib/linecook/commands/helper.rb +3 -3
- data/lib/linecook/commands/init.rb +1 -1
- data/lib/linecook/commands/state.rb +2 -2
- data/lib/linecook/commands/vbox_command.rb +1 -1
- data/lib/linecook/package.rb +18 -3
- data/lib/linecook/recipe.rb +7 -0
- data/lib/linecook/template.rb +1 -1
- data/lib/linecook/test/file_test.rb +2 -0
- data/lib/linecook/test/shell_test.rb +1 -0
- data/lib/linecook/test/shim.rb +71 -0
- data/lib/linecook/test.rb +0 -29
- data/lib/linecook/utils.rb +1 -1
- data/lib/linecook/version.rb +1 -1
- metadata +9 -8
data/History
CHANGED
@@ -1,3 +1,10 @@
|
|
1
|
+
== 1.2.0 2011/05/23
|
2
|
+
|
3
|
+
* updated to run on 1.9.2, jruby
|
4
|
+
* allow build of recipes without a package file
|
5
|
+
* added Recipe#close! to unregister a recipe from a package
|
6
|
+
* allow .yml,.yaml,.json attributes files
|
7
|
+
|
1
8
|
== 1.1.0 2011/05/02
|
2
9
|
|
3
10
|
* updated scaffold generated by 'linecook init' to be current and simpler
|
@@ -19,17 +19,17 @@ module Linecook
|
|
19
19
|
sources = {}
|
20
20
|
helpers = []
|
21
21
|
|
22
|
-
Dir.glob("#{helpers_dir}/*/**/*").each do |
|
23
|
-
next if File.directory?(
|
24
|
-
(sources[File.dirname(
|
22
|
+
Dir.glob("#{helpers_dir}/*/**/*").each do |source_file|
|
23
|
+
next if File.directory?(source_file)
|
24
|
+
(sources[File.dirname(source_file)] ||= []) << source_file
|
25
25
|
end
|
26
26
|
|
27
|
-
sources.each_pair do |dir,
|
27
|
+
sources.each_pair do |dir, source_files|
|
28
28
|
name = dir[(helpers_dir.length + 1)..-1]
|
29
|
-
helpers << [name,
|
29
|
+
helpers << [name, source_files]
|
30
30
|
end
|
31
31
|
|
32
|
-
helpers.sort_by {|name,
|
32
|
+
helpers.sort_by {|name, source_files| name }
|
33
33
|
end
|
34
34
|
|
35
35
|
def glob_package_files(package_names)
|
@@ -211,7 +211,7 @@ module Linecook
|
|
211
211
|
compiler = ERB::Compiler.new('<>')
|
212
212
|
compiler.put_cmd = "write"
|
213
213
|
compiler.insert_cmd = "write"
|
214
|
-
code = compiler.compile(body)
|
214
|
+
code = [compiler.compile(body)].flatten.first
|
215
215
|
|
216
216
|
"#{source}\n#{code}".gsub(/^(\s*)/) do |m|
|
217
217
|
indent = 2 + $1.length - ($1.length % 2)
|
@@ -274,11 +274,11 @@ DOC
|
|
274
274
|
DEFINITION_TEMPLATE_LINE = __LINE__ + 2
|
275
275
|
DEFINITION_TEMPLATE = ERB.new(<<-DOC, nil, '<>').src
|
276
276
|
<%= sections['head'] %>
|
277
|
-
<% definitions.each do |desc, method_name, signature,
|
277
|
+
<% definitions.each do |desc, method_name, signature, method_body| %>
|
278
278
|
<% desc.split("\n").each do |line| %>
|
279
279
|
# <%= line %><% end %>
|
280
280
|
def <%= method_name %><%= signature %>
|
281
|
-
<%=
|
281
|
+
<%= method_body %>
|
282
282
|
|
283
283
|
chain_proxy
|
284
284
|
end
|
@@ -12,14 +12,14 @@ module Linecook
|
|
12
12
|
config :hosts, false, :short => :n, &c.flag # print state by host
|
13
13
|
|
14
14
|
def state(vm_name)
|
15
|
-
|
15
|
+
`VBoxManage showvminfo #{vm_name}` =~ /^State:\s+(.*)$/ ? $1 : 'unknown'
|
16
16
|
end
|
17
17
|
|
18
18
|
def process(*hosts)
|
19
19
|
vm_names = resolve_vm_names(hosts)
|
20
20
|
if hosts
|
21
21
|
each_host(vm_names) do |host|
|
22
|
-
puts "#{host}: #{state(host_map[host])}"
|
22
|
+
puts "#{host}: #{state(host_map[host] || host)}"
|
23
23
|
end
|
24
24
|
else
|
25
25
|
each_vm_name(vm_names) do |vm_name|
|
data/lib/linecook/package.rb
CHANGED
@@ -197,14 +197,29 @@ module Linecook
|
|
197
197
|
resource_path('recipes', recipe_name)
|
198
198
|
end
|
199
199
|
|
200
|
-
# Loads the attributes file
|
201
|
-
#
|
200
|
+
# Loads the named attributes file into and returns an instance of
|
201
|
+
# Attributes. The loading mechanism depends on the attributes file
|
202
|
+
# extname.
|
203
|
+
#
|
204
|
+
# .rb: evaluate in the context of attributes
|
205
|
+
# .yml,.yaml,.json: load as YAML and merge into attributes
|
206
|
+
#
|
207
|
+
# All other file types raise an error. Simply returns a new Attributes
|
208
|
+
# instance if no name is given.
|
202
209
|
def load_attributes(attributes_name=nil)
|
203
210
|
attributes = Attributes.new
|
204
211
|
|
205
212
|
if attributes_name
|
206
213
|
path = attributes_path(attributes_name)
|
207
|
-
|
214
|
+
|
215
|
+
case File.extname(path)
|
216
|
+
when '.rb'
|
217
|
+
attributes.instance_eval(File.read(path), path)
|
218
|
+
when '.yml', '.yaml', '.json'
|
219
|
+
attributes.attrs.merge!(YAML.load_file(path))
|
220
|
+
else
|
221
|
+
raise "invalid attributes format: #{path.inspect}"
|
222
|
+
end
|
208
223
|
end
|
209
224
|
|
210
225
|
attributes
|
data/lib/linecook/recipe.rb
CHANGED
@@ -81,6 +81,13 @@ module Linecook
|
|
81
81
|
self
|
82
82
|
end
|
83
83
|
|
84
|
+
# Closes _target_ and returns self, and unregisters _target_ from the
|
85
|
+
# package. Useful for recipes that only generate other files.
|
86
|
+
def close!
|
87
|
+
_package_.registry.delete _target_name_
|
88
|
+
close
|
89
|
+
end
|
90
|
+
|
84
91
|
# Returns true if _target_ is closed.
|
85
92
|
def closed?
|
86
93
|
_target_.closed?
|
data/lib/linecook/template.rb
CHANGED
@@ -0,0 +1,71 @@
|
|
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
|
data/lib/linecook/test.rb
CHANGED
@@ -18,39 +18,10 @@ module Linecook
|
|
18
18
|
pattern.kind_of?(Regexp) ? pattern : /\A#{pattern}\z/
|
19
19
|
end
|
20
20
|
|
21
|
-
@skip_test_suite = false
|
22
21
|
unless patterns.any? {|pattern| host =~ pattern }
|
23
22
|
skip_test "not for host (#{host})"
|
24
23
|
end
|
25
24
|
end
|
26
|
-
|
27
|
-
# Causes a test suite to be skipped. If a message is given, it will
|
28
|
-
# print and notify the user the test suite has been skipped.
|
29
|
-
def skip_test(msg=nil)
|
30
|
-
@skip_test_suite = true
|
31
|
-
skip_messages << msg
|
32
|
-
end
|
33
|
-
|
34
|
-
# Modifies the default suite method to skip the suit unless
|
35
|
-
# run_test_suite is true. If the test is skipped, the skip_messages
|
36
|
-
# will be printed along with the default 'Skipping <Test>' message.
|
37
|
-
def suite # :nodoc:
|
38
|
-
if (@skip_test_suite ||= false)
|
39
|
-
skip_message = skip_messages.compact.join(', ')
|
40
|
-
puts "Skipping #{name}#{skip_message.empty? ? '' : ': ' + skip_message}"
|
41
|
-
|
42
|
-
# return an empty test suite of the appropriate name
|
43
|
-
::Test::Unit::TestSuite.new(name)
|
44
|
-
else
|
45
|
-
super
|
46
|
-
end
|
47
|
-
end
|
48
|
-
|
49
|
-
protected
|
50
|
-
|
51
|
-
def skip_messages # :nodoc:
|
52
|
-
@skip_messages ||= []
|
53
|
-
end
|
54
25
|
end
|
55
26
|
|
56
27
|
module ModuleMethods
|
data/lib/linecook/utils.rb
CHANGED
data/lib/linecook/version.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: linecook
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 31
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 1
|
8
|
-
-
|
8
|
+
- 2
|
9
9
|
- 0
|
10
|
-
version: 1.
|
10
|
+
version: 1.2.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Simon Chiang
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-05-
|
18
|
+
date: 2011-05-23 00:00:00 -06:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -26,12 +26,12 @@ dependencies:
|
|
26
26
|
requirements:
|
27
27
|
- - ~>
|
28
28
|
- !ruby/object:Gem::Version
|
29
|
-
hash:
|
29
|
+
hash: 59
|
30
30
|
segments:
|
31
31
|
- 0
|
32
|
-
-
|
33
|
-
-
|
34
|
-
version: 0.
|
32
|
+
- 9
|
33
|
+
- 0
|
34
|
+
version: 0.9.0
|
35
35
|
type: :runtime
|
36
36
|
version_requirements: *id001
|
37
37
|
- !ruby/object:Gem::Dependency
|
@@ -109,6 +109,7 @@ files:
|
|
109
109
|
- lib/linecook/test/file_test.rb
|
110
110
|
- lib/linecook/test/regexp_escape.rb
|
111
111
|
- lib/linecook/test/shell_test.rb
|
112
|
+
- lib/linecook/test/shim.rb
|
112
113
|
- lib/linecook/utils.rb
|
113
114
|
- lib/linecook/version.rb
|
114
115
|
- templates/Gemfile
|