whirly 0.1.0 → 0.1.1

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: 09dc6464dd66bfd1b0efbfb714f46c772e455755
4
- data.tar.gz: 6cbb8096a92177335fa21c0e9ae6e84d3b114b64
3
+ metadata.gz: f12112b921f3f00166d7acf85d4d86cac8836005
4
+ data.tar.gz: ec7da03c93842811b381ca1fdfbe0df418ff05e1
5
5
  SHA512:
6
- metadata.gz: fb4ef9f577068ecfe20eadf4b4632440a1babf4d5a3d3007240590ca37810c15c8d018d52d85344df3c026786c7a80b167b38d66e63dd5dc4b803d1ee81ce4a4
7
- data.tar.gz: 0ab11d2404dd4326f0af3c87d26f1ce02396ad566bc95a29ff15b6de43912867aca5c8f63959bab4531b0a335c913b38f9914eaa9f05a810396aefa430c33523
6
+ metadata.gz: eccb4074399d77acf9e4454fddc27b894d08506095285f4004271d116fa03e6450d2fe2cdd3a1ff6ca8a445b634a6e6ab32a379d8cb2c4b9edc0756cb2ae2a10
7
+ data.tar.gz: 5a1e9ae823be1884e8e1f0e6783a63b2b540dbfe17d8e74c8cd6634949b69fa6df41d4cb0724fb47760b2fd45984d44c5729b5b8ef70174e264652d0cfce1d00
data/CHANGELOG.md CHANGED
@@ -1,6 +1,11 @@
1
1
  ## CHANGELOG
2
2
 
3
+ ### 0.1.1
4
+
5
+ - `non_tty` option to force TTY behaviour (whirly deactivates itself for non TTY by default)
6
+ - Allow passing in spinner hashes instead of only spinner names
7
+
3
8
  ### 0.1.0
4
9
 
5
- * Inital release
10
+ - Inital release
6
11
 
data/README.md CHANGED
@@ -21,7 +21,7 @@ gem 'paint' # makes whirly colorful (recommended)
21
21
  Whirly.start do
22
22
  Whirly.status = "Working on it…"
23
23
  sleep 3
24
- Whirly.status = "Almoste done…
24
+ Whirly.status = "Almoste done…"
25
25
  sleep 2
26
26
  end
27
27
  ```
data/lib/whirly.rb CHANGED
@@ -30,9 +30,10 @@ module Whirly
30
30
  use_color: defined?(Paint),
31
31
  color_change_rate: 30,
32
32
  status: nil,
33
- hide_cursor: true)
34
- # only actviate if we are on a real terminal
35
- return false unless stream.tty?
33
+ hide_cursor: true,
34
+ non_tty: false)
35
+ # only actviate if we are on a real terminal (or forced)
36
+ return false unless stream.tty? || non_tty
36
37
 
37
38
  # ensure cursor is visible after exit
38
39
  at_exit{ @stream.print CLI_COMMANDS[:show_cursor] } if !defined?(@enabled) && hide_cursor
@@ -45,7 +46,11 @@ module Whirly
45
46
  @paused = false
46
47
  @stream = stream
47
48
  @status = status
48
- @spinner = SPINNERS[spinner.to_s]
49
+ if spinner.is_a? Hash
50
+ @spinner = spinner
51
+ else
52
+ @spinner = SPINNERS[spinner.to_s]
53
+ end
49
54
  raise(ArgumentError, "Whirly: Invalid spinner given") if !@spinner || (!@spinner["frames"] && !@spinner["proc"])
50
55
  @hide_cursor = hide_cursor
51
56
  @interval = (interval || @spinner["interval"] || 100) * 0.001
@@ -1,4 +1,4 @@
1
1
  module Whirly
2
- VERSION = "0.1.0".freeze
2
+ VERSION = "0.1.1".freeze
3
3
  end
4
4
 
data/spec/whirly_spec.rb CHANGED
@@ -2,8 +2,44 @@ require_relative "../lib/whirly"
2
2
  require "minitest/autorun"
3
3
 
4
4
  describe Whirly do
5
- it "works" do
6
- assert_equal true, false
5
+ describe "usage" do
6
+ it "outputs every frame of the spinner" do
7
+ spinner = { "frames" => ["first", "second", "third"], "interval" => 10 }
8
+
9
+ assert_output /first.*second.*third/m do
10
+ Whirly.start(spinner: spinner, non_tty: true)
11
+ sleep 0.1
12
+ Whirly.stop
13
+ end
14
+ end
15
+
16
+ it "calls spinner proc instead of frames if proc is given" do
17
+ spinner = { "proc" => ->(){ "frame" }, "interval" => 10 }
18
+
19
+ assert_output /frame/ do
20
+ Whirly.start(spinner: spinner, non_tty: true)
21
+ sleep 0.1
22
+ Whirly.stop
23
+ end
24
+ end
25
+ end
26
+
27
+ describe ".enabled?" do
28
+ it "returns false if whirly was not started yet" do
29
+ refute_predicate Whirly, :enabled?
30
+ end
31
+
32
+ it "returns true if whirly was started, but not yet stopped" do
33
+ Whirly.start
34
+ assert_predicate Whirly, :enabled?
35
+ Whirly.stop
36
+ end
37
+
38
+ it "returns false if whirly was stopped" do
39
+ Whirly.start
40
+ Whirly.stop
41
+ refute_predicate Whirly, :enabled?
42
+ end
7
43
  end
8
44
  end
9
45
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: whirly
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jan Lelis
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-09-23 00:00:00.000000000 Z
11
+ date: 2016-09-30 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: 'Whirly: The friendly terminal spinner'
14
14
  email:
@@ -17,8 +17,6 @@ executables: []
17
17
  extensions: []
18
18
  extra_rdoc_files: []
19
19
  files:
20
- - ".README.md.swp"
21
- - ".euruko.rb.swp"
22
20
  - ".gitignore"
23
21
  - ".gitmodules"
24
22
  - ".travis.yml"
@@ -31,10 +29,11 @@ files:
31
29
  - Rakefile
32
30
  - data/spinners.json
33
31
  - euruko.rb
34
- - lib/.whirly.rb.swp
35
32
  - lib/whirly.rb
33
+ - lib/whirly/.spinners.rb.swp
36
34
  - lib/whirly/spinners.rb
37
35
  - lib/whirly/version.rb
36
+ - spec/.whirly_spec.rb.swp
38
37
  - spec/whirly_spec.rb
39
38
  - whirly.gemspec
40
39
  homepage: https://github.com/janlelis/whirly
@@ -62,4 +61,5 @@ signing_key:
62
61
  specification_version: 4
63
62
  summary: 'Whirly: The friendly terminal spinner'
64
63
  test_files:
64
+ - spec/.whirly_spec.rb.swp
65
65
  - spec/whirly_spec.rb
data/lib/.whirly.rb.swp DELETED
Binary file