downup 0.6.4 → 0.7.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0435ee2e94d2c6466abdd1bced4565b8ac38bd8d
4
- data.tar.gz: cb7fc59f8bfbc4ebe2227cf1bc03db79aa221019
3
+ metadata.gz: e8d62e2eb0a1759c717dd5d7d265bc0953522205
4
+ data.tar.gz: 4c4b849657a446d334d262aeda77c14b6e3bd2b5
5
5
  SHA512:
6
- metadata.gz: e8532f0756b21a56b83a0ac032d9746378761e01807ecd292045681ed6daa0588f34591c9962ab766d18d8ddfd2f4da13982c1bb06f14aa6d4ff887b33de938d
7
- data.tar.gz: 0f46bf69d76027cbb44d9279c51bea4f942764f8e2407272af8c03fbf42430f402640f6b7378cc555dd6088b5e8d1248f827361751245d75ec98c0445637fea1
6
+ metadata.gz: 3552fad6e0d12819d4e7efb2b991605e224517741a850a48c2c4ef2a70375aaf35cb3eaee273716dd0095571d3081edb9a7dc3cbf6cc4ea4802de1f2be2ad116
7
+ data.tar.gz: 5e3918e403ead42633a6c5885127e37b043aaf26b744a0cf774f4d0fee7651d211c9acd7e35272ee47ce51ca49c65c027a23d6adda5a6664750f309bb8540800
data/README.md CHANGED
@@ -75,6 +75,22 @@ Downup::Base.new(
75
75
  default_color: :bg_gray,
76
76
  selected_color: :cyan
77
77
  ).prompt
78
+
79
+ # You can also pass in a hash, and then quickly jump around,
80
+ # but the key
81
+ options = {
82
+ "a" => "Cat",
83
+ "b" => "Dog",
84
+ "c" => "Kangaroo",
85
+ "d" => "Snake",
86
+ "e" => "Eel"
87
+ }
88
+
89
+ puts Downup::Base.new(options: options).prompt
90
+
91
+ # You can also pass in the selector you would like
92
+ # if passing in a hash
93
+ puts Downup::Base.new(options: options, selector: "†").prompt
78
94
  ```
79
95
 
80
96
  ## Inspired By
data/downup-0.6.4.gem ADDED
Binary file
data/examples/basic.rb CHANGED
@@ -41,3 +41,5 @@ options = {
41
41
  }
42
42
 
43
43
  puts Downup::Base.new(options: options).prompt
44
+
45
+ puts Downup::Base.new(options: options, selector: "†").prompt
@@ -1,3 +1,3 @@
1
1
  module Downup
2
- VERSION = "0.6.4"
2
+ VERSION = "0.7.4"
3
3
  end
data/lib/downup.rb CHANGED
@@ -8,14 +8,16 @@ module Downup
8
8
  class Base
9
9
  def initialize(options:,
10
10
  title: nil,
11
- default_color: :gray,
12
- selected_color: :green,
11
+ default_color: :brown,
12
+ selected_color: :magenta,
13
+ selector: "‣",
13
14
  header_proc: Proc.new {})
14
15
 
15
16
  @options = options
16
17
  @title = title
17
18
  @default_color = default_color
18
19
  @selected_color = selected_color
20
+ @selector = selector
19
21
  @header_proc = header_proc
20
22
  @stdin = STDIN
21
23
  @stdout = $stdout
@@ -38,6 +40,7 @@ module Downup
38
40
  :selected_position,
39
41
  :header_proc,
40
42
  :selected_color,
43
+ :selector,
41
44
  :default_color,
42
45
  :stdin,
43
46
  :stdout
@@ -78,22 +81,29 @@ module Downup
78
81
 
79
82
  def print_options
80
83
  case options
81
- when Array
82
- options.each_with_index do |option, index|
83
- stdout.puts colorize_option(option, index)
84
- end
85
- when Hash
86
- options.each_with_index do |option_array, index|
87
- if index == selected_position
88
- stdout.puts "(#{option_array.first}) #{option_array.last}"
89
- else
90
- stdout.print "(#{eval("option_array.first.#{default_color}")}) "
91
- stdout.print "#{eval("option_array.last.#{default_color}")}\n"
92
- end
84
+ when Array then print_array_options
85
+ when Hash then print_hash_options
86
+ end
87
+ end
88
+
89
+ def print_hash_options
90
+ options.each_with_index do |option_array, index|
91
+ if index == selected_position
92
+ stdout.puts "(#{eval("selector.#{selected_color}")}) " +
93
+ eval("option_array.last.#{selected_color}")
94
+ else
95
+ stdout.print "(#{eval("option_array.first.#{default_color}")}) "
96
+ stdout.print "#{eval("option_array.last.#{default_color}")}\n"
93
97
  end
94
98
  end
95
99
  end
96
100
 
101
+ def print_array_options
102
+ options.each_with_index do |option, index|
103
+ stdout.puts colorize_option(option, index)
104
+ end
105
+ end
106
+
97
107
  def colorize_option(option, index)
98
108
  if index == selected_position
99
109
  eval("option.#{selected_color}")
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: downup
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.4
4
+ version: 0.7.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Begin
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2015-08-07 00:00:00.000000000 Z
11
+ date: 2015-08-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -55,7 +55,7 @@ files:
55
55
  - Rakefile
56
56
  - bin/console
57
57
  - bin/setup
58
- - downup-0.5.4.gem
58
+ - downup-0.6.4.gem
59
59
  - downup.gemspec
60
60
  - examples/basic.rb
61
61
  - lib/downup.rb
data/downup-0.5.4.gem DELETED
Binary file