deelay 0.2.6 → 0.2.7

Sign up to get free protection for your applications and to get access to all the features.
data/lib/deelay.rb CHANGED
@@ -1,3 +1,4 @@
1
1
  require "deelay/version"
2
2
  require "deelay/homepage"
3
- require "deelay/deelay_app"
3
+ require "deelay/delay"
4
+ require "deelay/app"
data/lib/deelay/app.rb ADDED
@@ -0,0 +1,14 @@
1
+ require_relative "delay.rb"
2
+ require "sinatra"
3
+
4
+ module Deelay
5
+ class App < Sinatra::Base
6
+ get '/:delay' do
7
+ redirect Deelay.delay(params[:delay], request.query_string)
8
+ end
9
+
10
+ error do
11
+ redirect "#{Deelay::HOMEPAGE}/error"
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,13 @@
1
+ require "uri"
2
+
3
+ module Deelay
4
+ def self.delay(delay, url)
5
+ sleep_time = delay.to_i
6
+ resource_url = URI.unescape(url)
7
+
8
+ raise "Invalid URL" if (URI::regexp =~ resource_url).nil?
9
+
10
+ sleep(sleep_time / 1000)
11
+ return resource_url
12
+ end
13
+ end
File without changes
@@ -1,3 +1,3 @@
1
1
  module Deelay
2
- VERSION = "0.2.6"
2
+ VERSION = "0.2.7"
3
3
  end
@@ -4,11 +4,11 @@ require 'rack/test'
4
4
 
5
5
  Sinatra::Base.set :environment, :test
6
6
 
7
- describe "DeelayApp" do
7
+ describe "Deelay::App" do
8
8
  include Rack::Test::Methods
9
9
 
10
10
  def app
11
- Deelay::DeelayApp
11
+ Deelay::App
12
12
  end
13
13
 
14
14
  context "when url invalid" do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: deelay
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.6
4
+ version: 0.2.7
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-11-23 00:00:00.000000000 Z
12
+ date: 2013-02-28 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rake
@@ -42,7 +42,8 @@ files:
42
42
  - bin/deelay
43
43
  - deelay.gemspec
44
44
  - lib/deelay.rb
45
- - lib/deelay/deelay_app.rb
45
+ - lib/deelay/app.rb
46
+ - lib/deelay/delay.rb
46
47
  - lib/deelay/homepage.rb
47
48
  - lib/deelay/version.rb
48
49
  - spec/deelay_app_spec.rb
@@ -58,12 +59,18 @@ required_ruby_version: !ruby/object:Gem::Requirement
58
59
  - - ! '>='
59
60
  - !ruby/object:Gem::Version
60
61
  version: '0'
62
+ segments:
63
+ - 0
64
+ hash: -1122285937117374849
61
65
  required_rubygems_version: !ruby/object:Gem::Requirement
62
66
  none: false
63
67
  requirements:
64
68
  - - ! '>='
65
69
  - !ruby/object:Gem::Version
66
70
  version: '0'
71
+ segments:
72
+ - 0
73
+ hash: -1122285937117374849
67
74
  requirements: []
68
75
  rubyforge_project: deelay
69
76
  rubygems_version: 1.8.24
@@ -1,22 +0,0 @@
1
- require "sinatra"
2
- require "uri"
3
-
4
- module Deelay
5
- class DeelayApp < Sinatra::Base
6
-
7
- get '/:delay' do
8
- delay = params[:delay].to_i
9
- url = URI.unescape(request.query_string)
10
-
11
- raise "Invalid URL" if (URI::regexp =~ url).nil?
12
-
13
- sleep(delay / 1000)
14
- redirect url
15
- end
16
-
17
- error do
18
- redirect "#{Deelay::HOMEPAGE}/error"
19
- end
20
-
21
- end
22
- end