beep 0.0.1
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.
- data/.gitignore +5 -0
- data/Gemfile +5 -0
- data/LICENSE +21 -0
- data/README.rdoc +48 -0
- data/Rakefile +8 -0
- data/beep.gemspec +20 -0
- data/lib/beep.rb +6 -0
- data/lib/beep/sound.rb +25 -0
- data/lib/beep/version.rb +3 -0
- data/spec/beep/sound_spec.rb +29 -0
- data/spec/spec.opts +2 -0
- data/spec/spec_helper.rb +5 -0
- metadata +76 -0
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
Copyright (c) 2011 Rory McKinley
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
21
|
+
|
data/README.rdoc
ADDED
@@ -0,0 +1,48 @@
|
|
1
|
+
= beep
|
2
|
+
|
3
|
+
Currently, beep is a very simple wrapper around the beep utility of Linux. It handles a small subset of the functionality provided by the utility.
|
4
|
+
|
5
|
+
== Installing beep
|
6
|
+
|
7
|
+
Install beep (the utility) using your package management app of choice. If you type in `beep` at the command prompt, you should be rewarded with, well, pretty much just a beep.
|
8
|
+
Note: In some recent Ubuntu versions, the pcspkr module is blacklisted, so you will need to comment out the relevant line in /etc/modprobe.d/blacklistif you want the pcspkr permanently enabled (it can be quite annoying) or manually load it using `sudo modprobe pcspkr`
|
9
|
+
|
10
|
+
And then, install the gem.
|
11
|
+
|
12
|
+
gem install beep
|
13
|
+
|
14
|
+
== Usage
|
15
|
+
|
16
|
+
In your Ruby code:
|
17
|
+
|
18
|
+
require 'beep'
|
19
|
+
|
20
|
+
=== Issuing the default beep
|
21
|
+
|
22
|
+
Beep::Sound.generate
|
23
|
+
|
24
|
+
=== Passing through a sequence of beeps
|
25
|
+
|
26
|
+
sounds = [
|
27
|
+
{:frequency => 100, :duration => 200, :pause => 300},
|
28
|
+
{:frequency => 400, :duration => 500, :pause => 600},
|
29
|
+
{:frequency => 700, :duration => 800, :pause => 900},
|
30
|
+
]
|
31
|
+
|
32
|
+
Beep::Sound.generate(sounds)
|
33
|
+
|
34
|
+
The duration and pause sounds are in milliseconds. Frequency is in MHz.
|
35
|
+
|
36
|
+
== Note on Patches/Pull Requests
|
37
|
+
|
38
|
+
* Fork the project.
|
39
|
+
* Make your feature addition or bug fix.
|
40
|
+
* Add tests for it. This is important so I don't break it in a
|
41
|
+
future version unintentionally.
|
42
|
+
* Commit, do not mess with rakefile, version, or history.
|
43
|
+
(if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
|
44
|
+
* Send me a pull request. Bonus points for topic branches.
|
45
|
+
|
46
|
+
== Copyright
|
47
|
+
|
48
|
+
Copyright (c) 2011 Rory McKinley. See LICENSE for details.
|
data/Rakefile
ADDED
data/beep.gemspec
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "beep/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "beep"
|
7
|
+
s.version = Beep::VERSION
|
8
|
+
s.authors = ["Rory McKinley"]
|
9
|
+
s.email = ["rorymckinley@gmail.com"]
|
10
|
+
s.homepage = "https://github.com/rorymckinley/beep"
|
11
|
+
s.summary = %q{A small gem to manipulate the Linux beep utility}
|
12
|
+
s.description = %q{This gem provides a very simple wrapper around the Linux beep utility}
|
13
|
+
|
14
|
+
s.rubyforge_project = "beep"
|
15
|
+
|
16
|
+
s.files = `git ls-files`.split("\n")
|
17
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
18
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
19
|
+
s.require_paths = ["lib"]
|
20
|
+
end
|
data/lib/beep.rb
ADDED
data/lib/beep/sound.rb
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
module Beep
|
2
|
+
class Sound
|
3
|
+
def self.generate(instructions=[])
|
4
|
+
basic_command = 'beep%s' % create_arguments(instructions)
|
5
|
+
system(basic_command)
|
6
|
+
end
|
7
|
+
|
8
|
+
private
|
9
|
+
|
10
|
+
def self.create_arguments(instructions)
|
11
|
+
instructions_to_args = {
|
12
|
+
:frequency => ' -f %s',
|
13
|
+
:duration => ' -l %s',
|
14
|
+
:pause => ' -D %s'
|
15
|
+
}
|
16
|
+
(instructions.map do |instruction|
|
17
|
+
arguments = ''
|
18
|
+
instruction.each do |name,value|
|
19
|
+
arguments += instructions_to_args[name] % value
|
20
|
+
end
|
21
|
+
arguments
|
22
|
+
end).join(" -n")
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
data/lib/beep/version.rb
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
2
|
+
|
3
|
+
describe Beep::Sound do
|
4
|
+
it "should be able to call the default beep command without arguments" do
|
5
|
+
Beep::Sound.should_receive(:system).with('beep')
|
6
|
+
Beep::Sound.generate
|
7
|
+
end
|
8
|
+
it "should allow a beep to be generated with a given frequency" do
|
9
|
+
Beep::Sound.should_receive(:system).with('beep -f 100')
|
10
|
+
Beep::Sound.generate([{:frequency => 100}])
|
11
|
+
end
|
12
|
+
it "should allow a beep to be generated with a given duration in milliseconds" do
|
13
|
+
Beep::Sound.should_receive(:system).with('beep -l 1000')
|
14
|
+
Beep::Sound.generate([{:duration => 1000}])
|
15
|
+
end
|
16
|
+
it "should allow a beep to be generated with a given pause after the beep" do
|
17
|
+
Beep::Sound.should_receive(:system).with('beep -D 1000')
|
18
|
+
Beep::Sound.generate([{:pause => 1000}])
|
19
|
+
end
|
20
|
+
it "should be able to handle multiple beeps with a single command" do
|
21
|
+
sounds = [
|
22
|
+
{:frequency => 100, :duration => 200, :pause => 300},
|
23
|
+
{:frequency => 400, :duration => 500, :pause => 600},
|
24
|
+
{:frequency => 700, :duration => 800, :pause => 900},
|
25
|
+
]
|
26
|
+
Beep::Sound.should_receive(:system).with('beep -f 100 -l 200 -D 300 -n -f 400 -l 500 -D 600 -n -f 700 -l 800 -D 900')
|
27
|
+
Beep::Sound.generate(sounds)
|
28
|
+
end
|
29
|
+
end
|
data/spec/spec.opts
ADDED
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,76 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: beep
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 0
|
7
|
+
- 0
|
8
|
+
- 1
|
9
|
+
version: 0.0.1
|
10
|
+
platform: ruby
|
11
|
+
authors:
|
12
|
+
- Rory McKinley
|
13
|
+
autorequire:
|
14
|
+
bindir: bin
|
15
|
+
cert_chain: []
|
16
|
+
|
17
|
+
date: 2011-06-02 00:00:00 +02:00
|
18
|
+
default_executable:
|
19
|
+
dependencies: []
|
20
|
+
|
21
|
+
description: This gem provides a very simple wrapper around the Linux beep utility
|
22
|
+
email:
|
23
|
+
- rorymckinley@gmail.com
|
24
|
+
executables: []
|
25
|
+
|
26
|
+
extensions: []
|
27
|
+
|
28
|
+
extra_rdoc_files: []
|
29
|
+
|
30
|
+
files:
|
31
|
+
- .gitignore
|
32
|
+
- Gemfile
|
33
|
+
- LICENSE
|
34
|
+
- README.rdoc
|
35
|
+
- Rakefile
|
36
|
+
- beep.gemspec
|
37
|
+
- lib/beep.rb
|
38
|
+
- lib/beep/sound.rb
|
39
|
+
- lib/beep/version.rb
|
40
|
+
- spec/beep/sound_spec.rb
|
41
|
+
- spec/spec.opts
|
42
|
+
- spec/spec_helper.rb
|
43
|
+
has_rdoc: true
|
44
|
+
homepage: https://github.com/rorymckinley/beep
|
45
|
+
licenses: []
|
46
|
+
|
47
|
+
post_install_message:
|
48
|
+
rdoc_options: []
|
49
|
+
|
50
|
+
require_paths:
|
51
|
+
- lib
|
52
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
53
|
+
none: false
|
54
|
+
requirements:
|
55
|
+
- - ">="
|
56
|
+
- !ruby/object:Gem::Version
|
57
|
+
segments:
|
58
|
+
- 0
|
59
|
+
version: "0"
|
60
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
61
|
+
none: false
|
62
|
+
requirements:
|
63
|
+
- - ">="
|
64
|
+
- !ruby/object:Gem::Version
|
65
|
+
segments:
|
66
|
+
- 0
|
67
|
+
version: "0"
|
68
|
+
requirements: []
|
69
|
+
|
70
|
+
rubyforge_project: beep
|
71
|
+
rubygems_version: 1.3.7
|
72
|
+
signing_key:
|
73
|
+
specification_version: 3
|
74
|
+
summary: A small gem to manipulate the Linux beep utility
|
75
|
+
test_files: []
|
76
|
+
|