restpack_web 0.2.21 → 0.4.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +6 -14
- data/.gitignore +1 -1
- data/Gemfile +2 -0
- data/LICENSE.txt +22 -0
- data/README.md +2 -29
- data/Rakefile +2 -39
- data/lib/restpack_web.rb +6 -1
- data/lib/restpack_web/configuration.rb +16 -0
- data/lib/restpack_web/context.rb +52 -101
- data/lib/restpack_web/rack/domain.rb +36 -0
- data/lib/restpack_web/rack/session.rb +7 -0
- data/lib/restpack_web/rack/user.rb +35 -0
- data/lib/restpack_web/rails/controller.rb +9 -13
- data/lib/restpack_web/sinatra/app.rb +9 -16
- data/lib/restpack_web/version.rb +2 -2
- data/restpack_web.gemspec +23 -24
- metadata +55 -94
- data/LICENSE +0 -22
- data/lib/restpack_web/app.rb +0 -55
- data/lib/restpack_web/test_support.rb +0 -26
- data/spec/fixtures/channels.json +0 -354
- data/spec/fixtures/configurations_root.json +0 -59
- data/spec/fixtures/domains_search.json +0 -40
- data/spec/fixtures/users.json +0 -14
- data/spec/lib/restpack_web_spec.rb +0 -39
- data/spec/lib/test_support_spec.rb +0 -23
- data/spec/spec_helper.rb +0 -8
data/lib/restpack_web/version.rb
CHANGED
data/restpack_web.gemspec
CHANGED
@@ -1,32 +1,31 @@
|
|
1
|
-
#
|
1
|
+
# coding: utf-8
|
2
2
|
lib = File.expand_path('../lib', __FILE__)
|
3
3
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
4
|
require 'restpack_web/version'
|
5
5
|
|
6
|
-
Gem::Specification.new do |
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "restpack_web"
|
8
|
+
spec.version = RestPack::Web::VERSION
|
9
|
+
spec.authors = ["Gavin Joyce"]
|
10
|
+
spec.email = ["gavinjoyce@gmail.com"]
|
11
|
+
spec.description = %q{Rack middleware for your RestPack web apps}
|
12
|
+
spec.summary = %q{Rack middleware}
|
13
|
+
spec.homepage = "http://restpack.org/"
|
14
|
+
spec.license = "MIT"
|
14
15
|
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
16
|
+
spec.files = `git ls-files`.split($/)
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
19
20
|
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
21
|
+
spec.add_dependency "restpack_gem"
|
22
|
+
spec.add_dependency "restpack_core_service"
|
23
|
+
spec.add_dependency "restpack_user_service"
|
24
|
+
spec.add_dependency "restpack_account_service"
|
25
|
+
spec.add_dependency "restpack_group_service"
|
24
26
|
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
gem.add_development_dependency 'rack-test', '~> 0.6'
|
30
|
-
gem.add_development_dependency 'webmock', '~> 1.11'
|
31
|
-
gem.add_development_dependency 'rest-client'
|
27
|
+
spec.add_development_dependency "bundler", "~> 1.3"
|
28
|
+
spec.add_development_dependency "rake"
|
29
|
+
spec.add_development_dependency "rspec"
|
30
|
+
spec.add_development_dependency "bump"
|
32
31
|
end
|
metadata
CHANGED
@@ -1,170 +1,142 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: restpack_web
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gavin Joyce
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-
|
11
|
+
date: 2013-11-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name:
|
14
|
+
name: restpack_gem
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - '>='
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 0
|
19
|
+
version: '0'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- -
|
24
|
+
- - '>='
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 0
|
27
|
-
- !ruby/object:Gem::Dependency
|
28
|
-
name: restpack_core_client
|
29
|
-
requirement: !ruby/object:Gem::Requirement
|
30
|
-
requirements:
|
31
|
-
- - ~>
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version: 0.2.6
|
34
|
-
type: :runtime
|
35
|
-
prerelease: false
|
36
|
-
version_requirements: !ruby/object:Gem::Requirement
|
37
|
-
requirements:
|
38
|
-
- - ~>
|
39
|
-
- !ruby/object:Gem::Version
|
40
|
-
version: 0.2.6
|
26
|
+
version: '0'
|
41
27
|
- !ruby/object:Gem::Dependency
|
42
|
-
name:
|
28
|
+
name: restpack_core_service
|
43
29
|
requirement: !ruby/object:Gem::Requirement
|
44
30
|
requirements:
|
45
|
-
- -
|
31
|
+
- - '>='
|
46
32
|
- !ruby/object:Gem::Version
|
47
|
-
version:
|
33
|
+
version: '0'
|
48
34
|
type: :runtime
|
49
35
|
prerelease: false
|
50
36
|
version_requirements: !ruby/object:Gem::Requirement
|
51
37
|
requirements:
|
52
|
-
- -
|
38
|
+
- - '>='
|
53
39
|
- !ruby/object:Gem::Version
|
54
|
-
version:
|
40
|
+
version: '0'
|
55
41
|
- !ruby/object:Gem::Dependency
|
56
|
-
name:
|
42
|
+
name: restpack_user_service
|
57
43
|
requirement: !ruby/object:Gem::Requirement
|
58
44
|
requirements:
|
59
|
-
- -
|
45
|
+
- - '>='
|
60
46
|
- !ruby/object:Gem::Version
|
61
|
-
version:
|
47
|
+
version: '0'
|
62
48
|
type: :runtime
|
63
49
|
prerelease: false
|
64
50
|
version_requirements: !ruby/object:Gem::Requirement
|
65
51
|
requirements:
|
66
|
-
- -
|
52
|
+
- - '>='
|
67
53
|
- !ruby/object:Gem::Version
|
68
|
-
version:
|
54
|
+
version: '0'
|
69
55
|
- !ruby/object:Gem::Dependency
|
70
|
-
name:
|
56
|
+
name: restpack_account_service
|
71
57
|
requirement: !ruby/object:Gem::Requirement
|
72
58
|
requirements:
|
73
|
-
- -
|
59
|
+
- - '>='
|
74
60
|
- !ruby/object:Gem::Version
|
75
61
|
version: '0'
|
76
|
-
type: :
|
62
|
+
type: :runtime
|
77
63
|
prerelease: false
|
78
64
|
version_requirements: !ruby/object:Gem::Requirement
|
79
65
|
requirements:
|
80
|
-
- -
|
66
|
+
- - '>='
|
81
67
|
- !ruby/object:Gem::Version
|
82
68
|
version: '0'
|
83
69
|
- !ruby/object:Gem::Dependency
|
84
|
-
name:
|
70
|
+
name: restpack_group_service
|
85
71
|
requirement: !ruby/object:Gem::Requirement
|
86
72
|
requirements:
|
87
|
-
- -
|
73
|
+
- - '>='
|
88
74
|
- !ruby/object:Gem::Version
|
89
75
|
version: '0'
|
90
|
-
type: :
|
76
|
+
type: :runtime
|
91
77
|
prerelease: false
|
92
78
|
version_requirements: !ruby/object:Gem::Requirement
|
93
79
|
requirements:
|
94
|
-
- -
|
80
|
+
- - '>='
|
95
81
|
- !ruby/object:Gem::Version
|
96
82
|
version: '0'
|
97
83
|
- !ruby/object:Gem::Dependency
|
98
|
-
name:
|
84
|
+
name: bundler
|
99
85
|
requirement: !ruby/object:Gem::Requirement
|
100
86
|
requirements:
|
101
87
|
- - ~>
|
102
88
|
- !ruby/object:Gem::Version
|
103
|
-
version: '
|
89
|
+
version: '1.3'
|
104
90
|
type: :development
|
105
91
|
prerelease: false
|
106
92
|
version_requirements: !ruby/object:Gem::Requirement
|
107
93
|
requirements:
|
108
94
|
- - ~>
|
109
95
|
- !ruby/object:Gem::Version
|
110
|
-
version: '
|
96
|
+
version: '1.3'
|
111
97
|
- !ruby/object:Gem::Dependency
|
112
|
-
name:
|
113
|
-
requirement: !ruby/object:Gem::Requirement
|
114
|
-
requirements:
|
115
|
-
- - ~>
|
116
|
-
- !ruby/object:Gem::Version
|
117
|
-
version: '4.7'
|
118
|
-
type: :development
|
119
|
-
prerelease: false
|
120
|
-
version_requirements: !ruby/object:Gem::Requirement
|
121
|
-
requirements:
|
122
|
-
- - ~>
|
123
|
-
- !ruby/object:Gem::Version
|
124
|
-
version: '4.7'
|
125
|
-
- !ruby/object:Gem::Dependency
|
126
|
-
name: rack-test
|
98
|
+
name: rake
|
127
99
|
requirement: !ruby/object:Gem::Requirement
|
128
100
|
requirements:
|
129
|
-
- -
|
101
|
+
- - '>='
|
130
102
|
- !ruby/object:Gem::Version
|
131
|
-
version: '0
|
103
|
+
version: '0'
|
132
104
|
type: :development
|
133
105
|
prerelease: false
|
134
106
|
version_requirements: !ruby/object:Gem::Requirement
|
135
107
|
requirements:
|
136
|
-
- -
|
108
|
+
- - '>='
|
137
109
|
- !ruby/object:Gem::Version
|
138
|
-
version: '0
|
110
|
+
version: '0'
|
139
111
|
- !ruby/object:Gem::Dependency
|
140
|
-
name:
|
112
|
+
name: rspec
|
141
113
|
requirement: !ruby/object:Gem::Requirement
|
142
114
|
requirements:
|
143
|
-
- -
|
115
|
+
- - '>='
|
144
116
|
- !ruby/object:Gem::Version
|
145
|
-
version: '
|
117
|
+
version: '0'
|
146
118
|
type: :development
|
147
119
|
prerelease: false
|
148
120
|
version_requirements: !ruby/object:Gem::Requirement
|
149
121
|
requirements:
|
150
|
-
- -
|
122
|
+
- - '>='
|
151
123
|
- !ruby/object:Gem::Version
|
152
|
-
version: '
|
124
|
+
version: '0'
|
153
125
|
- !ruby/object:Gem::Dependency
|
154
|
-
name:
|
126
|
+
name: bump
|
155
127
|
requirement: !ruby/object:Gem::Requirement
|
156
128
|
requirements:
|
157
|
-
- -
|
129
|
+
- - '>='
|
158
130
|
- !ruby/object:Gem::Version
|
159
131
|
version: '0'
|
160
132
|
type: :development
|
161
133
|
prerelease: false
|
162
134
|
version_requirements: !ruby/object:Gem::Requirement
|
163
135
|
requirements:
|
164
|
-
- -
|
136
|
+
- - '>='
|
165
137
|
- !ruby/object:Gem::Version
|
166
138
|
version: '0'
|
167
|
-
description:
|
139
|
+
description: Rack middleware for your RestPack web apps
|
168
140
|
email:
|
169
141
|
- gavinjoyce@gmail.com
|
170
142
|
executables: []
|
@@ -173,26 +145,22 @@ extra_rdoc_files: []
|
|
173
145
|
files:
|
174
146
|
- .gitignore
|
175
147
|
- Gemfile
|
176
|
-
- LICENSE
|
148
|
+
- LICENSE.txt
|
177
149
|
- README.md
|
178
150
|
- Rakefile
|
179
151
|
- lib/restpack_web.rb
|
180
|
-
- lib/restpack_web/
|
152
|
+
- lib/restpack_web/configuration.rb
|
181
153
|
- lib/restpack_web/context.rb
|
154
|
+
- lib/restpack_web/rack/domain.rb
|
155
|
+
- lib/restpack_web/rack/session.rb
|
156
|
+
- lib/restpack_web/rack/user.rb
|
182
157
|
- lib/restpack_web/rails/controller.rb
|
183
158
|
- lib/restpack_web/sinatra/app.rb
|
184
|
-
- lib/restpack_web/test_support.rb
|
185
159
|
- lib/restpack_web/version.rb
|
186
160
|
- restpack_web.gemspec
|
187
|
-
|
188
|
-
|
189
|
-
-
|
190
|
-
- spec/fixtures/users.json
|
191
|
-
- spec/lib/restpack_web_spec.rb
|
192
|
-
- spec/lib/test_support_spec.rb
|
193
|
-
- spec/spec_helper.rb
|
194
|
-
homepage: https://github.com/RestPack
|
195
|
-
licenses: []
|
161
|
+
homepage: http://restpack.org/
|
162
|
+
licenses:
|
163
|
+
- MIT
|
196
164
|
metadata: {}
|
197
165
|
post_install_message:
|
198
166
|
rdoc_options: []
|
@@ -200,25 +168,18 @@ require_paths:
|
|
200
168
|
- lib
|
201
169
|
required_ruby_version: !ruby/object:Gem::Requirement
|
202
170
|
requirements:
|
203
|
-
- -
|
171
|
+
- - '>='
|
204
172
|
- !ruby/object:Gem::Version
|
205
173
|
version: '0'
|
206
174
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
207
175
|
requirements:
|
208
|
-
- -
|
176
|
+
- - '>='
|
209
177
|
- !ruby/object:Gem::Version
|
210
178
|
version: '0'
|
211
179
|
requirements: []
|
212
180
|
rubyforge_project:
|
213
|
-
rubygems_version: 2.0.
|
181
|
+
rubygems_version: 2.0.7
|
214
182
|
signing_key:
|
215
183
|
specification_version: 4
|
216
|
-
summary:
|
217
|
-
test_files:
|
218
|
-
- spec/fixtures/channels.json
|
219
|
-
- spec/fixtures/configurations_root.json
|
220
|
-
- spec/fixtures/domains_search.json
|
221
|
-
- spec/fixtures/users.json
|
222
|
-
- spec/lib/restpack_web_spec.rb
|
223
|
-
- spec/lib/test_support_spec.rb
|
224
|
-
- spec/spec_helper.rb
|
184
|
+
summary: Rack middleware
|
185
|
+
test_files: []
|
data/LICENSE
DELETED
@@ -1,22 +0,0 @@
|
|
1
|
-
MIT License
|
2
|
-
-----------
|
3
|
-
|
4
|
-
Copyright (c) 2013 Gavin Joyce and RestPack contributors
|
5
|
-
|
6
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
7
|
-
this software and associated documentation files (the "Software"), to deal in
|
8
|
-
the Software without restriction, including without limitation the rights to
|
9
|
-
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
10
|
-
of the Software, and to permit persons to whom the Software is furnished to do
|
11
|
-
so, subject to the following conditions:
|
12
|
-
|
13
|
-
The above copyright notice and this permission notice shall be included in all
|
14
|
-
copies or substantial portions of the Software.
|
15
|
-
|
16
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
17
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
18
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
19
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
20
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
21
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
22
|
-
SOFTWARE.
|
data/lib/restpack_web/app.rb
DELETED
@@ -1,55 +0,0 @@
|
|
1
|
-
require 'restpack_core_client'
|
2
|
-
|
3
|
-
module RestPack
|
4
|
-
module Web
|
5
|
-
class App
|
6
|
-
def initialize(app, options = {})
|
7
|
-
@app = app
|
8
|
-
|
9
|
-
options[:core_domain] ||= ENV['RESTPACK_CORE_SERVICE']
|
10
|
-
options[:access_key] ||= ENV['RESTPACK_ACCESS_KEY']
|
11
|
-
|
12
|
-
raise "missing RestPack configuration" unless options[:core_domain] || options[:access_key]
|
13
|
-
|
14
|
-
@core_cache = RestPack::Core::Client::Cache.create(options[:core_domain], options[:access_key])
|
15
|
-
end
|
16
|
-
|
17
|
-
def call(env)
|
18
|
-
env[:restpack] ||= {}
|
19
|
-
|
20
|
-
request = Rack::Request.new(env)
|
21
|
-
|
22
|
-
domain = @core_cache.get_domain(request.host)
|
23
|
-
|
24
|
-
env[:restpack][:request] = request
|
25
|
-
env[:restpack][:host] = request.host
|
26
|
-
env[:restpack][:channel] = domain.channel
|
27
|
-
env[:restpack][:application] = domain.application
|
28
|
-
env[:restpack][:domain] = domain
|
29
|
-
env[:restpack][:configurations] = @core_cache.configurations
|
30
|
-
|
31
|
-
add_user env
|
32
|
-
|
33
|
-
@app.call(env)
|
34
|
-
end
|
35
|
-
|
36
|
-
private
|
37
|
-
|
38
|
-
def add_user(env)
|
39
|
-
return unless env['rack.session']
|
40
|
-
|
41
|
-
user_id = env['rack.session'][:user_id]
|
42
|
-
|
43
|
-
if user_id
|
44
|
-
context = RestPack::Web::Context.new(env)
|
45
|
-
|
46
|
-
user_service_domain = context.get_service_domain('restpack-user-service')
|
47
|
-
json = RestClient.get("http://:#{ENV['RESTPACK_ACCESS_KEY']}@#{user_service_domain}/api/v1/users/#{user_id}.json")
|
48
|
-
env[:restpack][:user] = Yajl::Parser.parse(json, :symbolize_keys => true)[:user]
|
49
|
-
end
|
50
|
-
|
51
|
-
env[:restpack][:user_id] = user_id
|
52
|
-
end
|
53
|
-
end
|
54
|
-
end
|
55
|
-
end
|
@@ -1,26 +0,0 @@
|
|
1
|
-
require 'webmock'
|
2
|
-
include WebMock::API
|
3
|
-
|
4
|
-
module Rack
|
5
|
-
module Test
|
6
|
-
DEFAULT_HOST = 'sinatra.restpack-sample.org'
|
7
|
-
end
|
8
|
-
end
|
9
|
-
|
10
|
-
module RestPack
|
11
|
-
module Web
|
12
|
-
class TestSupport
|
13
|
-
def self.stub_restpack_web
|
14
|
-
host = "http://:#{ENV['RESTPACK_ACCESS_KEY']}@#{ENV['RESTPACK_CORE_SERVICE']}/api/v1"
|
15
|
-
stub_request(:get, "#{host}/configurations/root.json").to_return(:body => read_fixture('configurations_root'))
|
16
|
-
stub_request(:get, "#{host}/domains/search.json?host=sinatra.restpack-sample.org").to_return(:body => read_fixture('domains_search'))
|
17
|
-
stub_request(:get, "#{host}/channels/1.json").to_return(:body => read_fixture('channels'))
|
18
|
-
end
|
19
|
-
|
20
|
-
def self.read_fixture(name)
|
21
|
-
file = File.open("#{File.expand_path('../../../spec/fixtures', __FILE__)}/#{name}.json")
|
22
|
-
file.read
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|