orbit-rb 0.2.3 → 0.2.4
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.
- checksums.yaml +4 -4
- data/lib/orbit.rb +3 -4
- data/lib/orbit/config.rb +6 -1
- data/lib/orbit/controller.rb +10 -3
- data/lib/orbit/interceptors/base.rb +5 -5
- data/lib/orbit/interceptors/list.rb +8 -2
- data/lib/orbit/session/cookie.rb +23 -0
- data/lib/orbit/template_binding.rb +6 -6
- data/lib/orbit/version.rb +1 -1
- data/orbit.gemspec +2 -2
- metadata +8 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 539a864424d742bd0e80de77ca310b0f5fd59b68
|
4
|
+
data.tar.gz: 3208aa93a064f77f8f228be96e56023efe2e451c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ef7bda8fe73be7f43762641695b6eadc942c212fe55b06a720c62f84ddb170e7b264b282eea107bf175b46876b66a77541bf1b98562017f001fd0c1027175642
|
7
|
+
data.tar.gz: 4d5b58fa6126f426d7cf0d7a37b648de7484c8481791ed984a8cf9f2564c9f070705786090af8dfa128b4d0d99e5da53e10eab6368e9876bf7fee378c16c0bc7
|
data/lib/orbit.rb
CHANGED
@@ -30,12 +30,11 @@ module Orbit
|
|
30
30
|
builder.use Rack::Static, :urls => Config.static_files_path
|
31
31
|
builder.use config.rack_logger_class
|
32
32
|
|
33
|
-
use_session
|
33
|
+
use_session(config.session_options)
|
34
34
|
use_protection
|
35
35
|
end
|
36
36
|
|
37
|
-
def use_session
|
38
|
-
options = {}
|
37
|
+
def use_session(options)
|
39
38
|
options[:secret] = config.session_secret
|
40
39
|
|
41
40
|
builder.use Rack::Session::Cookie, options
|
@@ -81,7 +80,7 @@ module Orbit
|
|
81
80
|
route = Config.router_class.match(verb, requested_path)
|
82
81
|
|
83
82
|
if route
|
84
|
-
intercepted = Interceptors::List.intercept_path(
|
83
|
+
intercepted = Interceptors::List.intercept_path(@request)
|
85
84
|
|
86
85
|
return intercepted if intercepted
|
87
86
|
|
data/lib/orbit/config.rb
CHANGED
@@ -9,7 +9,7 @@ module Orbit
|
|
9
9
|
attr_accessor :app_path, :static_files_path, :rack_logger_class,
|
10
10
|
:logger_class, :log_level, :log_appname, :log_file,
|
11
11
|
:path_class, :request_class, :response_class, :route_class,
|
12
|
-
:router_class, :session_secret
|
12
|
+
:router_class, :session_secret, :session_options
|
13
13
|
|
14
14
|
def initialize
|
15
15
|
instantiate
|
@@ -35,12 +35,17 @@ module Orbit
|
|
35
35
|
@response_class = Orbit::Response
|
36
36
|
@route_class = Orbit::Routing::Route
|
37
37
|
@router_class = Orbit::Router
|
38
|
+
@session_options = {}
|
38
39
|
end
|
39
40
|
|
40
41
|
def self.app_path
|
41
42
|
@instance.app_path
|
42
43
|
end
|
43
44
|
|
45
|
+
def self.session_options
|
46
|
+
@instance.session_options
|
47
|
+
end
|
48
|
+
|
44
49
|
def self.static_files_path
|
45
50
|
@instance.static_files_path
|
46
51
|
end
|
data/lib/orbit/controller.rb
CHANGED
@@ -42,7 +42,7 @@ module Orbit
|
|
42
42
|
end
|
43
43
|
|
44
44
|
def locals
|
45
|
-
@_locals ||= TemplateBinding.
|
45
|
+
@_locals ||= TemplateBinding.new(params)
|
46
46
|
end
|
47
47
|
|
48
48
|
def self.path(path)
|
@@ -106,14 +106,13 @@ module Orbit
|
|
106
106
|
end
|
107
107
|
|
108
108
|
def cookies
|
109
|
-
request.cookies
|
109
|
+
@_cookies ||= Session::Cookie.new(self, request.cookies)
|
110
110
|
end
|
111
111
|
|
112
112
|
def cookie_domain
|
113
113
|
request.host
|
114
114
|
end
|
115
115
|
|
116
|
-
protected
|
117
116
|
def params
|
118
117
|
@request.params
|
119
118
|
end
|
@@ -130,6 +129,14 @@ module Orbit
|
|
130
129
|
response.status = code
|
131
130
|
end
|
132
131
|
|
132
|
+
def responds_to_last_request_update_allowed?
|
133
|
+
true
|
134
|
+
end
|
135
|
+
|
136
|
+
def last_request_update_allowed?
|
137
|
+
true
|
138
|
+
end
|
139
|
+
|
133
140
|
private
|
134
141
|
def self.create_method(verb, action, &handler)
|
135
142
|
method = (action == '/') ? "root" : parameterize(action.to_s.gsub("*", "splat"))
|
@@ -1,18 +1,18 @@
|
|
1
1
|
module Orbit
|
2
2
|
module Interceptors
|
3
3
|
class Base < Rack::Response
|
4
|
-
def initialize
|
5
|
-
super
|
4
|
+
def initialize(request)
|
5
|
+
super()
|
6
|
+
@request = request
|
6
7
|
@status = 302
|
7
8
|
end
|
8
9
|
|
9
|
-
def self.execute
|
10
|
-
new.execute
|
10
|
+
def self.execute(request)
|
11
|
+
new(request).execute
|
11
12
|
end
|
12
13
|
|
13
14
|
def execute
|
14
15
|
@intercept = redirect(intercept, status)
|
15
|
-
|
16
16
|
|
17
17
|
@intercept ? self : nil
|
18
18
|
end
|
@@ -14,6 +14,10 @@ module Orbit
|
|
14
14
|
instance.interceptors.push(interceptor)
|
15
15
|
end
|
16
16
|
|
17
|
+
def self.interceptors
|
18
|
+
instance.interceptors
|
19
|
+
end
|
20
|
+
|
17
21
|
def interceptors_for_path(path)
|
18
22
|
return [] unless path
|
19
23
|
|
@@ -22,9 +26,11 @@ module Orbit
|
|
22
26
|
end
|
23
27
|
end
|
24
28
|
|
25
|
-
def self.intercept_path(
|
29
|
+
def self.intercept_path(request)
|
30
|
+
path = request.path_info
|
31
|
+
|
26
32
|
instance.interceptors_for_path(path).each do |hash|
|
27
|
-
result = hash.interceptor_class.execute
|
33
|
+
result = hash.interceptor_class.execute(request)
|
28
34
|
|
29
35
|
return result if result
|
30
36
|
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module Orbit
|
2
|
+
module Session
|
3
|
+
class Cookie < Rack::Session::Cookie
|
4
|
+
def initialize(controller, cookies, options={})
|
5
|
+
@controller = controller
|
6
|
+
@cookies = cookies
|
7
|
+
options[:secret] = Orbit::Config.session_secret
|
8
|
+
super(cookies, options)
|
9
|
+
end
|
10
|
+
|
11
|
+
def [](key)
|
12
|
+
@cookies[key]
|
13
|
+
end
|
14
|
+
|
15
|
+
def []=(key, value)
|
16
|
+
@cookies[key] = value
|
17
|
+
end
|
18
|
+
|
19
|
+
def delete(key, options)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -1,10 +1,10 @@
|
|
1
1
|
module Orbit
|
2
2
|
class TemplateBinding
|
3
3
|
def initialize(hash)
|
4
|
-
@variables =
|
4
|
+
@variables = {}
|
5
5
|
|
6
6
|
hash.each do |key, value|
|
7
|
-
@variables
|
7
|
+
@variables[key.to_sym] = value
|
8
8
|
end
|
9
9
|
end
|
10
10
|
|
@@ -13,13 +13,13 @@ module Orbit
|
|
13
13
|
end
|
14
14
|
|
15
15
|
def locals
|
16
|
-
|
16
|
+
@variables
|
17
17
|
end
|
18
18
|
|
19
19
|
def variables
|
20
20
|
binding.tap do |bind|
|
21
|
-
@variables.
|
22
|
-
|
21
|
+
@variables.each do |key, value|
|
22
|
+
bind.local_variable_set(key.to_sym, value)
|
23
23
|
end
|
24
24
|
end
|
25
25
|
end
|
@@ -27,7 +27,7 @@ module Orbit
|
|
27
27
|
def method_missing(method, *args, &block)
|
28
28
|
if method.to_s[-1] == '='
|
29
29
|
var_name = method.to_s[0..-2].to_sym
|
30
|
-
@variables
|
30
|
+
@variables[var_name] = args.first
|
31
31
|
end
|
32
32
|
end
|
33
33
|
end
|
data/lib/orbit/version.rb
CHANGED
data/orbit.gemspec
CHANGED
@@ -26,8 +26,8 @@ Gem::Specification.new do |spec|
|
|
26
26
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
27
27
|
spec.require_paths = ["lib"]
|
28
28
|
|
29
|
-
spec.add_dependency "rack", "~>
|
30
|
-
spec.add_dependency "rack-protection", "~> 1.
|
29
|
+
spec.add_dependency "rack", "~> 2.0.0"
|
30
|
+
spec.add_dependency "rack-protection", "~> 1.5.3"
|
31
31
|
|
32
32
|
spec.add_development_dependency "bundler", "~> 1.10"
|
33
33
|
spec.add_development_dependency "rake", "~> 10.0"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: orbit-rb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Caio Torres
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-08-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rack
|
@@ -16,28 +16,28 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
19
|
+
version: 2.0.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:
|
26
|
+
version: 2.0.0
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rack-protection
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version:
|
33
|
+
version: 1.5.3
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version:
|
40
|
+
version: 1.5.3
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: bundler
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -111,6 +111,7 @@ files:
|
|
111
111
|
- lib/orbit/routing/path.rb
|
112
112
|
- lib/orbit/routing/pattern.rb
|
113
113
|
- lib/orbit/routing/route.rb
|
114
|
+
- lib/orbit/session/cookie.rb
|
114
115
|
- lib/orbit/singleton.rb
|
115
116
|
- lib/orbit/template_binding.rb
|
116
117
|
- lib/orbit/version.rb
|
@@ -136,7 +137,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
136
137
|
version: '0'
|
137
138
|
requirements: []
|
138
139
|
rubyforge_project:
|
139
|
-
rubygems_version: 2.
|
140
|
+
rubygems_version: 2.5.1
|
140
141
|
signing_key:
|
141
142
|
specification_version: 4
|
142
143
|
summary: Orbit is a Ruby Framework focused on simplicity and flexibility.
|