nabaztag_hack_kit 0.1.0.alpha3 → 0.1.0.alpha4

Sign up to get free protection for your applications and to get access to all the features.
@@ -3,3 +3,8 @@ source "http://rubygems.org"
3
3
 
4
4
  gem "nabaztag_hack_kit"
5
5
  gem "ruby-echonest"
6
+
7
+ group :development do
8
+ gem "heroku"
9
+ gem "foreman"
10
+ end
@@ -6,7 +6,7 @@ require "echonest"
6
6
  class Server < NabaztagHackKit::Server
7
7
 
8
8
  def initialize(echonest_cfg, soundcloud_cfg)
9
- super('bytecode.bin')
9
+ super
10
10
  @@echonest = Echonest(echonest_cfg[:key])
11
11
  @@soundcloud = Soundcloud.new(soundcloud_cfg)
12
12
  end
@@ -11,12 +11,15 @@ module NabaztagHackKit
11
11
  enable :logging
12
12
  end
13
13
 
14
+ # set :public_folder, File.dirname(__FILE__) + '../public'
15
+
14
16
  REC_FILE = "rec.wav"
15
17
  PREFIX = "/api/:bunnyid"
16
18
 
17
- def initialize(bytecode_path = nil)
19
+ def initialize(opts = {})
18
20
  super
19
- @bytecode_path = bytecode_path || public_file('bytecode.bin')
21
+ @base_file = opts.fetch(:base_file, __FILE__)
22
+ @bytecode_file = opts.fetch(:bytecode_file, public_file('bytecode.bin'))
20
23
  end
21
24
 
22
25
  class << self
@@ -60,8 +63,12 @@ module NabaztagHackKit
60
63
  end
61
64
 
62
65
  get "/bc.jsp" do
63
- logger.info "Serving Bytecode from #{@bytecode_path}"
64
- send_file @bytecode_path
66
+ if File.exists?(@bytecode_file)
67
+ logger.info "Serving Bytecode from #{@bytecode_file}"
68
+ send_file @bytecode_file
69
+ else
70
+ status 404
71
+ end
65
72
  end
66
73
 
67
74
  post "#{PREFIX}/log.jsp" do
@@ -90,7 +97,11 @@ module NabaztagHackKit
90
97
  end
91
98
 
92
99
  get "/streams/:file.mp3" do
93
- File.read public_file("#{params[:file]}.mp3")
100
+ if (file = public_file("#{params[:file]}.mp3")) && File.exists?(file)
101
+ File.read file
102
+ else
103
+ status 404
104
+ end
94
105
  end
95
106
 
96
107
  # generic callback
@@ -108,7 +119,7 @@ module NabaztagHackKit
108
119
 
109
120
  protected
110
121
  def public_file(name)
111
- File.expand_path(File.join('..', 'public', name), __FILE__)
122
+ File.expand_path(File.join('..', 'public', name), @base_file)
112
123
  end
113
124
  end
114
125
  end
@@ -1,3 +1,3 @@
1
1
  module NabaztagHackKit
2
- VERSION = "0.1.0.alpha3"
2
+ VERSION = "0.1.0.alpha4"
3
3
  end
@@ -13,7 +13,7 @@ end
13
13
  describe NabaztagHackKit::Server do
14
14
  include Rack::Test::Methods
15
15
 
16
- let(:app) { NabaztagHackKit::Server.new }
16
+ let(:app) { NabaztagHackKit::Server.new(:bytecode_file => __FILE__) }
17
17
 
18
18
  describe "/bc.jsp" do
19
19
  let(:route) { "/bc.jsp" }
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nabaztag_hack_kit
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0.alpha3
4
+ version: 0.1.0.alpha4
5
5
  prerelease: 6
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bytecode/bin
11
11
  cert_chain: []
12
- date: 2012-09-20 00:00:00.000000000Z
12
+ date: 2012-09-21 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: sinatra
16
- requirement: &70172330100880 !ruby/object:Gem::Requirement
16
+ requirement: &70133294055600 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70172330100880
24
+ version_requirements: *70133294055600
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: rake
27
- requirement: &70172330100340 !ruby/object:Gem::Requirement
27
+ requirement: &70133294055060 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '0'
33
33
  type: :development
34
34
  prerelease: false
35
- version_requirements: *70172330100340
35
+ version_requirements: *70133294055060
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: rspec
38
- requirement: &70172330099880 !ruby/object:Gem::Requirement
38
+ requirement: &70133294054600 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: '0'
44
44
  type: :development
45
45
  prerelease: false
46
- version_requirements: *70172330099880
46
+ version_requirements: *70133294054600
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: rack-test
49
- requirement: &70172330099420 !ruby/object:Gem::Requirement
49
+ requirement: &70133294054140 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ! '>='
@@ -54,7 +54,7 @@ dependencies:
54
54
  version: '0'
55
55
  type: :development
56
56
  prerelease: false
57
- version_requirements: *70172330099420
57
+ version_requirements: *70133294054140
58
58
  description: Sinatra server api framework to run custom bytecode on Nabaztag v1/v2.
59
59
  Sources + Compiler included (linux only)
60
60
  email: