Skip to content

Commit

Permalink
Merge pull request #276 from Agis-/shorter-case-syntax
Browse files Browse the repository at this point in the history
Use a more compact case syntax when assigning the default_task
  • Loading branch information
sferik committed Jan 23, 2013
2 parents ca06fb8 + 1308bff commit 553b52f
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 26 deletions.
16 changes: 8 additions & 8 deletions lib/thor.rb
Expand Up @@ -9,14 +9,14 @@ class << self
# meth<Symbol>:: name of the default task
#
def default_task(meth=nil)
case meth
when :none
@default_task = 'help'
when nil
@default_task ||= from_superclass(:default_task, 'help')
else
@default_task = meth.to_s
end
@default_task = case meth
when :none
'help'
when nil
@default_task || from_superclass(:default_task, 'help')
else
meth.to_s
end
end

# Registers another Thor subclass as a command.
Expand Down
24 changes: 12 additions & 12 deletions lib/thor/base.rb
Expand Up @@ -313,12 +313,12 @@ def remove_class_option(*names)
# name<String|Symbol>
#
def group(name=nil)
case name
when nil
@group ||= from_superclass(:group, 'standard')
else
@group = name.to_s
end
@group = case name
when nil
@group || from_superclass(:group, 'standard')
else
name.to_s
end
end

# Returns the tasks for this Thor class.
Expand Down Expand Up @@ -413,12 +413,12 @@ def no_tasks
# thor :my_task
#
def namespace(name=nil)
case name
when nil
@namespace ||= Thor::Util.namespace_from_thor_class(self)
else
@namespace = name.to_s
end
@namespace = case name
when nil
@namespace || Thor::Util.namespace_from_thor_class(self)
else
@namespace = name.to_s
end
end

# Parses the task and options from the given args, instantiate the class
Expand Down
12 changes: 6 additions & 6 deletions lib/thor/group.rb
Expand Up @@ -14,12 +14,12 @@ class << self
# description<String>:: The description for this Thor::Group.
#
def desc(description=nil)
case description
when nil
@desc ||= from_superclass(:desc, nil)
else
@desc = description
end
@desc = case description
when nil
@desc || from_superclass(:desc, nil)
else
description
end
end

# Prints help information.
Expand Down

0 comments on commit 553b52f

Please sign in to comment.