Browse files

improvements for removing hosts

add possibility to remove hosts if the directory was already deleted,
show in `ls`-command if application has been removed, bump version
  • Loading branch information...
1 parent d259764 commit faf9329839c24149e753364d4b334572d5e7bdb4 @fschwahn committed Nov 25, 2011
Showing with 23 additions and 14 deletions.
  1. +5 −1 README.md
  2. +17 −12 lib/passify/cli.rb
  3. +1 −1 lib/passify/version.rb
View
6 README.md
@@ -23,7 +23,7 @@ To restart the application run
To remove the application run
- passify remove
+ passify remove [name]
To change the rack environment to e.g. production run
@@ -55,6 +55,10 @@ It makes sense to create a wrapper for `passify` if you are using multiple versi
rvm wrapper 1.8.7 --no-prefix passify
## Changelog
+### 0.2.3 (25-11-2011)
+* add possibility to remove hosts if the directory was already deleted
+* show in `ls`-command if application has been removed
+
### 0.2.2 (25-11-2011)
* added conf command to which opens the configuration file if $EDITOR is set, and shows the path otherwise
* fixed small bug with `list`-command showing truncated paths for legacy apps
View
29 lib/passify/cli.rb
@@ -20,9 +20,7 @@ class CLI < Thor
def add(name = nil)
check_for_passify
error("This directory can not be served with passify. It has to be either a Rack application, a Rails 2.x application or a legacy (PHP/HTML) application.") unless is_valid_app?
- name = File.basename(pwd) if name.nil? || name.empty?
- name = urlify(name)
- host = "#{name}.local"
+ host = get_host_from_name(name)
if app_exists?(host)
if is_same_app?(host, pwd)
notice("This directory is already being served from http://#{host}. Run `passify open` to view it.")
@@ -41,10 +39,10 @@ def add(name = nil)
say "The application was successfully set up and can be reached from http://#{host} . Run `passify open` to view it."
end
- desc "remove", "Removes an existing link to the current working directory."
- def remove
+ desc "remove", "Removes an existing application."
+ def remove(name = nil)
check_for_passify
- host = find_host
+ host = find_host(name)
sudome
remove_app(host)
@@ -114,7 +112,8 @@ def list
Dir.foreach(VHOSTS_DIR) do |entry|
if File.file?("#{VHOSTS_DIR}/#{entry}")
host = entry[0..-12]
- say " #{host} --> #{directory_for_host(host)}"
+ dir = directory_for_host(host)
+ say " #{host} --> #{Dir.exists?(dir) ? dir : "[REMOVED]"}"
end
end
end
@@ -207,13 +206,13 @@ def is_legacy_app?(path = pwd)
File.exists?("#{path}/index.html") || File.exists?("#{path}/index.php")
end
- def find_host
- if File.exists?('.passify')
+ def find_host(name = nil)
+ if name
+ host = get_host_from_name(name)
+ elsif File.exists?('.passify')
host = File.open('.passify') {|f| f.readline}.strip
else # support for passify 0.1.x
- name = File.basename(pwd)
- name = urlify(name)
- host = "#{name}.local"
+ host = get_host_from_name
end
notice("The current directory is not served via passify. Please run `passify add` first.") unless app_exists?(host)
host
@@ -236,6 +235,12 @@ def find_line_in_conf(pattern)
`grep -n '#{pattern}' #{APACHE_CONF}`.split(":").first
end
+ def get_host_from_name(name = nil)
+ name = File.basename(pwd) if name.nil? || name.empty?
+ name = urlify(name)
+ "#{name}.local"
+ end
+
def pwd
@pwd ||= Dir.pwd
end
View
2 lib/passify/version.rb
@@ -1,3 +1,3 @@
module Passify
- VERSION = "0.2.2"
+ VERSION = "0.2.3"
end

0 comments on commit faf9329

Please sign in to comment.