cocina 0.1.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.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 1d34176d91ada403ab2e2c934f9ac61432b329ec
4
+ data.tar.gz: 9c16d0e49045dd6e64789374e294c713ac4db3cb
5
+ SHA512:
6
+ metadata.gz: 761c31d77e0598ee78489e4534c523820510299229e6bc75a2541d0bac67ad2a42dc1fe826c769d03c750d305cf7c43b202d3996616d588787f7e83d15a999a2
7
+ data.tar.gz: 9fc621c4200547d6c008d7f5024a819a4786e5821c15b9f3eedd23c5d8e2de7cee25803753c1fcdc40962ba1a33f431bac06c55ef7a4fbdc2e981e785e7b6642
data/.gitignore ADDED
@@ -0,0 +1,11 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ .kitchen/
11
+ .kitchen.local.yml
data/.kitchen.yml ADDED
@@ -0,0 +1,19 @@
1
+ ---
2
+ driver:
3
+ name: vagrant
4
+
5
+ provisioner:
6
+ name: chef_zero
7
+
8
+ platforms:
9
+ - name: ubuntu-14.04
10
+ - name: centos-7.1
11
+
12
+ suites:
13
+ - name: app
14
+ run_list:
15
+ attributes:
16
+
17
+ - name: web
18
+ run_list:
19
+ attributes:
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ ruby-2.2.4
data/.travis.yml ADDED
@@ -0,0 +1,4 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.1.6
4
+ before_install: gem install bundler -v 1.10.6
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in cocina.gemspec
4
+ gemspec
5
+
6
+ gem 'simplecov', require: false, group: :test
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015 Brandon Raabe
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,78 @@
1
+ # Cocina [![Build Status](https://travis-ci.org/brandocorp/cocina.svg?branch=master)](https://travis-ci.org/brandocorp/cocina)
2
+
3
+ A thin wrapper around Test Kitchen allowing you to define dependencies for your
4
+ suites
5
+
6
+ ## Usage
7
+
8
+ Assuming you have a `.kitchen.yml` which looks like the following
9
+
10
+ ```yaml
11
+ ---
12
+ driver:
13
+ name: vagrant
14
+
15
+ provisioner:
16
+ name: chef_zero
17
+
18
+ platforms:
19
+ - name: ubuntu-14.04
20
+ - name: centos-7.1
21
+
22
+ suites:
23
+ - name: app
24
+ run_list:
25
+ attributes:
26
+
27
+ - name: web
28
+ run_list:
29
+ attributes:
30
+ ```
31
+
32
+ In the root directory of your cookbook, along side your `.kitchen.yml` add a
33
+ `Cochinafile`.
34
+
35
+ ```ruby
36
+ instance 'web-ubuntu-1404' do
37
+ depends 'db-ubuntu-1404'
38
+ depends 'app-ubuntu-1404'
39
+ end
40
+ ```
41
+
42
+ This tells Cochina that the `web` suite depends on the `app` suite. Now, wen you
43
+ run `cochina web-ubuntu-1404` it will first converge `db-ubuntu-1404`, followed
44
+ by `app-ubuntu-1404`, before continuing with `web-ubuntu-1404`.
45
+
46
+ By default the target instance is sent the `:verify` action, and each dependency
47
+ is sent the `:converge` action.
48
+
49
+ After all instances have finished running, each instance is destroyed.
50
+
51
+ ## Installation
52
+
53
+ Add this line to your application's Gemfile:
54
+
55
+ ```ruby
56
+ gem 'cocina'
57
+ ```
58
+
59
+ And then execute:
60
+
61
+ $ bundle
62
+
63
+ Or install it yourself as:
64
+
65
+ $ gem install cocina
66
+
67
+ ## Development
68
+
69
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
70
+
71
+ ## Contributing
72
+
73
+ Bug reports and pull requests are welcome on GitHub at https://github.com/brandocorp/cocina.
74
+
75
+
76
+ ## License
77
+
78
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
data/bin/cocina ADDED
@@ -0,0 +1,10 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ Signal.trap('INT') { exit 1 }
4
+
5
+ $LOAD_PATH.unshift File.join(File.dirname(__FILE__), %w(.. lib))
6
+ require 'rubygems'
7
+ require 'cocina'
8
+ require 'cocina/cli'
9
+
10
+ Cocina::CLI.new(ARGV.dup.first).run
data/cocina.gemspec ADDED
@@ -0,0 +1,30 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'cocina/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'cocina'
8
+ spec.version = Cocina::VERSION
9
+ spec.authors = ['Brandon Raabe']
10
+ spec.email = ['brandocorp+cochina@gmail.com']
11
+
12
+ spec.summary = 'Test Kitchen with Dependencies'
13
+ spec.description = spec.summary
14
+ spec.homepage = 'https://github.com/brandocorp/cocina'
15
+ spec.license = 'MIT'
16
+
17
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
18
+ spec.bindir = 'bin'
19
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
20
+ spec.require_paths = ['lib']
21
+
22
+ spec.add_development_dependency 'bundler', '~> 1.10'
23
+ spec.add_development_dependency 'rake', '~> 10.0'
24
+ spec.add_development_dependency 'rspec'
25
+ spec.add_development_dependency 'pry'
26
+
27
+ spec.add_dependency 'logify'
28
+ spec.add_dependency 'test-kitchen'
29
+ spec.add_dependency 'kitchen-vagrant'
30
+ end
@@ -0,0 +1,3 @@
1
+ instance 'web-ubuntu-1404' do
2
+ depends_on 'app-ubuntu-1404'
3
+ end
data/lib/cocina/cli.rb ADDED
@@ -0,0 +1,78 @@
1
+ require 'logify'
2
+ require 'kitchen'
3
+ require 'kitchen/cli'
4
+
5
+ module Cocina
6
+ class CLI
7
+ include Logify
8
+
9
+ attr_reader :config, :instances, :dependencies, :primary_instance
10
+
11
+ # essentially startup a Kitchen::CLI
12
+ def initialize(target)
13
+ super()
14
+
15
+ $stdout.sync = true
16
+ Logify.level = :debug
17
+
18
+ @dependencies = []
19
+ @config = Cocina::Config.new('Cocinafile')
20
+
21
+ @kitchen_loader = Kitchen::Loader::YAML.new(
22
+ project_config: ENV["KITCHEN_YAML"],
23
+ local_config: ENV["KITCHEN_LOCAL_YAML"],
24
+ global_config: ENV["KITCHEN_GLOBAL_YAML"]
25
+ )
26
+ @kitchen_config = Kitchen::Config.new(
27
+ loader: @kitchen_loader
28
+ )
29
+ @kitchen_config.log_level =
30
+ Kitchen.env_log unless Kitchen.env_log.nil?
31
+ @kitchen_config.log_overwrite =
32
+ Kitchen.env_log_overwrite unless Kitchen.env_log_overwrite.nil?
33
+
34
+ prepare_instances_for target
35
+ end
36
+
37
+ def run
38
+ log.info "Running for Target: #{primary_instance.name}"
39
+ dependencies.each do |machine|
40
+ log.info "Converging #{machine.name}"
41
+ machine.converge
42
+ end
43
+ primary_instance.verify
44
+ cleanup
45
+ end
46
+
47
+ def instance_by_name(target)
48
+ @config[target]
49
+ end
50
+
51
+ def kitchen_instance_for(target)
52
+ @kitchen_config.instances.get(target)
53
+ end
54
+
55
+ def prepare_instances_for(target)
56
+ log.info "Preparing all dependencies"
57
+ instance = instance_by_name(target)
58
+ @primary_instance = kitchen_instance_for(target)
59
+ instance.dependencies.each do |dependency|
60
+ log.info "#{target} depends on #{dependency}"
61
+ @dependencies << kitchen_instance_for(dependency)
62
+ end
63
+ end
64
+
65
+ def cleanup
66
+ log.info "Cleaning up all dependencies"
67
+ destroy_dependencies
68
+ primary_instance.destroy
69
+ end
70
+
71
+ def destroy_dependencies
72
+ dependencies.each do |machine|
73
+ log.info "Destroying #{machine.name}"
74
+ machine.destroy
75
+ end
76
+ end
77
+ end
78
+ end
@@ -0,0 +1,28 @@
1
+ require 'cocina/instance'
2
+
3
+ module Cocina
4
+ class Config
5
+ attr_reader :cocinafile
6
+ attr_reader :instances
7
+
8
+ def initialize(file)
9
+ @cocinafile = file
10
+ @instances = []
11
+ load_cocinafile
12
+ end
13
+
14
+ def load_cocinafile
15
+ self.instance_eval(IO.read(cocinafile), cocinafile, 1)
16
+ end
17
+
18
+ def instance(name, &block)
19
+ i = Cocina::Instance.new(name)
20
+ i.instance_eval(&block)
21
+ @instances << i
22
+ end
23
+
24
+ def [](target)
25
+ @instances.select {|i| i.name == target }.first
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,14 @@
1
+ module Cocina
2
+ class Instance
3
+ attr_reader :name, :dependencies
4
+
5
+ def initialize(name)
6
+ @name = name
7
+ @dependencies = []
8
+ end
9
+
10
+ def depends(dep)
11
+ @dependencies << dep
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,3 @@
1
+ module Cocina
2
+ VERSION = "0.1.0"
3
+ end
data/lib/cocina.rb ADDED
@@ -0,0 +1,15 @@
1
+ require 'cocina/version'
2
+ require 'cocina/cli'
3
+ require 'cocina/config'
4
+
5
+ # Cocina base module
6
+ #
7
+ # @author Brandon Raabe
8
+ module Cocina
9
+ extend self
10
+
11
+ # @return [String] the version
12
+ def version
13
+ Cocina::VERSION
14
+ end
15
+ end
metadata ADDED
@@ -0,0 +1,160 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: cocina
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Brandon Raabe
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-12-25 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.10'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.10'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: pry
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: logify
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: test-kitchen
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: kitchen-vagrant
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :runtime
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ description: Test Kitchen with Dependencies
112
+ email:
113
+ - brandocorp+cochina@gmail.com
114
+ executables:
115
+ - cocina
116
+ extensions: []
117
+ extra_rdoc_files: []
118
+ files:
119
+ - ".gitignore"
120
+ - ".kitchen.yml"
121
+ - ".rspec"
122
+ - ".ruby-version"
123
+ - ".travis.yml"
124
+ - Gemfile
125
+ - LICENSE.txt
126
+ - README.md
127
+ - Rakefile
128
+ - bin/cocina
129
+ - cocina.gemspec
130
+ - example/Cocinafile
131
+ - lib/cocina.rb
132
+ - lib/cocina/cli.rb
133
+ - lib/cocina/config.rb
134
+ - lib/cocina/instance.rb
135
+ - lib/cocina/version.rb
136
+ homepage: https://github.com/brandocorp/cocina
137
+ licenses:
138
+ - MIT
139
+ metadata: {}
140
+ post_install_message:
141
+ rdoc_options: []
142
+ require_paths:
143
+ - lib
144
+ required_ruby_version: !ruby/object:Gem::Requirement
145
+ requirements:
146
+ - - ">="
147
+ - !ruby/object:Gem::Version
148
+ version: '0'
149
+ required_rubygems_version: !ruby/object:Gem::Requirement
150
+ requirements:
151
+ - - ">="
152
+ - !ruby/object:Gem::Version
153
+ version: '0'
154
+ requirements: []
155
+ rubyforge_project:
156
+ rubygems_version: 2.4.5.1
157
+ signing_key:
158
+ specification_version: 4
159
+ summary: Test Kitchen with Dependencies
160
+ test_files: []