queue_it 0.0.1 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/README.md +59 -5
- data/lib/queue_it/queueable.rb +16 -5
- data/lib/queue_it/version.rb +1 -1
- data/queue_it.gemspec +2 -0
- metadata +23 -15
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 80302e4595250a93745ae5cdde295cc1ef9c4dfe
|
4
|
+
data.tar.gz: 98f55674bca1f8d64ea1ea35b3cc0f9f14096cd5
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 734e01bc853574e3e963c60212debdc7ce9ea33e87cdb2d6b9619d7aecef8de31994a8aa7c2559935478ee0bae6a8825ecdcce1b3cc0ea90169ede943c798535
|
7
|
+
data.tar.gz: f86d410b4b320462e8aaa82c702ac1c1ef6eb700ec00117f212e9b2a132ef51d825cc734d52445544e7ccb4e9b21eb6c6766c806d2ba1e22e8696d4bb4c1755e
|
data/README.md
CHANGED
@@ -1,24 +1,78 @@
|
|
1
1
|
# QueueIt
|
2
2
|
|
3
|
-
|
3
|
+
This is a gem for integrating Ruby on Rails with Queue-it that is an online queuing system, https://queue-it.com/
|
4
4
|
|
5
5
|
## Installation
|
6
6
|
|
7
7
|
Add this line to your application's Gemfile:
|
8
8
|
|
9
|
-
|
9
|
+
```ruby
|
10
|
+
gem 'queue_it'
|
11
|
+
```
|
10
12
|
|
11
13
|
And then execute:
|
12
14
|
|
13
|
-
|
15
|
+
```
|
16
|
+
$ bundle
|
17
|
+
```
|
14
18
|
|
15
19
|
Or install it yourself as:
|
16
20
|
|
17
|
-
|
21
|
+
```
|
22
|
+
$ gem install queue_it
|
23
|
+
```
|
18
24
|
|
19
25
|
## Usage
|
20
26
|
|
21
|
-
|
27
|
+
We are using Queue-it on http://billetto.co.ok, and we create our queued events like this:
|
28
|
+
|
29
|
+
```ruby
|
30
|
+
event = create(:event,
|
31
|
+
:queue_it_enabled => true,
|
32
|
+
:queue_it_customer_id => 'billettodk',
|
33
|
+
:queue_it_event_id => 'rainmaking',
|
34
|
+
:queue_it_known_user_secret_key => 'asdfbmnwqeklrj'
|
35
|
+
)
|
36
|
+
```
|
37
|
+
|
38
|
+
In our Event-model, we determine whether or not its queue-enabled:
|
39
|
+
|
40
|
+
```ruby
|
41
|
+
class Event < ActiveRecord::Base
|
42
|
+
def queue_enabled?
|
43
|
+
queue_it_enabled? &&
|
44
|
+
queue_it_customer_id.present? &&
|
45
|
+
queue_it_event_id.present? &&
|
46
|
+
queue_it_known_user_secret_key.present?
|
47
|
+
end
|
48
|
+
end
|
49
|
+
```
|
50
|
+
|
51
|
+
For us, our precious actions are all about tickets, so we protect these actions like this:
|
52
|
+
|
53
|
+
```ruby
|
54
|
+
class EventsController < ApplicationController
|
55
|
+
include QueueIt::Queueable
|
56
|
+
|
57
|
+
def tickets
|
58
|
+
event = Event.find(params[:id])
|
59
|
+
|
60
|
+
if event.queue_enabled?
|
61
|
+
protect_with_queue!(event.queue_it_known_user_secret_key,
|
62
|
+
event.queue_it_event_id,
|
63
|
+
event.queue_it_customer_id)
|
64
|
+
# We use performed to see if our queue protection have rendered something,
|
65
|
+
# if it has rendered stop all other execution
|
66
|
+
return if performed?
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
def receipt
|
71
|
+
# The user has bought his/her tickets, push them out of the queue
|
72
|
+
destroy_all_queue_it_sessions
|
73
|
+
end
|
74
|
+
end
|
75
|
+
```
|
22
76
|
|
23
77
|
## Contributing
|
24
78
|
|
data/lib/queue_it/queueable.rb
CHANGED
@@ -3,6 +3,14 @@ module QueueIt
|
|
3
3
|
extend ActiveSupport::Concern
|
4
4
|
|
5
5
|
included do
|
6
|
+
def protect_with_queue!(known_user_secret_key, event_id, customer_id)
|
7
|
+
create_or_verify_queue_it_session(known_user_secret_key,
|
8
|
+
event_id,
|
9
|
+
customer_id,
|
10
|
+
request.url,
|
11
|
+
params)
|
12
|
+
end
|
13
|
+
|
6
14
|
def queue_it_queue_id(event_id)
|
7
15
|
session[queue_it_session_variable(event_id)].to_i
|
8
16
|
end
|
@@ -16,6 +24,12 @@ module QueueIt
|
|
16
24
|
session.delete(queue_it_session_variable(event_id))
|
17
25
|
end
|
18
26
|
|
27
|
+
def queue_it_session_variable(event_id)
|
28
|
+
"KnownQueueItUser-#{event_id}"
|
29
|
+
end
|
30
|
+
|
31
|
+
private
|
32
|
+
|
19
33
|
def create_or_verify_queue_it_session(secret_key, event_id, customer_id, request_url, params)
|
20
34
|
# If there exists a session, we return. This needs to be refactored when we start to look at the timestamp parameter
|
21
35
|
return if session[queue_it_session_variable(event_id)].present?
|
@@ -31,16 +45,13 @@ module QueueIt
|
|
31
45
|
end
|
32
46
|
rescue QueueIt::MissingArgsGiven
|
33
47
|
queue_url = QueueIt::UrlBuilder.build_queue_url(customer_id, event_id)
|
48
|
+
destroy_all_queue_it_sessions
|
34
49
|
render("queue_it/enter_queue", layout: false, locals: { queue_it_url: queue_url }) and return
|
35
50
|
rescue QueueIt::NotAuthorized
|
36
51
|
queue_cancel_url = QueueIt::UrlBuilder.build_cancel_url(customer_id, event_id)
|
52
|
+
destroy_all_queue_it_sessions
|
37
53
|
render("queue_it/cheating_queue", layout: false, locals: { queue_it_url: queue_cancel_url }) and return
|
38
54
|
end
|
39
|
-
|
40
|
-
end
|
41
|
-
|
42
|
-
def queue_it_session_variable(event_id)
|
43
|
-
"KnownQueueItUser-#{event_id}"
|
44
55
|
end
|
45
56
|
|
46
57
|
end
|
data/lib/queue_it/version.rb
CHANGED
data/queue_it.gemspec
CHANGED
@@ -18,6 +18,8 @@ Gem::Specification.new do |spec|
|
|
18
18
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
19
|
spec.require_paths = ["lib"]
|
20
20
|
|
21
|
+
spec.add_runtime_dependency 'addressable'
|
22
|
+
|
21
23
|
spec.add_development_dependency "bundler", "~> 1.3"
|
22
24
|
spec.add_development_dependency "rake"
|
23
25
|
end
|
metadata
CHANGED
@@ -1,20 +1,32 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: queue_it
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
5
|
-
prerelease:
|
4
|
+
version: 1.0.0
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Kasper Grubbe
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date: 2014-
|
11
|
+
date: 2014-11-06 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: addressable
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - '>='
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - '>='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
14
27
|
- !ruby/object:Gem::Dependency
|
15
28
|
name: bundler
|
16
29
|
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
30
|
requirements:
|
19
31
|
- - ~>
|
20
32
|
- !ruby/object:Gem::Version
|
@@ -22,7 +34,6 @@ dependencies:
|
|
22
34
|
type: :development
|
23
35
|
prerelease: false
|
24
36
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
37
|
requirements:
|
27
38
|
- - ~>
|
28
39
|
- !ruby/object:Gem::Version
|
@@ -30,17 +41,15 @@ dependencies:
|
|
30
41
|
- !ruby/object:Gem::Dependency
|
31
42
|
name: rake
|
32
43
|
requirement: !ruby/object:Gem::Requirement
|
33
|
-
none: false
|
34
44
|
requirements:
|
35
|
-
- -
|
45
|
+
- - '>='
|
36
46
|
- !ruby/object:Gem::Version
|
37
47
|
version: '0'
|
38
48
|
type: :development
|
39
49
|
prerelease: false
|
40
50
|
version_requirements: !ruby/object:Gem::Requirement
|
41
|
-
none: false
|
42
51
|
requirements:
|
43
|
-
- -
|
52
|
+
- - '>='
|
44
53
|
- !ruby/object:Gem::Version
|
45
54
|
version: '0'
|
46
55
|
description: Gem to handle the implementation of http://queue-it.net!
|
@@ -67,26 +76,25 @@ files:
|
|
67
76
|
homepage: https://github.com/gfish/queue_it
|
68
77
|
licenses:
|
69
78
|
- GNU/GPLv3
|
79
|
+
metadata: {}
|
70
80
|
post_install_message:
|
71
81
|
rdoc_options: []
|
72
82
|
require_paths:
|
73
83
|
- lib
|
74
84
|
required_ruby_version: !ruby/object:Gem::Requirement
|
75
|
-
none: false
|
76
85
|
requirements:
|
77
|
-
- -
|
86
|
+
- - '>='
|
78
87
|
- !ruby/object:Gem::Version
|
79
88
|
version: '0'
|
80
89
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
81
|
-
none: false
|
82
90
|
requirements:
|
83
|
-
- -
|
91
|
+
- - '>='
|
84
92
|
- !ruby/object:Gem::Version
|
85
93
|
version: '0'
|
86
94
|
requirements: []
|
87
95
|
rubyforge_project:
|
88
|
-
rubygems_version:
|
96
|
+
rubygems_version: 2.0.14
|
89
97
|
signing_key:
|
90
|
-
specification_version:
|
98
|
+
specification_version: 4
|
91
99
|
summary: Gem to handle the implementation of http://queue-it.net
|
92
100
|
test_files: []
|