plezi 0.12.11 → 0.12.13
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +20 -0
- data/README.md +4 -4
- data/lib/plezi.rb +1 -3
- data/lib/plezi/builders/app_builder.rb +2 -2
- data/lib/plezi/common/cache.rb +2 -2
- data/lib/plezi/common/redis.rb +3 -4
- data/lib/plezi/common/renderer.rb +3 -3
- data/lib/plezi/handlers/controller_magic.rb +10 -9
- data/lib/plezi/handlers/placebo.rb +2 -2
- data/lib/plezi/handlers/route.rb +10 -10
- data/lib/plezi/handlers/session.rb +4 -3
- data/lib/plezi/handlers/ws_identity.rb +4 -1
- data/lib/plezi/handlers/ws_object.rb +2 -2
- data/lib/plezi/version.rb +1 -1
- data/plezi.gemspec +1 -1
- data/resources/mini_app.rb +5 -1
- data/resources/redis_config.rb +4 -4
- data/resources/routes.rb +5 -0
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0f12a2dfa8c950088854171c45e5dc7ee421f4ec
|
4
|
+
data.tar.gz: 97a219277d93b9202c0a07a15285c3d6f1f395f6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a5a885d9cdc4aba8fd45185b585b8edafe34419cba34af216b1bb0387b041fd7e29fe1f8e35b941f979190e08e0ebb168b00f30ec489667a6b89fc362ea93cd7
|
7
|
+
data.tar.gz: b952c39778f6a130b637e8175f10d1b3897a7d0da8093025744d84e8e5cbbb6cbb6441c0a774af20b20e58ea58bb9d0e98bea7e7385eba5e95c1e24d8ec70db2
|
data/CHANGELOG.md
CHANGED
@@ -2,6 +2,26 @@
|
|
2
2
|
|
3
3
|
***
|
4
4
|
|
5
|
+
Change log v.0.12.13
|
6
|
+
|
7
|
+
**Fix**: fixed an error in te rendering engine, where the default :format was an empty String instead of 'html'.
|
8
|
+
|
9
|
+
**Update**: if `params[:format]` exists, the `params[:format]` will be used to set the format of the template to be rendered (i.e., if `params[:format] == 'json'`, Plezi will look for `template_name.json.erb` instead of `template_name.html.erb`)
|
10
|
+
|
11
|
+
***
|
12
|
+
|
13
|
+
Change log v.0.12.12
|
14
|
+
|
15
|
+
**Update**: Redis will now connect to the selected database if the database is set in the `ENV['PL_REDIS_URL']`.
|
16
|
+
|
17
|
+
**Security**: Redis session local storage will now expire after 24 hours from last visit.
|
18
|
+
|
19
|
+
**Compatibility**: minor fixes and changes in preperation for Ruby 2.3.0. Updated the Session object API to match Iodine (added the `#refresh` method as an alias for `#to_h`).
|
20
|
+
|
21
|
+
**Change**: changed the `Controller#render` method to accept `:format` instead of `:type`, for more clarity. `:type` is still supported for the 0.12.0 version line.
|
22
|
+
|
23
|
+
***
|
24
|
+
|
5
25
|
Change log v.0.12.11
|
6
26
|
|
7
27
|
**Update/Fix**: dedicated methods for Controllers shouldn't be case sensitive. i.e. `/humans` and `/huMans/` should lead to the same route, IF that route is a method called `:humans` within a Controller class.
|
data/README.md
CHANGED
@@ -145,8 +145,8 @@ Broadcasting isn't the only tool Plezi offers, we can also send a message to a s
|
|
145
145
|
|
146
146
|
Scale your Websocket application with one line of code:
|
147
147
|
|
148
|
-
# REDIS_URL is where
|
149
|
-
ENV['PL_REDIS_URL'] ||= ENV['REDIS_URL'] || "redis
|
148
|
+
# REDIS_URL is where Heroku-Redis stores it's URL
|
149
|
+
ENV['PL_REDIS_URL'] ||= ENV['REDIS_URL'] || "redis://:password@my.host:6389/0"
|
150
150
|
|
151
151
|
Websocket messages (broadcasts, unicasts, etc') and even session data (Plezi keeps it away from the client) will now sync using Redis throughout all your server instances.
|
152
152
|
|
@@ -225,7 +225,7 @@ Remember to connect to the service from at least two browser windows - to truly
|
|
225
225
|
|
226
226
|
# do you need automated redis support?
|
227
227
|
# require 'redis'
|
228
|
-
# ENV['PL_REDIS_URL'] = "redis
|
228
|
+
# ENV['PL_REDIS_URL'] = "redis://:password@localhost:6379/0"
|
229
229
|
|
230
230
|
class BroadcastCtrl
|
231
231
|
def index
|
@@ -305,7 +305,7 @@ require './my_plezi_app/environment.rb'
|
|
305
305
|
require './my_plezi_app/routes.rb'
|
306
306
|
|
307
307
|
# # Make sure the following is already in your 'my_plezi_app/environment.rb' file:
|
308
|
-
# ENV['PL_REDIS_URL'] = "redis
|
308
|
+
# ENV['PL_REDIS_URL'] = "redis://:password@my.host:6379/0"
|
309
309
|
# Plezi::Settings.redis_channel_name = 'unique_channel_name_for_app_b24270e2'
|
310
310
|
|
311
311
|
Plezi.start_placebo
|
data/lib/plezi.rb
CHANGED
@@ -48,7 +48,7 @@ require 'plezi/handlers/session.rb'
|
|
48
48
|
## erb templating
|
49
49
|
begin
|
50
50
|
require 'erb'
|
51
|
-
rescue
|
51
|
+
rescue
|
52
52
|
|
53
53
|
end
|
54
54
|
|
@@ -140,8 +140,6 @@ end
|
|
140
140
|
module Plezi
|
141
141
|
end
|
142
142
|
|
143
|
-
Encoding.default_internal = 'utf-8'
|
144
|
-
Encoding.default_external = 'utf-8'
|
145
143
|
Iodine.threads = 30
|
146
144
|
Iodine.run { puts "Plezi is feeling optimistic running version #{::Plezi::VERSION}.\n\n"}
|
147
145
|
# PL is a shortcut for the Plezi module, so that `PL == Plezi`.
|
@@ -15,9 +15,9 @@ module Plezi
|
|
15
15
|
require 'plezi/version'
|
16
16
|
app_tree["#{app_name}"] ||= IO.read( File.join(@root, "resources" ,"mini_exec.rb")).gsub('appname', app_name)
|
17
17
|
app_tree["#{app_name}.rb"] ||= IO.read( File.join(@root, "resources" ,"mini_app.rb")).gsub('appname', app_name).gsub('appsecret', "#{app_name}_#{SecureRandom.hex}")
|
18
|
-
app_tree["Procfile"] ||=
|
18
|
+
app_tree["Procfile"] ||= String.new
|
19
19
|
app_tree["Procfile"] << "\nweb: bundle exec ruby ./#{app_name} -p $PORT\n"
|
20
|
-
app_tree["Gemfile"] ||=
|
20
|
+
app_tree["Gemfile"] ||= String.new
|
21
21
|
app_tree["Gemfile"] << "source 'https://rubygems.org'\n\n####################\n# core gems\n\n# include the basic plezi framework and server\ngem 'plezi', '~> #{Plezi::VERSION}'\n"
|
22
22
|
app_tree["Gemfile"] << "\n\n\nruby '#{RUBY_VERSION}'\n"
|
23
23
|
app_tree["templates"] ||= {}
|
data/lib/plezi/common/cache.rb
CHANGED
@@ -49,7 +49,7 @@ module Plezi
|
|
49
49
|
cache_data filename, data if CACHABLE.include? filename.match(/\.([^\.]+)$/)[1]
|
50
50
|
begin
|
51
51
|
IO.binwrite filename, data if save_to_disk
|
52
|
-
rescue
|
52
|
+
rescue
|
53
53
|
Plezi.warn("File couldn't be written (#{filename}) - file system error?")
|
54
54
|
end
|
55
55
|
data
|
@@ -89,7 +89,7 @@ module Plezi
|
|
89
89
|
|
90
90
|
# returns true if the file exists on disk or in the cache.
|
91
91
|
def file_exists? filename
|
92
|
-
( CACHE_STORE[filename] || File.
|
92
|
+
( CACHE_STORE[filename] || File.exist?(filename) ) && true
|
93
93
|
end
|
94
94
|
|
95
95
|
# returns true if the file has been update since data was last cached.
|
data/lib/plezi/common/redis.rb
CHANGED
@@ -10,13 +10,12 @@ module Plezi
|
|
10
10
|
return false unless ENV['PL_REDIS_URL'] && defined?(::Redis)
|
11
11
|
@redis_locker.synchronize do
|
12
12
|
return @redis if (@redis_sub_thread && @redis_sub_thread.alive?) && @redis # repeat the test once syncing is done.
|
13
|
-
@redis_uri ||= URI.parse(ENV['PL_REDIS_URL'])
|
14
13
|
@redis.quit if @redis
|
15
|
-
@redis = ::Redis.new(
|
14
|
+
@redis = ::Redis.new(ENV['PL_REDIS_URL'])
|
16
15
|
raise "Redis connction failed for: #{ENV['PL_REDIS_URL']}" unless @redis
|
17
16
|
@redis_sub_thread = Thread.new do
|
18
17
|
begin
|
19
|
-
::Redis.new(
|
18
|
+
::Redis.new(ENV['PL_REDIS_URL']).subscribe(Plezi::Settings.redis_channel_name, Plezi::Settings.uuid) do |on|
|
20
19
|
on.message do |channel, msg|
|
21
20
|
::Plezi::Base::WSObject.forward_message ::Plezi::Base::WSObject.translate_message(msg)
|
22
21
|
end
|
@@ -48,7 +47,7 @@ module Plezi
|
|
48
47
|
# for example:
|
49
48
|
# ENV['PL_REDIS_URL'] = ENV['REDISCLOUD_URL']`
|
50
49
|
# or
|
51
|
-
# ENV['PL_REDIS_URL'] = "redis
|
50
|
+
# ENV['PL_REDIS_URL'] = "redis://:password@my.host:6379/0"
|
52
51
|
#
|
53
52
|
# Accepts an optional block that will receive the Redis connection object. i.e.
|
54
53
|
#
|
@@ -33,7 +33,7 @@ module Plezi
|
|
33
33
|
|
34
34
|
|
35
35
|
def render base_filename, context = ( Object.new.instance_eval { binding } ), &block
|
36
|
-
@render_library.each {|ext, handler| f = "#{base_filename}.#{ext}".freeze ; return handler.call(f, context, &block) if File.
|
36
|
+
@render_library.each {|ext, handler| f = "#{base_filename}.#{ext}".freeze ; return handler.call(f, context, &block) if File.exist?(f) }
|
37
37
|
false
|
38
38
|
end
|
39
39
|
|
@@ -104,8 +104,8 @@ module Plezi
|
|
104
104
|
|
105
105
|
|
106
106
|
def render base_filename, context = ( Object.new.instance_eval { binding } ), &block
|
107
|
-
|
108
|
-
|
107
|
+
handlers = @render_library[File.extname(base_filename)[1..-1]]
|
108
|
+
handlers.each {|ext, handler| f = "#{base_filename}.#{ext}".freeze ; return handler.call(f, context, &block) if File.exists?(f) } if handlers
|
109
109
|
false
|
110
110
|
end
|
111
111
|
end
|
@@ -78,7 +78,7 @@ module Plezi
|
|
78
78
|
# representing the index of the application (http://server/)
|
79
79
|
#
|
80
80
|
def redirect_to url, options = {}
|
81
|
-
return super
|
81
|
+
return super() if defined? super
|
82
82
|
raise 'Cannot redirect after headers were sent.' if response.headers_sent?
|
83
83
|
url = "#{request.base_url}/#{url.to_s.gsub('_', '/')}" if url.is_a?(Symbol) || ( url.is_a?(String) && url.empty? ) || url.nil?
|
84
84
|
# redirect
|
@@ -160,7 +160,7 @@ module Plezi
|
|
160
160
|
# block:: an optional block, in case the template has `yield`, the block will be passed on to the template and it's value will be used inplace of the yield statement.
|
161
161
|
#
|
162
162
|
# options aceept the following keys:
|
163
|
-
#
|
163
|
+
# format:: the format for the `:layout' and 'template'. can be any format (the file's sub-extention), such as `"json"`. defaults to `"html"`.
|
164
164
|
# layout:: a layout template that has at least one `yield` statement where the template will be rendered.
|
165
165
|
# locale:: the I18n locale for the render. (defaults to params\[:locale]) - only if the I18n gem namespace is defined (`require 'i18n'`).
|
166
166
|
#
|
@@ -181,20 +181,21 @@ module Plezi
|
|
181
181
|
return render(layout, options) { inner }
|
182
182
|
end
|
183
183
|
# set up defaults
|
184
|
-
options[:type]
|
184
|
+
@warned_type ||= (Iodine.warn("Deprecation warning! `#render` method called with optional `:type`. Use `:format` instead!") && true) if options[:type]
|
185
|
+
options[:format] ||= (options[:type] || params[:format] || 'html'.freeze).to_s
|
185
186
|
options[:locale] ||= params[:locale].to_sym if params[:locale]
|
186
187
|
#update content-type header
|
187
|
-
case options[:
|
188
|
+
case options[:format]
|
188
189
|
when 'html', 'js', 'txt'
|
189
|
-
response['content-type'] ||= "#{MimeTypeHelper::MIME_DICTIONARY[".#{options[:
|
190
|
+
response['content-type'] ||= "#{MimeTypeHelper::MIME_DICTIONARY[".#{options[:format]}".freeze]}; charset=utf-8".freeze
|
190
191
|
else
|
191
|
-
response['content-type'] ||= "#{MimeTypeHelper::MIME_DICTIONARY[".#{options[:
|
192
|
+
response['content-type'] ||= "#{MimeTypeHelper::MIME_DICTIONARY[".#{options[:format]}".freeze]}".freeze
|
192
193
|
end
|
193
194
|
# Circumvents I18n persistance issues (live updating and thread data storage).
|
194
195
|
I18n.locale = options[:locale] || I18n.default_locale if defined?(I18n) # sets the locale to nil for default behavior even if the locale was set by a previous action - removed: # && options[:locale]
|
195
196
|
# find template and create template object
|
196
197
|
template = [template] if template.is_a?(String)
|
197
|
-
filename = ( template.is_a?(Array) ? File.join( host_params[:templates].to_s, *template) : File.join( host_params[:templates].to_s, *template.to_s.split('_') ) ) + (options[:
|
198
|
+
filename = ( template.is_a?(Array) ? File.join( host_params[:templates].to_s, *template) : File.join( host_params[:templates].to_s, *template.to_s.split('_'.freeze) ) ) + (options[:format].empty? ? ''.freeze : ".#{options[:format]}".freeze)
|
198
199
|
::Plezi::Renderer.render filename, binding, &block
|
199
200
|
end
|
200
201
|
|
@@ -211,9 +212,9 @@ module Plezi
|
|
211
212
|
# respond to websocket special case
|
212
213
|
return :pre_connect if request.upgrade?
|
213
214
|
# respond to save 'new' special case
|
214
|
-
return (self.class.has_method?(:save) ? :save : false) if (request.request_method =~ /POST|PUT|PATCH/i.freeze) && (params[:id].nil? || params[:id] == 'new')
|
215
|
+
return (self.class.has_method?(:save) ? :save : false) if (request.request_method =~ /POST|PUT|PATCH/i.freeze) && (params[:id].nil? || params[:id] == 'new'.freeze)
|
215
216
|
# set DELETE method if simulated
|
216
|
-
request.request_method = 'DELETE' if params[:_method] && params[:_method].to_s.downcase == 'delete'
|
217
|
+
request.request_method = 'DELETE'.freeze if params[:_method] && params[:_method].to_s.downcase == 'delete'.freeze
|
217
218
|
# respond to special :id routing
|
218
219
|
params[:id].to_s.downcase.to_sym.tap { |met| return met if self.class.has_exposed_method?(met) } if params[:id]
|
219
220
|
#review general cases
|
@@ -92,7 +92,7 @@ module Plezi
|
|
92
92
|
end
|
93
93
|
module_function
|
94
94
|
def new placebo_class, create = true
|
95
|
-
new_class_name = "PlaceboPlezi__#{placebo_class.name.gsub /[\:\-\#\<\>\{\}\(\)\s]
|
95
|
+
new_class_name = "PlaceboPlezi__#{placebo_class.name.gsub( /[\:\-\#\<\>\{\}\(\)\s]/ , '_')}"
|
96
96
|
new_class = nil
|
97
97
|
new_class = Module.const_get new_class_name if Module.const_defined? new_class_name
|
98
98
|
unless new_class
|
@@ -105,7 +105,7 @@ module Plezi
|
|
105
105
|
i, o = IO.pipe
|
106
106
|
req = {}
|
107
107
|
handler = new_class.new(i, o, req)
|
108
|
-
|
108
|
+
Placebo::Base::PlaceboIO.new i, handler: handler, request: req
|
109
109
|
handler
|
110
110
|
end
|
111
111
|
end
|
data/lib/plezi/handlers/route.rb
CHANGED
@@ -120,7 +120,7 @@ module Plezi
|
|
120
120
|
end
|
121
121
|
dest.default_proc = Plezi::Base::Helpers::HASH_SYM_PROC
|
122
122
|
|
123
|
-
url = '/'
|
123
|
+
url = '/'.dup
|
124
124
|
|
125
125
|
@url_array.each do |sec|
|
126
126
|
raise NotImplementedError, "#url_for isn't implemented for this router - Regexp multi-path routes are still being worked on... use a named parameter instead (i.e. '/foo/(:multi_route){route1|route2}/bar')" if REGEXP_FORMATTED_PATH === sec
|
@@ -130,19 +130,19 @@ module Plezi
|
|
130
130
|
|
131
131
|
if param_name && dest[param_name]
|
132
132
|
url << Plezi::Base::Helpers.encode_url(dest.delete(param_name))
|
133
|
-
url << '/'
|
133
|
+
url << '/'.freeze
|
134
134
|
elsif !param_name
|
135
135
|
url << sec
|
136
|
-
url << '/'
|
136
|
+
url << '/'.freeze
|
137
137
|
elsif REGEXP_REQUIRED_PARAMS === sec || REGEXP_OPTIONAL_PARAMS === sec
|
138
|
-
url << '/'
|
138
|
+
url << '/'.freeze
|
139
139
|
elsif REGEXP_FORMATTED_REQUIRED_PARAMS === sec
|
140
140
|
raise ArgumentError, "URL can't be formatted becuse a required parameter (#{param_name.to_s}) isn't specified and it requires a special format (#{REGEXP_FORMATTED_REQUIRED_PARAMS.match(sec)[2]})."
|
141
141
|
end
|
142
142
|
end
|
143
143
|
unless dest.empty?
|
144
|
-
add = '?'
|
145
|
-
dest.each {|k, v| url << "#{add}#{Plezi::Base::Helpers.encode_url k}=#{Plezi::Base::Helpers.encode_url v}"; add = '&'}
|
144
|
+
add = '?'.freeze
|
145
|
+
dest.each {|k, v| url << "#{add}#{Plezi::Base::Helpers.encode_url k}=#{Plezi::Base::Helpers.encode_url v}"; add = '&'.freeze}
|
146
146
|
end
|
147
147
|
url
|
148
148
|
|
@@ -177,9 +177,9 @@ module Plezi
|
|
177
177
|
@url_array = []
|
178
178
|
|
179
179
|
# prep path string and split it where the '/' charected is unescaped.
|
180
|
-
@url_array = path.gsub(/(^\/)|(\/$)/, '').gsub(/([^\\])\//, '\1 - /').split ' - /'
|
180
|
+
@url_array = path.gsub(/(^\/)|(\/$)/, ''.freeze).gsub(/([^\\])\//, '\1 - /').split ' - /'
|
181
181
|
@url_array.each.with_index do |section, section_index|
|
182
|
-
if section == '*'
|
182
|
+
if section == '*'.freeze
|
183
183
|
# create catch all
|
184
184
|
section_index == 0 ? (@path << "(.*)") : (@path << "(\\/.*)?")
|
185
185
|
# finish
|
@@ -252,7 +252,7 @@ module Plezi
|
|
252
252
|
# end
|
253
253
|
m = @path.match path
|
254
254
|
return false unless m
|
255
|
-
@fill_parameters.each { |k, v| hash[v] = m[k][1..-1] if m[k] && m[k] != '/' }
|
255
|
+
@fill_parameters.each { |k, v| hash[v] = m[k][1..-1] if m[k] && m[k] != '/'.freeze }
|
256
256
|
hash
|
257
257
|
end
|
258
258
|
|
@@ -270,7 +270,7 @@ module Plezi
|
|
270
270
|
# flash:: an amazing Hash object that sets temporary cookies for one request only - greate for saving data between redirect calls.
|
271
271
|
#
|
272
272
|
def self.make_controller_magic(controller, container)
|
273
|
-
new_class_name = "Plezi__#{controller.name.gsub
|
273
|
+
new_class_name = "Plezi__#{controller.name.gsub(/[\:\-\#\<\>\{\}\(\)\s]/ , '_'.freeze)}"
|
274
274
|
return Module.const_get new_class_name if Module.const_defined? new_class_name
|
275
275
|
# controller.include Plezi::ControllerMagic
|
276
276
|
controller.instance_exec(container) {|r| include Plezi::ControllerMagic; }
|
@@ -15,12 +15,12 @@ module Plezi
|
|
15
15
|
# delete(key); clear;
|
16
16
|
class Session
|
17
17
|
|
18
|
-
# The session's lifetime in seconds =
|
19
|
-
SESSION_LIFETIME =
|
18
|
+
# The session's lifetime in seconds = 24 hours. This is only true when using the built in support for the Redis persistent storage.
|
19
|
+
SESSION_LIFETIME = 60*60*24
|
20
20
|
# called by the Plezi framework to initiate a session with the id requested
|
21
21
|
def initialize id
|
22
22
|
@id = id
|
23
|
-
if id &&
|
23
|
+
if id && Plezi.redis
|
24
24
|
return self
|
25
25
|
end
|
26
26
|
failed
|
@@ -67,6 +67,7 @@ module Plezi
|
|
67
67
|
end
|
68
68
|
failed
|
69
69
|
end
|
70
|
+
alias :refresh :to_h
|
70
71
|
|
71
72
|
# @return [String] returns the Session data in YAML format.
|
72
73
|
def to_s
|
@@ -77,7 +77,7 @@ module Plezi
|
|
77
77
|
@results << ret if @results
|
78
78
|
ret
|
79
79
|
else
|
80
|
-
@locker.synchronize { sync
|
80
|
+
@locker.synchronize { sync(&block) }
|
81
81
|
end
|
82
82
|
end
|
83
83
|
|
@@ -92,6 +92,7 @@ module Plezi
|
|
92
92
|
module InstanceMethods
|
93
93
|
protected
|
94
94
|
|
95
|
+
# @!visibility public
|
95
96
|
# The following method registers the connections as a unique global identity.
|
96
97
|
#
|
97
98
|
# Like {Plezi::Base::WSObject::SuperClassMethods#notify}, using this method requires an active Redis connection
|
@@ -134,10 +135,12 @@ module Plezi
|
|
134
135
|
end
|
135
136
|
end
|
136
137
|
|
138
|
+
# @!visibility public
|
137
139
|
# sends a notification to an Identity. Returns false if the Identity never registered or it's registration expired.
|
138
140
|
def notify identity, event_name, *args
|
139
141
|
self.class.notify identity, event_name, *args
|
140
142
|
end
|
143
|
+
# @!visibility public
|
141
144
|
# returns true if the Identity in question is registered to receive notifications.
|
142
145
|
def registered? identity
|
143
146
|
self.class.registered? identity
|
@@ -29,7 +29,7 @@ module Plezi
|
|
29
29
|
def self.translate_message msg
|
30
30
|
begin
|
31
31
|
@safe_types ||= [Symbol, Date, Time, Encoding, Struct, Regexp, Range, Set]
|
32
|
-
|
32
|
+
YAML.safe_load(msg, @safe_types)
|
33
33
|
rescue => e
|
34
34
|
Iodine.error "The following could be a security breach attempt:"
|
35
35
|
Iodine.error e
|
@@ -79,7 +79,7 @@ module Plezi
|
|
79
79
|
return false if data[:type] && data[:type] != :all && !self.is_a?(data[:type])
|
80
80
|
# return ( self.class.placebo? ? true : we.write(ws.data)) if :method == :to_client
|
81
81
|
return ((data[:type] == :all) ? false : (raise "Broadcasting recieved but no method can handle it - dump:\r\n #{data.to_s}") ) unless self.class.has_super_method?(data[:method])
|
82
|
-
self.method(data[:method]).call
|
82
|
+
self.method(data[:method]).call(*data[:data])
|
83
83
|
end
|
84
84
|
|
85
85
|
# Get's the websocket's unique identifier for unicast transmissions.
|
data/lib/plezi/version.rb
CHANGED
data/plezi.gemspec
CHANGED
@@ -18,7 +18,7 @@ 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_dependency "iodine", "~> 0.1.
|
21
|
+
spec.add_dependency "iodine", "~> 0.1.13"
|
22
22
|
spec.add_development_dependency "bundler", "~> 1.7"
|
23
23
|
spec.add_development_dependency "rake", "~> 10.0"
|
24
24
|
|
data/resources/mini_app.rb
CHANGED
@@ -22,7 +22,7 @@
|
|
22
22
|
ENV['PL_REDIS_URL'] ||= ENV['REDIS_URL'] ||
|
23
23
|
ENV['REDISCLOUD_URL'] ||
|
24
24
|
ENV['REDISTOGO_URL'] ||
|
25
|
-
nil # "redis
|
25
|
+
nil # "redis://:password@my.host:6389/0"
|
26
26
|
# # redis channel name should be changed is using Placebo API
|
27
27
|
# Plezi::Settings.redis_channel_name = 'appsecret'
|
28
28
|
|
@@ -68,6 +68,10 @@ host templates: Root.join('templates').to_s,
|
|
68
68
|
# # I18n re-write, i.e.: `/en/home` will be rewriten as `/home`, while setting params[:locale] to "en"
|
69
69
|
# route "/:locale{#{I18n.available_locales.join "|"}}/*" , false if defined? I18n
|
70
70
|
|
71
|
+
# # Response format re-write, i.e.: `/xml/home` will use .xml templates automatically
|
72
|
+
# # with :locale a request might look like `/en/json/...`
|
73
|
+
# route "/:format{html|json|xml}/*" , false
|
74
|
+
|
71
75
|
# # OAuth2 - Facebook / Google authentication
|
72
76
|
# ENV["FB_APP_ID"] ||= "app id"; ENV["FB_APP_SECRET"] ||= "secret"; ENV['GOOGLE_APP_ID'] = "app id"; ENV['GOOGLE_APP_SECRET'] = "secret"
|
73
77
|
# require 'plezi/oauth' # do this AFTER setting ENV variables.
|
data/resources/redis_config.rb
CHANGED
@@ -18,7 +18,7 @@ if defined? Redis
|
|
18
18
|
ENV['PL_REDIS_URL'] ||= ENV['REDIS_URL'] ||
|
19
19
|
ENV['REDISCLOUD_URL'] ||
|
20
20
|
ENV['REDISTOGO_URL'] ||
|
21
|
-
nil # use: "redis
|
21
|
+
nil # use: "redis://:password@my.host:6389/0"
|
22
22
|
|
23
23
|
|
24
24
|
# ## OR, write your own custom Redis implementation here
|
@@ -28,10 +28,10 @@ if defined? Redis
|
|
28
28
|
# ##
|
29
29
|
# ## the following is only sample code for you to change:
|
30
30
|
# RADIS_CHANNEL = 'appsecret'
|
31
|
-
# RADIS_URI =
|
32
|
-
# RADIS_CONNECTION = Redis.new(
|
31
|
+
# RADIS_URI = ENV['REDIS_URL'] || ENV['REDISCLOUD_URL'] || "redis://:password@my.host:6389/0"
|
32
|
+
# RADIS_CONNECTION = Redis.new(RADIS_URI)
|
33
33
|
# RADIS_THREAD = Thread.new do
|
34
|
-
# Redis.new(
|
34
|
+
# Redis.new(RADIS_URI).subscribe(RADIS_CHANNEL) do |on|
|
35
35
|
# on.message do |channel, msg|
|
36
36
|
# msg = JSON.parse(msg)
|
37
37
|
# # do stuff, i.e.:
|
data/resources/routes.rb
CHANGED
@@ -13,6 +13,11 @@
|
|
13
13
|
# i.e.: `/en/home` will be rewriten as `/home`, while setting params[:locale] to "en"
|
14
14
|
route "/:locale{#{I18n.available_locales.join "|"}}/*" , false if defined? I18n
|
15
15
|
|
16
|
+
# # This is an optional re-write route response formats.
|
17
|
+
# # Response format re-write, i.e.: `/xml/home` will use .xml templates automatically
|
18
|
+
# # with :locale a request might look like `/en/json/...`
|
19
|
+
# route "/:format{html|json|xml}/*" , false
|
20
|
+
|
16
21
|
###
|
17
22
|
# add your routes here:
|
18
23
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: plezi
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.12.
|
4
|
+
version: 0.12.13
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Boaz Segev
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-11-
|
11
|
+
date: 2015-11-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: iodine
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 0.1.
|
19
|
+
version: 0.1.13
|
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.1.
|
26
|
+
version: 0.1.13
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: bundler
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|