color_wave 0.0.5 → 0.1.0
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 +4 -4
- data/README.md +12 -9
- data/bin/color_wave +6 -6
- data/lib/color_wave/color_wave.rb +12 -5
- data/lib/color_wave/version.rb +1 -1
- metadata +1 -5
- data/bin/console +0 -10
- data/bin/setup +0 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5aacaab444c91b6fe32b1f2254db321b7238db5b
|
4
|
+
data.tar.gz: fe295feaaf56f627ab5ad3eb546191a552e20cbe
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9904322801784ecd78448a9029ee7fb18a98c6af69db7664be87e54a68f6e420f2b3b2a0457261951d6a9b5f73f40e09be0490bfb0b48fda638f3ae194b77241
|
7
|
+
data.tar.gz: 7a18164cbef3291c0494aeed4bcea9b387abd085ea29b9d2eb56a14e9f3acc20fa2e2305dd6f51373475b2bc0650f9903882fed237054c38b1bea2960c66feba
|
data/README.md
CHANGED
@@ -21,26 +21,29 @@ Or install it yourself as:
|
|
21
21
|
|
22
22
|
You can run it from the command line with or without some options:
|
23
23
|
|
24
|
-
$ color_wave --lines
|
24
|
+
$ color_wave --lines 20 --cycles 3 --speed 10.0
|
25
|
+
|
26
|
+
The above values are the defaults.
|
27
|
+
##### Options
|
28
|
+
* `--lines` - the height of the wave in terminal lines
|
29
|
+
* `--cycles` - how many cycles of the wave will be drawn
|
30
|
+
* `--speed` - used as the divisor of the delay time between drawing loops; use higher values for faster redrawing
|
31
|
+
* `--help` - show usage information
|
25
32
|
|
26
33
|
You can use it in Ruby too:
|
27
34
|
```ruby
|
28
35
|
require 'color_wave'
|
29
36
|
|
30
|
-
ColorWave.new(lines: 10, cycles: 2, colors: %w( ff0000 00ff00 0000ff ), chars: %w( _ / ^ \ )).run
|
37
|
+
ColorWave.new(lines: 10, cycles: 2, speed: 1, colors: %w( ff0000 00ff00 0000ff ), chars: %w( _ / ^ \ )).run
|
31
38
|
```
|
32
39
|
|
33
|
-
`
|
34
|
-
|
35
|
-
## Development
|
40
|
+
The `speed` option is used as the divisor to a `BASE_SLEEP_TIME` constant so higher speeds will redraw the wave more quickly. The `colors` and `chars` options specify the colors and characters to be cycled through when drawing the wave.
|
36
41
|
|
37
|
-
|
38
|
-
|
39
|
-
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
42
|
+
`Ctrl-C` will stop it once it's running.
|
40
43
|
|
41
44
|
## Contributing
|
42
45
|
|
43
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/jbratton/color_wave. This project is intended to be a safe, welcoming space for collaboration
|
46
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/jbratton/color_wave. This project is intended to be a safe, welcoming space for collaboration and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
44
47
|
|
45
48
|
## License
|
46
49
|
|
data/bin/color_wave
CHANGED
@@ -3,14 +3,14 @@
|
|
3
3
|
require 'color_wave'
|
4
4
|
require 'trollop'
|
5
5
|
|
6
|
-
DEFAULT_LINES = 20
|
7
|
-
DEFAULT_CYCLES = 3
|
8
|
-
|
9
6
|
opts = Trollop::options do
|
10
|
-
opt :lines, "Wave height in lines", default: DEFAULT_LINES
|
11
|
-
opt :cycles, "Wave cycles to display", default: DEFAULT_CYCLES
|
7
|
+
opt :lines, "Wave height in lines", default: ColorWave::DEFAULT_LINES
|
8
|
+
opt :cycles, "Wave cycles to display", default: ColorWave::DEFAULT_CYCLES
|
9
|
+
opt :speed, "Speed of redrawing", default: ColorWave::DEFAULT_SPEED
|
12
10
|
end
|
11
|
+
|
13
12
|
Trollop::die :lines, "must be greater than zero" unless opts[:lines] > 0
|
14
13
|
Trollop::die :cycles, "must be greater than zero" unless opts[:cycles] > 0
|
14
|
+
Trollop::die :speed, "must be greater than zero" unless opts[:speed] > 0
|
15
15
|
|
16
|
-
ColorWave.new(lines: opts[:lines], cycles: opts[:cycles]).run
|
16
|
+
ColorWave.new(lines: opts[:lines], cycles: opts[:cycles], speed: opts[:speed]).run
|
@@ -8,6 +8,7 @@ class ColorWave
|
|
8
8
|
DEFAULT_LINES = 20
|
9
9
|
DEFAULT_CHARS = %w( O ).freeze
|
10
10
|
DEFAULT_CYCLES = 3
|
11
|
+
DEFAULT_SPEED = 10.0
|
11
12
|
|
12
13
|
# rainbow RGB values stolen from Term-Colormap on CPAN
|
13
14
|
# https://metacpan.org/source/XXFELIXXX/Term-Colormap-0.06/lib/Term/Colormap.pm
|
@@ -19,18 +20,19 @@ class ColorWave
|
|
19
20
|
).freeze
|
20
21
|
|
21
22
|
TWO_PI = Math::PI * 2
|
22
|
-
|
23
|
+
BASE_SLEEP_TIME = 0.001
|
23
24
|
|
24
|
-
attr_reader :lines, :cycles, :chars, :colors
|
25
|
+
attr_reader :lines, :cycles, :chars, :colors, :speed
|
25
26
|
|
26
27
|
def initialize(lines: DEFAULT_LINES, cycles: DEFAULT_CYCLES,
|
27
|
-
chars: DEFAULT_CHARS, colors: DEFAULT_COLORS
|
28
|
+
chars: DEFAULT_CHARS, colors: DEFAULT_COLORS,
|
29
|
+
speed: DEFAULT_SPEED)
|
28
30
|
@lines = lines
|
29
31
|
@cycles = cycles
|
30
32
|
@chars = chars.cycle
|
31
33
|
@colors = colors.cycle
|
34
|
+
@speed = speed
|
32
35
|
|
33
|
-
@sleep_time = LOOP_SLEEP
|
34
36
|
@current_line = 0
|
35
37
|
@shutdown = false
|
36
38
|
|
@@ -51,7 +53,7 @@ class ColorWave
|
|
51
53
|
|
52
54
|
private
|
53
55
|
|
54
|
-
attr_accessor :current_line, :cycles, :shutdown, :
|
56
|
+
attr_accessor :current_line, :cycles, :shutdown, :wave_rows
|
55
57
|
|
56
58
|
def width
|
57
59
|
TermInfo.screen_width
|
@@ -83,12 +85,17 @@ class ColorWave
|
|
83
85
|
|
84
86
|
def write_one_pass(pass)
|
85
87
|
width.times do |step|
|
88
|
+
break if shutdown
|
86
89
|
move_to_line next_line
|
87
90
|
print Rainbow(next_char).color(next_color(pass, step))
|
88
91
|
sleep sleep_time
|
89
92
|
end
|
90
93
|
end
|
91
94
|
|
95
|
+
def sleep_time
|
96
|
+
BASE_SLEEP_TIME / speed
|
97
|
+
end
|
98
|
+
|
92
99
|
def ready_next_pass
|
93
100
|
print "\r"
|
94
101
|
end
|
data/lib/color_wave/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: color_wave
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- jbratton
|
@@ -113,8 +113,6 @@ email:
|
|
113
113
|
- jeremy@alumni.rice.edu
|
114
114
|
executables:
|
115
115
|
- color_wave
|
116
|
-
- console
|
117
|
-
- setup
|
118
116
|
extensions: []
|
119
117
|
extra_rdoc_files: []
|
120
118
|
files:
|
@@ -126,8 +124,6 @@ files:
|
|
126
124
|
- README.md
|
127
125
|
- Rakefile
|
128
126
|
- bin/color_wave
|
129
|
-
- bin/console
|
130
|
-
- bin/setup
|
131
127
|
- color_wave.gemspec
|
132
128
|
- lib/color_wave.rb
|
133
129
|
- lib/color_wave/color_wave.rb
|
data/bin/console
DELETED