rack-app 0.8.2 → 0.9.0

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: f354006b28577531d5475264217bc1f94770bc78
4
- data.tar.gz: e0d5291b96f6d00be4286771a81b796f85476b62
3
+ metadata.gz: dde5ac113879f10a79548e3c815ce6df2ce1c1f4
4
+ data.tar.gz: 737dce792b8d47068228ff468e6a25db9224e377
5
5
  SHA512:
6
- metadata.gz: 4d1fefa42b85e8eb4dcd181dacab530dd482674d07f72ed760ab82ea2341e7f68051102e7c8c8d8cc71a0c548de0d979086defc232dd1f535844aa18967b647d
7
- data.tar.gz: 4ebfc87b84b62cc0d1cb4b1e32cda171fc5c0b2184ad755afdc982f0423deae75bcb941d54c616146f3780baa5afc6a6c9aaec2baf05da25790273d6624c9a2a
6
+ metadata.gz: 3749bd9e51a5da2eead8467043088bfaa73d25952128366a098c09e24449691eed5771f2976e3bce79b481637d6e10dc92bb6af8aef686996c93ab722c99f5ca
7
+ data.tar.gz: abd365ac5e50dc6780a7171ae2e47bab25de55339fe92d7d61475d5ec8d6b4279d41b42dd996fa5ef5c08998e602f946e277a028503d9de9ba66a8556a04c7e5
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.8.2
1
+ 0.9.0
@@ -30,6 +30,8 @@ class Rack::App
30
30
  @last_description = description_texts.join("\n")
31
31
  end
32
32
 
33
+ alias desc description
34
+
33
35
  def get(path = '/', &block)
34
36
  add_route('GET', path, &block)
35
37
  end
@@ -1,5 +1,7 @@
1
1
  class Rack::App::Endpoint
2
2
 
3
+ attr_reader :properties
4
+
3
5
  def initialize(api_class, properties={}, &logic_block)
4
6
  @properties = properties
5
7
  @logic_block = logic_block
@@ -3,32 +3,39 @@ class Rack::App::Router
3
3
  require 'rack/app/router/static'
4
4
  require 'rack/app/router/dynamic'
5
5
 
6
+ #TD
7
+ def endpoint_paths
8
+ @static.endpoints.map do |indentifiers, endpoint|
9
+ [[*indentifiers].join("\t"),endpoint.properties[:description]].compact.join("\t\t\t")
10
+ end
11
+ end
12
+
6
13
  def add_endpoint(request_method, request_path, endpoint)
7
14
  if defined_path_is_dynamic?(Rack::App::Utils.normalize_path(request_path))
8
- @dynamic_router.add_endpoint(request_method, request_path, endpoint)
15
+ @dynamic.add_endpoint(request_method, request_path, endpoint)
9
16
  else
10
- @static_router.add_endpoint(request_method, request_path, endpoint)
17
+ @static.add_endpoint(request_method, request_path, endpoint)
11
18
  end
12
19
  end
13
20
 
14
21
  def fetch_endpoint(request_method, request_path)
15
- @static_router.fetch_endpoint(request_method, request_path) or
16
- @dynamic_router.fetch_endpoint(request_method, request_path) or
22
+ @static.fetch_endpoint(request_method, request_path) or
23
+ @dynamic.fetch_endpoint(request_method, request_path) or
17
24
  Rack::App::Endpoint::NOT_FOUND
18
25
  end
19
26
 
20
27
  def merge!(router)
21
28
  raise(ArgumentError, "invalid router object, must be instance of #{self.class}") unless router.is_a?(self.class)
22
- @static_router.merge!(router.instance_variable_get(:@static_router))
23
- @dynamic_router.merge!(router.instance_variable_get(:@dynamic_router))
29
+ @static.merge!(router.instance_variable_get(:@static))
30
+ @dynamic.merge!(router.instance_variable_get(:@dynamic))
24
31
  nil
25
32
  end
26
33
 
27
34
  protected
28
35
 
29
36
  def initialize
30
- @static_router = Rack::App::Router::Static.new
31
- @dynamic_router = Rack::App::Router::Dynamic.new
37
+ @static = Rack::App::Router::Static.new
38
+ @dynamic = Rack::App::Router::Dynamic.new
32
39
  end
33
40
 
34
41
  def defined_path_is_dynamic?(path_str)
@@ -1,5 +1,8 @@
1
1
  class Rack::App::Router::Static
2
2
 
3
+ #TD
4
+ attr_reader :endpoints
5
+
3
6
  def add_endpoint(request_method, request_path, endpoint)
4
7
  @endpoints[[request_method.to_s.upcase, Rack::App::Utils.normalize_path(request_path)]]= endpoint
5
8
  end
@@ -14,6 +17,7 @@ class Rack::App::Router::Static
14
17
  nil
15
18
  end
16
19
 
20
+
17
21
  protected
18
22
 
19
23
  def initialize
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rack-app
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.2
4
+ version: 0.9.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adam Luzsi
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2015-12-09 00:00:00.000000000 Z
11
+ date: 2015-12-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler