soar_sc_routing 0.1.0 → 0.1.1

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: 9d26f7e7fdd02b09bad20b2d58479c51c0ca4289
4
- data.tar.gz: 242a83d9dbc18128a59a85cb708fa4c99b8cced6
3
+ metadata.gz: 4fea3c6587e087f991be068900975cf9cb55de40
4
+ data.tar.gz: 3de8a711bc33523266652720ac014c18e9946e71
5
5
  SHA512:
6
- metadata.gz: d0c9f3bbf5783e53cf09d75b239a2634891c94de0f4131369720df89b135b892aa33e2365040c1143dd003c2a274806c225b2566fe8c0ab2b0d3eca4a8e15136
7
- data.tar.gz: cddba5d15e661327dcc2bf9f80522f92a09f5c28db3200dfc9d6aa5c348a333d9c021aea2cc68c7c02631fd558d9ca996aa1bf8e7ce0048575edb49bb1ce8374
6
+ metadata.gz: 96c82424d98aeac09b2aa1d367d0a0d73be9b8fc4c99d5aa4dc5344213b72411defe5d81282b81541d02c4286d545aed43f20ab934f9352cc48a7c0c6021beab
7
+ data.tar.gz: 25dc7233e50a22e72da73375efb30aa07b741283180776039bfb0fb875a6f489211ecb8aa3588d19127f8f13df3d6801ce7dae34f0e48b31e956c4ecb548547c
data/.gitignore CHANGED
@@ -1,3 +1,4 @@
1
+ *.gem
1
2
  /.bundle/
2
3
  /.yardoc
3
4
  /Gemfile.lock
data/README.md CHANGED
@@ -1,8 +1,57 @@
1
1
  # SoarScRouting
2
2
 
3
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/soar_sc_routing`. To experiment with that code, run `bin/console` for an interactive prompt.
3
+ ## Features
4
4
 
5
- TODO: Delete this and the text above, and describe your gem
5
+ ### RouterMeta
6
+ This library facilitates the registration of routes and their meta for use by a router. The SOAR reference implementation uses this library to register routes and meta for soar_sc routers.
7
+
8
+ When a route is registered, control is delegated as appropriate to the controller, renderer and access manager indicated in the meta.
9
+
10
+ An IoC function is provided that specialization classes can use to group registrations in during initialization of the router meta instance.
11
+
12
+ An IoC function is provided to delegate rendering of views to the specialized class.
13
+
14
+ ### BaseRouter
15
+
16
+ This library also provides a base router to build routers from. The router will search all paths registered with it and call the block registered for the first matched path.
17
+
18
+ The block delegates to the controller specified in the meta, and then renders the ouput using the renderer (view) specified in the meta.
19
+
20
+ The base router also provides two IoC functions to cater for routes not found and exceptions while routing.
21
+
22
+ ### Router meta
23
+
24
+ Router meta is validated during registration and takes the form:
25
+
26
+ ```ruby
27
+ { 'description' => 'description',
28
+ 'service_name' => 'service_name',
29
+ 'method' => 'GET/POST/...',
30
+ 'path' => '/path',
31
+ 'params' => { 'para' => 'm1'},
32
+ 'nfrs' => { 'secured' => 'SIGNED/UNSIGNED',
33
+ 'authorization' => 'AUTHORIZED/UNAUTHORIZED'
34
+ }
35
+ }
36
+ ```
37
+
38
+ If a route is marked as AUTHORIZED, the route and the access manager set are registered with SoarAuthorization::Authorize.
39
+
40
+ The interpretation of a route marked as SIGNED is left up to the router implementation. In soar_sc SIGNED activates and requires SMAAK for requests traversing the route.
41
+
42
+ ###Validation errors:
43
+
44
+ ```ruby
45
+ ArgumentError "detail must not be nil" if the detail parameter is nil
46
+ ArgumentError "path must be provided" if detail['path'] is nil
47
+ ArgumentError "description must be provided" if detail['description']
48
+ ArgumentError "service_name must be provided" if detail['service_name']
49
+ ArgumentError "method must be provided" if detail['method'] is nil
50
+ ArgumentError "params must be provided" if detail['params']
51
+ ArgumentError "nfrs must be provided" if detail['nfrs']
52
+ ArgumentError "nfrs['authorization'] must be provided" if detail['nfrs']['authorization'] is nil
53
+ ArgumentError "nfrs['secured'] must be provided" if detail['nfrs']['secured'] is nil
54
+ ```
6
55
 
7
56
  ## Installation
8
57
 
@@ -22,18 +71,66 @@ Or install it yourself as:
22
71
 
23
72
  ## Usage
24
73
 
25
- TODO: Write usage instructions here
74
+ ### RouterMeta
26
75
 
27
- ## Development
76
+ ```ruby
77
+ class AuthenticatedRouterMeta < SoarScRouting::RouterMeta
78
+ def policy_am
79
+ @policy_am ||= SoarPolicyAccessManager::PolicyAccessManager.new(SoarSc::service_registry)
80
+ @policy_am
81
+ end
82
+
83
+ def setup_routing_table
84
+ # register_route({
85
+ # 'description' => 'Given a pattern, finds services matching the pattern and reports where they can be accessed',
86
+ # 'service_name' => 'where-is-it',
87
+ # 'path' => '/where-is-it',
88
+ # 'method' => 'get',
89
+ # 'params' => {
90
+ # 'pattern' => {
91
+ # 'required' => 'true', 'type' => 'string'
92
+ # }
93
+ # },
94
+ # 'nfrs' => {
95
+ # 'authorization' => 'AUTHORIZED',
96
+ # 'secured' => 'UNSIGNED'
97
+ # },
98
+ # 'view' => {
99
+ # 'renderer' => 'json',
100
+ # 'name' => 'where_is_it'
101
+ # },
102
+ # 'controller' => 'WhereIsIt'
103
+ # }, SoarSc::startup_flow_id)
104
+ end
105
+
106
+ def render_view(detail, http_code, body)
107
+ renderer = SoarSc::Renderer.new
108
+ renderer.render_view(detail, http_code, body)
109
+ end
110
+ end
111
+ ```
28
112
 
29
- After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
113
+ ### BaseRouter
30
114
 
31
- To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
115
+ ```ruby
116
+ class SoarScRouter < SoarScRouting::BaseRouter
117
+ def not_found
118
+ SoarSc::Web::Views::Default.not_found
119
+ end
120
+
121
+ def excepted(ex)
122
+ SoarSc::Web::Views::Default.error(ex)
123
+ end
124
+ end
125
+ ```
32
126
 
33
127
  ## Contributing
34
128
 
35
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/soar_sc_routing.
129
+ Please send feedback and comments to the author at:
130
+
131
+ Ernst van Graan <ernst.van.graan@hetzner.co.za>
36
132
 
133
+ This gem is sponsored by Hetzner (Pty) Ltd - http://hetzner.co.za
37
134
 
38
135
  ## License
39
136
 
@@ -73,7 +73,7 @@ module SoarScRouting
73
73
  def setup_routing_table
74
74
  end
75
75
 
76
- # IOC renderer for views
76
+ # IoC renderer for views
77
77
  def render_view(detail, http_code, body)
78
78
  raise NotImplementedError.new "No renderer"
79
79
  end
@@ -1,3 +1,3 @@
1
1
  module SoarScRouting
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: soar_sc_routing
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ernst Van Graan