Skip to content
Browse files

Add rakefile, readme, gemspec

  • Loading branch information...
1 parent bca5d0b commit 3efca1d3807048f79a43b998ffcf5e204e5da839 @nicksieger committed Nov 2, 2010
Showing with 207 additions and 0 deletions.
  1. +21 −0 ringpiano/LICENSE
  2. +47 −0 ringpiano/README.md
  3. +103 −0 ringpiano/Rakefile
  4. +1 −0 ringpiano/lib/ringpiano.rb
  5. +35 −0 ringpiano/ringpiano.gemspec
View
21 ringpiano/LICENSE
@@ -0,0 +1,21 @@
+The MIT License
+
+Copyright (c) 2010 Nick Sieger
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
View
47 ringpiano/README.md
@@ -0,0 +1,47 @@
+RingPiano
+=========
+
+http://github.com/nicksieger/ringpiano
+
+## Description
+
+An example featuring JRuby to build a distributed piano using Rinda,
+Swing and javax.sound.midi APIs.
+
+This example was built to showcase packaging a Ruby application as a
+Java jar file. To see this in action, install Warbler and type
+`warble` to create a jar file that can be run with `java -jar`.
+
+## Requirements
+
+- JRuby-only for the keyboard and soundboard. This Ruby code uses
+ JRuby's Java integration to call the Swing and javax.sound APIs.
+- Other rubies can run the tuplespace server or run the console to
+ interact with the tuplespace and send note_on/note_off commands to
+ remote soundboards.
+
+## Install
+
+ gem install ringpiano
+
+## Run
+
+RingPiano consists of several components: a server, a soundboard, a
+keyboard, and a console. `ringpiano <component>` runs the requested
+component. `ringpiano` alone will run the server, soundboard and
+keyboard.
+
+When RingPiano starts up, it will attempt to locate a
+Rinda::RingServer broadcasting UDP on the local network. If it does
+not find one within five seconds, it will start one up.
+
+On JRuby, the server component also will display a participant list
+window showing all the local and remote components participating in
+the RingPiano.
+
+## Give back
+
+I'll gladly accept [pull requests][pr] and [bug reports][issues].
+
+[pr]: http://github.com/nicksieger/ringpiano/pulls
+[issues]: http://github.com/nicksieger/ringpiano/issues
View
103 ringpiano/Rakefile
@@ -0,0 +1,103 @@
+require 'date'
+require 'rake/clean'
+
+#############################################################################
+#
+# Helper functions
+#
+#############################################################################
+
+def name
+ @name ||= Dir['*.gemspec'].first.split('.').first
+end
+
+def version
+ line = File.read("lib/#{name}.rb")[/^\s*VERSION\s*=\s*.*/]
+ line.match(/.*VERSION\s*=\s*['"](.*)['"]/)[1]
+end
+
+def date
+ Date.today.to_s
+end
+
+def rubyforge_project
+ "caldersphere"
+end
+
+def gemspec_file
+ "#{name}.gemspec"
+end
+
+def gem_file
+ "#{name}-#{version}*.gem"
+end
+
+def replace_header(head, header_name)
+ head.sub!(/(\.#{header_name}\s*= ').*'/) { "#{$1}#{send(header_name)}'"}
+end
+
+#############################################################################
+#
+# Standard tasks
+#
+#############################################################################
+
+task :default do
+ puts "To package RingPiano into a gem, type `rake build'."
+ puts "To package RingPiano as a jar, install Warbler and type `warble'."
+end
+
+require 'rake/rdoctask'
+Rake::RDocTask.new do |rdoc|
+ rdoc.rdoc_dir = 'rdoc'
+ rdoc.title = "#{name} #{version}"
+ rdoc.rdoc_files.include('README*')
+ rdoc.rdoc_files.include('lib/**/*.rb')
+end
+
+task :release => :build do
+ unless `git branch` =~ /^\* master$/
+ puts "You must be on the master branch to release!"
+ exit!
+ end
+ sh "git commit --allow-empty -a -m 'Release #{version}'"
+ sh "git tag v#{version}"
+ sh "git push origin master"
+ sh "git push origin v#{version}"
+ sh "gem push pkg/#{name}-#{version}.gem"
+end
+
+task :build => :gemspec do
+ sh "mkdir -p pkg"
+ sh "gem build #{gemspec_file}"
+ sh "mv #{gem_file} pkg"
+end
+CLEAN << 'pkg'
+
+task :gemspec do
+ # read spec file and split out manifest section
+ spec = File.read(gemspec_file)
+ head, manifest, tail = spec.split(" # = MANIFEST =\n")
+
+ # replace name version and date
+ replace_header(head, :name)
+ replace_header(head, :version)
+ replace_header(head, :date)
+ #comment this out if your rubyforge_project has a different name
+ replace_header(head, :rubyforge_project)
+
+ # determine file list from git ls-files
+ files = `git ls-files`.
+ split("\n").
+ sort.
+ reject { |file| file =~ /^\./ }.
+ reject { |file| file =~ /^(rdoc|pkg)/ }.
+ map { |file| " #{file}" }.
+ join("\n")
+
+ # piece file back together and write
+ manifest = " s.files = %w[\n#{files}\n ]\n"
+ spec = [head, manifest, tail].join(" # = MANIFEST =\n")
+ File.open(gemspec_file, 'w') { |io| io.write(spec) }
+ puts "Updated #{gemspec_file}"
+end
View
1 ringpiano/lib/ringpiano.rb
@@ -5,6 +5,7 @@
DRb.start_service
module RingPiano
+ VERSION = "1.0.0"
LOG = Logger.new(STDOUT)
LOG.level = ENV['DEBUG'] ? Logger::DEBUG : Logger::INFO
end
View
35 ringpiano/ringpiano.gemspec
@@ -0,0 +1,35 @@
+# -*- encoding: utf-8 ; mode: ruby -*-
+
+Gem::Specification.new do |s|
+ s.name = 'ringpiano'
+ s.version = '1.0.0'
+ s.date = '2010-10-27'
+
+ s.rubyforge_project = %q{caldersphere}
+
+ s.summary = "Distributed MIDI piano using Rinda and JRuby"
+ s.description = "Distributed MIDI Piano example from RubyConf 2010."
+
+ s.authors = ["Nick Sieger"]
+ s.email = 'nick@nicksieger.com'
+ s.homepage = 'http://github.com/nicksieger/ringpiano'
+ s.require_paths = %w[lib]
+ s.rdoc_options = ["--charset=UTF-8"]
+ s.extra_rdoc_files = %w[README.md LICENSE]
+ s.executables = ["ringpiano"]
+ s.default_executable = "ringpiano"
+
+ # = MANIFEST =
+ s.files = %w[
+ ]
+ # = MANIFEST =
+
+ s.test_files = []
+
+ s.rubygems_version = %q{1.3.7}
+ s.required_rubygems_version = Gem::Requirement.new("> 1.3.1") if s.respond_to? :required_rubygems_version=
+ if s.respond_to? :specification_version then
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
+ s.specification_version = 3
+ end
+end

0 comments on commit 3efca1d

Please sign in to comment.
Something went wrong with that request. Please try again.