JosephPecoraro / scripts

Some scripts I have written and tend to keep up to date. They reside in my personal bin folder.

scripts / inflate_choices
100755 38 lines (31 sloc) 0.808 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#!/usr/bin/env ruby
# Date: Thursday May 29, 2008
# Author: Joseph Pecoraro
# Contact: joepeck02@gmail.com
# Original Idea by defunkt - http://balloon.hobix.com/~defunkt
# Decription: Open or run a balloon.
 
require 'open-uri'
require 'rubygems'
require '/Users/joe/code/choice/lib/choice'
 
# Optional arg
Choice.options do
  destructive
  
  banner "Usage: #{$0.split(/\//).last} [-o] balloon"
  header ''
  header 'Options:'
  
  option :open do
    short '-o'
    long '--open'
    desc 'open in browser, do not download'
  end
end
 
# No args, print usage
Choice.help if Choice.choices[:open].nil? && ARGV.empty?
 
# Work it!
url = 'http://balloon.hobix.com/'
url += ARGV.shift unless ARGV.empty?
if Choice.choices[:open]
  `open #{url}`
else
  eval(open(url).read) rescue puts "** balloon not found"
end