diff options
| author | Ralph Amissah <ralph@amissah.com> | 2015-01-11 22:14:48 -0500 | 
|---|---|---|
| committer | Ralph Amissah <ralph@amissah.com> | 2015-01-19 23:46:16 -0500 | 
| commit | 127db38021e15f8ce9e095bea1a4b917c44f0a8a (patch) | |
| tree | b3d5fe4ea5ae7c6da89df4e0cd98fbb75b1673f1 | |
| parent | bin/sisu + c&d: SiSU_is now methods (instead of hash) (diff) | |
d: utils_response, ease selection options
| -rw-r--r-- | data/doc/sisu/CHANGELOG_v6 | 2 | ||||
| -rw-r--r-- | lib/sisu/develop/utils_response.rb | 17 | 
2 files changed, 12 insertions, 7 deletions
| diff --git a/data/doc/sisu/CHANGELOG_v6 b/data/doc/sisu/CHANGELOG_v6 index a8206116..4a385a72 100644 --- a/data/doc/sisu/CHANGELOG_v6 +++ b/data/doc/sisu/CHANGELOG_v6 @@ -94,6 +94,8 @@ http://www.jus.uio.no/sisu/pkg/src/sisu_6.4.0.orig.tar.xz    * utils_composite, composite documents (.ssm) extract the list of insert files +  * utils_response, ease selection options +    * SiSU_is switched to a method (instead of a hash) (bin and lib)    * use RbConfig instead of Config diff --git a/lib/sisu/develop/utils_response.rb b/lib/sisu/develop/utils_response.rb index 31092bed..4603646e 100644 --- a/lib/sisu/develop/utils_response.rb +++ b/lib/sisu/develop/utils_response.rb @@ -56,17 +56,20 @@  =end  module SiSU_Response    class Response -    def response?(ask) #move to more appropriate directory later +    def available_selections_ +      %{'yes', 'no', 'quit' or 'exit'; [ynqx]} +    end +    def response?(ask)        response='redo' -      print ask + " ['yes', 'no' or 'quit']: " +      print ask + %{ [#{available_selections_}]: }        response=File.new('/dev/tty').gets.strip -      ans=if response=='yes'         then true -      elsif response=='no'           then false -      elsif response =~/^quit|exit$/ then exit -      else puts "[please type: 'yes', 'no' or 'quit']" +      case response +      when /^(?:y|yes)$/          then true +      when /^(?:n|no)$/           then false +      when /^(?:[qx]|quit|exit)$/ then exit +      else puts %{[please type: #{available_selections_}]}          response?(ask)        end -      ans      end    end  end | 
