global_session 1.0.4 → 1.0.5
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/global_session.gemspec +2 -2
- data/lib/global_session/configuration.rb +16 -8
- data/lib/global_session/rack.rb +5 -1
- metadata +4 -4
data/global_session.gemspec
CHANGED
@@ -7,8 +7,8 @@ spec = Gem::Specification.new do |s|
|
|
7
7
|
s.required_ruby_version = Gem::Requirement.new(">= 1.8.7")
|
8
8
|
|
9
9
|
s.name = 'global_session'
|
10
|
-
s.version = '1.0.
|
11
|
-
s.date = '2011-
|
10
|
+
s.version = '1.0.5'
|
11
|
+
s.date = '2011-07-26'
|
12
12
|
|
13
13
|
s.authors = ['Tony Spataro']
|
14
14
|
s.email = 'code@tracker.xeger.net'
|
@@ -52,21 +52,29 @@ module GlobalSession
|
|
52
52
|
# you are integrating; see GlobalSession::Rails for more information.
|
53
53
|
#
|
54
54
|
class Configuration
|
55
|
-
# Create a new Configuration
|
55
|
+
# Create a new Configuration object
|
56
56
|
#
|
57
57
|
# === Parameters
|
58
|
-
#
|
58
|
+
# config(String|Hash):: Absolute filesystem path to the configuration file, or Hash containing configuration
|
59
59
|
# environment(String):: Config file section from which to read settings
|
60
60
|
#
|
61
61
|
# === Raise
|
62
62
|
# MissingConfiguration:: if config file is missing or unreadable
|
63
63
|
# TypeError:: if config file does not contain a YAML-serialized Hash
|
64
|
-
def initialize(
|
65
|
-
|
64
|
+
def initialize(config, environment)
|
65
|
+
if config.is_a?(Hash)
|
66
|
+
@config = config
|
67
|
+
elsif File.readable?(config)
|
68
|
+
data = YAML.load(File.read(config))
|
69
|
+
unless data.is_a?(Hash)
|
70
|
+
raise TypeError, "Configuration file #{File.basename(config)} must contain a hash as its top-level element"
|
71
|
+
end
|
72
|
+
@config = data
|
73
|
+
else
|
74
|
+
raise MissingConfiguration, "Missing or unreadable configuration file #{config}"
|
75
|
+
end
|
76
|
+
|
66
77
|
@environment = environment
|
67
|
-
raise MissingConfiguration, "Missing or unreadable configuration file" unless File.readable?(@config_file)
|
68
|
-
@config = YAML.load(File.read(@config_file))
|
69
|
-
raise TypeError, "#{config_file} must contain a Hash!" unless Hash === @config
|
70
78
|
validate
|
71
79
|
end
|
72
80
|
|
@@ -103,7 +111,7 @@ module GlobalSession
|
|
103
111
|
elements.each do |element|
|
104
112
|
object = object[element] if object
|
105
113
|
if object.nil?
|
106
|
-
msg = "
|
114
|
+
msg = "Configuration does not specify required element #{elements.map { |x| "['#{x}']"}.join('')}"
|
107
115
|
raise MissingConfiguration, msg
|
108
116
|
end
|
109
117
|
end
|
data/lib/global_session/rack.rb
CHANGED
@@ -166,7 +166,11 @@ module GlobalSession
|
|
166
166
|
# env(Hash): Rack environment
|
167
167
|
# e(Exception): error that happened
|
168
168
|
def handle_error(activity, env, e)
|
169
|
-
|
169
|
+
if env['rack.logger']
|
170
|
+
msg = "#{e.class} while #{activity}: #{e}"
|
171
|
+
msg += " #{e.backtrace}" unless e.is_a?(ExpiredSession)
|
172
|
+
env['rack.logger'].error(msg)
|
173
|
+
end
|
170
174
|
|
171
175
|
if e.is_a?(ClientError) || e.is_a?(SecurityError)
|
172
176
|
env['global_session.error'] = e
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: global_session
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 29
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 1
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 1.0.
|
9
|
+
- 5
|
10
|
+
version: 1.0.5
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Tony Spataro
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-
|
18
|
+
date: 2011-07-26 00:00:00 -07:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|