delaycalc 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.
@@ -0,0 +1,4 @@
1
+ == 0.0.1 2007-12-11
2
+
3
+ * 1 major enhancement:
4
+ * Initial release
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2007 Doug Sparling
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.
@@ -0,0 +1,25 @@
1
+ History.txt
2
+ License.txt
3
+ Manifest.txt
4
+ README.txt
5
+ Rakefile
6
+ config/hoe.rb
7
+ config/requirements.rb
8
+ lib/delaycalc.rb
9
+ lib/delaycalc/version.rb
10
+ log/debug.log
11
+ script/delaycalc
12
+ script/destroy
13
+ script/generate
14
+ script/txt2html
15
+ setup.rb
16
+ tasks/deployment.rake
17
+ tasks/environment.rake
18
+ tasks/website.rake
19
+ test/test_delaycalc.rb
20
+ test/test_helper.rb
21
+ website/index.html
22
+ website/index.txt
23
+ website/javascripts/rounded_corners_lite.inc.js
24
+ website/stylesheets/screen.css
25
+ website/template.rhtml
@@ -0,0 +1,68 @@
1
+ = delaycalc
2
+
3
+ == About
4
+
5
+ delcaycalc is a simple delay time calculator for calculating delay settings based on song BPM (beats per minute)
6
+
7
+ == Installing delaycalc
8
+
9
+ Just intall the gem:
10
+
11
+ $ sudo gem install delaycalc
12
+
13
+ == Using delaycalc
14
+
15
+ script/delaycalc
16
+ ================
17
+
18
+ #!/usr/local/bin/ruby
19
+ require 'rubygems'
20
+ require 'delaycalc'
21
+
22
+ bpm = 120
23
+
24
+ puts "BPM: #{bpm}"
25
+
26
+ puts "W(1/1): #{bpm.W} ms"
27
+
28
+ puts "HD(1/2.): #{bpm.HD} ms"
29
+ puts "H(1/2): #{bpm.H} ms"
30
+ puts "HT(1/2T): #{bpm.HT} ms"
31
+
32
+ puts "QD(1/4.): #{bpm.QD} ms"
33
+ puts "Q(1/4): #{bpm.Q} ms"
34
+ puts "QT(1/4T): #{bpm.QT} ms"
35
+
36
+ puts "ED(1/8.): #{bpm.ED} ms"
37
+ puts "E(1/8): #{bpm.E} ms"
38
+ puts "ET(1/8T): #{bpm.ET} ms"
39
+
40
+ puts "SD(1/16.): #{bpm.SD} ms"
41
+ puts "S(1/16): #{bpm.S} ms"
42
+ puts "ST(1/16T): #{bpm.ST} ms"
43
+
44
+ puts "TD(1/32.): #{bpm.TD} ms"
45
+ puts "T(1/32): #{bpm.T} ms"
46
+ puts "TT(1/32T): #{bpm.TT} ms"
47
+
48
+ # Or Explicit
49
+ puts "Q(1/4): " + Delaycalc.convert_bpm(120,1.0).to_s + " ms"
50
+
51
+ Initial release uses these abbreviations:
52
+
53
+ W: Whole note
54
+ HD: Half note Dotted
55
+ H: Half note
56
+ HT: Half note Triplet
57
+ QD: Quarter note Dotted
58
+ Q: Quarter note
59
+ QT: Quarter noteTriplet
60
+ ED: Eighth note Dotted
61
+ E: Eighth note
62
+ ET: Eighth note Triplete
63
+ SD: Sixteenth note Dotted
64
+ S: Sixteenth note
65
+ ST: Sixteenth note Triplet
66
+ TD: Thirty second note Dotted
67
+ T: Thirty second note
68
+ TT: Thirty second note Triplet
@@ -0,0 +1,4 @@
1
+ require 'config/requirements'
2
+ require 'config/hoe' # setup Hoe + all gem configuration
3
+
4
+ Dir['tasks/**/*.rake'].each { |rake| load rake }
@@ -0,0 +1,70 @@
1
+ require 'delaycalc/version'
2
+
3
+ AUTHOR = 'Doug Sparling'
4
+ EMAIL = "dougsparling@yahoo.com"
5
+ DESCRIPTION = "delay time calculator for digital delays"
6
+ GEM_NAME = 'delaycalc' # what ppl will type to install your gem
7
+ RUBYFORGE_PROJECT = 'delaycalc' # The unix name for your project
8
+ HOMEPATH = "http://#{RUBYFORGE_PROJECT}.rubyforge.org"
9
+ DOWNLOAD_PATH = "http://rubyforge.org/projects/#{RUBYFORGE_PROJECT}"
10
+
11
+ @config_file = "~/.rubyforge/user-config.yml"
12
+ @config = nil
13
+ RUBYFORGE_USERNAME = "dsparling"
14
+ def rubyforge_username
15
+ unless @config
16
+ begin
17
+ @config = YAML.load(File.read(File.expand_path(@config_file)))
18
+ rescue
19
+ puts <<-EOS
20
+ ERROR: No rubyforge config file found: #{@config_file}"
21
+ Run 'rubyforge setup' to prepare your env for access to Rubyforge
22
+ - See http://newgem.rubyforge.org/rubyforge.html for more details
23
+ EOS
24
+ exit
25
+ end
26
+ end
27
+ RUBYFORGE_USERNAME.replace @config["username"]
28
+ end
29
+
30
+
31
+ REV = nil
32
+ # UNCOMMENT IF REQUIRED:
33
+ # REV = `svn info`.each {|line| if line =~ /^Revision:/ then k,v = line.split(': '); break v.chomp; else next; end} rescue nil
34
+ VERS = Delaycalc::VERSION::STRING + (REV ? ".#{REV}" : "")
35
+ RDOC_OPTS = ['--quiet', '--title', 'delaycalc documentation',
36
+ "--opname", "index.html",
37
+ "--line-numbers",
38
+ "--main", "README",
39
+ "--inline-source"]
40
+
41
+ class Hoe
42
+ def extra_deps
43
+ @extra_deps.reject! { |x| Array(x).first == 'hoe' }
44
+ @extra_deps
45
+ end
46
+ end
47
+
48
+ # Generate all the Rake tasks
49
+ # Run 'rake -T' to see list of generated tasks (from gem root directory)
50
+ hoe = Hoe.new(GEM_NAME, VERS) do |p|
51
+ p.author = AUTHOR
52
+ p.description = DESCRIPTION
53
+ p.email = EMAIL
54
+ p.summary = DESCRIPTION
55
+ p.url = HOMEPATH
56
+ p.rubyforge_name = RUBYFORGE_PROJECT if RUBYFORGE_PROJECT
57
+ p.test_globs = ["test/**/test_*.rb"]
58
+ p.clean_globs |= ['**/.*.sw?', '*.gem', '.config', '**/.DS_Store'] #An array of file patterns to delete on clean.
59
+
60
+ # == Optional
61
+ p.changes = p.paragraphs_of("History.txt", 0..1).join("\\n\\n")
62
+ #p.extra_deps = [] # An array of rubygem dependencies [name, version], e.g. [ ['active_support', '>= 1.3.1'] ]
63
+
64
+ #p.spec_extras = {} # A hash of extra values to set in the gemspec.
65
+
66
+ end
67
+
68
+ CHANGES = hoe.paragraphs_of('History.txt', 0..1).join("\\n\\n")
69
+ PATH = (RUBYFORGE_PROJECT == GEM_NAME) ? RUBYFORGE_PROJECT : "#{RUBYFORGE_PROJECT}/#{GEM_NAME}"
70
+ hoe.remote_rdoc_dir = File.join(PATH.gsub(/^#{RUBYFORGE_PROJECT}\/?/,''), 'rdoc')
@@ -0,0 +1,17 @@
1
+ require 'fileutils'
2
+ include FileUtils
3
+
4
+ require 'rubygems'
5
+ %w[rake hoe newgem rubigen].each do |req_gem|
6
+ begin
7
+ require req_gem
8
+ rescue LoadError
9
+ puts "This Rakefile requires the '#{req_gem}' RubyGem."
10
+ puts "Installation: gem install #{req_gem} -y"
11
+ exit
12
+ end
13
+ end
14
+
15
+ $:.unshift(File.join(File.dirname(__FILE__), %w[.. lib]))
16
+
17
+ require 'delaycalc'
@@ -0,0 +1,81 @@
1
+ $:.unshift File.dirname(__FILE__)
2
+
3
+ module Delaycalc
4
+
5
+ def self.convert_bpm(bpm,sub)
6
+ ( (1.0/sub) * (60000/bpm) ).round
7
+ end
8
+
9
+ def _convert_bpm(bpm,sub)
10
+ ( (1.0/sub) * (60000/bpm) ).round
11
+ end
12
+
13
+ def W
14
+ _convert_bpm(self,0.25)
15
+ end
16
+
17
+ def HD
18
+ _convert_bpm(self,0.3333333333333333)
19
+ end
20
+
21
+ def H
22
+ _convert_bpm(self,0.5)
23
+ end
24
+
25
+ def HT
26
+ _convert_bpm(self,0.75)
27
+ end
28
+
29
+ def QD
30
+ _convert_bpm(self,0.6666666666666666)
31
+ end
32
+
33
+ def Q
34
+ _convert_bpm(self,1.0)
35
+ end
36
+
37
+ def QT
38
+ _convert_bpm(self,1.5)
39
+ end
40
+
41
+ def ED
42
+ _convert_bpm(self,1.3333333333333333)
43
+ end
44
+
45
+ def E
46
+ _convert_bpm(self,2)
47
+ end
48
+
49
+ def ET
50
+ _convert_bpm(self,3)
51
+ end
52
+
53
+ def SD
54
+ _convert_bpm(self,2.6666666666666666)
55
+ end
56
+
57
+ def S
58
+ _convert_bpm(self,4)
59
+ end
60
+
61
+ def ST
62
+ _convert_bpm(self,6)
63
+ end
64
+
65
+ def TD
66
+ _convert_bpm(self,5.3333333333333333)
67
+ end
68
+
69
+ def T
70
+ _convert_bpm(self,8)
71
+ end
72
+
73
+ def TT
74
+ _convert_bpm(self,12)
75
+ end
76
+
77
+ end
78
+
79
+ class Integer
80
+ include Delaycalc
81
+ end
@@ -0,0 +1,9 @@
1
+ module Delaycalc #:nodoc:
2
+ module VERSION #:nodoc:
3
+ MAJOR = 0
4
+ MINOR = 0
5
+ TINY = 1
6
+
7
+ STRING = [MAJOR, MINOR, TINY].join('.')
8
+ end
9
+ end
File without changes
@@ -0,0 +1,32 @@
1
+ #!/usr/local/bin/ruby
2
+ require 'rubygems'
3
+ require 'delaycalc'
4
+
5
+ bpm = 120
6
+
7
+ puts "BPM: #{bpm}"
8
+
9
+ puts "W(1/1): #{bpm.W} ms"
10
+
11
+ puts "HD(1/2.): #{bpm.HD} ms"
12
+ puts "H(1/2): #{bpm.H} ms"
13
+ puts "HT(1/2T): #{bpm.HT} ms"
14
+
15
+ puts "QD(1/4.): #{bpm.QD} ms"
16
+ puts "Q(1/4): #{bpm.Q} ms"
17
+ puts "QT(1/4T): #{bpm.QT} ms"
18
+
19
+ puts "ED(1/8.): #{bpm.ED} ms"
20
+ puts "E(1/8): #{bpm.E} ms"
21
+ puts "ET(1/8T): #{bpm.ET} ms"
22
+
23
+ puts "SD(1/16.): #{bpm.SD} ms"
24
+ puts "S(1/16): #{bpm.S} ms"
25
+ puts "ST(1/16T): #{bpm.ST} ms"
26
+
27
+ puts "TD(1/32.): #{bpm.TD} ms"
28
+ puts "T(1/32): #{bpm.T} ms"
29
+ puts "TT(1/32T): #{bpm.TT} ms"
30
+
31
+ # Or Explicit
32
+ puts "Q(1/4): " + Delaycalc.convert_bpm(120,1.0).to_s + " ms"
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+ APP_ROOT = File.join(File.dirname(__FILE__), '..')
3
+
4
+ begin
5
+ require 'rubigen'
6
+ rescue LoadError
7
+ require 'rubygems'
8
+ require 'rubigen'
9
+ end
10
+ require 'rubigen/scripts/destroy'
11
+
12
+ ARGV.shift if ['--help', '-h'].include?(ARGV[0])
13
+ RubiGen::Base.use_component_sources! [:rubygems, :newgem, :newgem_theme]
14
+ RubiGen::Scripts::Destroy.new.run(ARGV)
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+ APP_ROOT = File.join(File.dirname(__FILE__), '..')
3
+
4
+ begin
5
+ require 'rubigen'
6
+ rescue LoadError
7
+ require 'rubygems'
8
+ require 'rubigen'
9
+ end
10
+ require 'rubigen/scripts/generate'
11
+
12
+ ARGV.shift if ['--help', '-h'].include?(ARGV[0])
13
+ RubiGen::Base.use_component_sources! [:rubygems, :newgem, :newgem_theme]
14
+ RubiGen::Scripts::Generate.new.run(ARGV)
@@ -0,0 +1,74 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'rubygems'
4
+ begin
5
+ require 'newgem'
6
+ rescue LoadError
7
+ puts "\n\nGenerating the website requires the newgem RubyGem"
8
+ puts "Install: gem install newgem\n\n"
9
+ exit(1)
10
+ end
11
+ require 'redcloth'
12
+ require 'syntax/convertors/html'
13
+ require 'erb'
14
+ require File.dirname(__FILE__) + '/../lib/delaycalc/version.rb'
15
+
16
+ version = Delaycalc::VERSION::STRING
17
+ download = 'http://rubyforge.org/projects/delaycalc'
18
+
19
+ class Fixnum
20
+ def ordinal
21
+ # teens
22
+ return 'th' if (10..19).include?(self % 100)
23
+ # others
24
+ case self % 10
25
+ when 1: return 'st'
26
+ when 2: return 'nd'
27
+ when 3: return 'rd'
28
+ else return 'th'
29
+ end
30
+ end
31
+ end
32
+
33
+ class Time
34
+ def pretty
35
+ return "#{mday}#{mday.ordinal} #{strftime('%B')} #{year}"
36
+ end
37
+ end
38
+
39
+ def convert_syntax(syntax, source)
40
+ return Syntax::Convertors::HTML.for_syntax(syntax).convert(source).gsub(%r!^<pre>|</pre>$!,'')
41
+ end
42
+
43
+ if ARGV.length >= 1
44
+ src, template = ARGV
45
+ template ||= File.join(File.dirname(__FILE__), '/../website/template.rhtml')
46
+
47
+ else
48
+ puts("Usage: #{File.split($0).last} source.txt [template.rhtml] > output.html")
49
+ exit!
50
+ end
51
+
52
+ template = ERB.new(File.open(template).read)
53
+
54
+ title = nil
55
+ body = nil
56
+ File.open(src) do |fsrc|
57
+ title_text = fsrc.readline
58
+ body_text = fsrc.read
59
+ syntax_items = []
60
+ body_text.gsub!(%r!<(pre|code)[^>]*?syntax=['"]([^'"]+)[^>]*>(.*?)</\1>!m){
61
+ ident = syntax_items.length
62
+ element, syntax, source = $1, $2, $3
63
+ syntax_items << "<#{element} class='syntax'>#{convert_syntax(syntax, source)}</#{element}>"
64
+ "syntax-temp-#{ident}"
65
+ }
66
+ title = RedCloth.new(title_text).to_html.gsub(%r!<.*?>!,'').strip
67
+ body = RedCloth.new(body_text).to_html
68
+ body.gsub!(%r!(?:<pre><code>)?syntax-temp-(\d+)(?:</code></pre>)?!){ syntax_items[$1.to_i] }
69
+ end
70
+ stat = File.stat(src)
71
+ created = stat.ctime
72
+ modified = stat.mtime
73
+
74
+ $stdout << template.result(binding)