jamie 0.1.0.alpha4 → 0.1.0.alpha5
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/Rakefile +2 -2
- data/bin/jamie +7 -0
- data/jamie.gemspec +2 -1
- data/lib/jamie/cli.rb +85 -0
- data/lib/jamie/version.rb +1 -1
- data/lib/jamie.rb +41 -5
- data/lib/{jamie/core_ext.rb → vendor/hash_recursive_merge.rb} +0 -0
- metadata +23 -4
data/Rakefile
CHANGED
@@ -9,10 +9,10 @@ Cane::RakeTask.new do |cane|
|
|
9
9
|
Jamie::Vagrant.define_vagrant_vm
|
10
10
|
)
|
11
11
|
cane.style_exclude = %w(
|
12
|
-
lib/
|
12
|
+
lib/vendor/hash_recursive_merge.rb
|
13
13
|
)
|
14
14
|
cane.doc_exclude = %w(
|
15
|
-
lib/
|
15
|
+
lib/vendor/hash_recursive_merge.rb
|
16
16
|
)
|
17
17
|
end
|
18
18
|
|
data/bin/jamie
ADDED
data/jamie.gemspec
CHANGED
@@ -13,10 +13,11 @@ Gem::Specification.new do |gem|
|
|
13
13
|
gem.homepage = ""
|
14
14
|
|
15
15
|
gem.files = `git ls-files`.split($/)
|
16
|
-
gem.executables =
|
16
|
+
gem.executables = %w(jamie)
|
17
17
|
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
18
18
|
gem.require_paths = ["lib"]
|
19
19
|
|
20
|
+
gem.add_dependency 'thor'
|
20
21
|
gem.add_dependency 'mixlib-shellout'
|
21
22
|
gem.add_dependency 'vagrant', '~> 1.0.5'
|
22
23
|
|
data/lib/jamie/cli.rb
ADDED
@@ -0,0 +1,85 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
require 'thor'
|
4
|
+
|
5
|
+
require 'jamie'
|
6
|
+
|
7
|
+
module Jamie
|
8
|
+
|
9
|
+
# The command line runner for Jamie.
|
10
|
+
class CLI < Thor
|
11
|
+
|
12
|
+
# Constructs a new instance.
|
13
|
+
def initialize(*args)
|
14
|
+
super
|
15
|
+
@config = Jamie::Config.new(ENV['JAMIE_YAML'])
|
16
|
+
end
|
17
|
+
|
18
|
+
desc "list", "List all instances"
|
19
|
+
def list
|
20
|
+
say @config.instances.as_names.join("\n")
|
21
|
+
end
|
22
|
+
|
23
|
+
[:create, :converge, :setup, :verify, :test, :destroy].each do |action|
|
24
|
+
desc(
|
25
|
+
"#{action} (all ['REGEX']|[INSTANCE])",
|
26
|
+
"#{action.capitalize} one or more instances"
|
27
|
+
)
|
28
|
+
define_method(action) { |*args| exec_action(action) }
|
29
|
+
end
|
30
|
+
|
31
|
+
private
|
32
|
+
|
33
|
+
attr_reader :task
|
34
|
+
|
35
|
+
def exec_action(action)
|
36
|
+
@task = action
|
37
|
+
result = parse_subcommand(args[0], args[1])
|
38
|
+
Array(result).each { |instance| instance.send(task) }
|
39
|
+
end
|
40
|
+
|
41
|
+
def parse_subcommand(name_or_all, regexp)
|
42
|
+
if name_or_all.nil? || (name_or_all == "all" && regexp.nil?)
|
43
|
+
get_all_instances
|
44
|
+
elsif name_or_all == "all" && regexp
|
45
|
+
get_filtered_instances(regexp)
|
46
|
+
elsif name_or_all != "all" && regexp.nil?
|
47
|
+
get_instance(name_or_all)
|
48
|
+
else
|
49
|
+
die task, "Invalid invocation."
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
def get_all_instances
|
54
|
+
result = @config.instances
|
55
|
+
if result.empty?
|
56
|
+
die task, "No instances defined"
|
57
|
+
else
|
58
|
+
result
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
def get_filtered_instances(regexp)
|
63
|
+
result = @config.instances.get_all(/#{regexp}/)
|
64
|
+
if result.empty?
|
65
|
+
die task, "No instances for regex `#{regexp}', try running `jamie list'"
|
66
|
+
else
|
67
|
+
result
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
def get_instance(name)
|
72
|
+
result = @config.instances.get(name)
|
73
|
+
if result.nil?
|
74
|
+
die task, "No instance `#{name}', try running `jamie list'"
|
75
|
+
end
|
76
|
+
result
|
77
|
+
end
|
78
|
+
|
79
|
+
def die(task, msg)
|
80
|
+
error "\n#{msg}\n\n"
|
81
|
+
help(task)
|
82
|
+
exit 1
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
data/lib/jamie/version.rb
CHANGED
data/lib/jamie.rb
CHANGED
@@ -1,11 +1,12 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
2
|
|
3
3
|
require 'base64'
|
4
|
+
require 'delegate'
|
4
5
|
require 'digest'
|
5
6
|
require 'net/https'
|
6
7
|
require 'yaml'
|
8
|
+
require 'vendor/hash_recursive_merge'
|
7
9
|
|
8
|
-
require 'jamie/core_ext'
|
9
10
|
require 'jamie/version'
|
10
11
|
|
11
12
|
module Jamie
|
@@ -42,21 +43,23 @@ module Jamie
|
|
42
43
|
# @return [Array<Platform>] all defined platforms which will be used in
|
43
44
|
# convergence integration
|
44
45
|
def platforms
|
45
|
-
@platforms ||=
|
46
|
+
@platforms ||= Collection.new(
|
47
|
+
Array(yaml["platforms"]).map { |hash| new_platform(hash) })
|
46
48
|
end
|
47
49
|
|
48
50
|
# @return [Array<Suite>] all defined suites which will be used in
|
49
51
|
# convergence integration
|
50
52
|
def suites
|
51
|
-
@suites ||=
|
53
|
+
@suites ||= Collection.new(
|
54
|
+
Array(yaml["suites"]).map { |hash| Suite.new(hash) })
|
52
55
|
end
|
53
56
|
|
54
57
|
# @return [Array<Instance>] all instances, resulting from all platform and
|
55
58
|
# suite combinations
|
56
59
|
def instances
|
57
|
-
@instances ||= suites.map { |suite|
|
60
|
+
@instances ||= Collection.new(suites.map { |suite|
|
58
61
|
platforms.map { |platform| Instance.new(suite, platform) }
|
59
|
-
}.flatten
|
62
|
+
}.flatten)
|
60
63
|
end
|
61
64
|
|
62
65
|
# @return [String] path to the Jamie YAML file
|
@@ -75,6 +78,39 @@ module Jamie
|
|
75
78
|
@test_base_path ||= DEFAULT_TEST_BASE_PATH
|
76
79
|
end
|
77
80
|
|
81
|
+
# Delegate class which adds the ability to find single and multiple
|
82
|
+
# objects by their #name in an Array. Hey, it's better than monkey-patching
|
83
|
+
# Array, right?
|
84
|
+
class Collection < SimpleDelegator
|
85
|
+
|
86
|
+
# Returns a single object by its name, or nil if none are found.
|
87
|
+
#
|
88
|
+
# @param name [String] name of object
|
89
|
+
# @return [Object] first match by name, or nil if none are found
|
90
|
+
def get(name)
|
91
|
+
__getobj__.find { |i| i.name == name }
|
92
|
+
end
|
93
|
+
|
94
|
+
# Returns a Collection of all objects whose #name is matched by the
|
95
|
+
# regular expression.
|
96
|
+
#
|
97
|
+
# @param regexp [Regexp] a regular expression pattern
|
98
|
+
# @return [Jamie::Config::Collection<Object>] a new collection of
|
99
|
+
# matched objects
|
100
|
+
def get_all(regexp)
|
101
|
+
Jamie::Config::Collection.new(
|
102
|
+
__getobj__.find_all { |i| i.name =~ regexp }
|
103
|
+
)
|
104
|
+
end
|
105
|
+
|
106
|
+
# Returns an Array of names from the collection as strings.
|
107
|
+
#
|
108
|
+
# @return [Array<String>] array of name strings
|
109
|
+
def as_names
|
110
|
+
__getobj__.map { |i| i.name }
|
111
|
+
end
|
112
|
+
end
|
113
|
+
|
78
114
|
private
|
79
115
|
|
80
116
|
def new_platform(hash)
|
File without changes
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jamie
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.0.
|
4
|
+
version: 0.1.0.alpha5
|
5
5
|
prerelease: 6
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,8 +9,24 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-12-
|
12
|
+
date: 2012-12-13 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: thor
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0'
|
14
30
|
- !ruby/object:Gem::Dependency
|
15
31
|
name: mixlib-shellout
|
16
32
|
requirement: !ruby/object:Gem::Requirement
|
@@ -110,7 +126,8 @@ dependencies:
|
|
110
126
|
description: A Chef convergence integration test harness
|
111
127
|
email:
|
112
128
|
- fnichol@nichol.ca
|
113
|
-
executables:
|
129
|
+
executables:
|
130
|
+
- jamie
|
114
131
|
extensions: []
|
115
132
|
extra_rdoc_files: []
|
116
133
|
files:
|
@@ -121,13 +138,15 @@ files:
|
|
121
138
|
- LICENSE
|
122
139
|
- README.md
|
123
140
|
- Rakefile
|
141
|
+
- bin/jamie
|
124
142
|
- jamie.gemspec
|
125
143
|
- lib/jamie.rb
|
126
|
-
- lib/jamie/
|
144
|
+
- lib/jamie/cli.rb
|
127
145
|
- lib/jamie/driver/vagrant.rb
|
128
146
|
- lib/jamie/rake_tasks.rb
|
129
147
|
- lib/jamie/vagrant.rb
|
130
148
|
- lib/jamie/version.rb
|
149
|
+
- lib/vendor/hash_recursive_merge.rb
|
131
150
|
homepage: ''
|
132
151
|
licenses: []
|
133
152
|
post_install_message:
|