plezi 0.12.10 → 0.12.11

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 370c59a78e3874c2067f70543d851f99955d861c
4
- data.tar.gz: 07eed42ed14d2697e2121e59a491e3c971bb0ed4
3
+ metadata.gz: 62e0baae54098f49628c5839052832c2043ebb8e
4
+ data.tar.gz: b2ca34509ef493ea4d6ba05cdd717d18caf3c125
5
5
  SHA512:
6
- metadata.gz: 8255bf1ff52a41d9bb1451f568945dfc7c41d89f0e7c49bca160b00811439f3ae8be39656968509659031dbc60223f47086330054de7462283374e1223123da8
7
- data.tar.gz: 603b3c5130068700e8a4511b85b20c015dc68bf995cf13a034577b431a0f0a52f6f10d4cbac54b54def075d1bfd2d6d19e6b7404de13b4cb7342ed644f97de6c
6
+ metadata.gz: 150705d026352147363f666b1b5caa764a7fc7043a2ebc62fefd15b0402da748477ae9731fb4b60fad448540738fb73792a30406b153e83a5e485df61e2ba4aa
7
+ data.tar.gz: 408cd6ca1b67c831f65b1bdbdd38cbca9c96786f2510c12eca380001234263fe23b51882972abb0818ac46f77bb9dc9bd6d6126448e8c42bfd6ed97de547f28c
@@ -2,6 +2,12 @@
2
2
 
3
3
  ***
4
4
 
5
+ Change log v.0.12.11
6
+
7
+ **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.
8
+
9
+ ***
10
+
5
11
  Change log v.0.12.10
6
12
 
7
13
  **Fix**: removed a debug message introduced when fixing the renderer for version 0.12.9.
data/README.md CHANGED
@@ -14,6 +14,14 @@ With Plezi, you can easily:
14
14
 
15
15
  3. Create an easily scalable backend for your SPA.
16
16
 
17
+ ## Guides and documentation
18
+
19
+ You can find [tutorials and guides at Plezi.io](http://www.plezi.io/guides).
20
+
21
+ Plezi leverages Ruby's mixins and meta-programming, so the YARD documentation is hard to navigate... I started writing guides for Plezi and would really appreciate any help you can offer.
22
+
23
+ Please feel free to [contribute to Plezi's guides](https://github.com/boazsegev/plezi-website), or even just observe the [plezi.io website's code](https://github.com/boazsegev/plezi-website) (implemented using Plezi).
24
+
17
25
  ## Installation
18
26
 
19
27
  Add this line to your application's Gemfile:
@@ -26,46 +34,42 @@ Or install it yourself as:
26
34
 
27
35
  $ gem install plezi
28
36
 
29
- ## Our first Plezi Application
37
+ ## Quick start
30
38
 
31
- I love starting small and growing. So, for my first Plezi application, I just want the basics. I will run the following in my terminal:
39
+ Plezi is super easy. Please read our [Getting Started guide](http://www.plezi.io/guides/basics) for more information.
32
40
 
33
- $ plezi mini appname
41
+ Here's a super quick intro:
34
42
 
35
- If you prefer to have the application template already full blown and ready for heavy lifting, complete with some common settings for common gems and code snippets you can activate, open your terminal and type:
43
+ ### A running start
36
44
 
37
- $ plezi new appname
45
+ Get a jump start by typing (in your terminal):
38
46
 
39
- That's it, we now have a our first Plezi application - it's a websocket chatroom (that's the starter code).
47
+ $ plezi mini appname
48
+ OR
49
+ $ plezi new appname
40
50
 
41
- On MacOS or linux, simply double click the `appname` script file to start the server. Or, from the terminal:
51
+ Next, simply double click the `appname` script file to start the server. Or, from the terminal:
42
52
 
43
53
  $ cd appname
44
- $ ./appname # ( or: plezi s )
54
+ $ ruby ./appname
45
55
 
46
56
  See it work: [http://localhost:3000/](http://localhost:3000/)
47
57
 
48
- ## So easy, we can code an app in the terminal!
58
+ ### Hello world
49
59
 
50
60
  The Plezi framework was designed with intuitive ease of use in mind.
51
61
 
52
- Question - what's the shortest "Hello World" web-application when writing for Sinatra or Rails? ... can you write one in your own terminal window?
53
-
54
- In Plezi, it looks like this:
62
+ Open the `irb` terminal and type:
55
63
 
56
64
  require 'plezi'
57
65
  route('*') { "Hello World!" }
58
66
  exit # <- this exits the terminal and starts the server
59
67
 
60
- Three lines! Now visit [localhost:3000](http://localhost:3000/)
68
+ A Hello World web application using three lines of code (one line is the actual code)... see it at [localhost:3000](http://localhost:3000/).
61
69
 
62
- ### Object Oriented design is fun!
70
+ ### Hello Object Oriented design
63
71
 
64
- While Plezi allows us to utilize methods, like we just did, Plezi really shines when we use Controller classes.
65
-
66
- Plezi will automatically map instance methods in any class to routes with complete RESTful routing support.
67
-
68
- Let's copy and paste this into our `irb` terminal:
72
+ Plezi really shines when we use Controller classes. Try this in your `irb` terminal:
69
73
 
70
74
  require 'plezi'
71
75
  class MyDemo
@@ -77,7 +81,7 @@ Let's copy and paste this into our `irb` terminal:
77
81
  def foo
78
82
  "Bar!"
79
83
  end
80
- # show is RESTful, it will answer '/(:id)'
84
+ # show is RESTful, it will answer any request looking like: '/(:id)'
81
85
  def show
82
86
  "Are you looking for: #{params[:id]}?"
83
87
  end
@@ -88,11 +92,7 @@ Let's copy and paste this into our `irb` terminal:
88
92
 
89
93
  Now visit [index](http://localhost:3000/) and [foo](http://localhost:3000/foo) or request an id, i.e. [http://localhost:3000/1](http://localhost:3000/1).
90
94
 
91
- Did you notice how the controller has natural access to the request's `params`?
92
-
93
- This is because Plezi inherits our controller and adds some magic to it, allowing us to read _and set_ cookies using the `cookies` Hash based cookie-jar, set or read session data using `session`, look into the `request`, set special headers for the `response`, store self destructing cookies using `flash` and so much more!
94
-
95
- ### Can websockets do that?!
95
+ ### Quick, websockets!
96
96
 
97
97
  Plezi was designed for websockets from the ground up. If your controller class defines an `on_message(data)` callback, plezi will automatically enable websocket connections for that route.
98
98
 
@@ -109,29 +109,25 @@ Here's a Websocket echo server using Plezi:
109
109
  route '/', MyDemo
110
110
  exit
111
111
 
112
- But that's not all, each controller is also a "channel" which can broadcast to everyone who's connected to it.
112
+ Each controller is also a "channel" which can broadcast to everyone who's connected to it.
113
113
 
114
114
  Here's a websocket chat-room server using Plezi, comeplete with minor authentication (requires a chat handle):
115
115
 
116
116
  require 'plezi'
117
117
  class MyDemo
118
118
  def on_open
119
- # there's a better way to require a user handle, but this is good enough for now.
120
119
  close unless params[:id]
121
120
  end
122
121
  def on_message data
123
- # sanitize the data.
124
- data = ERB::Util.html_escape data
125
122
  # broadcast to everyone else (NOT ourselves):
126
- # this will have every connection execute the `chat_message` with the following argument(s).
127
- broadcast :chat_message, "#{params[:id]}: #{data}"
123
+ broadcast :chat_message, "#{params[:id]}: #{data}"
128
124
  # write to our own websocket:
129
- write "Me: #{data}"
125
+ chat_message "Me: #{data}"
130
126
  end
131
127
  protected
132
- # receive and implement the broadcast
128
+ # implement the broadcast event
133
129
  def chat_message data
134
- write data
130
+ write ERB::Util.html_escape(data)
135
131
  end
136
132
  end
137
133
 
@@ -145,17 +141,16 @@ Broadcasting isn't the only tool Plezi offers, we can also send a message to a s
145
141
 
146
142
  ...It's even possible to register a unique identity, such as a specific user or even a `session.id`, so their messages are waiting for them even when they're off-line (you decide how long they wait)! We simply use `register_as @user.id` in our `on_open` callback, and than the user can get notifications sent by `notify user.id, :evet_method, *args`.
147
143
 
148
- ### Websocket scaling is as easy as one line of code!
149
-
150
- A common issue with Websocket scaling is trying to send websocket messages from server X to a user connected to server Y... On Heroku, it's enough add one Dyno (a total of two Dynos) to break some websocket applications.
144
+ ### Scaling? easy!
151
145
 
152
- Plezi leverages the power or Redis to automatically push both websocket messages and Http session data across servers, so that you can easily scale your applications (on Heroku, add Dynos) with only one line of code!
153
-
154
- Just tell Plezi how to acess your Redis server and Plezi will make sure that your users get their messages and that your application can access it's session data accross different servers:
146
+ Scale your Websocket application with one line of code:
155
147
 
156
148
  # REDIS_URL is where Herolu-Redis stores it's URL
157
149
  ENV['PL_REDIS_URL'] ||= ENV['REDIS_URL'] || "redis://username:password@my.host:6389"
158
150
 
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
+
153
+
159
154
  ### Hosts, template rendering, assets...?
160
155
 
161
156
  Plezi allows us to use different host-names for different routes. i.e.:
@@ -189,7 +184,8 @@ Each host has it's own settings for a public folder, asset rendering, templates
189
184
 
190
185
  Plezi supports ERB (i.e. `template.html.erb`), Slim (i.e. `template.html.slim`), Haml (i.e. `template.html.haml`), CoffeeScript (i.e. `asset.js.coffee`) and Sass (i.e. `asset.css.scss`) right out of the box... and it's even extendible using the `Plezi::Renderer.register` and `Plezi::AssetManager.register`
191
186
 
192
- ## More about Plezi Controller classes
187
+
188
+ ## Longer version - Plezi Controller classes
193
189
 
194
190
  One of the best things about the Plezi is it's ability to take in any class as a controller class and route to the classes methods with special support for RESTful methods (`index`, `show`, `new`, `save`, `update`, `delete`, `before` and `after`) and for WebSockets (`pre_connect`, `on_open`, `on_message(data)`, `on_close`, `broadcast`, `unicast`, `multicast`, `on_broadcast(data)`, `register_as(identity)`, `notify`).
195
191
 
@@ -213,9 +213,9 @@ module Plezi
213
213
  # respond to save 'new' special case
214
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
215
  # set DELETE method if simulated
216
- request.request_method = 'DELETE' if params[:_method].to_s.downcase == 'delete'
216
+ request.request_method = 'DELETE' if params[:_method] && params[:_method].to_s.downcase == 'delete'
217
217
  # respond to special :id routing
218
- return params[:id].to_s.to_sym if params[:id] && self.class.has_exposed_method?(params[:id].to_s.to_sym)
218
+ params[:id].to_s.downcase.to_sym.tap { |met| return met if self.class.has_exposed_method?(met) } if params[:id]
219
219
  #review general cases
220
220
  case request.request_method
221
221
  when 'GET'.freeze, 'HEAD'.freeze
@@ -1,3 +1,3 @@
1
1
  module Plezi
2
- VERSION = "0.12.10"
2
+ VERSION = "0.12.11"
3
3
  end
@@ -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.11"
21
+ spec.add_dependency "iodine", "~> 0.1.12"
22
22
  spec.add_development_dependency "bundler", "~> 1.7"
23
23
  spec.add_development_dependency "rake", "~> 10.0"
24
24
 
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.10
4
+ version: 0.12.11
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 00:00:00.000000000 Z
11
+ date: 2015-11-12 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.11
19
+ version: 0.1.12
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.11
26
+ version: 0.1.12
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: bundler
29
29
  requirement: !ruby/object:Gem::Requirement