metronome 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,2 @@
1
+ *.swp
2
+ /pkg
data/.rvmrc ADDED
@@ -0,0 +1 @@
1
+ rvm 1.9.2@metronome --create
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in metronome.gemspec
4
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,36 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ metronome (0.0.1)
5
+ ruby-sdl-ffi
6
+ rubygame
7
+
8
+ GEM
9
+ remote: http://rubygems.org/
10
+ specs:
11
+ diff-lcs (1.1.3)
12
+ ffi (1.0.11)
13
+ nice-ffi (0.4)
14
+ ffi (>= 0.5.0)
15
+ rake (0.9.2.2)
16
+ rspec (2.7.0)
17
+ rspec-core (~> 2.7.0)
18
+ rspec-expectations (~> 2.7.0)
19
+ rspec-mocks (~> 2.7.0)
20
+ rspec-core (2.7.1)
21
+ rspec-expectations (2.7.0)
22
+ diff-lcs (~> 1.1.2)
23
+ rspec-mocks (2.7.0)
24
+ ruby-sdl-ffi (0.4)
25
+ nice-ffi (>= 0.2)
26
+ rubygame (2.6.4)
27
+ rake (>= 0.7.0)
28
+ ruby-sdl-ffi (>= 0.1.0)
29
+
30
+ PLATFORMS
31
+ ruby
32
+
33
+ DEPENDENCIES
34
+ metronome!
35
+ rake
36
+ rspec
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License
2
+
3
+ Copyright (c) 2011 Jorge Luis Pérez (jolisper@gmail.com)
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.markdown ADDED
@@ -0,0 +1,22 @@
1
+ metronome
2
+ =========
3
+
4
+ command-line metronome
5
+
6
+ Dependencies
7
+ ------------
8
+
9
+ This program uses rubygame gem that requires sdllib to work, follow the next instructions:
10
+
11
+ [https://github.com/rubygame/rubygame/wiki/Install](https://github.com/rubygame/rubygame/wiki/Install)
12
+
13
+ Usage
14
+ -----
15
+
16
+ $ metronome -t 60
17
+
18
+ Copyright
19
+ ---------
20
+
21
+ Copyright (c) 2011 Jorge Luis Pérez. See LICENSE for details.
22
+
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
data/bin/metronome ADDED
@@ -0,0 +1,10 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ $:.unshift File.expand_path("../../lib", __FILE__)
4
+
5
+ require 'metronome'
6
+
7
+ args = ARGV.dup
8
+ ARGV.clear
9
+
10
+ Metronome::Command.run( args )
data/lib/metronome.rb ADDED
@@ -0,0 +1,44 @@
1
+ require 'metronome/version'
2
+ require 'optparse'
3
+ require 'rubygame'
4
+
5
+ module Metronome
6
+
7
+ module Command
8
+
9
+ # Parse option and start metronome
10
+ def self.run( args )
11
+ options = {}
12
+
13
+ OptionParser.new do |opts|
14
+ opts.on( '-t BPM', '--tempo BPM', /^[0-9]+/ ) do |bpm|
15
+ options[:bpm] = bpm
16
+ end
17
+ end.parse!( args )
18
+
19
+ start( options[:bpm] )
20
+ end
21
+
22
+ # Start metronome
23
+ def self.start( bpm )
24
+ sound = Rubygame::Sound.load( File.expand_path("../../sounds/tap_short.wav", __FILE__) )
25
+
26
+ t = Thread.new do
27
+ puts 'press Ctrl+C to stop'
28
+ # main loop
29
+ loop do
30
+ sound.play
31
+ sleep( 60 / bpm.to_f )
32
+ end
33
+ end
34
+
35
+ begin
36
+ t.join
37
+ rescue Interrupt
38
+ puts "\nmetronome off"
39
+ end
40
+ end
41
+
42
+ end
43
+
44
+ end
@@ -0,0 +1,3 @@
1
+ module Metronome
2
+ VERSION = "0.0.1"
3
+ end
data/metronome.gemspec ADDED
@@ -0,0 +1,24 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "metronome/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "metronome"
7
+ s.version = Metronome::VERSION
8
+ s.authors = ["Jorge Luis Pérez"]
9
+ s.email = ["jolisper@gmail.com"]
10
+ s.homepage = "https://github.com/jolisper/metronome"
11
+ s.summary = %q{command-line metronome}
12
+ s.description = %q{command-line metronome}
13
+
14
+ s.files = `git ls-files`.split("\n")
15
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
16
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
17
+ s.require_paths = ["lib"]
18
+
19
+ s.add_development_dependency "rspec"
20
+ s.add_development_dependency "rake"
21
+
22
+ s.add_runtime_dependency "rubygame"
23
+ s.add_runtime_dependency "ruby-sdl-ffi"
24
+ end
Binary file
Binary file
metadata ADDED
@@ -0,0 +1,103 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: metronome
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Jorge Luis Pérez
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-04-30 00:00:00.000000000Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: rspec
16
+ requirement: &11105100 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :development
23
+ prerelease: false
24
+ version_requirements: *11105100
25
+ - !ruby/object:Gem::Dependency
26
+ name: rake
27
+ requirement: &11104680 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ! '>='
31
+ - !ruby/object:Gem::Version
32
+ version: '0'
33
+ type: :development
34
+ prerelease: false
35
+ version_requirements: *11104680
36
+ - !ruby/object:Gem::Dependency
37
+ name: rubygame
38
+ requirement: &11104260 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ! '>='
42
+ - !ruby/object:Gem::Version
43
+ version: '0'
44
+ type: :runtime
45
+ prerelease: false
46
+ version_requirements: *11104260
47
+ - !ruby/object:Gem::Dependency
48
+ name: ruby-sdl-ffi
49
+ requirement: &11103840 !ruby/object:Gem::Requirement
50
+ none: false
51
+ requirements:
52
+ - - ! '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ type: :runtime
56
+ prerelease: false
57
+ version_requirements: *11103840
58
+ description: command-line metronome
59
+ email:
60
+ - jolisper@gmail.com
61
+ executables:
62
+ - metronome
63
+ extensions: []
64
+ extra_rdoc_files: []
65
+ files:
66
+ - .gitignore
67
+ - .rvmrc
68
+ - Gemfile
69
+ - Gemfile.lock
70
+ - LICENSE
71
+ - README.markdown
72
+ - Rakefile
73
+ - bin/metronome
74
+ - lib/metronome.rb
75
+ - lib/metronome/version.rb
76
+ - metronome.gemspec
77
+ - sounds/agogo_high.wav
78
+ - sounds/tap_short.wav
79
+ homepage: https://github.com/jolisper/metronome
80
+ licenses: []
81
+ post_install_message:
82
+ rdoc_options: []
83
+ require_paths:
84
+ - lib
85
+ required_ruby_version: !ruby/object:Gem::Requirement
86
+ none: false
87
+ requirements:
88
+ - - ! '>='
89
+ - !ruby/object:Gem::Version
90
+ version: '0'
91
+ required_rubygems_version: !ruby/object:Gem::Requirement
92
+ none: false
93
+ requirements:
94
+ - - ! '>='
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ requirements: []
98
+ rubyforge_project:
99
+ rubygems_version: 1.8.10
100
+ signing_key:
101
+ specification_version: 3
102
+ summary: command-line metronome
103
+ test_files: []