Update_Site_Cookbooks 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.
- data/.gitignore +8 -0
- data/Gemfile +6 -0
- data/README.md +52 -0
- data/Rakefile +3 -0
- data/Update_Site_Cookbooks.gemspec +32 -0
- data/bin/Update_Site_Cookbooks +22 -0
- data/lib/Update_Site_Cookbooks.rb +7 -0
- data/lib/Update_Site_Cookbooks/version.rb +3 -0
- data/spec/helper.rb +15 -0
- data/spec/main.rb +26 -0
- data/spec/tests/bin.rb +13 -0
- data/spec/tests/update.rb +45 -0
- metadata +155 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/README.md
ADDED
@@ -0,0 +1,52 @@
|
|
1
|
+
|
2
|
+
Update\_Site\_Cookbooks
|
3
|
+
================
|
4
|
+
|
5
|
+
|
6
|
+
This gem automates updating all your cookbooks installed with:
|
7
|
+
"knife cookbook site install NAME".
|
8
|
+
|
9
|
+
Implementation
|
10
|
+
==============
|
11
|
+
|
12
|
+
It uses your git branch names
|
13
|
+
that begin with "chef-vender-" to determine which
|
14
|
+
cookbooks to download.
|
15
|
+
|
16
|
+
All the code is in one page:
|
17
|
+
[https://github.com/da99/Update\_Site\_Cookbooks/blob/master/bin/Update\_Site\_Cookbooks](https://github.com/da99/Update_Site_Cookbooks/blob/master/bin/Update_Site_Cookbooks)
|
18
|
+
|
19
|
+
Installation
|
20
|
+
------------
|
21
|
+
|
22
|
+
gem 'Update_Site_Cookbooks'
|
23
|
+
|
24
|
+
Usage
|
25
|
+
------
|
26
|
+
|
27
|
+
One way:
|
28
|
+
|
29
|
+
git branch chef-vendor-openssh
|
30
|
+
Update_Site_Cookbooks
|
31
|
+
|
32
|
+
Another way:
|
33
|
+
|
34
|
+
knife cookbook site install openssh
|
35
|
+
knife cookbook site install nginx
|
36
|
+
knife cookbook site install varnish
|
37
|
+
Update_Site_Cookbooks
|
38
|
+
|
39
|
+
Run Tests
|
40
|
+
---------
|
41
|
+
|
42
|
+
git clone git@github.com:da99/Update_Site_Cookbooks.git
|
43
|
+
cd Update_Site_Cookbooks
|
44
|
+
bundle update
|
45
|
+
bundle exec bacon spec/main.rb
|
46
|
+
|
47
|
+
"I hate writing."
|
48
|
+
-----------------------------
|
49
|
+
|
50
|
+
If you know of existing software that makes the above redundant,
|
51
|
+
please tell me. The last thing I want to do is maintain code.
|
52
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
$:.push File.expand_path("../lib", __FILE__)
|
4
|
+
require "Update_Site_Cookbooks/version"
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = "Update_Site_Cookbooks"
|
8
|
+
s.version = Update_Site_Cookbooks::VERSION
|
9
|
+
s.authors = ["da99"]
|
10
|
+
s.email = ["i-hate-spam-45671204@mailinator.com"]
|
11
|
+
s.homepage = "https://github.com/da99/Update_Site_Cookbooks"
|
12
|
+
s.summary = %q{Update opscode cookbooks you downloaded.}
|
13
|
+
s.description = %q{
|
14
|
+
This gem automates updating all your cookbooks installed with:
|
15
|
+
"knife cookbook site install NAME".
|
16
|
+
}
|
17
|
+
|
18
|
+
s.files = `git ls-files`.split("\n")
|
19
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
20
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
21
|
+
s.require_paths = ["lib"]
|
22
|
+
|
23
|
+
s.add_development_dependency 'bacon'
|
24
|
+
s.add_development_dependency 'rake'
|
25
|
+
s.add_development_dependency 'Bacon_Colored'
|
26
|
+
s.add_development_dependency 'pry'
|
27
|
+
s.add_development_dependency 'Exit_Zero'
|
28
|
+
|
29
|
+
# s.rubyforge_project = "Update_Site_Cookbooks"
|
30
|
+
# specify any dependencies here; for example:
|
31
|
+
s.add_runtime_dependency "chef"
|
32
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# -*- ruby -*-
|
3
|
+
#
|
4
|
+
|
5
|
+
|
6
|
+
require "Exit_Zero"
|
7
|
+
|
8
|
+
PREFIX = "chef-vendor-"
|
9
|
+
|
10
|
+
Exit_Zero( %!
|
11
|
+
git branch
|
12
|
+
!).out.strip.split("\n").each { |raw|
|
13
|
+
line = raw.strip
|
14
|
+
name = line.sub(PREFIX, '')
|
15
|
+
|
16
|
+
next unless line[ %r!^#{PREFIX}! ]
|
17
|
+
next if !ARGV.empty? && !ARGV.include?(name)
|
18
|
+
|
19
|
+
Exit_Zero "knife cookbook site install #{name}"
|
20
|
+
}
|
21
|
+
|
22
|
+
|
data/spec/helper.rb
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'bundler'
|
3
|
+
begin
|
4
|
+
Bundler.setup(:default, :development)
|
5
|
+
rescue Bundler::BundlerError => e
|
6
|
+
$stderr.print e.message, "\n"
|
7
|
+
$stderr.print "Run `bundle install` to install missing gems\n"
|
8
|
+
exit e.status_code
|
9
|
+
end
|
10
|
+
require 'bacon'
|
11
|
+
|
12
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
13
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
14
|
+
|
15
|
+
Bacon.summary_on_exit
|
data/spec/main.rb
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
|
2
|
+
require File.expand_path('spec/helper')
|
3
|
+
require 'Update_Site_Cookbooks'
|
4
|
+
require 'Bacon_Colored'
|
5
|
+
require 'pry'
|
6
|
+
require 'Exit_Zero'
|
7
|
+
|
8
|
+
TEMP = "/tmp/Update_Site_Cookbooks"
|
9
|
+
`rm -rf #{TEMP}`
|
10
|
+
`mkdir -p #{TEMP}`
|
11
|
+
|
12
|
+
def chdir name = ""
|
13
|
+
dir = File.join(TEMP, name)
|
14
|
+
`mkdir -p #{dir}` unless File.directory?(dir)
|
15
|
+
|
16
|
+
Dir.chdir(dir) { yield }
|
17
|
+
end
|
18
|
+
|
19
|
+
# ======== Include the tests.
|
20
|
+
if ARGV.size > 1 && ARGV[1, ARGV.size - 1].detect { |a| File.exists?(a) }
|
21
|
+
# Do nothing. Bacon grabs the file.
|
22
|
+
else
|
23
|
+
Dir.glob('spec/tests/*.rb').each { |file|
|
24
|
+
require File.expand_path(file.sub('.rb', '')) if File.file?(file)
|
25
|
+
}
|
26
|
+
end
|
data/spec/tests/bin.rb
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
|
2
|
+
bins = Dir.glob("bin/*")
|
3
|
+
|
4
|
+
unless bins.empty?
|
5
|
+
describe "permissions of bin/" do
|
6
|
+
bins.each { |file|
|
7
|
+
it "should chmod 755 for: #{file}" do
|
8
|
+
`stat -c %a #{file}`.strip
|
9
|
+
.should.be == "755"
|
10
|
+
end
|
11
|
+
}
|
12
|
+
end # === permissions of bin/
|
13
|
+
end # === unless bins.empty?
|
@@ -0,0 +1,45 @@
|
|
1
|
+
def Multi_Exit str
|
2
|
+
str.strip.split("\n").each { |line|
|
3
|
+
Exit_Zero line
|
4
|
+
}
|
5
|
+
end
|
6
|
+
|
7
|
+
def git_init
|
8
|
+
Multi_Exit %!
|
9
|
+
git init
|
10
|
+
mkdir cookbooks
|
11
|
+
touch cookbooks/.gitkeep
|
12
|
+
git add .
|
13
|
+
git commit -m "First."
|
14
|
+
!
|
15
|
+
end
|
16
|
+
|
17
|
+
describe "Update_Site_Cookbooks (bin executable)" do
|
18
|
+
|
19
|
+
it "downloads site cookbook for any git branch starting with 'chef-vendor-'" do
|
20
|
+
chdir("News") {
|
21
|
+
git_init
|
22
|
+
|
23
|
+
Multi_Exit %!
|
24
|
+
git branch "chef-vendor-openssh"
|
25
|
+
Update_Site_Cookbooks
|
26
|
+
!
|
27
|
+
File.directory?("cookbooks/openssh").should.be == true
|
28
|
+
}
|
29
|
+
end
|
30
|
+
|
31
|
+
it "does not download any other cookbook except specified cookbook" do
|
32
|
+
chdir("News_2") {
|
33
|
+
git_init
|
34
|
+
Multi_Exit %!
|
35
|
+
git branch "chef-vendor-openssh"
|
36
|
+
git branch "chef-vendor-nginx"
|
37
|
+
Update_Site_Cookbooks nginx
|
38
|
+
!
|
39
|
+
File.directory?("cookbooks/openssh").should.be == false
|
40
|
+
File.directory?("cookbooks/nginx").should.be == true
|
41
|
+
}
|
42
|
+
end
|
43
|
+
|
44
|
+
end # === Update_Site_Cookbooks (bin executable)
|
45
|
+
|
metadata
ADDED
@@ -0,0 +1,155 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: Update_Site_Cookbooks
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- da99
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-04-13 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: bacon
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :development
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: rake
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
type: :development
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: Bacon_Colored
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ! '>='
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
54
|
+
type: :development
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
name: pry
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
66
|
+
requirements:
|
67
|
+
- - ! '>='
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0'
|
70
|
+
type: :development
|
71
|
+
prerelease: false
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ! '>='
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '0'
|
78
|
+
- !ruby/object:Gem::Dependency
|
79
|
+
name: Exit_Zero
|
80
|
+
requirement: !ruby/object:Gem::Requirement
|
81
|
+
none: false
|
82
|
+
requirements:
|
83
|
+
- - ! '>='
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: '0'
|
86
|
+
type: :development
|
87
|
+
prerelease: false
|
88
|
+
version_requirements: !ruby/object:Gem::Requirement
|
89
|
+
none: false
|
90
|
+
requirements:
|
91
|
+
- - ! '>='
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: '0'
|
94
|
+
- !ruby/object:Gem::Dependency
|
95
|
+
name: chef
|
96
|
+
requirement: !ruby/object:Gem::Requirement
|
97
|
+
none: false
|
98
|
+
requirements:
|
99
|
+
- - ! '>='
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
version: '0'
|
102
|
+
type: :runtime
|
103
|
+
prerelease: false
|
104
|
+
version_requirements: !ruby/object:Gem::Requirement
|
105
|
+
none: false
|
106
|
+
requirements:
|
107
|
+
- - ! '>='
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: '0'
|
110
|
+
description: ! "\n This gem automates updating all your cookbooks installed with:
|
111
|
+
\n \"knife cookbook site install NAME\".\n "
|
112
|
+
email:
|
113
|
+
- i-hate-spam-45671204@mailinator.com
|
114
|
+
executables:
|
115
|
+
- Update_Site_Cookbooks
|
116
|
+
extensions: []
|
117
|
+
extra_rdoc_files: []
|
118
|
+
files:
|
119
|
+
- .gitignore
|
120
|
+
- Gemfile
|
121
|
+
- README.md
|
122
|
+
- Rakefile
|
123
|
+
- Update_Site_Cookbooks.gemspec
|
124
|
+
- bin/Update_Site_Cookbooks
|
125
|
+
- lib/Update_Site_Cookbooks.rb
|
126
|
+
- lib/Update_Site_Cookbooks/version.rb
|
127
|
+
- spec/helper.rb
|
128
|
+
- spec/main.rb
|
129
|
+
- spec/tests/bin.rb
|
130
|
+
- spec/tests/update.rb
|
131
|
+
homepage: https://github.com/da99/Update_Site_Cookbooks
|
132
|
+
licenses: []
|
133
|
+
post_install_message:
|
134
|
+
rdoc_options: []
|
135
|
+
require_paths:
|
136
|
+
- lib
|
137
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
138
|
+
none: false
|
139
|
+
requirements:
|
140
|
+
- - ! '>='
|
141
|
+
- !ruby/object:Gem::Version
|
142
|
+
version: '0'
|
143
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
144
|
+
none: false
|
145
|
+
requirements:
|
146
|
+
- - ! '>='
|
147
|
+
- !ruby/object:Gem::Version
|
148
|
+
version: '0'
|
149
|
+
requirements: []
|
150
|
+
rubyforge_project:
|
151
|
+
rubygems_version: 1.8.19
|
152
|
+
signing_key:
|
153
|
+
specification_version: 3
|
154
|
+
summary: Update opscode cookbooks you downloaded.
|
155
|
+
test_files: []
|