plezi 0.12.0 → 0.12.1

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: c3641815744ffb10926c4e95a6fd47a7fcb4ba1f
4
- data.tar.gz: a44e5be3f88040d8d46ff5adf6469fd3efad66c9
3
+ metadata.gz: bb98dd3b32e4204480007a592bdd9e7d7b55fa08
4
+ data.tar.gz: b5b670f66538b2a98d7306176528ddfd45e6a878
5
5
  SHA512:
6
- metadata.gz: 88072db2e3f71acb5a5b5e96764f285f20e7b8a0194e07122b24fd06e46fec9b38aa98c0a27a9c6551c3e30625b7568f8bb2765db752e20dd836da371c4bfe18
7
- data.tar.gz: 77c52cfba2bfb6e2ad0c7c7a80dd0d2d84a8d0893327ccb983406b0b4e049fcbbf4134dbbdb22517ed46f19ac4d1b6093b9701c0ab6ad223cb537a31303a2da5
6
+ metadata.gz: 78e46c96f20cc3955000f0cb32a2ebf7c5cd1d472176bdba6990b3f4f840271a6cb3426bd0774eb96d9493e90e44ad22c68164ce4fa7bf2a4be4ef869ef12fe0
7
+ data.tar.gz: 90fe75d999ab81c05ea98249907c368858eaf0c4bab5145630e23428cf3549a5c96eef0fc78abb53ae7b3341ddd34818723da8fd4b20fd28803da005bf25d5f6
data/CHANGELOG.md CHANGED
@@ -2,7 +2,17 @@
2
2
 
3
3
  ***
4
4
 
5
- Change log v.0.12.0 - API changes (throwing out dead code)
5
+ Change log v.0.12.1
6
+
7
+ **Fix**: fixed an issue with the app template, where a typo (an extra comma sign ',') caused the `host` command to fail.
8
+
9
+ **API**: The `host` method can now be used without a host name (only passing a Hash), automatically falling back to the default host.
10
+
11
+ **Update**: Plezi version number now displays as the server starts running.
12
+
13
+ ***
14
+
15
+ Change log v.0.12.0 - API changes (throwing out dead code and many more changes)
6
16
 
7
17
  **Feature** The `Controller.failed_unicast(target, method, arguments_array)` callback is here, allowing you to write a class level callback that will be called if `unicast` fails to find it's target (i.e. if the Websocket connection was already closed or the hosting server shutdown).
8
18
 
data/README.md CHANGED
@@ -330,18 +330,26 @@ Plezi can be used to create virtual hosts for the same service, allowing you to
330
330
 
331
331
  require 'plezi'
332
332
 
333
+ # define a named host.
333
334
  host 'localhost', alias: 'localhost2', public: File.join('my', 'public', 'folder')
334
335
 
335
- shared_route '/humans.txt' do |req, res|
336
- res << "we are people - shared by all routes."
336
+ shared_route '/shared' do |req, res|
337
+ res << "shared by all existing hosts.... but the default host doesn't exist yet, so we're only on localhost and localhost2."
337
338
  end
338
339
 
340
+ # define a default (catch-all) host.
339
341
  host
340
342
 
343
+ shared_route '/humans.txt' do |req, res|
344
+ res << "we are people - we're in every existing hosts."
345
+ end
346
+
347
+
341
348
  route('*') do |req, res|
342
349
  res << "this is a 'catch-all' host. you got here by putting in the IP adderess."
343
350
  end
344
351
 
352
+ # get's the existing named host
345
353
  host 'localhost'
346
354
 
347
355
  route('*') do |req, res|
@@ -352,6 +360,8 @@ Now visit:
352
360
 
353
361
  * [http://127.0.0.1:3000/]( http://127.0.0.1:3000/ )
354
362
  * [http://localhost:3000/]( http://localhost:3000/ )
363
+ * [http://127.0.0.1:3000/shared]( http://127.0.0.1:3000/shared ) - won't show, becuse this host was created AFTER the route was declered.
364
+ * [http://localhost:3000/shared]( http://localhost:3000/shared )
355
365
  * [http://127.0.0.1:3000/humans.txt]( http://127.0.0.1:3000/humans.txt )
356
366
  * [http://localhost:3000/humans.txt]( http://localhost:3000/humans.txt )
357
367
  * notice: `localhost2` will only work if it was defined in your OS's `hosts` file.
@@ -460,7 +470,7 @@ try:
460
470
  * [http://localhost:3000/](http://localhost:3000/)
461
471
  * [http://localhost:3000/fr](http://localhost:3000/fr)
462
472
  * [http://localhost:3000/users/hello](http://localhost:3000/users/hello)
463
- * [http://localhost:3000/users/(5+5*20-15)/9.0](http://localhost:3000/users/(5+5*20-15)/9.0)
473
+ * [http://localhost:3000/users/(5+5*20-15)/9.0](http://localhost:3000/users/(5+5*20-15)/9.0) - should return a 404 not found message.
464
474
  * [http://localhost:3000/(5+5*20-15)/9.0](http://localhost:3000/(5+5*20-15)/9)
465
475
  * [http://localhost:3000/fr/(5+5*20-15)/9.0](http://localhost:3000/fr/(5+5*20-15)/9)
466
476
  * [http://localhost:3000/users/hello?_method=delete](http://localhost:3000/users/hello?_method=delete)
data/lib/plezi.rb CHANGED
@@ -141,3 +141,13 @@ require 'plezi/handlers/session.rb'
141
141
  ##############################################################################
142
142
  module Plezi
143
143
  end
144
+
145
+ Encoding.default_internal = 'utf-8'
146
+ Encoding.default_external = 'utf-8'
147
+ Iodine.threads = 30
148
+ Iodine.run { puts "Plezi is feeling optimistic running version #{::Plezi::VERSION}.\n\n"}
149
+ # PL is a shortcut for the Plezi module, so that `PL == Plezi`.
150
+ PL = Plezi
151
+
152
+
153
+
@@ -27,10 +27,12 @@ module Plezi
27
27
  # A default host can be created or accessed by using `:default` of false for the host name.
28
28
  #
29
29
  # Accepts:
30
- # host_name:: the name (domain name) of the host as a String object. Use the Symbol `:default` for the catch-all domain name.
30
+ # host_name:: (optional, can be omitted) the name (domain name) of the host as a String object. Use the Symbol `:default` for the catch-all domain name.
31
+ # options_hash:: see further detail.
31
32
  #
32
33
  #
33
34
  # The options is a Hash object with any of the following options (Hash keys):
35
+ # host:: the ost name to be used if one isn't supplied as a direct argument. Defaults to the `:default` host.
34
36
  # alias:: a String or an Array of Strings which represent alternative host names (i.e. `alias: ["admin.google.com", "admin.gmail.com"]`).
35
37
  # public:: the public root folder. if this is defined, static files will be served from this folder and all it's sub-folders. Plezi does NOT support file indexing.
36
38
  # assets:: the assets root folder. defaults to nil (no assets support). if the path is defined, assets will be served from `/assets/...` (or the public_asset path defined) before any static files. assets will not be served if the file in the /public/assets folder if up to date (a rendering attempt will be made for systems that allow file writing).
@@ -52,7 +54,7 @@ module Plezi
52
54
  #
53
55
  # @return [::Plezi::Base::HTTPRouter]
54
56
  #
55
- def host(host_name, params)
57
+ def host(host_name, params = {})
56
58
  ::Plezi::Base::HTTPRouter.add_host host_name, params
57
59
  end
58
60
 
@@ -80,7 +82,4 @@ module Plezi
80
82
  def start_rack
81
83
  Iodine.warn "`start_rack` is deprecated. There is no need to call this method."
82
84
  end
83
- end
84
-
85
- Encoding.default_internal = 'utf-8'
86
- Encoding.default_external = 'utf-8'
85
+ end
@@ -1,6 +1,3 @@
1
- # PL is a shortcut for the Plezi module, so that `PL == Plezi`.
2
- PL = Plezi
3
-
4
1
  unless defined? PLEZI_NON_DSL
5
2
 
6
3
  # shortcut for Plezi.listen. Deprecated.
@@ -37,5 +37,4 @@ module Plezi
37
37
  @uuid ||= SecureRandom.uuid
38
38
  end
39
39
  end
40
- end
41
- Iodine.threads = 30
40
+ end
@@ -40,6 +40,7 @@ module Plezi
40
40
 
41
41
  # adds a host to the router (or activates an existing host to add new routes). accepts a host name and any parameters not related to the actual connection (ssl etc') (see {Plezi.host})
42
42
  def add_host host_name, params = {}
43
+ (params = host_name) && (host_name = params.delete(:host)) if host_name.is_a?(Hash)
43
44
  params[:index_file] ||= 'index.html'
44
45
  params[:assets_public] ||= '/assets'
45
46
  params[:assets_public].chomp! '/'
@@ -52,7 +53,7 @@ module Plezi
52
53
  # adds an alias to an existing host name (normally through the :alias parameter in the `add_host` method).
53
54
  def add_alias host_name, *aliases
54
55
  host = get_host host_name
55
- host ||= add_host :default
56
+ raise "Couldn't find requested host to add alias." unless host.
56
57
  aliases.each {|a| @hosts[a.to_s.downcase] = host}
57
58
  true
58
59
  end
data/lib/plezi/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Plezi
2
- VERSION = "0.12.0"
2
+ VERSION = "0.12.1"
3
3
  end
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.0"
21
+ spec.add_dependency "iodine", "~> 0.1.2"
22
22
  spec.add_development_dependency "bundler", "~> 1.7"
23
23
  spec.add_development_dependency "rake", "~> 10.0"
24
24
 
@@ -42,8 +42,8 @@ Dir[File.join "{lib}", "**" , "*.rb"].each {|file| load File.expand_path(file)}
42
42
  Dir[File.join "{app}", "**" , "*.rb"].each {|file| load File.expand_path(file)}
43
43
 
44
44
  # change some of the default settings here.
45
- host :default,
46
- public: Root.join('public').to_s,
47
- assets: Root.join('assets').to_s,
48
- assets_public: '/assets',
49
- templates: Root.join('app','views').to_s,
45
+ host host: :default,
46
+ public: Root.join('public').to_s,
47
+ assets: Root.join('assets').to_s,
48
+ assets_public: '/assets',
49
+ templates: Root.join('app','views').to_s
@@ -63,7 +63,7 @@ end
63
63
 
64
64
 
65
65
  # change some of the default settings here.
66
- host :default,
66
+ host host: :default,
67
67
  # public: Root.join('public').to_s,
68
68
  assets: Root.join('assets').to_s,
69
69
  templates: Root.join('templates').to_s
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.0
4
+ version: 0.12.1
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-10-23 00:00:00.000000000 Z
11
+ date: 2015-10-25 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.0
19
+ version: 0.1.2
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.0
26
+ version: 0.1.2
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: bundler
29
29
  requirement: !ruby/object:Gem::Requirement