vagrantboxes 0.0.2
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 +4 -0
- data/Gemfile +4 -0
- data/README.md +16 -0
- data/Rakefile +2 -0
- data/lib/vagrant_init.rb +6 -0
- data/lib/vagrantboxes.rb +2 -0
- data/lib/vagrantboxes/client.rb +68 -0
- data/lib/vagrantboxes/command.rb +33 -0
- data/lib/vagrantboxes/version.rb +3 -0
- data/vagrantboxes.gemspec +26 -0
- metadata +122 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/README.md
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
## Introduction
|
2
|
+
|
3
|
+
This application extends the [vagrant](http://vagrantup.com) command line tool to allow for searching the [vagrantbox.es](http://vagrantbox.es) repository of base boxes.
|
4
|
+
|
5
|
+
## Usage:
|
6
|
+
|
7
|
+
- List all currently available boxes: <pre>vagrant vagrantboxes search</pre>
|
8
|
+
- Do simple text searches: <pre>vagrant vagrantboxes search centos </pre>
|
9
|
+
- Do slightly more complex text searches: <pre>vagrant vagrantboxes search "debian puppet" </pre>
|
10
|
+
- Show all the details of a particular box: <pre>vagrant vagrantboxes show 1</pre>
|
11
|
+
- Show only the url of a particular box: <pre>vagrant vagrantboxes url 1</pre>
|
12
|
+
- Download a box listed on vagrantbox.es: <pre>vagrant vagrantboxes add 1</pre>
|
13
|
+
|
14
|
+
## Installation
|
15
|
+
|
16
|
+
<pre>gem install vagrantboxes</pre>
|
data/Rakefile
ADDED
data/lib/vagrant_init.rb
ADDED
data/lib/vagrantboxes.rb
ADDED
@@ -0,0 +1,68 @@
|
|
1
|
+
require 'cgi'
|
2
|
+
require 'json'
|
3
|
+
require 'net/http'
|
4
|
+
require 'vagrant'
|
5
|
+
|
6
|
+
|
7
|
+
module Vagrantboxes
|
8
|
+
|
9
|
+
ENDPOINT = "http://api2.vagrantbox.es"
|
10
|
+
|
11
|
+
module Client
|
12
|
+
|
13
|
+
def self.search(term, api_url)
|
14
|
+
base = api_url ? api_url : ENDPOINT
|
15
|
+
url = "#{base}/boxes.json"
|
16
|
+
if term
|
17
|
+
url = "#{url}?q=#{CGI.escape(term)}"
|
18
|
+
end
|
19
|
+
results = request(url)
|
20
|
+
results.sort! { |a,b| a['id'] <=> b['id'] }
|
21
|
+
results.each { |result|
|
22
|
+
puts "#{result['id'].to_s.ljust(4)} #{result['title'].ljust(25)} #{result['url']}"
|
23
|
+
}
|
24
|
+
end
|
25
|
+
|
26
|
+
def self.url(id, api_url)
|
27
|
+
base = api_url ? api_url : ENDPOINT
|
28
|
+
if id =~ /^[-+]?[0-9]+$/
|
29
|
+
url = "#{base}/boxes/#{id}.json"
|
30
|
+
result = request(url)
|
31
|
+
puts result['url']
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
def self.show(id, api_url)
|
36
|
+
base = api_url ? api_url : ENDPOINT
|
37
|
+
if id =~ /^[-+]?[0-9]+$/
|
38
|
+
url = "#{base}/boxes/#{id}.json"
|
39
|
+
result = request(url)
|
40
|
+
|
41
|
+
puts
|
42
|
+
puts result['title']
|
43
|
+
puts result['url']
|
44
|
+
puts
|
45
|
+
puts result['description']
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
def self.add(id, api_url)
|
50
|
+
base = api_url ? api_url : ENDPOINT
|
51
|
+
if id =~ /^[-+]?[0-9]+$/
|
52
|
+
url = "#{base}/boxes/#{id}.json"
|
53
|
+
result = request(url)
|
54
|
+
env = Vagrant::Environment.new
|
55
|
+
env.ui = Vagrant::UI::Shell.new(env, Thor::Base.shell.new)
|
56
|
+
env.load!
|
57
|
+
Vagrant::Box.add(env, result['title'], result['url'])
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
def self.request(url)
|
62
|
+
resp = Net::HTTP.get_response(URI.parse(url))
|
63
|
+
data = resp.body
|
64
|
+
resp.code == "200" ? JSON.parse(data) : nil
|
65
|
+
end
|
66
|
+
|
67
|
+
end
|
68
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require 'vagrantboxes/client'
|
2
|
+
|
3
|
+
module Vagrantboxes
|
4
|
+
class Command < Vagrant::Command::GroupBase
|
5
|
+
register "vagrantboxes","Interact with the vagrantbox.es list of boxes"
|
6
|
+
|
7
|
+
desc "search [TERM]", "Find a box"
|
8
|
+
method_option :api
|
9
|
+
def search(term=nil)
|
10
|
+
Vagrantboxes::Client.search(term, options[:api])
|
11
|
+
end
|
12
|
+
|
13
|
+
desc "show [ID]", "Show all information for a given box"
|
14
|
+
method_option :api
|
15
|
+
def show(id=nil)
|
16
|
+
Vagrantboxes::Client.show(id, options[:api])
|
17
|
+
end
|
18
|
+
|
19
|
+
desc "url [ID]", "Return the URL for a given box"
|
20
|
+
method_option :api
|
21
|
+
def url(id=nil)
|
22
|
+
Vagrantboxes::Client.url(id, options[:api])
|
23
|
+
end
|
24
|
+
|
25
|
+
desc "add [ID]", "Download and add the box to your vagrant installation"
|
26
|
+
method_option :api
|
27
|
+
def add(id=nil)
|
28
|
+
Vagrantboxes::Client.add(id, options[:api])
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "vagrantboxes/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "vagrantboxes"
|
7
|
+
s.version = Vagrantboxes::VERSION
|
8
|
+
s.platform = Gem::Platform::RUBY
|
9
|
+
s.authors = ["Gareth Rushgrove"]
|
10
|
+
s.email = ["gareth@morethanseven.net"]
|
11
|
+
s.homepage = "http://vagrantbox.es"
|
12
|
+
s.summary = %q{Vagrant extension to download boxes from vagrantbox.es}
|
13
|
+
s.description = %q{Vagrant extension to search and download boxes from vagrantbox.es}
|
14
|
+
|
15
|
+
s.rubyforge_project = "vagrantboxes"
|
16
|
+
|
17
|
+
s.add_dependency "vagrant", "~> 0.7.0"
|
18
|
+
s.add_dependency "json"
|
19
|
+
|
20
|
+
s.add_development_dependency "bundler", ">= 1.0.0"
|
21
|
+
|
22
|
+
s.files = `git ls-files`.split("\n")
|
23
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
24
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
25
|
+
s.require_paths = ["lib"]
|
26
|
+
end
|
metadata
ADDED
@@ -0,0 +1,122 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: vagrantboxes
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 27
|
5
|
+
prerelease:
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 0
|
9
|
+
- 2
|
10
|
+
version: 0.0.2
|
11
|
+
platform: ruby
|
12
|
+
authors:
|
13
|
+
- Gareth Rushgrove
|
14
|
+
autorequire:
|
15
|
+
bindir: bin
|
16
|
+
cert_chain: []
|
17
|
+
|
18
|
+
date: 2011-05-08 00:00:00 +01:00
|
19
|
+
default_executable:
|
20
|
+
dependencies:
|
21
|
+
- !ruby/object:Gem::Dependency
|
22
|
+
name: vagrant
|
23
|
+
prerelease: false
|
24
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ~>
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
hash: 3
|
30
|
+
segments:
|
31
|
+
- 0
|
32
|
+
- 7
|
33
|
+
- 0
|
34
|
+
version: 0.7.0
|
35
|
+
type: :runtime
|
36
|
+
version_requirements: *id001
|
37
|
+
- !ruby/object:Gem::Dependency
|
38
|
+
name: json
|
39
|
+
prerelease: false
|
40
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ">="
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
hash: 3
|
46
|
+
segments:
|
47
|
+
- 0
|
48
|
+
version: "0"
|
49
|
+
type: :runtime
|
50
|
+
version_requirements: *id002
|
51
|
+
- !ruby/object:Gem::Dependency
|
52
|
+
name: bundler
|
53
|
+
prerelease: false
|
54
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
55
|
+
none: false
|
56
|
+
requirements:
|
57
|
+
- - ">="
|
58
|
+
- !ruby/object:Gem::Version
|
59
|
+
hash: 23
|
60
|
+
segments:
|
61
|
+
- 1
|
62
|
+
- 0
|
63
|
+
- 0
|
64
|
+
version: 1.0.0
|
65
|
+
type: :development
|
66
|
+
version_requirements: *id003
|
67
|
+
description: Vagrant extension to search and download boxes from vagrantbox.es
|
68
|
+
email:
|
69
|
+
- gareth@morethanseven.net
|
70
|
+
executables: []
|
71
|
+
|
72
|
+
extensions: []
|
73
|
+
|
74
|
+
extra_rdoc_files: []
|
75
|
+
|
76
|
+
files:
|
77
|
+
- .gitignore
|
78
|
+
- Gemfile
|
79
|
+
- README.md
|
80
|
+
- Rakefile
|
81
|
+
- lib/vagrant_init.rb
|
82
|
+
- lib/vagrantboxes.rb
|
83
|
+
- lib/vagrantboxes/client.rb
|
84
|
+
- lib/vagrantboxes/command.rb
|
85
|
+
- lib/vagrantboxes/version.rb
|
86
|
+
- vagrantboxes.gemspec
|
87
|
+
has_rdoc: true
|
88
|
+
homepage: http://vagrantbox.es
|
89
|
+
licenses: []
|
90
|
+
|
91
|
+
post_install_message:
|
92
|
+
rdoc_options: []
|
93
|
+
|
94
|
+
require_paths:
|
95
|
+
- lib
|
96
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
97
|
+
none: false
|
98
|
+
requirements:
|
99
|
+
- - ">="
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
hash: 3
|
102
|
+
segments:
|
103
|
+
- 0
|
104
|
+
version: "0"
|
105
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
106
|
+
none: false
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
hash: 3
|
111
|
+
segments:
|
112
|
+
- 0
|
113
|
+
version: "0"
|
114
|
+
requirements: []
|
115
|
+
|
116
|
+
rubyforge_project: vagrantboxes
|
117
|
+
rubygems_version: 1.4.2
|
118
|
+
signing_key:
|
119
|
+
specification_version: 3
|
120
|
+
summary: Vagrant extension to download boxes from vagrantbox.es
|
121
|
+
test_files: []
|
122
|
+
|