cli_miami 0.0.4 → 0.0.5

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.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/cli_miami/say.rb +30 -23
  3. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f27ada6d252c35a283bccb8ad5fed5dfb7bf50a1
4
- data.tar.gz: 521ac8de8dc309bd31637e778b45fa3ba06adc2e
3
+ metadata.gz: 48662d5ea8d91aff8cb48d9e0fe7ed1358de0b8e
4
+ data.tar.gz: 338e8dee36d5ebd7bbecfb6f105ec2277279ff44
5
5
  SHA512:
6
- metadata.gz: f6add69a2ff9a694dd4e35b6b2c71a0cdfe349956402e5b486bb7b905b8b1779238193fa08eaf92b1c1de12bbb3fd829d2384c906788cbba21442f7aaaabf4a7
7
- data.tar.gz: 4b68335b9b95a96a06a5fcb72a45c44a85087dcc68d4069628f6751ff871266d47dc3abe9600e3118e0e2fdc47d9ecccd1e2c9eaeac912b1bee9f7d45e22f1cd
6
+ metadata.gz: eeba0dee1b30c80e8d36cb5b73c0cda1333bb0fa290b90137dfa956e2eaf220ee0f2b3e0e4d6d540af28c694d66f1bee62a3aaf1ac2051acd67f0ff8c5ed671d
7
+ data.tar.gz: a1023e81d0816d6961c8f932c5f33483b59ece1ef63521f95180644c9dda73576389a3c19cc6f373f9d5b3cf2b0ce8660389a12dff7ad8616c23bea9aec05d2f
data/lib/cli_miami/say.rb CHANGED
@@ -38,60 +38,67 @@ class CliMiami::S
38
38
  # newline: => [boolean] True if you want a newline after the output
39
39
  # overwrite: => [boolean] True if you want the next line to overwrite the current line
40
40
  #
41
- def self.ay text = '', options = {}
42
- # get preset if symbol is passed
43
- if options.is_a? Symbol
44
- options = @@presets[options]
45
- end
46
-
41
+ def self.ay text = '', options
47
42
  # set default options
48
- options = {
43
+ @options = {
49
44
  :style => [],
50
45
  :newline => true
51
- }.merge options
46
+ }
47
+
48
+ # merge preset options
49
+ if options.is_a? Symbol
50
+ @options.merge! @@presets[options]
51
+ elsif preset = options.delete(:preset)
52
+ @options.merge! @@presets[preset]
53
+ end
54
+
55
+ # merge remaining options
56
+ if options.is_a? Hash
57
+ @options.merge! options || {}
58
+ end
52
59
 
53
60
  # convert single style into an array for processing
54
- if !options[:style].is_a? Array
55
- options[:style] = [options[:style]]
61
+ if !@options[:style].is_a? Array
62
+ @options[:style] = [@options[:style]]
56
63
  end
57
64
 
58
65
  # Justify/Padding options
59
- if options[:justify] && options[:padding]
60
- text = text.send options[:justify], options[:padding]
66
+ if @options[:justify] && @options[:padding]
67
+ text = text.send @options[:justify], @options[:padding]
61
68
  end
62
69
 
63
70
  # Set foreground color
64
- if options[:color]
71
+ if @options[:color]
65
72
  # if bright style is passed, use the bright color variation
66
- text = if options[:style].delete :bright
67
- text.send("bright_#{options[:color]}")
73
+ text = if @options[:style].delete :bright
74
+ text.send("bright_#{@options[:color]}")
68
75
  else
69
- text.send(options[:color])
76
+ text.send(@options[:color])
70
77
  end
71
78
  end
72
79
 
73
80
  # Set background color
74
- if options[:bgcolor]
75
- text = text.send("on_#{options[:bgcolor]}")
81
+ if @options[:bgcolor]
82
+ text = text.send("on_#{@options[:bgcolor]}")
76
83
  end
77
84
 
78
85
  # Apply all styles
79
- options[:style].each do |style|
86
+ @options[:style].each do |style|
80
87
  text = text.send(style)
81
88
  end
82
89
 
83
90
  # Indent
84
- if options[:indent]
85
- text = (' ' * options[:indent]) + text
91
+ if @options[:indent]
92
+ text = (' ' * @options[:indent]) + text
86
93
  end
87
94
 
88
95
  # Flag text to be overwritten by next text written
89
- if options[:overwrite]
96
+ if @options[:overwrite]
90
97
  text = "#{text}\r"
91
98
  end
92
99
 
93
100
  # Determine if a newline should be used
94
- if !options[:newline] || options[:overwrite]
101
+ if !@options[:newline] || @options[:overwrite]
95
102
  $stdout.print text
96
103
  else
97
104
  $stdout.puts text
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cli_miami
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan Brewster