spatula 0.0.1
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/README.textile +42 -0
- data/bin/spatula +11 -0
- data/lib/spatula.rb +65 -0
- metadata +57 -0
data/README.textile
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
h1. Spatula
|
2
|
+
|
3
|
+
Spatula is a command line helper app for use with "Chef":http://www.opscode.com/chef. It currently lets you search and install cookbooks from http://cookbooks.opscode.com. It does not yet implement the full API, but that will be coming in future versions (as I need it). If you need it to support the full API *right now*, please make it do so and send me a pull request :-)
|
4
|
+
|
5
|
+
Spatula is really, really alpha. It does not handle errors at all, but it works pretty well given that you hand it the correct input. Please give it a try and pretty please fork it and make it better.
|
6
|
+
|
7
|
+
h1. Usage
|
8
|
+
|
9
|
+
Spatula currently supports 3 commands: search, show, and install.
|
10
|
+
|
11
|
+
<pre>
|
12
|
+
$ ruby spatula.rb search apache2
|
13
|
+
apache2 Installs and configures all aspects of apache2 using Debian style symlinks with helper definitions
|
14
|
+
... more output ...
|
15
|
+
|
16
|
+
$ ruby spatula.rb show apache2
|
17
|
+
name: apache2
|
18
|
+
average_rating:
|
19
|
+
category: Web Servers
|
20
|
+
created_at: 2009-10-25T23:47:55Z
|
21
|
+
updated_at: 2009-10-25T23:47:55Z
|
22
|
+
maintainer: jtimberman
|
23
|
+
latest_version: http://cookbooks.opscode.com/api/v1/cookbooks/apache2/versions/0_9_1
|
24
|
+
external_url:
|
25
|
+
versions: http://cookbooks.opscode.com/api/v1/cookbooks/apache2/versions/0_9_1
|
26
|
+
description: Installs and configures all aspects of apache2 using Debian style symlinks with helper definitions
|
27
|
+
|
28
|
+
$ ruby spatula.rb install apache2
|
29
|
+
... downloads the apache2 cookbook and installs it into $(pwd)/cookbooks ...
|
30
|
+
... also creates a $(pwd)/cookbook_tarballs dir to store the download ...
|
31
|
+
</pre>
|
32
|
+
|
33
|
+
h1. About
|
34
|
+
|
35
|
+
h2. Official Repo
|
36
|
+
|
37
|
+
http://github.com/trotter/spatula
|
38
|
+
|
39
|
+
h2. Author
|
40
|
+
|
41
|
+
Trotter Cashion
|
42
|
+
|
data/bin/spatula
ADDED
data/lib/spatula.rb
ADDED
@@ -0,0 +1,65 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'net/http'
|
3
|
+
require 'uri'
|
4
|
+
require 'json'
|
5
|
+
|
6
|
+
class Spatula
|
7
|
+
BASE_URL = "http://cookbooks.opscode.com/api/v1"
|
8
|
+
|
9
|
+
def self.run
|
10
|
+
command = ARGV.shift
|
11
|
+
Spatula.new.send(command, *ARGV)
|
12
|
+
end
|
13
|
+
|
14
|
+
# Search for cookbooks matching :query:
|
15
|
+
def search(query, start=0, items=10)
|
16
|
+
url = URI.parse("%s/search?q=%s&start=%s&items=%s" % [BASE_URL, query, start, items])
|
17
|
+
response = Net::HTTP.get(url)
|
18
|
+
items = JSON.parse(response)["items"]
|
19
|
+
items.each do |item|
|
20
|
+
puts [item["cookbook_name"], item["cookbook_description"], item["cookbook_maintainer"]].join("\t")
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
# Show the cookbook named :name:
|
25
|
+
def show(name)
|
26
|
+
print_response(get_cookbook_info(name))
|
27
|
+
end
|
28
|
+
|
29
|
+
# Show the latest version of the cookbook named :name:
|
30
|
+
def show_latest_version(name)
|
31
|
+
print_response(get_version_info(name))
|
32
|
+
end
|
33
|
+
|
34
|
+
# Install the cookbook :name: into cwd/cookbooks
|
35
|
+
# Will create a cookbook_tarballs dir for storing downloaded tarballs
|
36
|
+
def install(name)
|
37
|
+
file = JSON.parse(get_version_info(name))["file"]
|
38
|
+
filename = File.basename(file)
|
39
|
+
FileUtils.mkdir_p("cookbook_tarballs")
|
40
|
+
`curl #{file} -o cookbook_tarballs/#{filename}`
|
41
|
+
`tar xzvf cookbook_tarballs/#{filename} -C cookbooks`
|
42
|
+
end
|
43
|
+
|
44
|
+
private
|
45
|
+
def get_cookbook_info(name)
|
46
|
+
url = URI.parse("%s/cookbooks/%s" % [BASE_URL, name])
|
47
|
+
Net::HTTP.get(url)
|
48
|
+
end
|
49
|
+
|
50
|
+
def get_version_info(name)
|
51
|
+
latest = JSON.parse(get_cookbook_info(name))["latest_version"]
|
52
|
+
response = Net::HTTP.get(URI.parse(latest))
|
53
|
+
end
|
54
|
+
|
55
|
+
def print_response(response)
|
56
|
+
item = JSON.parse(response)
|
57
|
+
item.each_pair do |k, v|
|
58
|
+
puts "#{k}:\t#{v}"
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
if __FILE__ == $0
|
64
|
+
Spatula.run
|
65
|
+
end
|
metadata
ADDED
@@ -0,0 +1,57 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: spatula
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Trotter Cashion
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2009-11-07 00:00:00 -05:00
|
13
|
+
default_executable:
|
14
|
+
dependencies: []
|
15
|
+
|
16
|
+
description: " Spatula is a command line helper app for use with Chef. It currently lets you\n search and install cookbooks from http://cookbooks.opscode.com.\n"
|
17
|
+
email: cashion@gmail.com
|
18
|
+
executables:
|
19
|
+
- spatula
|
20
|
+
extensions: []
|
21
|
+
|
22
|
+
extra_rdoc_files: []
|
23
|
+
|
24
|
+
files:
|
25
|
+
- README.textile
|
26
|
+
- bin/spatula
|
27
|
+
- lib/spatula.rb
|
28
|
+
has_rdoc: true
|
29
|
+
homepage: http://trottercashion.com
|
30
|
+
licenses: []
|
31
|
+
|
32
|
+
post_install_message:
|
33
|
+
rdoc_options: []
|
34
|
+
|
35
|
+
require_paths:
|
36
|
+
- lib
|
37
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
38
|
+
requirements:
|
39
|
+
- - ">="
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
version: "0"
|
42
|
+
version:
|
43
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: "0"
|
48
|
+
version:
|
49
|
+
requirements: []
|
50
|
+
|
51
|
+
rubyforge_project:
|
52
|
+
rubygems_version: 1.3.5
|
53
|
+
signing_key:
|
54
|
+
specification_version: 3
|
55
|
+
summary: Command line helper app for use with Chef
|
56
|
+
test_files: []
|
57
|
+
|