Browse files

more refactoring

  • Loading branch information...
1 parent 9f4bacd commit 648f0e41b32845a2b90674970555d867f6953dda @markburns committed Mar 18, 2012
Showing with 17 additions and 20 deletions.
  1. +14 −13 lib/kaboom/command.rb
  2. +3 −7 lib/kaboom/platform/base.rb
View
27 lib/kaboom/command.rb
@@ -103,13 +103,14 @@ def delegate(command, major, minor)
return random(major) if command == 'random' || command == 'rand' || command == 'r'
# if we're operating on a List
- if storage.list_exists?(command)
- return delete_list(command) if major == 'delete'
- return detail_list(command) unless major
+ list = command
+ if storage.list_exists?(list)
+ return delete_list(list) if major == 'delete'
+ return detail_list(list) unless major
unless minor == 'delete'
- return add_item(command,major,minor) if minor
- return add_item(command,major,stdin.read) if stdin.stat.size > 0
- return search_list_for_item(command, major)
+ return add_item(list,major,minor) if minor
+ return add_item(list,major,stdin.read) if stdin.stat.size > 0
+ return search_list_for_item(list, major)
end
end
@@ -157,18 +158,18 @@ def detail_list(name)
# Public: opens the Item.
#
# Returns nothing.
- def open(major, minor)
- if storage.list_exists?(major)
- list = List.find(major)
- if minor
- item = storage.items.detect { |item| item.name == minor }
+ def open(key, value)
+ if storage.list_exists?(key)
+ list = List.find(key)
+ if value
+ item = storage.items.detect { |item| item.name == value }
output "#{cyan("Boom!")} We just opened #{yellow(Platform.open(item))} for you."
else
list.items.each { |item| Platform.open(item) }
- output "#{cyan("Boom!")} We just opened all of #{yellow(major)} for you."
+ output "#{cyan("Boom!")} We just opened all of #{yellow(key)} for you."
end
else
- item = storage.items.detect { |item| item.name == major }
+ item = storage.items.detect { |item| item.name == key }
output "#{cyan("Boom!")} We just opened #{yellow(Platform.open(item))} for you."
end
end
View
10 lib/kaboom/platform/base.rb
@@ -6,16 +6,12 @@ def open_file file
def edit json_file
if $EDITOR
- if block_given?
- yield
- else
- system "`echo $EDITOR` #{json_file} &"
- end
+ return yield if block_given?
+
+ system "`echo $EDITOR` #{json_file} &"
else
open_file json_file
end
-
- "Make your edits, and do be sure to save."
end
def copy item

0 comments on commit 648f0e4

Please sign in to comment.