blacksheep 0.2.0 → 0.2.2

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
  SHA256:
3
- metadata.gz: 75dfef125950bec755e918dba9e56bf6877ab8a3baedc2e42d16b62e31aa395c
4
- data.tar.gz: 4ef04a290cd93670d126e910022cada3a16bb446af06eb26e759073c87e2a3b6
3
+ metadata.gz: 0f9f95a300f2d7c84826615cb86a66fabe8ecdd680edabf6b9e960973d8f5f83
4
+ data.tar.gz: 3cdfd65ec9647bed1ff5df0261b000227f395d379a9c310e8def4de9b0439c83
5
5
  SHA512:
6
- metadata.gz: '0084555561e9b92801cf7524379c6e3523eda987a612beb869f8be81abf69c4ebba673ebf609c1310074f7f2d65c954998061cb70701e1052a6efb6507431eeb'
7
- data.tar.gz: d5e729097addb0df435e051c8289de2e8c0ca06d1d17d1690c630ab251a657d169719b5dc70cde2744537aac5f0cf544d9ee05d2596668151ff306609d5054b2
6
+ metadata.gz: ac515283bff176a47ffa4b6159e169c7a3776bc1e2d0f587182e479420b805b0633e2f909a9720bbff15bcc68776ce9f180e51e6a014e2e2ef2ae261b6114d94
7
+ data.tar.gz: 1c7008322b347109e570b87f8a83b6512a7380c4021e779655fb80f8bd426efc9aad3a1a606c73dd09e7735f2a85dd927e5f8f472ce5650323ec7d90283c82cf
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- blacksheep (0.1.0)
4
+ blacksheep (0.2.2)
5
5
  dry-matcher
6
6
 
7
7
  GEM
@@ -38,4 +38,4 @@ DEPENDENCIES
38
38
  rspec (~> 3.0)
39
39
 
40
40
  BUNDLED WITH
41
- 1.17.2
41
+ 1.17.3
data/README.md CHANGED
@@ -24,24 +24,24 @@ Or install it yourself as:
24
24
 
25
25
  ### Actions
26
26
 
27
- Core if blacksheep is the Blacksheep::Action. It provides basic fuctionality to handle rest API actions - but can handle other actions as well. The core methods of Actions are:
27
+ Core of blacksheep is the `Blacksheep::Action`. It provides basic functionality to handle rest API actions - but can handle other actions as well. The core methods of actions are:
28
28
 
29
- * #perform, and…
30
- * #call
29
+ * #perform with a block that implements the action
30
+ * #call on an action instance for processing and a potential block for result matching (see dcorators below).
31
31
 
32
32
  `#perform` takes a block that is executed with the params passed. #perform has the following api:
33
33
  `#perform(params, current_user: (default to nil), **options)`
34
34
 
35
- `#call` can be used when a Blacksheep::Action is sublassed as an action processing its opertation in a call method with the same signature of `#perform`
35
+ `#call` can be used when a Blacksheep::Action is sublassed as an action processing its opertation in a call method with the same signature of `#perform`. When using the `ResultMatcher` decorator a block can be used for result matching.
36
36
 
37
37
 
38
38
  ```ruby
39
- ##perform sample
39
+ #perform sample
40
40
  action_result = Blacksheep::Action.new.perform(params) do |params|
41
41
  # do somethin with the params that return a `Blacksheep::ActionResult`
42
42
  end
43
43
 
44
- ##perform sample
44
+ #call sample
45
45
  action_result = MyAction.new.call(params, current_user: current_user)
46
46
  ```
47
47
 
@@ -50,14 +50,14 @@ action_result = MyAction.new.call(params, current_user: current_user)
50
50
 
51
51
  ### Decorators
52
52
 
53
- This alone does not give any benefit. It more interesting to modifiy the action with decorators such as:
53
+ This alone does not give any benefit. Modifying the action with decorators adds additional functionality:
54
54
 
55
55
  * `JsonTransformer`
56
56
  * `Localizer`
57
57
  * `DefaultErrorHandler`
58
58
  * `ResultMatcher`
59
59
 
60
- The decaorators can be configured globaly by defining them in an initializer.
60
+ The decaorators can be configured globally by defining them in an initializer.
61
61
 
62
62
  ```ruby
63
63
  # Defining decorator wheras innermost is first
@@ -74,7 +74,7 @@ A localizer sets the I18n locale when passed in a request parameter named `_loca
74
74
 
75
75
  #### Blacksheep::Decorators::DefaultErrorHandler
76
76
 
77
- A default error handler can be used in API opertions. The handler catches an error and returns a JsonResultObject such as
77
+ A default error handler can be used in API opertions. The handler catches an error and returns an ActionResult such as
78
78
 
79
79
  ```ruby
80
80
  def handle_exception(exception)
@@ -93,20 +93,20 @@ def handle_exception(exception)
93
93
  end
94
94
  ```
95
95
 
96
- You can write your own Errorhandler by including the module `Blacksheep::Decorators::ErrorHandler` and implementing the method `#handle(exception)`.
96
+ You can write your own ErrorHandler by including the module `Blacksheep::Decorators::ErrorHandler` and implementing the method `#handle_exception(<Exception>)`.
97
97
 
98
98
 
99
99
  #### Blacksheep::Decorators::JsonTransformer
100
100
 
101
- Assuming the params is a json payload with a specific caseing (e.g. camelCase when used in a JS application such as vue) the JsonTransfomer takes the params and tranforms it's keys into snake_case as used in ruby often.
102
- The request has to define the case passed (and hence desired response casing) in the parameter `_case`. If the case is requests as `camel` then paramter keys are tranformed to `snake_case` before going into the action and are transformed back into CamelCase when leaving the operation.
101
+ Assuming the params is a json payload with a specific caseing (e.g. camelCase when used in a JS application such as Vue) the JsonTransfomer takes the params and transforms it's keys into snake_case as used in ruby often.
102
+ The request has to define the case passed (and hence desired response casing) in the parameter `_case`. If the case is requests as `camel` then parameter keys are transformed to `snake_case` before beeing passed into the action and are transformed back into CamelCase when leaving the operation.
103
103
 
104
104
  If JsonTransfomer is used the action should return a simple JSON structure which is transfformed and stored in an ActionResult.
105
105
 
106
106
 
107
107
  #### Blacksheep::Decorators::ResultMatcher
108
108
 
109
- This decorator can be used when implementing your own actions by subclassing `Blacksheep::Action` and using the `#call` style for processing. Adding the matcher decorator enables to write a matchers such as e.g.
109
+ This decorator can be used when implementing your own actions by subclassing `Blacksheep::Action` and using the `#call` style for processing. Adding the `ResultMatcher` decorator enables to write a matcher block such as
110
110
 
111
111
  ```ruby
112
112
  MyAction.new.call(params) do |m|
@@ -122,7 +122,7 @@ MyAction.new.call(params) do |m|
122
122
  end
123
123
  ```
124
124
 
125
- The action has to return a Blacksheep::ActionResult which is check for status :ok in sucess case and any other status in failure case.
125
+ The action has to return a Blacksheep::ActionResult which is checked for status `:ok` for success case and any other status in failure case.
126
126
 
127
127
 
128
128
  ## Development
@@ -134,7 +134,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
134
134
  ```
135
135
  gem build blacksheep
136
136
  gem push blacksheep-0.x.y.gem
137
- ```
137
+ ``
138
138
 
139
139
  ## Contributing
140
140
 
data/blacksheep.gemspec CHANGED
@@ -18,7 +18,7 @@ Gem::Specification.new do |spec|
18
18
  # to allow pushing to a single host or delete this section to allow pushing to any host.
19
19
  if spec.respond_to?(:metadata)
20
20
  spec.metadata["homepage_uri"] = spec.homepage
21
- # spec.metadata["source_code_uri"] = "Put your gem's public repo URL here."
21
+ spec.metadata["source_code_uri"] = "https://github.com/verticonaut/blacksheep"
22
22
  # spec.metadata["changelog_uri"] = "Put your gem's CHANGELOG.md URL here."
23
23
  else
24
24
  raise "RubyGems 2.0 or newer is required to protect against " \
@@ -1,3 +1,3 @@
1
1
  module Blacksheep
2
- VERSION = "0.2.0"
2
+ VERSION = "0.2.2"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: blacksheep
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Martin Schweizer
@@ -99,6 +99,7 @@ licenses:
99
99
  - MIT
100
100
  metadata:
101
101
  homepage_uri: http://verticonaut.me
102
+ source_code_uri: https://github.com/verticonaut/blacksheep
102
103
  post_install_message:
103
104
  rdoc_options: []
104
105
  require_paths: