plezi 0.7.1 → 0.7.2

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: 030d9117d441e83606c9ad6c5e27fbc19a6db318
4
- data.tar.gz: ad87f43274ae4c0186f5357dcde773968fb17f0e
3
+ metadata.gz: c99bfcd9b6a94d36a2fa750a98c0c7316e24845c
4
+ data.tar.gz: 078b931cef17cedb26f6ff8e7de28da62601164d
5
5
  SHA512:
6
- metadata.gz: 8267042b38ee5f2db6a21d32c2f0d533a32aae06c66627bd74b100f06850126ede7ceaf758cb79d8d963050d645cd4292730e57f1025d3fa273f2848cb8f3f2b
7
- data.tar.gz: fa8952d9489c4282c517889c73f32644a3bc16247e9c31ab6aef57e9131ebc645e81387bd2fa16c12d3cbf227d2c971cd6b70fcfe2139f596a0bb663370ada0a
6
+ metadata.gz: 82e261621440b280c9a50e95b96c3ea0621a2097a1780a5da76889fc374aa094449e7c1bd262266d64839238eafb982e05f2455aee16f264ff45caaa1fb230da
7
+ data.tar.gz: 2540f2e21dc643fd5395617841a6c3d3e5aa1da294461eab4db0c919355fe5c2771bfa346061e5556df9a646916cb9f39fae99a20a97c3a971198cc3a5a4bd93
data/CHANGELOG.md CHANGED
@@ -2,6 +2,14 @@
2
2
 
3
3
  ***
4
4
 
5
+ Change log v.0.7.2
6
+
7
+ **fix**: fixed the template's Proc file for Heroku integration. There was a issue due to the main app file name convention change (the app file no longer has the .rb extention, and now the Proc file correctly reflects that change).
8
+
9
+ **fix**: recognition of floats caused conversion errors for stings that are nomeric with multiple dots (i.e. 1.1.2015). Also, float recognition was discovered to be non-reversable (i.e `"1.10".to_f.to_s #==> "1.1"`). For this reason, float recognition has been removed. Fixnum recognition is still active.
10
+
11
+ ***
12
+
5
13
  Change log v.0.7.1 - OLDER CODE MIGHT BREAK!
6
14
 
7
15
  **feature**: ruby objects (Integers, Floats, true & false) are now automatically converted from strings to Ruby objects (notice that 'true' and 'false' ARE case sensative, to preserve the value in case of a #to_s method call)
@@ -276,7 +284,7 @@ Change log v.0.5.1
276
284
 
277
285
  Change log v.0.5.0
278
286
 
279
- **feature:** Multiple (virtual) hosts on the same port are now available `listen port, host: 'foo', file_root: 'public/'`, each host holds it's own route stack, file_root and special paramaters (i.e. `:debug` etc'). greate for different namespaces (admin.foo.com, www.foo.com, etc').
287
+ **feature:** Multiple (virtual) hosts on the same port are now available `listen port, host: 'foo', file_root: 'public/'`, each host holds it's own route stack, file_root and special parameters (i.e. `:debug` etc'). greate for different namespaces (admin.foo.com, www.foo.com, etc').
280
288
 
281
289
  **fix**: Magic params have full featured Regex capabilities for the optional routes (`(:optional){(regex)|([7]{3})}`).
282
290
 
@@ -325,15 +333,15 @@ the following features are added
325
333
 
326
334
  - magic routes:
327
335
 
328
- it is now possible to set required paramaters inside the route:
336
+ it is now possible to set required parameters inside the route:
329
337
  ```ruby
330
338
  route "/version/:number/", Controller
331
339
  # => accepts only paths styled "/version/foo".
332
- # => if no version paramater exists, path will not be called and paramaters will not be set.
340
+ # => if no version paramater exists, path will not be called and parameters will not be set.
333
341
  # => (this: "/version" fails).
334
342
  ```
335
343
 
336
- it is now possible to set optional paramaters inside the route:
344
+ it is now possible to set optional parameters inside the route:
337
345
  ```ruby
338
346
  route "/user/(:id)/(:visitor_id)", Controller
339
347
  # => accepts any of the following paths:
@@ -353,7 +361,7 @@ route "/user/(:id)/*", Controller
353
361
 
354
362
  - re-write routes:
355
363
 
356
- re-write routes allow us to extract paramaters from the route without any controller, rewriting the request's path.
364
+ re-write routes allow us to extract parameters from the route without any controller, rewriting the request's path.
357
365
 
358
366
  they can be extreamly powerful in fairly rare but interesting circumstances.
359
367
 
data/bin/plezi CHANGED
@@ -56,7 +56,7 @@ class AppTemplate
56
56
  app_tree["routes.rb"] ||= IO.read ::File.expand_path(File.join("..", "..", "resources" ,"routes.rb"), __FILE__)
57
57
  app_tree["rakefile.rb"] ||= IO.read ::File.expand_path(File.join("..", "..", "resources" ,"rakefile.rb"), __FILE__)
58
58
  app_tree["Procfile"] ||= ""
59
- app_tree["Procfile"] << "\nweb: bundle exec ./#{ARGV[1]}.rb -p $PORT\n"
59
+ app_tree["Procfile"] << "\nweb: bundle exec ./#{ARGV[1]} -p $PORT\n"
60
60
  app_tree["Gemfile"] ||= IO.read ::File.expand_path(File.join("..", "..", "resources" ,"Gemfile"), __FILE__)
61
61
 
62
62
  # set up config files
@@ -123,7 +123,7 @@ class AppTemplate
123
123
  @app_tree["#{ARGV[1]}"] ||= IO.read ::File.expand_path(File.join("..", "..", "resources" ,"code.rb"), __FILE__)
124
124
  write_files app_tree
125
125
  File.chmod 0775, "#{ARGV[1]}"
126
- puts "tried to update execution permissions. this probably failed.".pink
126
+ puts "tried to update execution permissions. this is system dependent and might have failed.".pink
127
127
  puts "use: chmod +x ./#{ARGV[1]} to set execution permissions on Unix machines."
128
128
  puts ""
129
129
  puts "done."
@@ -277,10 +277,10 @@ else
277
277
  puts "n alias for new."
278
278
  puts "new app with gem 'new' accepts the 'with' paramater (or w for short)."
279
279
  puts "starting up an app:".pink
280
- puts "start runs the app. accepts any paramaters the app supports."
280
+ puts "start runs the app. accepts any parameters the app supports."
281
281
  puts "s alias for start/server."
282
282
  puts "start console innsead of services:".pink
283
- puts "console runs the app. accepts any paramaters the app supports."
283
+ puts "console runs the app. accepts any parameters the app supports."
284
284
  puts "c alias for start/server."
285
285
  puts "==============================".green
286
286
  puts "create an app with specific plugins:".pink
@@ -291,9 +291,9 @@ else
291
291
  puts "plezi n app w all"
292
292
  puts "loads the all available gem(s) and allows them to update the template before building the app.".green
293
293
  puts ""
294
- puts "start the application with any paramaters it supports:".pink
294
+ puts "start the application with any parameters it supports:".pink
295
295
  puts "plezi s -p 80"
296
- puts "loads the app with paramaters -p 80".green
296
+ puts "loads the app with parameters -p 80".green
297
297
  puts ""
298
298
  end
299
299
 
data/lib/plezi.rb CHANGED
@@ -105,7 +105,7 @@ end
105
105
  # # client requests: /1
106
106
  # # => Plezi::StubRESTCtrl.new.show() # where params[:id] == 1
107
107
  #
108
- # it is possible to use "magic" routes (i.e. `/resource/:type/(:id)/(:date){/[0-9]{8}}/:foo`) and it is also possible to set the appropriate paramaters within the `before` method of the Conltroller.
108
+ # it is possible to use "magic" routes (i.e. `/resource/:type/(:id)/(:date){/[0-9]{8}}/:foo`) and it is also possible to set the appropriate parameters within the `before` method of the Conltroller.
109
109
  #
110
110
  # Routes are handled in the order they are created. If overlapping routes exist, the first will execute first:
111
111
  #
@@ -80,7 +80,7 @@ PL = Plezi
80
80
  # creates a server object and waits for routes to be set.
81
81
  #
82
82
  # port:: the port to listen to. the first port defaults to 3000 and increments by 1 with every `listen` call. it's possible to set the first port number by running the app with the -p paramater.
83
- # params:: a Hash of serever paramaters, as listed in the Plezi#add_service documentation.
83
+ # params:: a Hash of serever parameters, as listed in the Plezi#add_service documentation.
84
84
  #
85
85
  # The different keys in the params hash control the server's behaviour, as follows:
86
86
  #
@@ -114,7 +114,7 @@ end
114
114
  # path:: the path for the route
115
115
  # controller:: The controller class which will accept the route.
116
116
  #
117
- # `path` paramaters has a few options:
117
+ # `path` parameters has a few options:
118
118
  #
119
119
  # * `path` can be a Regexp object, forcing the all the logic into controller (typically using the before method).
120
120
  #
@@ -140,7 +140,7 @@ end
140
140
  #
141
141
  # magic routes make for difficult debugging - the smarter the routes, the more difficult the debugging.
142
142
  # use with care and avoid complex routes when possible. RESTful routes are recommended when possible.
143
- # json serving apps are advised to use required paramaters, empty sections indicating missing required paramaters (i.e. /path///foo/bar///).
143
+ # json serving apps are advised to use required parameters, empty sections indicating missing required parameters (i.e. /path///foo/bar///).
144
144
  #
145
145
  def route(path, controller = nil, &block)
146
146
  Plezi::DSL.route(path, controller, &block)
@@ -38,7 +38,7 @@ module Plezi
38
38
  # `callback( Kernel, :sleep, 1 ) { puts "this is a demo" }`
39
39
  # callback sets an asynchronous method call with a callback.
40
40
  #
41
- # paramaters:
41
+ # parameters:
42
42
  # object:: the object holding the method to be called (use `Kernel` for global methods).
43
43
  # method:: the method's name (Symbol). this is the method that will be called.
44
44
  # *arguments:: any additional arguments that should be sent to the method (the main method, not the callback).
@@ -14,7 +14,7 @@ module Plezi
14
14
  # public API to add a service to the framework.
15
15
  # accepts:
16
16
  # port:: port number
17
- # parameters:: a hash of paramaters that are passed on to the service for handling (and from there, service dependent, to the protocol and/or handler).
17
+ # parameters:: a hash of parameters that are passed on to the service for handling (and from there, service dependent, to the protocol and/or handler).
18
18
  #
19
19
  # parameters are any of the following:
20
20
  # host:: the host name. defaults to any host not explicitly defined (a catch-all).
@@ -38,12 +38,12 @@ module Plezi
38
38
  #
39
39
  # templates can be either an ERB file on a Haml file.
40
40
  #
41
- def add_service port, paramaters = {}
42
- paramaters[:port] ||= port
43
- paramaters[:service_type] ||= ( paramaters[:ssl] ? SSLService : BasicService)
41
+ def add_service port, parameters = {}
42
+ parameters[:port] ||= port
43
+ parameters[:service_type] ||= ( parameters[:ssl] ? SSLService : BasicService)
44
44
  service = nil
45
- service = paramaters[:service_type].create_service(port, paramaters) unless ( defined?(BUILDING_PLEZI_TEMPLATE) || defined?(PLEZI_ON_RACK) )
46
- S_LOCKER.synchronize {SERVICES[service] = paramaters}
45
+ service = parameters[:service_type].create_service(port, parameters) unless ( defined?(BUILDING_PLEZI_TEMPLATE) || defined?(PLEZI_ON_RACK) )
46
+ S_LOCKER.synchronize {SERVICES[service] = parameters}
47
47
  info "Started listening on port #{port}."
48
48
  true
49
49
  end
@@ -26,7 +26,7 @@ module Plezi
26
26
  # the request object, class: HTTPRequest.
27
27
  attr_reader :request
28
28
 
29
- # the ::params variable contains all the paramaters set by the request (/path?locale=he => params["locale"] == "he").
29
+ # the ::params variable contains all the parameters set by the request (/path?locale=he => params["locale"] == "he").
30
30
  attr_reader :params
31
31
 
32
32
  # a cookie-jar to get and set cookies (set: `cookie\[:name] = data` or get: `cookie\[:name]`).
@@ -14,9 +14,9 @@ module Plezi
14
14
 
15
15
  # lets the route answer the request. returns false if no response has been sent.
16
16
  def on_request request
17
- fill_paramaters = match request.path
18
- return false unless fill_paramaters
19
- fill_paramaters.each {|k,v| HTTP.add_param_to_hash k, v, request.params }
17
+ fill_parameters = match request.path
18
+ return false unless fill_parameters
19
+ fill_parameters.each {|k,v| HTTP.add_param_to_hash k, v, request.params }
20
20
  response = HTTPResponse.new request
21
21
  if controller
22
22
  ret = controller.new(request, response, params)._route_path_to_methods_and_set_the_response_
@@ -35,9 +35,9 @@ module Plezi
35
35
 
36
36
  # handles Rack requests (dresses up as Rack).
37
37
  def call request
38
- fill_paramaters = match request.path_info
39
- return false unless fill_paramaters
40
- fill_paramaters.each {|k,v| HTTP.add_param_to_hash k, v, request.params }
38
+ fill_parameters = match request.path_info
39
+ return false unless fill_parameters
40
+ fill_parameters.each {|k,v| HTTP.add_param_to_hash k, v, request.params }
41
41
  response = HTTPResponse.new request
42
42
  if controller
43
43
  ret = controller.new(request, response, params)._route_path_to_methods_and_set_the_response_
@@ -55,7 +55,7 @@ module Plezi
55
55
  #
56
56
  # Regexp paths will be left unchanged
57
57
  #
58
- # a string can be either a simple string `"/users"` or a string with paramaters:
58
+ # a string can be either a simple string `"/users"` or a string with parameters:
59
59
  # `"/static/:required/(:optional)/(:optional_with_format){[\d]*}/:optional_2"`
60
60
  def initialize path, controller, params={}, &block
61
61
  @path_sections , @params = false, params
@@ -78,7 +78,7 @@ module Plezi
78
78
  # initializes the path by converting the string into a Regexp
79
79
  # and noting any parameters that might need to be extracted for RESTful routes.
80
80
  def initialize_path path
81
- @fill_paramaters = {}
81
+ @fill_parameters = {}
82
82
  if path.is_a? Regexp
83
83
  @path = path
84
84
  elsif path.is_a? String
@@ -119,34 +119,34 @@ module Plezi
119
119
  @path = /#{@path}$/
120
120
  return
121
121
 
122
- # check for routes formatted: /:paramater - required paramaters
122
+ # check for routes formatted: /:paramater - required parameters
123
123
  elsif section.match /^\:([^\(\)\{\}\:]*)$/
124
124
  #create a simple section catcher
125
125
  @path << section_search
126
126
  # add paramater recognition value
127
- @fill_paramaters[param_num += 1] = section.match(/^\:([^\(\)\{\}\:]*)$/)[1]
127
+ @fill_parameters[param_num += 1] = section.match(/^\:([^\(\)\{\}\:]*)$/)[1]
128
128
 
129
- # check for routes formatted: /:paramater{regexp} - required paramaters
129
+ # check for routes formatted: /:paramater{regexp} - required parameters
130
130
  elsif section.match /^\:([^\(\)\{\}\:\/]*)\{(.*)\}$/
131
131
  #create a simple section catcher
132
132
  @path << ( "(\/(" + section.match(/^\:([^\(\)\{\}\:\/]*)\{(.*)\}$/)[2] + "))" )
133
133
  # add paramater recognition value
134
- @fill_paramaters[param_num += 1] = section.match(/^\:([^\(\)\{\}\:\/]*)\{(.*)\}$/)[1]
134
+ @fill_parameters[param_num += 1] = section.match(/^\:([^\(\)\{\}\:\/]*)\{(.*)\}$/)[1]
135
135
  param_num += 1 # we are using two spaces
136
136
 
137
- # check for routes formatted: /(:paramater) - optional paramaters
137
+ # check for routes formatted: /(:paramater) - optional parameters
138
138
  elsif section.match /^\(\:([^\(\)\{\}\:]*)\)$/
139
139
  #create a optional section catcher
140
140
  @path << optional_section_search
141
141
  # add paramater recognition value
142
- @fill_paramaters[param_num += 1] = section.match(/^\(\:([^\(\)\{\}\:]*)\)$/)[1]
142
+ @fill_parameters[param_num += 1] = section.match(/^\(\:([^\(\)\{\}\:]*)\)$/)[1]
143
143
 
144
- # check for routes formatted: /(:paramater){regexp} - optional paramaters
144
+ # check for routes formatted: /(:paramater){regexp} - optional parameters
145
145
  elsif section.match /^\(\:([^\(\)\{\}\:]*)\)\{(.*)\}$/
146
146
  #create a optional section catcher
147
147
  @path << ( "(\/(" + section.match(/^\(\:([^\(\)\{\}\:]*)\)\{(.*)\}$/)[2] + "))?" )
148
148
  # add paramater recognition value
149
- @fill_paramaters[param_num += 1] = section.match(/^\(\:([^\(\)\{\}\:]*)\)\{(.*)\}$/)[1]
149
+ @fill_parameters[param_num += 1] = section.match(/^\(\:([^\(\)\{\}\:]*)\)\{(.*)\}$/)[1]
150
150
  param_num += 1 # we are using two spaces
151
151
 
152
152
  else
@@ -154,9 +154,9 @@ module Plezi
154
154
  @path << section
155
155
  end
156
156
  end
157
- unless @fill_paramaters.values.include?("id")
157
+ unless @fill_parameters.values.include?("id")
158
158
  @path << optional_section_search
159
- @fill_paramaters[param_num += 1] = "id"
159
+ @fill_parameters[param_num += 1] = "id"
160
160
  end
161
161
  @path = /#{@path}$/
162
162
  else
@@ -165,11 +165,11 @@ module Plezi
165
165
  return
166
166
  end
167
167
 
168
- # this performs the match and assigns the paramaters, if required.
168
+ # this performs the match and assigns the parameters, if required.
169
169
  def match path
170
170
  hash = {}
171
171
  m = nil
172
- # unless @fill_paramaters.values.include?("format")
172
+ # unless @fill_parameters.values.include?("format")
173
173
  # if (m = path.match /([^\.]*)\.([^\.\/]+)$/)
174
174
  # HTTP.add_param_to_hash 'format', m[2], hash
175
175
  # path = m[1]
@@ -177,7 +177,7 @@ module Plezi
177
177
  # end
178
178
  m = @path.match path
179
179
  return false unless m
180
- @fill_paramaters.each { |k, v| hash[v] = m[k][1..-1] if m[k] && m[k] != '/' }
180
+ @fill_parameters.each { |k, v| hash[v] = m[k][1..-1] if m[k] && m[k] != '/' }
181
181
  hash
182
182
  end
183
183
 
@@ -190,7 +190,7 @@ module Plezi
190
190
  #
191
191
  # adds the `redirect_to` and `send_data` methods to the controller class, as well as the properties:
192
192
  # env:: the env recieved by the Rack server.
193
- # params:: the request's paramaters.
193
+ # params:: the request's parameters.
194
194
  # cookies:: the request's cookies.
195
195
  # flash:: an amazing Hash object that sets temporary cookies for one request only - greate for saving data between redirect calls.
196
196
  #
@@ -79,7 +79,7 @@ module Plezi
79
79
  p.each_index { |i| p[i].strip! ; n = p[i].match(/^[0-9]+$/) ? p[i].to_i : p[i].to_sym ; p[i+1] ? [ ( a[n] ||= ( p[i+1] == ' ' ? [] : {} ) ), ( a = a[n]) ] : ( a.is_a?(Hash) ? (a[n] ? (a[n].is_a?(Array) ? (a << val) : a[n] = [a[n], val] ) : (a[n] = val) ) : (a << val) ) }
80
80
  rescue Exception => e
81
81
  Plezi.error e
82
- Plezi.error "(Silent): paramaters parse error for #{param_name} ... maybe conflicts with a different set?"
82
+ Plezi.error "(Silent): parameters parse error for #{param_name} ... maybe conflicts with a different set?"
83
83
  target_hash[param_name] = rubyfy! param_value
84
84
  end
85
85
  end
@@ -174,8 +174,6 @@ module Plezi
174
174
  string = false
175
175
  elsif string.match(/[0-9]/) && !string.match(/[^0-9]/)
176
176
  string = string.to_i
177
- elsif string.match(/[0-9]/) && !string.match(/[^0-9\.]/)
178
- string = string.to_f
179
177
  end
180
178
  string
181
179
  end
data/lib/plezi/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Plezi
2
- VERSION = "0.7.1"
2
+ VERSION = "0.7.2"
3
3
  end
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.7.1
4
+ version: 0.7.2
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-03-07 00:00:00.000000000 Z
11
+ date: 2015-03-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler