rackstep 0.0.5 → 0.0.6

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5ae595eef51cb68ce8488b0198916fd31f58a993
4
- data.tar.gz: e0cac291299b137a9d5c94369e67a6ef696a6396
3
+ metadata.gz: c3866ac6c17a85fac202f9de763be70c4d9df32b
4
+ data.tar.gz: 349bb18c310d7e97f52840e3df4e8df013df482b
5
5
  SHA512:
6
- metadata.gz: 8558d518e2296257a2e6c59b2423bc6532ffadb97aab79950aa765c36ab09661862fc0f25d055128e92fc9aca4f812756b7dcd6f6e723969928214e83aa8382e
7
- data.tar.gz: bd486f7573e6d50f024ec8fc09a61f96e85f520745e95bc68df2febe352d46d2eeb82d542bb254b0a6326ff6d1c06b08ffe7e135d42f137b3e71d2c0799de330
6
+ metadata.gz: 8383810ce40b6bccb3e73765474f2dd9c6c54f874c1f1f1afa0d2fbf6c876e9f2cef339551cf42bdd36770aa76617ee9dc0b869e5a3acbf6dd9b7215ecd183c1
7
+ data.tar.gz: 3fd135d83a1d24d03999c3be03a1057ebc3ea32afc3c8ae4109b0dc6742b72b97dae4a6e690077b2a0b7a1e01aa06e436d3a70fb4729e31091f65aa896336d8d
data/lib/controller.rb CHANGED
@@ -9,12 +9,6 @@ class RackStep::Controller
9
9
  # The Rack::Response object that will be delivered to the user.
10
10
  attr_accessor :response
11
11
 
12
- # The 'global' app settings will be injected here. This hash variable is
13
- # initialized only once (singleton) and may contain references to things
14
- # that should be initialize only once during the app start (eg: database
15
- # connection).
16
- attr_accessor :settings
17
-
18
12
  def initialize
19
13
  @response = RackStep::Response.new
20
14
  @response.body = ''
@@ -56,7 +50,7 @@ class RackStep::NotFoundController < RackStep::Controller
56
50
  def process_request
57
51
  @response.body = '404 - Page not found'
58
52
  @response.content_type = 'text/plain'
59
- @response.status = 404
53
+ @response.status = 404
60
54
  end
61
55
 
62
56
  end
@@ -79,6 +73,7 @@ module RackStep::Controller::ErbRendering
79
73
 
80
74
  end
81
75
 
76
+
82
77
  # A module for controllers to add basic http authentication helper method.
83
78
  module RackStep::Controller::BasicHttpAuthentication
84
79
 
data/lib/rackstep.rb CHANGED
@@ -8,7 +8,6 @@ require 'rack'
8
8
  require_relative 'response'
9
9
  require_relative 'route'
10
10
  require_relative 'router'
11
- require_relative 'global_configuration'
12
11
  require_relative 'controller'
13
12
 
14
13
  module RackStep
@@ -17,15 +16,10 @@ module RackStep
17
16
  # This class MUST be extended by the user.
18
17
  class App
19
18
 
20
- # Will store the received request which will be injected into the user controllers.
19
+ # Stores the received request which will then be injected into the user controllers.
21
20
  attr_reader :request
22
21
 
23
- # A hash that will be injected into the controller. This hash may contain
24
- # "global" settings, like a connection to database and other things that
25
- # should be initiaized only once while the app is starting.
26
- attr_accessor :settings
27
-
28
- # Router is a singleton that will store all the registred routes.
22
+ # Access the Router, a singleton class that stores all the registred routes.
29
23
  def router
30
24
  Router.instance
31
25
  end
@@ -35,10 +29,9 @@ module RackStep
35
29
  new(env).process_request
36
30
  end
37
31
 
38
- # Initialize all instance variables and add a default "not found" route.
32
+ # Initialize the request instance variable and add a default "not found" route.
39
33
  def initialize(env)
40
34
  @request = Rack::Request.new(env)
41
- @settings = RackStep::GlobalConfiguration.instance.settings
42
35
 
43
36
  # Adding default routes to handle page not found (404).
44
37
  router.add_route_for_all_verbs('notfound', 'RackStep::NotFoundController')
@@ -57,8 +50,6 @@ module RackStep
57
50
  controller = Object.const_get(route.controller).new
58
51
  # Inject the request into the controller.
59
52
  controller.request = request
60
- # Inject the settings into the controller.
61
- controller.settings = settings
62
53
  # Execute the before method of this controller.
63
54
  controller.send(:before)
64
55
  # Execute the apropriate method/action.
data/lib/router.rb CHANGED
@@ -20,6 +20,7 @@ module RackStep
20
20
  end
21
21
 
22
22
  def add_route(verb, path, controller)
23
+ path = path[1..-1] if path[0] == '/' # Ignoring the first char if path starts with '/'.
23
24
  route = Route.new(verb, path, controller)
24
25
  routes[route.id] = route
25
26
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rackstep
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Marcio Frayze David
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-02-23 00:00:00.000000000 Z
11
+ date: 2016-04-27 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: RackStep is (yet another) micro ruby framework for microservices and
14
14
  web development.
@@ -18,7 +18,6 @@ extensions: []
18
18
  extra_rdoc_files: []
19
19
  files:
20
20
  - lib/controller.rb
21
- - lib/global_configuration.rb
22
21
  - lib/rackstep.rb
23
22
  - lib/response.rb
24
23
  - lib/route.rb
@@ -1,24 +0,0 @@
1
- # A singleton class with a settings hash attribute which may be used to
2
- # to store all 'global' settings (eg: database connections, etc).
3
- # This settings variable will be injected into every controller
4
- # by RackStep.
5
-
6
- class RackStep::GlobalConfiguration
7
-
8
- # One and only one instance of this class will exist. To retrieve it,
9
- # we use RackStep::GlobalConfiguration.instance, but please DO NOT
10
- # get it this way. The settings hash will be available to you in the
11
- # controller and you should access it with the "settings" object that
12
- # is inject into your controller.
13
- # To see how to use it, please take a look at sample_app.rb initialize
14
- # method and SimpleSettingsRetrieveService controller class.
15
- include Singleton
16
-
17
- attr_accessor :settings
18
-
19
- # Defines a Hash where the settings shall be stored.
20
- def initialize
21
- @settings = Hash.new
22
- end
23
-
24
- end