nyan-cat-formatter 0.5.0 → 0.5.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 5c36ebbc63077bc95eac044c352cd9d5db4a09fc
4
+ data.tar.gz: 16232ddcb890396ad76aa298d7db287fabdf732a
5
+ SHA512:
6
+ metadata.gz: dcb8efa52a89447caf9a1620107f5df1a12c34b76b5686e075bdd491b909453eec5416da9464d7293862f006a966ed97b8660fd5f154a5bb036a37bc2a4a30b1
7
+ data.tar.gz: d178abff8856c7d951bb8ec90e7f4637624a97b08f39a071febf2c19993b3adb6cd200389e04a33dadb70dfaaca26a72a3e009dee45c731f5d58665d4e20a7b3
data/Gemfile CHANGED
@@ -1,4 +1,4 @@
1
- source "http://rubygems.org"
1
+ source "https://rubygems.org"
2
2
 
3
3
  # Specify your gem's dependencies in nyan-cat-formatter.gemspec
4
4
  gemspec
@@ -0,0 +1,80 @@
1
+ module NyanCatFormat
2
+ module Music
3
+
4
+ MUSIC_LENGTH = 27.06 # seconds
5
+
6
+ def osx?
7
+ platform.downcase.include?("darwin")
8
+ end
9
+
10
+ def linux?
11
+ platform.downcase.include?('linux')
12
+ end
13
+
14
+ def kernel=(kernel)
15
+ @kernel = kernel
16
+ end
17
+
18
+ def kernel
19
+ @kernel ||= Kernel
20
+ end
21
+
22
+ def platform=(platform)
23
+ @platform = platform
24
+ end
25
+
26
+ def platform
27
+ @platform ||= RUBY_PLATFORM
28
+ end
29
+
30
+ def nyan_mp3
31
+ File.expand_path('../../../data/nyan-cat.mp3', __FILE__)
32
+ end
33
+
34
+ def start input
35
+ super
36
+ t = Thread.new do
37
+ loop do
38
+ if osx?
39
+ kernel.system("afplay #{nyan_mp3} &")
40
+ elsif linux?
41
+ play_on_linux
42
+ end
43
+ Thread.current["started_playing"] ||= true
44
+ sleep MUSIC_LENGTH
45
+ end
46
+ end
47
+ until t["started_playing"]
48
+ sleep 0.001
49
+ end
50
+ end
51
+
52
+ def kill_music
53
+ if File.exists? nyan_mp3
54
+ if osx?
55
+ system("killall -9 afplay &>/dev/null")
56
+ elsif linux?
57
+ kill_music_on_linux
58
+ end
59
+ end
60
+ end
61
+
62
+ def dump_summary(duration, example_count, failure_count, pending_count)
63
+ kill_music
64
+ super
65
+ end
66
+
67
+ private
68
+
69
+ def play_on_linux
70
+ kernel.system("[ -e #{nyan_mp3} ] && type mpg321 &>/dev/null && mpg321 #{nyan_mp3} &>/dev/null &") if kernel.system('which mpg321 &>/dev/null && type mpg321 &>/dev/null')
71
+ kernel.system("[ -e #{nyan_mp3} ] && type mpg123 &>/dev/null && mpg123 #{nyan_mp3} &>/dev/null &") if kernel.system('which mpg123 &>/dev/null && type mpg123 &>/dev/null')
72
+ end
73
+
74
+ def kill_music_on_linux
75
+ system("killall -9 mpg321 &>/dev/null") if kernel.system("which mpg321 &>/dev/null && type mpg321 &>/dev/null")
76
+ system("killall -9 mpg123 &>/dev/null") if kernel.system("which mpg123 &>/dev/null && type mpg123 &>/dev/null")
77
+ end
78
+
79
+ end
80
+ end
@@ -0,0 +1,20 @@
1
+ module NyanCatFormat
2
+ module Wide
3
+
4
+ def example_width(example = current)
5
+ net_width_for(example) - net_width_for(example - 1)
6
+ end
7
+
8
+ def net_width_for(example)
9
+ @net_width ||= {}
10
+
11
+ @net_width[example] ||= begin
12
+ return 0 if example < 0
13
+ net_width = terminal_width - padding_width - cat_length
14
+ rough_example_width = (net_width * example.to_f / @example_count.to_f)
15
+ rough_example_width.round
16
+ end
17
+ end
18
+
19
+ end
20
+ end
@@ -40,7 +40,6 @@ module RSpec1
40
40
  end
41
41
 
42
42
  def dump_summary(duration, example_count, failure_count, pending_count)
43
- NyanCatMusicFormatter.new(NyanCatFormatter).kill_music if defined?(NyanCatMusicFormatter)
44
43
  @output.puts "\nYou've Nyaned for #{format_duration(duration)}\n".each_char.map {|c| rainbowify(c)}.join
45
44
  summary = "#{example_count} example#{'s' unless example_count == 1}, #{failure_count} failure#{'s' unless failure_count == 1}"
46
45
  summary << ", #{pending_count} pending" if pending_count > 0
@@ -28,7 +28,6 @@ module RSpec2
28
28
  end
29
29
 
30
30
  def dump_summary(duration, example_count, failure_count, pending_count)
31
- NyanCatMusicFormatter.new(NyanCatFormatter).kill_music if defined?(NyanCatMusicFormatter)
32
31
  dump_profile if profile_examples? && failure_count == 0
33
32
  summary = "\nYou've Nyaned for #{format_duration(duration)}\n".split(//).map { |c| rainbowify(c) }
34
33
  output.puts summary.join
@@ -1,75 +1,7 @@
1
1
  # -*- coding: utf-8 -*-
2
2
  require 'nyan_cat_formatter'
3
+ require 'nyan_cat_format/music'
3
4
 
4
5
  NyanCatMusicFormatter = Class.new(NyanCatFormatter) do
5
- MUSIC_LENGTH = 27.06 # seconds
6
-
7
- def osx?
8
- platform.downcase.include?("darwin")
9
- end
10
-
11
- def linux?
12
- platform.downcase.include?('linux')
13
- end
14
-
15
- def kernel=(kernel)
16
- @kernel = kernel
17
- end
18
-
19
- def kernel
20
- @kernel ||= Kernel
21
- end
22
-
23
- def platform=(platform)
24
- @platform = platform
25
- end
26
-
27
- def platform
28
- @platform ||= RUBY_PLATFORM
29
- end
30
-
31
- def nyan_mp3
32
- File.expand_path('../../data/nyan-cat.mp3', __FILE__)
33
- end
34
-
35
- def start input
36
- super
37
- t = Thread.new do
38
- loop do
39
- if osx?
40
- kernel.system("afplay #{nyan_mp3} &")
41
- elsif linux?
42
- play_on_linux
43
- end
44
- Thread.current["started_playing"] ||= true
45
- sleep MUSIC_LENGTH
46
- end
47
- end
48
- until t["started_playing"]
49
- sleep 0.001
50
- end
51
- end
52
-
53
- def kill_music
54
- if File.exists? nyan_mp3
55
- if osx?
56
- system("killall -9 afplay &>/dev/null")
57
- elsif linux?
58
- kill_music_on_linux
59
- end
60
- end
61
- end
62
-
63
- private
64
-
65
- def play_on_linux
66
- kernel.system("[ -e #{nyan_mp3} ] && type mpg321 &>/dev/null && mpg321 #{nyan_mp3} &>/dev/null &") if kernel.system('which mpg321 &>/dev/null && type mpg321 &>/dev/null')
67
- kernel.system("[ -e #{nyan_mp3} ] && type mpg123 &>/dev/null && mpg123 #{nyan_mp3} &>/dev/null &") if kernel.system('which mpg123 &>/dev/null && type mpg123 &>/dev/null')
68
- end
69
-
70
- def kill_music_on_linux
71
- system("killall -9 mpg321 &>/dev/null") if kernel.system("which mpg321 &>/dev/null && type mpg321 &>/dev/null")
72
- system("killall -9 mpg123 &>/dev/null") if kernel.system("which mpg123 &>/dev/null && type mpg123 &>/dev/null")
73
- end
74
-
6
+ include NyanCatFormat::Music
75
7
  end
@@ -1,19 +1,7 @@
1
1
  # -*- coding: utf-8 -*-
2
2
  require 'nyan_cat_formatter'
3
+ require 'nyan_cat_format/wide'
3
4
 
4
5
  NyanCatWideFormatter = Class.new(NyanCatFormatter) do
5
- def example_width(example = current)
6
- net_width_for(example) - net_width_for(example - 1)
7
- end
8
-
9
- def net_width_for(example)
10
- @net_width ||= {}
11
-
12
- @net_width[example] ||= begin
13
- return 0 if example < 0
14
- net_width = terminal_width - padding_width - cat_length
15
- rough_example_width = (net_width * example.to_f / @example_count.to_f)
16
- rough_example_width.round
17
- end
18
- end
6
+ include NyanCatFormat::Wide
19
7
  end
@@ -0,0 +1,9 @@
1
+ # -*- coding: utf-8 -*-
2
+ require 'nyan_cat_formatter'
3
+ require 'nyan_cat_format/wide'
4
+ require 'nyan_cat_format/music'
5
+
6
+ NyanCatWideMusicFormatter = Class.new(NyanCatFormatter) do
7
+ include NyanCatFormat::Wide
8
+ include NyanCatFormat::Music
9
+ end
@@ -2,7 +2,7 @@ $:.push File.expand_path("../lib", __FILE__)
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = "nyan-cat-formatter"
5
- s.version = "0.5.0"
5
+ s.version = "0.5.1"
6
6
  s.authors = ["Matt Sears"]
7
7
  s.email = ["matt@mattsears.com"]
8
8
  s.homepage = "https://github.com/mattsears/nyan-cat-formatter"
metadata CHANGED
@@ -1,46 +1,41 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nyan-cat-formatter
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
5
- prerelease:
4
+ version: 0.5.1
6
5
  platform: ruby
7
6
  authors:
8
7
  - Matt Sears
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2013-02-26 00:00:00.000000000 Z
11
+ date: 2013-09-27 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: rspec
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
- - - ! '>='
17
+ - - '>='
20
18
  - !ruby/object:Gem::Version
21
19
  version: '2.13'
22
20
  type: :runtime
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
- - - ! '>='
24
+ - - '>='
28
25
  - !ruby/object:Gem::Version
29
26
  version: '2.13'
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: rake
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
- - - ! '>='
31
+ - - '>='
36
32
  - !ruby/object:Gem::Version
37
33
  version: '0'
38
34
  type: :development
39
35
  prerelease: false
40
36
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
37
  requirements:
43
- - - ! '>='
38
+ - - '>='
44
39
  - !ruby/object:Gem::Version
45
40
  version: '0'
46
41
  description: Nyan Cat inspired RSpec formatter!
@@ -61,11 +56,14 @@ files:
61
56
  - Rakefile
62
57
  - data/nyan-cat.mp3
63
58
  - demo.rb
59
+ - lib/nyan_cat_format/music.rb
60
+ - lib/nyan_cat_format/wide.rb
64
61
  - lib/nyan_cat_formatter.rb
65
62
  - lib/nyan_cat_formatter/rspec1.rb
66
63
  - lib/nyan_cat_formatter/rspec2.rb
67
64
  - lib/nyan_cat_music_formatter.rb
68
65
  - lib/nyan_cat_wide_formatter.rb
66
+ - lib/nyan_cat_wide_music_formatter.rb
69
67
  - nyan-cat-formatter.gemspec
70
68
  - nyan_example.gif
71
69
  - spec/nyan_cat_formatter_spec.rb
@@ -74,27 +72,26 @@ files:
74
72
  - spec/spec_helper.rb
75
73
  homepage: https://github.com/mattsears/nyan-cat-formatter
76
74
  licenses: []
75
+ metadata: {}
77
76
  post_install_message:
78
77
  rdoc_options: []
79
78
  require_paths:
80
79
  - lib
81
80
  required_ruby_version: !ruby/object:Gem::Requirement
82
- none: false
83
81
  requirements:
84
- - - ! '>='
82
+ - - '>='
85
83
  - !ruby/object:Gem::Version
86
84
  version: '0'
87
85
  required_rubygems_version: !ruby/object:Gem::Requirement
88
- none: false
89
86
  requirements:
90
- - - ! '>='
87
+ - - '>='
91
88
  - !ruby/object:Gem::Version
92
89
  version: '0'
93
90
  requirements: []
94
91
  rubyforge_project: nyan-cat-formatter
95
- rubygems_version: 1.8.25
92
+ rubygems_version: 2.0.3
96
93
  signing_key:
97
- specification_version: 3
94
+ specification_version: 4
98
95
  summary: Nyan Cat inspired RSpec formatter!
99
96
  test_files:
100
97
  - spec/nyan_cat_formatter_spec.rb