sounder 0.0.2 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of sounder might be problematic. Click here for more details.

checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 17901b03c8659ea4d33e710ba33589307823c0d9
4
- data.tar.gz: a5c433c18b54de5d7f19773b3bdb6c8d2c7c9258
3
+ metadata.gz: 568c6f3644c7d7f3b1a41b30029be59d2ff60f60
4
+ data.tar.gz: c6fd88b98ff40e065a478859f91e0f8a48e6cd7d
5
5
  SHA512:
6
- metadata.gz: ce20ef9614600ff7a90b5ccf5fc2b812722b13850cc1b57c5406eee441494d9aef428d3303daeb2038c16a89c6dc7caf88e8cca602f726ad5ad0d167aea648db
7
- data.tar.gz: 0054629138b4b73ca2b72885ca3c8755751197d005ca8f1b17106a86e5b5c92cee3b1433aec7715877a961969aa8b6901a9d754596e85ea1014497c07602716a
6
+ metadata.gz: a50a56173c91396b072444aaefa7bc6718c98c4f765bf0a625af24b6744b21b7f81fe9c1fdbbd5a2be4811c232f2f9a0791792d6517fb0927ac8044c791d8ca0
7
+ data.tar.gz: 50af1099fca25b55b760e1fcc331a45518ccf04b6f48d1b0c2f572d666b33060805d4a216791de97290563f13136649f3503a17fc40120f9c96794d8c3fe9b8f
data/README.md CHANGED
@@ -25,6 +25,17 @@ Or install it yourself as:
25
25
  sound = Sounder::Sound.new "/path/to/audio/file"
26
26
  sound.play
27
27
 
28
+ my_group = Sounder::SoundGroup.new {
29
+ :sound_one => File.expand_path('../../lib/support/sound1.m4a', __FILE__),
30
+ "sound_two" => File.expand_path('../../lib/support/sound2.m4a', __FILE__)
31
+ }
32
+ my_group.play "tw" # fuzzy matching of names
33
+ my_group.random # plays a random sound from the group
34
+ my_group.usage # returns a usage string with all the sound
35
+ names and commands
36
+ *Not Implemented* my_group.names # array of sound names
37
+ *Not Implemented* my_group.sounds # array of Sounder::Sound objects
38
+
28
39
  ## Contributing
29
40
 
30
41
  1. Fork it
@@ -1,9 +1,12 @@
1
1
  require "sounder/version"
2
2
  require "sounder/system"
3
3
  require "sounder/sound"
4
+ require "sounder/sound_group"
4
5
 
5
6
  module Sounder
6
7
  def self.play path
7
8
  Sound.new(path).play
8
9
  end
10
+
11
+ class UnknownSoundError < ArgumentError; end
9
12
  end
@@ -0,0 +1,40 @@
1
+ module Sounder
2
+ class SoundGroup
3
+ attr_reader :sounds
4
+
5
+ def initialize sounds_hsh
6
+ @sounds = {}
7
+ sounds_hsh.each do |name, file|
8
+ @sounds[name.to_s] = Sounder::Sound.new file
9
+ end
10
+ end
11
+
12
+ def play name
13
+ sound = sounds.fetch(fuzzy_find name) { raise UnknownSoundError }
14
+ sound.play
15
+ end
16
+
17
+ def random
18
+ @sounds.map do |_,sound|
19
+ sound
20
+ end.sample.play
21
+ end
22
+
23
+ def usage
24
+ usage = [ "random (picks a random sound)",
25
+ "<sound name> (it will fuzzy match the name)",
26
+ "Available sounds:"
27
+ ] + @sounds.keys.map do |sound|
28
+ " #{sound}"
29
+ end
30
+ usage.join "\n"
31
+ end
32
+
33
+
34
+ private
35
+ def fuzzy_find name
36
+ @sounds.keys.select { |sn| sn.include? name }.first
37
+ end
38
+
39
+ end
40
+ end
@@ -1,3 +1,3 @@
1
1
  module Sounder
2
- VERSION = "0.0.2"
2
+ VERSION = "1.0.0"
3
3
  end
@@ -8,9 +8,9 @@ Gem::Specification.new do |spec|
8
8
  spec.version = Sounder::VERSION
9
9
  spec.authors = ["Adam Zaninovich"]
10
10
  spec.email = ["adam.zaninovich@gmail.com"]
11
- spec.description = %q{plays sounds}
12
- spec.summary = %q{plays sounds}
13
- spec.homepage = ""
11
+ spec.description = %q{Play sounds on your Mac}
12
+ spec.summary = %q{Play sounds on your Mac}
13
+ spec.homepage = "https://github.com/adamzaninovich/sounder"
14
14
  spec.license = "MIT"
15
15
 
16
16
  spec.files = `git ls-files`.split($/)
@@ -0,0 +1,64 @@
1
+ require 'spec_helper'
2
+
3
+ describe Sounder do
4
+
5
+ describe Sounder::SoundGroup do
6
+ let!(:sounds) do
7
+ {
8
+ sound_a: 'sounda.m4a',
9
+ 'sound_b' => 'soundb.m4a'
10
+ }
11
+ end
12
+
13
+ describe 'initialization' do
14
+ it "accepts a hash with strings or symbols as keys" do
15
+ Sounder::SoundGroup.new sounds
16
+ end
17
+ it "creates sound objects" do
18
+ sounds.each do |name, file|
19
+ Sounder::Sound.should_receive(:new).with file
20
+ end
21
+ Sounder::SoundGroup.new sounds
22
+ end
23
+ end
24
+
25
+ describe '#play' do
26
+ it "plays a sound corresponding to the argument passed in" do
27
+ group = Sounder::SoundGroup.new sounds
28
+ sound_b = group.sounds.fetch "sound_b"
29
+ sound_b.should_receive(:play)
30
+ group.play "sound_b"
31
+ end
32
+
33
+ it "fuzzy matches the sound name" do
34
+ group = Sounder::SoundGroup.new sounds
35
+ sound_b = group.sounds.fetch "sound_b"
36
+ sound_b.should_receive(:play)
37
+ group.play "b"
38
+ end
39
+
40
+ it "raises UnknownSoundError when no sound is found" do
41
+ group = Sounder::SoundGroup.new sounds
42
+ expect { group.play "x" }.to raise_error Sounder::UnknownSoundError
43
+ end
44
+ end
45
+
46
+ describe '#random' do
47
+ it "plays a random sound" do
48
+ group = Sounder::SoundGroup.new sounds
49
+ Sounder::Sound.any_instance.should_receive :play
50
+ group.random
51
+ end
52
+ end
53
+
54
+ describe '#usage' do
55
+ it "returns usage info in a string" do
56
+ group = Sounder::SoundGroup.new sounds
57
+ group.usage.should include "random"
58
+ group.usage.should include "sound_a"
59
+ group.usage.should include "sound_b"
60
+ end
61
+ end
62
+ end
63
+
64
+ end
@@ -0,0 +1,21 @@
1
+ require 'spec_helper'
2
+
3
+ describe Sounder do
4
+
5
+ describe Sounder::Sound do
6
+ let(:sound) { Sounder::Sound.new 'fake/file.m4a' }
7
+ describe 'initialization' do
8
+ it "saves the file as a path" do
9
+ sound.file.should == 'fake/file.m4a'
10
+ end
11
+ end
12
+
13
+ describe '#play' do
14
+ it "plays a file" do
15
+ sound.should_receive(:system).with %{/usr/bin/afplay "fake/file.m4a" &}
16
+ sound.play
17
+ end
18
+ end
19
+ end
20
+
21
+ end
@@ -0,0 +1,22 @@
1
+ require 'spec_helper'
2
+
3
+ describe Sounder do
4
+
5
+ describe Sounder::System do
6
+ describe '.set_volume' do
7
+ it "uses system to set the volume" do
8
+ Sounder::System.should_receive(:system).with %{osascript -e "set volume 7.0"}
9
+ Sounder::System.set_volume 100
10
+ end
11
+ it "converts the number to base 7" do
12
+ Sounder::System.should_receive(:system).with %{osascript -e "set volume 3.5"}
13
+ Sounder::System.set_volume 50
14
+ end
15
+ it "doesn't make the call if it isn't given a number" do
16
+ Sounder::System.should_not_receive(:system)
17
+ Sounder::System.set_volume "something bad"
18
+ end
19
+ end
20
+ end
21
+
22
+ end
@@ -1,38 +1,6 @@
1
- require 'sounder'
1
+ require 'spec_helper'
2
2
 
3
3
  describe Sounder do
4
- describe Sounder::System do
5
- describe '.set_volume' do
6
- it "uses system to set the volume" do
7
- Sounder::System.should_receive(:system).with %{osascript -e "set volume 7.0"}
8
- Sounder::System.set_volume 100
9
- end
10
- it "converts the number to base 7" do
11
- Sounder::System.should_receive(:system).with %{osascript -e "set volume 3.5"}
12
- Sounder::System.set_volume 50
13
- end
14
- it "doesn't make the call if it isn't given a number" do
15
- Sounder::System.should_not_receive(:system)
16
- Sounder::System.set_volume "something bad"
17
- end
18
- end
19
- end
20
-
21
- describe Sounder::Sound do
22
- let(:sound) { Sounder::Sound.new 'fake/file.m4a' }
23
- describe 'initialization' do
24
- it "saves the file as a path" do
25
- sound.file.should == 'fake/file.m4a'
26
- end
27
- end
28
- describe '#play' do
29
- it "plays a file" do
30
- sound.should_receive(:system).with %{/usr/bin/afplay "fake/file.m4a" &}
31
- sound.play
32
- end
33
- end
34
- end
35
-
36
4
  describe '#play' do
37
5
  it "plays a sound" do
38
6
  Sounder::Sound.any_instance.should_receive(:system).with %{/usr/bin/afplay "fake/file.m4a" &}
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sounder
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adam Zaninovich
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-07-31 00:00:00.000000000 Z
11
+ date: 2013-08-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -52,7 +52,7 @@ dependencies:
52
52
  - - '>='
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
- description: plays sounds
55
+ description: Play sounds on your Mac
56
56
  email:
57
57
  - adam.zaninovich@gmail.com
58
58
  executables: []
@@ -66,12 +66,16 @@ files:
66
66
  - Rakefile
67
67
  - lib/sounder.rb
68
68
  - lib/sounder/sound.rb
69
+ - lib/sounder/sound_group.rb
69
70
  - lib/sounder/system.rb
70
71
  - lib/sounder/version.rb
71
72
  - sounder.gemspec
73
+ - spec/sounder/sound_group_spec.rb
74
+ - spec/sounder/sound_spec.rb
75
+ - spec/sounder/system_spec.rb
72
76
  - spec/sounder_spec.rb
73
77
  - spec/spec_helper.rb
74
- homepage: ''
78
+ homepage: https://github.com/adamzaninovich/sounder
75
79
  licenses:
76
80
  - MIT
77
81
  metadata: {}
@@ -94,7 +98,10 @@ rubyforge_project:
94
98
  rubygems_version: 2.0.5
95
99
  signing_key:
96
100
  specification_version: 4
97
- summary: plays sounds
101
+ summary: Play sounds on your Mac
98
102
  test_files:
103
+ - spec/sounder/sound_group_spec.rb
104
+ - spec/sounder/sound_spec.rb
105
+ - spec/sounder/system_spec.rb
99
106
  - spec/sounder_spec.rb
100
107
  - spec/spec_helper.rb