rammer 1.1.2 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/Gemfile +27 -0
- data/MODULE_FILES +34 -0
- data/README.md +17 -5
- data/Rakefile +37 -0
- data/bin/rammer +2 -3
- data/bin/viber +37 -38
- data/lib/modules/authentication/authentication_apis.rb +64 -0
- data/lib/modules/authorization/authorization_apis.rb +89 -0
- data/lib/modules/common/Gemfile +43 -0
- data/lib/{template → modules/common}/Gemfile.lock +0 -0
- data/lib/{template → modules/common}/Procfile +0 -0
- data/lib/{template → modules/common}/Rakefile +27 -0
- data/lib/modules/common/application.rb +48 -0
- data/lib/{template → modules/common}/database.yml +1 -1
- data/lib/modules/common/server.rb +38 -0
- data/lib/modules/common/tree.rb +30 -0
- data/lib/{template → modules/migrations}/01_create_users.rb +27 -0
- data/lib/modules/migrations/02_create_sessions.rb +36 -0
- data/lib/modules/migrations/03_create_owners.rb +40 -0
- data/lib/modules/migrations/04_create_oauth2_authorizations.rb +50 -0
- data/lib/modules/migrations/05_create_oauth2_clients.rb +45 -0
- data/lib/modules/models/oauth2_authorization.rb +203 -0
- data/lib/modules/models/oauth2_client.rb +216 -0
- data/lib/modules/models/owner.rb +65 -0
- data/lib/modules/models/session.rb +30 -0
- data/lib/modules/models/user.rb +135 -0
- data/lib/modules/oauth/oauth_apis.rb +92 -0
- data/lib/rammer/module_generator.rb +236 -0
- data/lib/rammer/rammer_generator.rb +160 -0
- data/lib/rammer/version.rb +28 -1
- data/lib/rammer.rb +24 -278
- data/rammer.gemspec +37 -24
- data/test/helper.rb +49 -0
- data/test/test_rammer_root_structure.rb +80 -0
- data/test/test_viber_module_plugin.rb +104 -0
- data/test/test_viber_module_unplug.rb +87 -0
- metadata +77 -29
- data/lib/template/02_create_sessions.rb +0 -9
- data/lib/template/03_create_owners.rb +0 -13
- data/lib/template/04_create_oauth2_authorizations.rb +0 -23
- data/lib/template/05_create_oauth2_clients.rb +0 -18
- data/lib/template/Gemfile +0 -16
- data/lib/template/application.rb +0 -21
- data/lib/template/authentication_apis.rb +0 -35
- data/lib/template/authorization_apis.rb +0 -59
- data/lib/template/oauth2_authorization.rb +0 -113
- data/lib/template/oauth2_client.rb +0 -100
- data/lib/template/oauth_apis.rb +0 -138
- data/lib/template/owner.rb +0 -10
- data/lib/template/server.rb +0 -11
- data/lib/template/session.rb +0 -3
- data/lib/template/tree.rb +0 -3
- data/lib/template/user.rb +0 -78
data/Gemfile
CHANGED
@@ -1,3 +1,30 @@
|
|
1
|
+
=begin
|
2
|
+
**************************************************************************
|
3
|
+
* The MIT License (MIT)
|
4
|
+
|
5
|
+
* Copyright (c) 2013-2014 QBurst Technologies Inc.
|
6
|
+
|
7
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
8
|
+
* of this software and associated documentation files (the "Software"), to deal
|
9
|
+
* in the Software without restriction, including without limitation the rights
|
10
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
11
|
+
* copies of the Software, and to permit persons to whom the Software is
|
12
|
+
* furnished to do so, subject to the following conditions:
|
13
|
+
|
14
|
+
* The above copyright notice and this permission notice shall be included in
|
15
|
+
* all copies or substantial portions of the Software.
|
16
|
+
|
17
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
18
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
19
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
20
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
21
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
22
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
23
|
+
* THE SOFTWARE.
|
24
|
+
|
25
|
+
**************************************************************************
|
26
|
+
=end
|
27
|
+
|
1
28
|
source 'https://rubygems.org'
|
2
29
|
|
3
30
|
# Specify your gem's dependencies in rammer.gemspec
|
data/MODULE_FILES
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
lib/rammer.rb
|
2
|
+
lib/rammer/version.rb
|
3
|
+
lib/rammer/rammer_generator.rb
|
4
|
+
lib/rammer/module_generator.rb
|
5
|
+
lib/modules/migrations/01_create_users.rb
|
6
|
+
lib/modules/migrations/02_create_sessions.rb
|
7
|
+
lib/modules/migrations/03_create_owners.rb
|
8
|
+
lib/modules/migrations/04_create_oauth2_authorizations.rb
|
9
|
+
lib/modules/migrations/05_create_oauth2_clients.rb
|
10
|
+
lib/modules/common/Gemfile
|
11
|
+
lib/modules/common/Gemfile.lock
|
12
|
+
lib/modules/common/Procfile
|
13
|
+
lib/modules/common/Rakefile
|
14
|
+
lib/modules/common/application.rb
|
15
|
+
lib/modules/authentication/authentication_apis.rb
|
16
|
+
lib/modules/authorization/authorization_apis.rb
|
17
|
+
lib/modules/common/database.yml
|
18
|
+
lib/modules/models/oauth2_authorization.rb
|
19
|
+
lib/modules/models/oauth2_client.rb
|
20
|
+
lib/modules/oauth/oauth_apis.rb
|
21
|
+
lib/modules/models/owner.rb
|
22
|
+
lib/modules/common/server.rb
|
23
|
+
lib/modules/models/session.rb
|
24
|
+
lib/modules/common/tree.rb
|
25
|
+
lib/modules/models/user.rb
|
26
|
+
test/helper.rb
|
27
|
+
test/test_rammer_root_structure.rb
|
28
|
+
test/test_viber_module_plugin.rb
|
29
|
+
test/test_viber_module_unplug.rb
|
30
|
+
Gemfile
|
31
|
+
LICENSE.txt
|
32
|
+
README.md
|
33
|
+
Rakefile
|
34
|
+
rammer.gemspec
|
data/README.md
CHANGED
@@ -1,4 +1,6 @@
|
|
1
|
-
|
1
|
+
<img height="100" width="250" src="https://raw.github.com/qburstruby/rammer/master/rammer_logo.png">
|
2
|
+
|
3
|
+
[](http://badge.fury.io/rb/rammer) [](https://travis-ci.org/qburstruby/rammer-2.0.0)
|
2
4
|
|
3
5
|
Rammer is a framework dedicated to build high performance Async API servers on top of non-blocking (asynchronous) Ruby web server called Goliath. Rammer APIs are designed on top of REST-like API micro-framework Grape. Rammer is modular and integrates a powerful CLI called Viber to plug in and out its modules.
|
4
6
|
|
@@ -30,20 +32,27 @@ MODULE_NAME :
|
|
30
32
|
|
31
33
|
Endpoints enabled with respective module:
|
32
34
|
|
33
|
-
|
35
|
+
Authentication
|
34
36
|
* sign_up : "Enables user authentication using email, MD5 password and redirect url returning session token."
|
35
37
|
|
36
|
-
|
38
|
+
Authorization
|
37
39
|
* sign_in : "Enables user login using credentials returning session token."
|
38
40
|
* sign_out : "Enables user logout using credentials by invalidating the session token."
|
39
41
|
|
40
|
-
|
41
|
-
*
|
42
|
+
Oauth
|
43
|
+
* authenticate : "Registers ouath client using credentials returning client details like ID, Secret hash, authorization code."
|
44
|
+
* request_token : "Returns a request token which is further used for access token generation."
|
42
45
|
* authorize : "Enables functionality for activating authorization page access."
|
43
46
|
* access_token : "Returns oauth access token for registered clients to authorized users."
|
44
47
|
* token : "Returns bearer token to registered third party clients."
|
45
48
|
* invalidate_token : "Invalidated the issued bearer token."
|
46
49
|
|
50
|
+
## Wiki Link
|
51
|
+
|
52
|
+
For further details visit our wiki link :
|
53
|
+
|
54
|
+
https://github.com/qburstruby/rammer-2.0.0/wiki
|
55
|
+
|
47
56
|
## Contributors
|
48
57
|
|
49
58
|
This list is open to all. You are all welcome :).
|
@@ -51,6 +60,9 @@ This list is open to all. You are all welcome :).
|
|
51
60
|
* manishaharidas (Manisha Haridas) -
|
52
61
|
* Github: https://github.com/manishaharidas
|
53
62
|
|
63
|
+
* qburstruby (QBurst Ruby Team) -
|
64
|
+
* Github: https://github.com/qburstruby
|
65
|
+
|
54
66
|
## Comments/Requests
|
55
67
|
|
56
68
|
If anyone has comments or questions please let me know (qbruby@qburst.com).
|
data/Rakefile
CHANGED
@@ -1 +1,38 @@
|
|
1
|
+
=begin
|
2
|
+
**************************************************************************
|
3
|
+
* The MIT License (MIT)
|
4
|
+
|
5
|
+
* Copyright (c) 2013-2014 QBurst Technologies Inc.
|
6
|
+
|
7
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
8
|
+
* of this software and associated documentation files (the "Software"), to deal
|
9
|
+
* in the Software without restriction, including without limitation the rights
|
10
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
11
|
+
* copies of the Software, and to permit persons to whom the Software is
|
12
|
+
* furnished to do so, subject to the following conditions:
|
13
|
+
|
14
|
+
* The above copyright notice and this permission notice shall be included in
|
15
|
+
* all copies or substantial portions of the Software.
|
16
|
+
|
17
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
18
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
19
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
20
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
21
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
22
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
23
|
+
* THE SOFTWARE.
|
24
|
+
|
25
|
+
**************************************************************************
|
26
|
+
=end
|
27
|
+
|
1
28
|
require "bundler/gem_tasks"
|
29
|
+
|
30
|
+
require 'rake/testtask'
|
31
|
+
Rake::TestTask.new(:test) do |test|
|
32
|
+
test.test_files = FileList.new('test/**/test_*.rb') do |list|
|
33
|
+
list.exclude 'test/test_helper.rb'
|
34
|
+
list.exclude 'test/fixtures/**/*.rb'
|
35
|
+
end
|
36
|
+
test.libs << 'test'
|
37
|
+
test.verbose = true
|
38
|
+
end
|
data/bin/rammer
CHANGED
data/bin/viber
CHANGED
@@ -1,20 +1,19 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
-
|
3
2
|
require 'rammer'
|
4
3
|
|
5
4
|
def parse_options
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
5
|
+
case ARGV[1]
|
6
|
+
when "-p", "-plugin"
|
7
|
+
return true
|
8
|
+
when "-u", "-unplug"
|
9
|
+
return true
|
10
|
+
else
|
11
|
+
return false
|
12
|
+
end
|
14
13
|
end
|
15
14
|
|
16
15
|
def options_message
|
17
|
-
STDOUT.puts <<-EOF
|
16
|
+
STDOUT.puts <<-EOF
|
18
17
|
Please include module name
|
19
18
|
|
20
19
|
Usage:
|
@@ -28,38 +27,38 @@ EOF
|
|
28
27
|
end
|
29
28
|
|
30
29
|
def execute(module_name,action)
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
30
|
+
target_dir = Dir.pwd.split('/',Dir.pwd.count('/')+1).last
|
31
|
+
name = target_dir.split('_').map(&:capitalize)*''
|
32
|
+
case module_name
|
33
|
+
when "authentication"
|
34
|
+
module_class = "::#{name}::AuthenticationApis"
|
35
|
+
when "authorization"
|
36
|
+
module_class = "::#{name}::AuthorizationApis"
|
37
|
+
when "oauth"
|
38
|
+
module_class = "::#{name}::OauthApis"
|
39
|
+
end
|
40
|
+
options = { :project_name => target_dir, :module_class => module_class,
|
41
|
+
:module_name => module_name, :action => action}
|
42
|
+
module_generator = Rammer::ModuleGenerator.new(options)
|
43
|
+
module_generator.run
|
45
44
|
end
|
46
45
|
|
47
46
|
case ARGV[0]
|
48
47
|
when "module"
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
else
|
58
|
-
options_message
|
59
|
-
exit
|
60
|
-
end
|
48
|
+
if parse_options
|
49
|
+
case ARGV[2]
|
50
|
+
when "authentication"
|
51
|
+
execute("authentication",ARGV[1])
|
52
|
+
when "authorization"
|
53
|
+
execute("authorization",ARGV[1])
|
54
|
+
when "oauth"
|
55
|
+
execute("oauth",ARGV[1])
|
61
56
|
else
|
62
|
-
|
57
|
+
options_message
|
58
|
+
exit
|
59
|
+
end
|
60
|
+
else
|
61
|
+
STDOUT.puts <<-EOF
|
63
62
|
Please provide command options
|
64
63
|
|
65
64
|
Usage:
|
@@ -69,5 +68,5 @@ Usage:
|
|
69
68
|
-p,-plugin :Plugs in rammer specified modules.
|
70
69
|
-u,-unplug :Unplugs rammer specified modules.
|
71
70
|
EOF
|
72
|
-
|
71
|
+
end
|
73
72
|
end
|
@@ -0,0 +1,64 @@
|
|
1
|
+
=begin
|
2
|
+
**************************************************************************
|
3
|
+
* The MIT License (MIT)
|
4
|
+
|
5
|
+
* Copyright (c) 2013-2014 QBurst Technologies Inc.
|
6
|
+
|
7
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
8
|
+
* of this software and associated documentation files (the "Software"), to deal
|
9
|
+
* in the Software without restriction, including without limitation the rights
|
10
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
11
|
+
* copies of the Software, and to permit persons to whom the Software is
|
12
|
+
* furnished to do so, subject to the following conditions:
|
13
|
+
|
14
|
+
* The above copyright notice and this permission notice shall be included in
|
15
|
+
* all copies or substantial portions of the Software.
|
16
|
+
|
17
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
18
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
19
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
20
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
21
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
22
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
23
|
+
* THE SOFTWARE.
|
24
|
+
|
25
|
+
**************************************************************************
|
26
|
+
=end
|
27
|
+
|
28
|
+
require 'oauth2'
|
29
|
+
require 'songkick/oauth2/provider'
|
30
|
+
require 'ruby_regex'
|
31
|
+
|
32
|
+
module Rammer
|
33
|
+
|
34
|
+
class AuthenticationApis < Grape::API
|
35
|
+
Songkick::OAuth2::Provider.realm = 'PocketAPI Oauth Server'
|
36
|
+
version 'v1', :using => :path
|
37
|
+
format :json
|
38
|
+
|
39
|
+
=begin
|
40
|
+
This web service enables pockit server user sign up process with request parameters:
|
41
|
+
{"email"=> User email,
|
42
|
+
"password" => MD5 hash encrypted password,
|
43
|
+
"redirect_uri" => Callback url for this api call.
|
44
|
+
}
|
45
|
+
=end
|
46
|
+
[:get, :post].each do |method|
|
47
|
+
__send__ method, '/authentication/sign_up' do
|
48
|
+
if User.validate_params?(params,"sign_up")
|
49
|
+
@existing_user = User.find_by_email(params.email)
|
50
|
+
unless @existing_user
|
51
|
+
@user, @session = User.sign_up(params)
|
52
|
+
redirect @user.redirect_url(params,@session)
|
53
|
+
else
|
54
|
+
error = "User already exists."
|
55
|
+
Oauth2Authorization.error_response(error)
|
56
|
+
end
|
57
|
+
else
|
58
|
+
error = "Parameters missing or invalid."
|
59
|
+
Oauth2Authorization.error_response(error)
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
@@ -0,0 +1,89 @@
|
|
1
|
+
=begin
|
2
|
+
**************************************************************************
|
3
|
+
* The MIT License (MIT)
|
4
|
+
|
5
|
+
* Copyright (c) 2013-2014 QBurst Technologies Inc.
|
6
|
+
|
7
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
8
|
+
* of this software and associated documentation files (the "Software"), to deal
|
9
|
+
* in the Software without restriction, including without limitation the rights
|
10
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
11
|
+
* copies of the Software, and to permit persons to whom the Software is
|
12
|
+
* furnished to do so, subject to the following conditions:
|
13
|
+
|
14
|
+
* The above copyright notice and this permission notice shall be included in
|
15
|
+
* all copies or substantial portions of the Software.
|
16
|
+
|
17
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
18
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
19
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
20
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
21
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
22
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
23
|
+
* THE SOFTWARE.
|
24
|
+
|
25
|
+
**************************************************************************
|
26
|
+
=end
|
27
|
+
|
28
|
+
require 'oauth2'
|
29
|
+
require 'songkick/oauth2/provider'
|
30
|
+
require 'ruby_regex'
|
31
|
+
|
32
|
+
module Rammer
|
33
|
+
|
34
|
+
class AuthorizationApis < Grape::API
|
35
|
+
Songkick::OAuth2::Provider.realm = 'PocketAPI Oauth Server'
|
36
|
+
version 'v1', :using => :path
|
37
|
+
format :json
|
38
|
+
|
39
|
+
=begin
|
40
|
+
This web service enables pockit server user sign up process with request parameters:
|
41
|
+
{"email"=> User email,
|
42
|
+
"password" => MD5 hash encrypted password,
|
43
|
+
"redirect_uri" => Callback url for this api call.
|
44
|
+
}
|
45
|
+
=end
|
46
|
+
[:get, :post].each do |method|
|
47
|
+
__send__ method, '/authorization/sign_in' do
|
48
|
+
if User.validate_params?(params,"sign_in")
|
49
|
+
@authroized_user = User.find_by_email_and_encrypted_password(params.email,params.password)
|
50
|
+
if @authroized_user
|
51
|
+
@session = @authroized_user.sign_in(params)
|
52
|
+
redirect @authroized_user.redirect_url(params,@session)
|
53
|
+
else
|
54
|
+
error = "Not a registered user."
|
55
|
+
Oauth2Authorization.error_response(error)
|
56
|
+
end
|
57
|
+
else
|
58
|
+
error = "Parameters missing or invalid."
|
59
|
+
Oauth2Authorization.error_response(error)
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
=begin
|
65
|
+
This web service enables pockit server user sign up process with request parameters:
|
66
|
+
{"email"=> User email,
|
67
|
+
"session_token" => Session token obtained during sign in,
|
68
|
+
"redirect_uri" => Callback url for this api call.
|
69
|
+
}
|
70
|
+
=end
|
71
|
+
[:get, :post].each do |method|
|
72
|
+
__send__ method, '/authorization/sign_out' do
|
73
|
+
if User.validate_params?(params,"sign_out")
|
74
|
+
@authroized_user = User.find_by_email(params.email)
|
75
|
+
if @authroized_user && @authroized_user.signed_in?(params)
|
76
|
+
@authroized_user.sign_out(params)
|
77
|
+
redirect params.redirect_uri
|
78
|
+
else
|
79
|
+
error = "Invalid user or already signed out."
|
80
|
+
Oauth2Authorization.error_response(error)
|
81
|
+
end
|
82
|
+
else
|
83
|
+
error = "Parameters missing or invalid."
|
84
|
+
Oauth2Authorization.error_response(error)
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
=begin
|
2
|
+
**************************************************************************
|
3
|
+
* The MIT License (MIT)
|
4
|
+
|
5
|
+
* Copyright (c) 2013-2014 QBurst Technologies Inc.
|
6
|
+
|
7
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
8
|
+
* of this software and associated documentation files (the "Software"), to deal
|
9
|
+
* in the Software without restriction, including without limitation the rights
|
10
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
11
|
+
* copies of the Software, and to permit persons to whom the Software is
|
12
|
+
* furnished to do so, subject to the following conditions:
|
13
|
+
|
14
|
+
* The above copyright notice and this permission notice shall be included in
|
15
|
+
* all copies or substantial portions of the Software.
|
16
|
+
|
17
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
18
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
19
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
20
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
21
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
22
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
23
|
+
* THE SOFTWARE.
|
24
|
+
|
25
|
+
**************************************************************************
|
26
|
+
=end
|
27
|
+
|
28
|
+
source "http://rubygems.org"
|
29
|
+
|
30
|
+
|
31
|
+
gem 'pg'
|
32
|
+
gem 'em-postgresql-adapter', :git => 'git://github.com/leftbee/em-postgresql-adapter.git'
|
33
|
+
gem 'rack-fiber_pool', :require => 'rack/fiber_pool'
|
34
|
+
gem 'em-synchrony', :git => 'git://github.com/igrigorik/em-synchrony.git',
|
35
|
+
:require => ['em-synchrony', 'em-synchrony/activerecord', 'em-synchrony/mysql2']
|
36
|
+
|
37
|
+
gem 'grape'
|
38
|
+
gem 'goliath'
|
39
|
+
|
40
|
+
gem "activerecord", "~> 3.1.1"
|
41
|
+
gem 'rack-fiber_pool', :require => 'rack/fiber_pool'
|
42
|
+
gem "mysql2"
|
43
|
+
|
File without changes
|
File without changes
|
@@ -1,3 +1,30 @@
|
|
1
|
+
=begin
|
2
|
+
**************************************************************************
|
3
|
+
* The MIT License (MIT)
|
4
|
+
|
5
|
+
* Copyright (c) 2013-2014 QBurst Technologies Inc.
|
6
|
+
|
7
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
8
|
+
* of this software and associated documentation files (the "Software"), to deal
|
9
|
+
* in the Software without restriction, including without limitation the rights
|
10
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
11
|
+
* copies of the Software, and to permit persons to whom the Software is
|
12
|
+
* furnished to do so, subject to the following conditions:
|
13
|
+
|
14
|
+
* The above copyright notice and this permission notice shall be included in
|
15
|
+
* all copies or substantial portions of the Software.
|
16
|
+
|
17
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
18
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
19
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
20
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
21
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
22
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
23
|
+
* THE SOFTWARE.
|
24
|
+
|
25
|
+
**************************************************************************
|
26
|
+
=end
|
27
|
+
|
1
28
|
require "rubygems"
|
2
29
|
require "bundler/setup"
|
3
30
|
require 'em-synchrony/activerecord'
|
@@ -0,0 +1,48 @@
|
|
1
|
+
=begin
|
2
|
+
**************************************************************************
|
3
|
+
* The MIT License (MIT)
|
4
|
+
|
5
|
+
* Copyright (c) 2013-2014 QBurst Technologies Inc.
|
6
|
+
|
7
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
8
|
+
* of this software and associated documentation files (the "Software"), to deal
|
9
|
+
* in the Software without restriction, including without limitation the rights
|
10
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
11
|
+
* copies of the Software, and to permit persons to whom the Software is
|
12
|
+
* furnished to do so, subject to the following conditions:
|
13
|
+
|
14
|
+
* The above copyright notice and this permission notice shall be included in
|
15
|
+
* all copies or substantial portions of the Software.
|
16
|
+
|
17
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
18
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
19
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
20
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
21
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
22
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
23
|
+
* THE SOFTWARE.
|
24
|
+
|
25
|
+
**************************************************************************
|
26
|
+
=end
|
27
|
+
|
28
|
+
require 'uri'
|
29
|
+
require 'em-synchrony/activerecord'
|
30
|
+
require 'yaml'
|
31
|
+
require 'erb'
|
32
|
+
|
33
|
+
# Sets up database configuration
|
34
|
+
db = URI.parse(ENV['DATABASE_URL'] || 'http://localhost')
|
35
|
+
if db.scheme == 'postgres' # Heroku environment
|
36
|
+
ActiveRecord::Base.establish_connection(
|
37
|
+
:adapter => db.scheme == 'postgres' ? 'em_postgresql' : db.scheme,
|
38
|
+
:host => db.host,
|
39
|
+
:username => db.user,
|
40
|
+
:password => db.password,
|
41
|
+
:database => db.path[1..-1],
|
42
|
+
:encoding => 'utf8'
|
43
|
+
)
|
44
|
+
else # local environment
|
45
|
+
environment = ENV['DATABASE_URL'] ? 'production' : 'development'
|
46
|
+
db = YAML.load(ERB.new(File.read('config/database.yml')).result)[environment]
|
47
|
+
ActiveRecord::Base.establish_connection(db)
|
48
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
=begin
|
2
|
+
**************************************************************************
|
3
|
+
* The MIT License (MIT)
|
4
|
+
|
5
|
+
* Copyright (c) 2013-2014 QBurst Technologies Inc.
|
6
|
+
|
7
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
8
|
+
* of this software and associated documentation files (the "Software"), to deal
|
9
|
+
* in the Software without restriction, including without limitation the rights
|
10
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
11
|
+
* copies of the Software, and to permit persons to whom the Software is
|
12
|
+
* furnished to do so, subject to the following conditions:
|
13
|
+
|
14
|
+
* The above copyright notice and this permission notice shall be included in
|
15
|
+
* all copies or substantial portions of the Software.
|
16
|
+
|
17
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
18
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
19
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
20
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
21
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
22
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
23
|
+
* THE SOFTWARE.
|
24
|
+
|
25
|
+
**************************************************************************
|
26
|
+
=end
|
27
|
+
|
28
|
+
require "rubygems"
|
29
|
+
require "bundler/setup"
|
30
|
+
require 'goliath'
|
31
|
+
require 'em-synchrony/activerecord'
|
32
|
+
require 'grape'
|
33
|
+
require './tree'
|
34
|
+
|
35
|
+
class Application < Goliath::API
|
36
|
+
def response(env)
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
=begin
|
2
|
+
**************************************************************************
|
3
|
+
* The MIT License (MIT)
|
4
|
+
|
5
|
+
* Copyright (c) 2013-2014 QBurst Technologies Inc.
|
6
|
+
|
7
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
8
|
+
* of this software and associated documentation files (the "Software"), to deal
|
9
|
+
* in the Software without restriction, including without limitation the rights
|
10
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
11
|
+
* copies of the Software, and to permit persons to whom the Software is
|
12
|
+
* furnished to do so, subject to the following conditions:
|
13
|
+
|
14
|
+
* The above copyright notice and this permission notice shall be included in
|
15
|
+
* all copies or substantial portions of the Software.
|
16
|
+
|
17
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
18
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
19
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
20
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
21
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
22
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
23
|
+
* THE SOFTWARE.
|
24
|
+
|
25
|
+
**************************************************************************
|
26
|
+
=end
|
27
|
+
|
28
|
+
Dir[File.join("./app", "**/*.rb")].each do |file|
|
29
|
+
require file
|
30
|
+
end
|
@@ -1,3 +1,30 @@
|
|
1
|
+
=begin
|
2
|
+
**************************************************************************
|
3
|
+
* The MIT License (MIT)
|
4
|
+
|
5
|
+
* Copyright (c) 2013-2014 QBurst Technologies Inc.
|
6
|
+
|
7
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
8
|
+
* of this software and associated documentation files (the "Software"), to deal
|
9
|
+
* in the Software without restriction, including without limitation the rights
|
10
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
11
|
+
* copies of the Software, and to permit persons to whom the Software is
|
12
|
+
* furnished to do so, subject to the following conditions:
|
13
|
+
|
14
|
+
* The above copyright notice and this permission notice shall be included in
|
15
|
+
* all copies or substantial portions of the Software.
|
16
|
+
|
17
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
18
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
19
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
20
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
21
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
22
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
23
|
+
* THE SOFTWARE.
|
24
|
+
|
25
|
+
**************************************************************************
|
26
|
+
=end
|
27
|
+
|
1
28
|
class CreateUsers < ActiveRecord::Migration
|
2
29
|
def change
|
3
30
|
create_table(:users) do |t|
|