everyday-cli-utils 1.8.3 → 1.8.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7892604af4bb9b58227dea18a0c14a9c8daaffb9
4
- data.tar.gz: b0dfde2c8a940aeb9f09104f27b523f0a8867a5b
3
+ metadata.gz: 5d91beab1a1ce74081ab57134a8047ee6b6497f1
4
+ data.tar.gz: a071acf57054f2d6f81434b9fd5c9c48f09cffdd
5
5
  SHA512:
6
- metadata.gz: 65770fbd4440a17dfafd6d5b4234aad239de0ee499f5c7be24e8f1ed3589d02f190f80fdb3e4822c9887371194ae3acf7c17d58148fcefac67a01b6c02e8dddf
7
- data.tar.gz: 83ad2e2ad25d0fd7cfe1efdeb9fba19a71215f2ee27372cce584da79f51e7bb6b18c993bfcd2352d60a5482f5d6475c15b7a7a2b50c95e6648fb6cd798dca36a
6
+ metadata.gz: 67772a3f5c101be779fc63de1d3044180a7d1978214c4ba23e9f176236407b0958a7849d98aab5e6eec312b07a91f0225aef827e5cfba245e93f8a877d7b1b69
7
+ data.tar.gz: 4ec99aec1bcef43da7bcda9f5d687670c6f2de182b0a0f220c4641442787f062c7c5e0c3233c5ee030cb4f4d43af22c52207dd271627bae434a01fbab5f0971a
@@ -2,33 +2,32 @@ require 'readline'
2
2
 
3
3
  module EverydayCliUtils
4
4
  module Ask
5
- def self::setup_options(options)
5
+ def self.setup_options(options)
6
6
  mapped = []
7
7
  options.each_with_index { |v, k|
8
- mapped << "#{k+1}) #{v.to_s}"
8
+ mapped << "#{k + 1}) #{v}"
9
9
  }
10
10
  mapped.join("\n")
11
11
  end
12
12
 
13
- def self::ask(question, options, &block)
13
+ def self.ask(question, options, &block)
14
14
  val = '-1'
15
- while true
15
+ loop do
16
16
  print "#{question}\n\n#{setup_options(options)}\n\n"
17
17
  val = Readline.readline("Please enter your choice (1 - #{options.count}): ", true)
18
- if !(val =~ /^\d+$/).nil? && (1..options.count).include?(val.to_i)
19
- break
20
- end
18
+ break if !(val =~ /^\d+$/).nil? && (1..options.count).include?(val.to_i)
21
19
  print "\n\nYou must enter an integer between 1 and #{options.count}. Please try again.\n\n"
22
20
  end
23
21
  block.call(options[val.to_i - 1])
24
22
  end
25
23
 
26
- def self::ask_yn(question, &block)
27
- resp = Readline.readline("#{question} (yes/no) ", true)
28
- block.call(resp.downcase == 'yes' || resp.downcase == 'y')
24
+ def self.ask_yn(question, options = {}, &block)
25
+ resp = Readline.readline("#{question} ([y]es/[n]o) ", true)
26
+ val = resp.downcase == 'yes' || resp.downcase == 'y'
27
+ block.call(val) if !options[:only] || options[:only] == (val ? :yes : :no)
29
28
  end
30
29
 
31
- def self::hash_to_options(hash, extra = [])
30
+ def self.hash_to_options(hash, extra = [])
32
31
  hash.keys + extra
33
32
  end
34
33
  end
@@ -1,3 +1,3 @@
1
1
  module EverydayCliUtils
2
- VERSION = '1.8.3'
2
+ VERSION = '1.8.4'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: everyday-cli-utils
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.8.3
4
+ version: 1.8.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eric Henderson
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-08-18 00:00:00.000000000 Z
11
+ date: 2015-10-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler