Skip to content
This repository has been archived by the owner on Oct 5, 2023. It is now read-only.

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  * files restructured, speration byte & ruby code
  * update server for generic structure, added callback
  * mtl binaires respect defaults from local `.mtlrc` file
  • Loading branch information
Tobias Bielohlawek committed Sep 3, 2012
1 parent fcd83aa commit 12bf5a4
Show file tree
Hide file tree
Showing 109 changed files with 70 additions and 24 deletions.
8 changes: 7 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changes

## v0.1.0 - xx-09-2012

* files restructured, speration byte & ruby code
* update server for generic structure, added callback
* mtl binaires respect defaults from local `.mtlrc` file

## v0.0.2 - 29-01-2012

* rename to NabaztagHackKit
Expand All @@ -8,4 +14,4 @@

## v0.0.1 - 28-01-2012

* inital release
* inital release
12 changes: 1 addition & 11 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,16 +1,6 @@
require "bundler/gem_tasks"

require 'rspec/core/rake_task'
RSpec::Core::RakeTask.new("unit") do |t|
t.pattern = "./spec/**/*_spec.rb" # don't need this, it's default.
end

namespace :test do
desc "Test bytcode"
task :bytecode do
puts `bin/mtl_simu spec/bytecode/test.mtl`
end
end
RSpec::Core::RakeTask.new(:spec)

task :spec => [:unit]
task :default => :spec
7 changes: 7 additions & 0 deletions bytecode/Rakefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@

desc "Test bytcode"
task :test do
puts `bin/mtl_simu test/test.mtl`
end

task :default => :test
10 changes: 7 additions & 3 deletions bin/mtl_comp → bytecode/bin/mtl_comp
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
#!/usr/bin/env ruby

File.read(".mtlrc").split("\n").each do |line|
var, *data = line.split("=")
ENV[var] = data.join
MTL_FILE = ".mtlrc"

if File.exists?(MTL_FILE)
File.read(MTL_FILE).split("\n").each do |line|
var, *data = line.split("=")
ENV[var] = data.join
end
end

BIN_NAME = File.basename(__FILE__)
Expand Down
File renamed without changes.
10 changes: 7 additions & 3 deletions bin/mtl_simu → bytecode/bin/mtl_simu
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
#!/usr/bin/env ruby

File.read(".mtlrc").split("\n").each do |line|
var, *data = line.split("=")
ENV[var] = data.join
MTL_FILE = ".mtlrc"

if File.exists?(MTL_FILE)
File.read(MTL_FILE).split("\n").each do |line|
var, *data = line.split("=")
ENV[var] = data.join
end
end

BIN_NAME = File.basename(__FILE__)
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
1 change: 1 addition & 0 deletions examples/monitor/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.rvmrc
6 changes: 6 additions & 0 deletions examples/monitor/Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# A sample Gemfile
source "http://rubygems.org"

gem "nabaztag_hack_kit", {
:path => "/Users/tobi/Sites/ruby/NabaztagHackKit"
}
8 changes: 8 additions & 0 deletions examples/monitor/config.ru
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/usr/bin/env ruby

#$LOAD_PATH.unshift ::File.expand_path(::File.dirname(__FILE__) + '/lib')
require './server'

use Rack::Reloader, 0

run Server.new
19 changes: 19 additions & 0 deletions examples/monitor/server.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@

require "nabaztag_hack_kit/server"

class Server < NabaztagHackKit::Server

def initialize
super('bytecode.bin')
end

on "button-pressed" do
send_nabaztag({
LED_L1 => [100,0,0,0],
LED_L2 => [0,100,0,100],
LED_L3 => [0,0,100,0]
})
end

end

2 changes: 2 additions & 0 deletions examples/record/server.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@

class Server < NabaztagHackKit::Server

REC_FILE = "rec.wav"

def initialize(echonest_cfg, soundcloud_cfg)
super('bytecode.bin')
@@echonest = Echonest(echonest_cfg[:key])
Expand Down
5 changes: 2 additions & 3 deletions lib/nabaztag_hack_kit/server.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,11 @@
require 'nabaztag_hack_kit/message'
require 'nabaztag_hack_kit/message/api'


module NabaztagHackKit
class Server < Sinatra::Base
include Message::Api

REC_FILE = "rec.wav"
PREFIX = "/api"
PREFIX = "/api"

def initialize(bytecode_path = nil)
super
Expand Down Expand Up @@ -77,6 +75,7 @@ def callback(action, data, request)
callback('button-pressed', params[:duration], request)
end

# generic callback
%w(get post).each do |method|
send(method, "#{PREFIX}/:action.jsp") do
callback(params[:action], params, request)
Expand Down
2 changes: 1 addition & 1 deletion lib/nabaztag_hack_kit/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module NabaztagHackKit
VERSION = "0.0.3"
VERSION = "0.1.0"
end
4 changes: 2 additions & 2 deletions nabaztag_hack_kit.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ Gem::Specification.new do |s|

s.files = `git ls-files`.split("\n")
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
s.extensions = ['ext/mtl/extconf.rb']
s.executables = `git ls-files -- bytecode/bin/*`.split("\n").map{ |f| File.basename(f) }
s.extensions = ['bytecode/src/mtl/extconf.rb']
s.executables = ['mtl_comp', 'mtl_simu', 'mtl_merge']

s.require_paths = ["lib"]
Expand Down
Empty file added rec.wav
Empty file.

0 comments on commit 12bf5a4

Please sign in to comment.