From 77464e6958ae1304a044060999d534d27f492778 Mon Sep 17 00:00:00 2001 From: Agis Anastasopoulos Date: Sun, 11 Nov 2012 05:39:30 +0200 Subject: [PATCH 1/3] Use a more compact case syntax when assigning the default_task --- lib/thor.rb | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/lib/thor.rb b/lib/thor.rb index 5c19d0d62..867b51c92 100644 --- a/lib/thor.rb +++ b/lib/thor.rb @@ -9,14 +9,11 @@ class << self # meth:: 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 then 'help' + when nil then @default_task || from_superclass(:default_task, 'help') + else meth.to_s + end end # Registers another Thor subclass as a command. From 4f71c91cb8599ff61517e3c907ab70bc202db88a Mon Sep 17 00:00:00 2001 From: Agis Anastasopoulos Date: Tue, 20 Nov 2012 23:16:43 +0200 Subject: [PATCH 2/3] Switch to a more compact syntax when assigning default_task --- lib/thor.rb | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/thor.rb b/lib/thor.rb index 867b51c92..a85d0c9ba 100644 --- a/lib/thor.rb +++ b/lib/thor.rb @@ -10,9 +10,12 @@ class << self # def default_task(meth=nil) @default_task = case meth - when :none then 'help' - when nil then @default_task || from_superclass(:default_task, 'help') - else meth.to_s + when :none + 'help' + when nil + @default_task || from_superclass(:default_task, 'help') + else + meth.to_s end end From 1308bffd3eb217dfa5efebdf113a38eacdde628b Mon Sep 17 00:00:00 2001 From: Agis Anastasopoulos Date: Tue, 20 Nov 2012 23:28:57 +0200 Subject: [PATCH 3/3] Refactor case syntax to be more compact --- lib/thor/base.rb | 24 ++++++++++++------------ lib/thor/group.rb | 12 ++++++------ 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/lib/thor/base.rb b/lib/thor/base.rb index d599a7544..8772d5f27 100644 --- a/lib/thor/base.rb +++ b/lib/thor/base.rb @@ -313,12 +313,12 @@ def remove_class_option(*names) # name # 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. @@ -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 diff --git a/lib/thor/group.rb b/lib/thor/group.rb index 874ac47a1..91eaa7335 100644 --- a/lib/thor/group.rb +++ b/lib/thor/group.rb @@ -14,12 +14,12 @@ class << self # description:: 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.