Permalink
Browse files

Fixes open command, bumps version to 0.0.4

  • Loading branch information...
philnash committed Apr 10, 2011
1 parent 0c9d666 commit 98d1ad741361ea9aae00f7e5703024f40cc9810d
Showing with 35 additions and 16 deletions.
  1. +10 −0 Readme.md
  2. +23 −14 bin/pow
  3. +1 −1 lib/powder/version.rb
  4. +1 −1 powder.gemspec
View
@@ -8,9 +8,12 @@ Powder manages [Pow](http://pow.cx/)
$ pow
=> link the current dir_name to ~/.pow/dir_name
+ # if the dir_name has underscores in, powder changes them to hyphens
$ pow link bacon
=> link the current dir to ~/.pow/bacon
+ # If the current directory doesn't look like an app that can be powered
+ # by pow it will offer to download a basic config.ru for Rails 2
$ pow list
=> list all the current apps linked in ~/.pow
@@ -25,6 +28,13 @@ Powder manages [Pow](http://pow.cx/)
$ pow remove bacon
=> unlink bacon
+
+ $ pow open
+ => opens the pow link in a browser
+ # aliased as pow -o
+
+ $ pow open bacon
+ => opens http://bacon.dev in a browser
$ pow install
=> installs pow server (I know, "curl get.pow.cx | sh" isn't hard, but this is _even_ easier)
View
37 bin/pow
@@ -3,8 +3,7 @@
require 'rubygems'
require 'thor'
require 'fileutils'
-require 'open-uri'
-
+require "net/https"
class Pow < Thor
include Thor::Actions
@@ -13,37 +12,38 @@ class Pow < Thor
map '-r' => 'restart'
map '-l' => 'list'
map '-L' => 'link'
+ map '-o' => 'open'
POWPATH = "/Users/#{`whoami`.chomp}/.pow"
- desc "link", "link a pow"
+ desc "link", "Link a pow"
def link(name=nil)
return unless is_powable?
current_path = %x{pwd}.chomp
- name ||= File.basename(current_path).tr('_', '-')
+ name ||= current_dir_pow_name
symlink_path = "#{POWPATH}/#{name}"
FileUtils.ln_s(current_path, symlink_path) unless File.exists?(symlink_path)
- $stdout.puts "Your application is now available at http://#{name}.dev/"
+ say "Your application is now available at http://#{name}.dev/"
end
- desc "restart", "restart current pow"
+ desc "restart", "Restart current pow"
def restart
return unless is_powable?
FileUtils.mkdir_p('tmp')
%x{touch tmp/restart.txt}
end
- desc "list", "list current pows"
+ desc "list", "List current pows"
def list
- Dir[POWPATH + "/*"].map { |a| $stdout.puts File.basename(a) }
+ Dir[POWPATH + "/*"].map { |a| say File.basename(a) }
end
-
- desc "open", "open a pow"
+
+ desc "open", "Open a pow in the browser"
def open(name=nil)
- %x{open http://#{name || File.basename(%x{pwd}.chomp)}.dev}
+ %x{open http://#{name || current_dir_pow_name}.dev}
end
- desc "remove", "remove a pow"
+ desc "remove", "Remove a pow"
def remove(name=nil)
return unless is_powable?
FileUtils.rm POWPATH + '/' + (name || File.basename(%x{pwd}.chomp))
@@ -61,15 +61,24 @@ class Pow < Thor
private
+ def current_dir_pow_name
+ File.basename(%x{pwd}.chomp).tr('_', '-')
+ end
+
def is_powable?
if File.exists?('config.ru') || File.exists?('public/index.html')
true
else
say "This does not appear to be a rack app as there is no config.ru."
- say "If you are in a Rails 2 application, try https://gist.github.com/909308"
say "Pow can also host static apps if there is an index.html in public/"
+ say "If you are in a Rails 2 application, you need a config.ru file"
if yes? "Do you want to autogenerate a basic config.ru for Rails 2?"
- create_file "config.ru", open("https://gist.github.com/909308.txt").read
+ uri = URI.parse("https://gist.github.com/909308.txt")
+ http = Net::HTTP.new(uri.host, uri.port)
+ http.use_ssl = true
+ http.verify_mode = OpenSSL::SSL::VERIFY_NONE
+ request = Net::HTTP::Get.new(uri.request_uri)
+ create_file "config.ru", http.request(request).body
end
end
end
View
@@ -1,3 +1,3 @@
module Powder
- VERSION = "0.0.3"
+ VERSION = "0.0.4"
end
View
@@ -10,7 +10,7 @@ Gem::Specification.new do |s|
s.email = ["no"]
s.homepage = "http://github.com/Rodreegez/powder"
s.summary = %q{Makes Pow even easier}
- s.description = %q{Makes Pow even easier. I mean seriously, really really ridiculously easy.}
+ s.description = %q{Makes Pow even easier. I mean really, really, ridiculously easy.}
s.rubyforge_project = "powder"

0 comments on commit 98d1ad7

Please sign in to comment.