nabaztag_hack_kit 0.1.0.alpha1 → 0.1.0.alpha2

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,6 +1,11 @@
1
1
  # A sample Gemfile
2
2
  source "http://rubygems.org"
3
3
 
4
- gem "foreman"
5
- gem "heroku"
4
+ gem "nabaztag_hack_kit", {
5
+ :path => "../../"
6
+ }
6
7
 
8
+ group :development do
9
+ gem "heroku"
10
+ gem "foreman"
11
+ end
@@ -2,7 +2,11 @@
2
2
 
3
3
  $LOAD_PATH.unshift ::File.expand_path(::File.dirname(__FILE__) + '/lib')
4
4
  require 'nabaztag_hack_kit/server'
5
+ require 'nabaztag_hack_kit/redirect'
6
+
7
+ $stdout.sync = true
5
8
 
6
9
  use Rack::Reloader, 0
10
+ use NabaztagHackKit::Redirect
7
11
 
8
12
  run NabaztagHackKit::Server.new
@@ -0,0 +1,33 @@
1
+ require 'open-uri'
2
+
3
+ module NabaztagHackKit
4
+ class Redirect
5
+ def initialize(app)
6
+ @app = app
7
+ end
8
+
9
+ def call(env)
10
+ path = env['PATH_INFO']
11
+ query = env['QUERY_STRING']
12
+ if path =~ /\/redirect/
13
+ req = Rack::Request.new(env)
14
+ if (to = req.params["to"]) && !to.empty?
15
+ @redirect = to
16
+ render "Redirect turned on to #{@redirect}"
17
+ else
18
+ @redirect = nil
19
+ render "Redirect turned off"
20
+ end
21
+ elsif @redirect
22
+ render open("#{@redirect}#{path}?#{query}")
23
+ else
24
+ @app.call(env)
25
+ end
26
+ end
27
+
28
+ private
29
+ def render(body)
30
+ [200, {"Content-Type" => "text/html"}, Array(body)]
31
+ end
32
+ end
33
+ end
@@ -1,3 +1,3 @@
1
1
  module NabaztagHackKit
2
- VERSION = "0.1.0.alpha1"
2
+ VERSION = "0.1.0.alpha2"
3
3
  end
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.alpha1
4
+ version: 0.1.0.alpha2
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-10 00:00:00.000000000Z
12
+ date: 2012-09-11 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: sinatra
16
- requirement: &70137719624480 !ruby/object:Gem::Requirement
16
+ requirement: &70237085758020 !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: *70137719624480
24
+ version_requirements: *70237085758020
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: rake
27
- requirement: &70137719623940 !ruby/object:Gem::Requirement
27
+ requirement: &70237085757480 !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: *70137719623940
35
+ version_requirements: *70237085757480
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: rspec
38
- requirement: &70137719623480 !ruby/object:Gem::Requirement
38
+ requirement: &70237085757020 !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: *70137719623480
46
+ version_requirements: *70237085757020
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: rack-test
49
- requirement: &70137719623020 !ruby/object:Gem::Requirement
49
+ requirement: &70237085756560 !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: *70137719623020
57
+ version_requirements: *70237085756560
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:
@@ -192,6 +192,7 @@ files:
192
192
  - lib/nabaztag_hack_kit/message/api.rb
193
193
  - lib/nabaztag_hack_kit/message/helper.rb
194
194
  - lib/nabaztag_hack_kit/public/index.html
195
+ - lib/nabaztag_hack_kit/redirect.rb
195
196
  - lib/nabaztag_hack_kit/server.rb
196
197
  - lib/nabaztag_hack_kit/version.rb
197
198
  - nabaztag_hack_kit.gemspec