trailblazer 2.0.0 → 2.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (46) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGES.md +13 -0
  3. data/COMM-LICENSE +21 -21
  4. data/Gemfile +3 -0
  5. data/README.md +15 -77
  6. data/Rakefile +1 -2
  7. data/doc/operation-2017.png +0 -0
  8. data/lib/trailblazer.rb +0 -1
  9. data/lib/trailblazer/operation/callback.rb +10 -19
  10. data/lib/trailblazer/operation/contract.rb +7 -8
  11. data/lib/trailblazer/operation/guard.rb +4 -13
  12. data/lib/trailblazer/operation/model.rb +30 -32
  13. data/lib/trailblazer/operation/nested.rb +21 -32
  14. data/lib/trailblazer/operation/persist.rb +4 -8
  15. data/lib/trailblazer/operation/policy.rb +5 -15
  16. data/lib/trailblazer/operation/pundit.rb +8 -17
  17. data/lib/trailblazer/operation/rescue.rb +17 -17
  18. data/lib/trailblazer/operation/validate.rb +34 -21
  19. data/lib/trailblazer/operation/wrap.rb +12 -25
  20. data/lib/trailblazer/version.rb +1 -1
  21. data/test/docs/dry_test.rb +4 -4
  22. data/test/docs/fast_test.rb +164 -0
  23. data/test/docs/guard_test.rb +2 -2
  24. data/test/docs/macro_test.rb +36 -0
  25. data/test/docs/model_test.rb +52 -0
  26. data/test/docs/nested_test.rb +101 -4
  27. data/test/docs/operation_test.rb +225 -1
  28. data/test/docs/pundit_test.rb +18 -17
  29. data/test/docs/rescue_test.rb +3 -3
  30. data/test/docs/wrap_test.rb +1 -0
  31. data/test/operation/callback_test.rb +5 -5
  32. data/test/operation/contract_test.rb +30 -19
  33. data/test/operation/dsl/callback_test.rb +2 -2
  34. data/test/operation/dsl/contract_test.rb +4 -4
  35. data/test/operation/model_test.rb +12 -57
  36. data/test/operation/persist_test.rb +7 -7
  37. data/test/operation/pipedream_test.rb +9 -9
  38. data/test/operation/pipetree_test.rb +5 -5
  39. data/test/operation/pundit_test.rb +7 -7
  40. data/test/operation/resolver_test.rb +47 -47
  41. data/trailblazer.gemspec +1 -1
  42. metadata +18 -11
  43. data/lib/trailblazer/operation/builder.rb +0 -24
  44. data/lib/trailblazer/operation/resolver.rb +0 -22
  45. data/test/controller_test.rb +0 -115
  46. data/test/operation/builder_test.rb +0 -89
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9113e6cd01913594963d2bdd2007df2d82b1a162
4
- data.tar.gz: 6f9970934e06c98054d76635cfb0dd9353f03bb3
3
+ metadata.gz: 22aa58ebd31de1635012c1ef3af5758a7279d99f
4
+ data.tar.gz: bb3362c26f6efc71d04d97e156f59e89829aac3d
5
5
  SHA512:
6
- metadata.gz: 5252542b46421e3972eda278e6184ee4dffb478db5682918706474d9e4dff31c6ba93c23c3ca3ab34334a05df1ef7e1c30ccf04a1cec16f8935a62f9066f259c
7
- data.tar.gz: 03b85c2c94497c52f4017160fdedd11c670cbd22c2adc03af4fd920d266b5ddde1459aa3e03e3dabb0555b87b41c39c555add65796996d697486556de10bf713
6
+ metadata.gz: 0397f1c22e99920dffedcbd093f2cc2da8300aea8e07cd711b89defdb91a2600639ef304f9c57dafdc7afed4bc2f5d319387ec94a408ca407a23f9842017c381
7
+ data.tar.gz: c07b96c34bed66eee22f12477976010ddd9e094b7c0bb7581502abc79004afadf35f8b3d4351e79e1b89aac478c19e15aaef5ab1ebbcaf6434613e6843cba2e0
data/CHANGES.md CHANGED
@@ -1,3 +1,16 @@
1
+ # 2.0.1
2
+
3
+ * Add `fail_fast: true` for `step` and `failure` to short-circuit the pipe. Note that more "eloquent" semantics are coming in `trailblazer-bpmn`.
4
+ * Add `fail!`, `fail_fast!`, `pass!`, and `pass_fast!`. Note that they are all experimental API and not documented, yet.
5
+ * Remove Builder and allow [dynamic `Nested`](http://trailblazer.to/gems/operation/2.0/api.html#nested-callable).
6
+
7
+ ```ruby
8
+ step Nested( ->(options, params:) { params[:type] == "moderated" ? Moderated : Comment } )
9
+ ```
10
+ * Remove `override` in favor of `step .., override: true`. Note that this method wasn't documented.
11
+ * Numerous internal simplifications [documented here](https://github.com/trailblazer/trailblazer-operation/blob/master/CHANGES.md#0010).
12
+
13
+
1
14
  # 2.0.0
2
15
 
3
16
  All old semantics will be available via [trailblazer-compat](https://github.com/trailblazer/trailblazer-compat).
@@ -2,7 +2,7 @@ END-USER LICENSE AGREEMENT
2
2
 
3
3
  ------------------------------------------------------------------------------
4
4
 
5
- IMPORTANT: THIS SOFTWARE END-USER LICENSE AGREEMENT ("EULA") IS A LEGAL AGREEMENT (“Agreement”) BETWEEN YOU (THE CUSTOMER, EITHER AS AN INDIVIDUAL OR, IF PURCHASED OR OTHERWISE ACQUIRED BY OR FOR AN ENTITY, AS AN ENTITY) AND SYNERGY SOFTWARE SOLUTIONS. READ IT CAREFULLY BEFORE COMPLETING THE INSTALLATION PROCESS AND USING TRAILBLAZER ENTERPRISE AND RELATED SOFTWARE COMPONENTS (“SOFTWARE”). IT PROVIDES A LICENSE TO USE THE SOFTWARE AND CONTAINS WARRANTY INFORMATION AND LIABILITY DISCLAIMERS. BY INSTALLING AND USING THE SOFTWARE, YOU ARE CONFIRMING YOUR ACCEPTANCE OF THE SOFTWARE AND AGREEING TO BECOME BOUND BY THE TERMS OF THIS AGREEMENT.
5
+ IMPORTANT: THIS SOFTWARE END-USER LICENSE AGREEMENT ("EULA") IS A LEGAL AGREEMENT (“Agreement”) BETWEEN YOU (THE CUSTOMER, EITHER AS AN INDIVIDUAL OR, IF PURCHASED OR OTHERWISE ACQUIRED BY OR FOR AN ENTITY, AS AN ENTITY) AND SYNERGY SOFTWARE SOLUTIONS. READ IT CAREFULLY BEFORE COMPLETING THE INSTALLATION PROCESS AND USING TRAILBLAZER ENTERPRISE AND RELATED SOFTWARE COMPONENTS (“SOFTWARE”). IT PROVIDES A LICENSE TO USE THE SOFTWARE AND CONTAINS WARRANTY INFORMATION AND LIABILITY DISCLAIMERS. IN CONSIDERATION OF YOUR INSTALLATION AND USE OF THE SOFTWARE, YOU HEREBY CONFIRM YOUR ACCEPTANCE OF THE SOFTWARE AND AGREE TO BECOME BOUND BY THE TERMS OF THIS AGREEMENT.
6
6
 
7
7
  ------------------------------------------------------------------------------
8
8
 
@@ -12,19 +12,19 @@ In order to use the Software under this Agreement, you must receive a “Source
12
12
 
13
13
  1.1 General Use. This Agreement grants you a non-exclusive, non-transferable, limited license to the use rights for the Software, without the right to grant sublicenses, subject to the terms and conditions in this Agreement. The Software is licensed, not sold.
14
14
 
15
- 1.3 Limited Organization License. If you purchased an Organization License (included with the Trailblazer Enterprise Software), you may install the Software on an unlimited number of Hosts. “Host” means any physical or virtual machine which is controlled by you.
15
+ 1.2 Limited Organization License. If you purchased an Organization License (included with the Trailblazer Enterprise Software), you may install the Software on an unlimited number of Hosts. “Host” means any physical or virtual machine which is controlled by you.
16
16
 
17
- 1.4 Appliance License. If you purchased an Appliance License, you may distribute the Software in any applications, frameworks, or elements (collectively referred to as an “Application” or “Applications”) that you develop using the Software in accordance with this EULA, provided that such distribution does not violate the restrictions set forth in section 3 of this EULA. You must not remove, obscure or interfere with any copyright, acknowledgment, attribution, trademark, warning or disclaimer statement affixed to, incorporated in or otherwise applied in connection with the Software. You are required to ensure that the Software is not reused by or with any applications other than those with which you distribute it as permitted herein. For example, if You install the Software on a customer’s server, that customer is not permitted to use the Software independently of your Application. You must inform Synergy Software Solutions of your knowledge of any infringing use of the Software by any of your customers. You are liable for compliance by those third parties with the terms and conditions of this EULA. You will not owe Synergy Software Solutions any royalties for your distribution of the Software in accordance with this EULA.
17
+ 1.3 Appliance License. If you purchased an Appliance License, you may distribute the Software in any applications, frameworks, or elements (collectively referred to as an “Application” or “Applications”) that you develop using the Software in accordance with this EULA, provided that such distribution does not violate the restrictions set forth in section 3 of this EULA. You must not remove, obscure or interfere with any copyright, acknowledgment, attribution, trademark, warning or disclaimer statement affixed to, incorporated in or otherwise applied in connection with the Software. You are required to ensure that the Software is not reused by or with any applications other than those with which you distribute it as permitted herein. For example, if You install the Software on a customer’s server, that customer is not permitted to use the Software independently of your Application. You must inform Synergy Software Solutions of your knowledge of any infringing use of the Software by any of your customers. You are liable for compliance by those third parties with the terms and conditions of this EULA. You will not owe Synergy Software Solutions any royalties for your distribution of the Software in accordance with this EULA.
18
18
 
19
- 1.5 Archive Copies. You are entitled to make a reasonable amount of copies of the Software for archival purposes. Each copy must reproduce all copyright and other proprietary rights notices on or in the Software Product.
19
+ 1.4 Archive Copies. You are entitled to make a reasonable amount of copies of the Software for archival purposes. Each copy must reproduce all copyright and other proprietary rights notices on or in the Software Product.
20
20
 
21
- 1.6 Electronic Delivery. All Software and license documentation shall be delivered by electronic means unless otherwise specified on the applicable invoice or at the time of purchase. Software shall be deemed delivered when it is made available for download by you (“Delivery”).
21
+ 1.5 Electronic Delivery. All Software and license documentation shall be delivered by electronic means unless otherwise specified on the applicable invoice (“Invoice”) or at the time of purchase. Software shall be deemed delivered when it is made available for download by you (“Delivery”).
22
22
 
23
- 2. Modifications. Synergy Software Solutions shall provide you with source code so that you can create Modifications of the original software. “Modification” means: (a) any addition to or deletion from the contents of a file included in the original Software or previous Modifications created by You, or (b) any new file that contains any part of the original Software or previous Modifications. While you retain all rights to any original work authored by you as part of the Modifications, We continue to own all copyright and other intellectual property rights in the Software.
23
+ 2. Modifications. Synergy Software Solutions shall provide you with source code so that you can create Modifications of the Software. “Modification” means: (a) any addition to or deletion from the contents of a file included in the original Software or previous Modifications created by You, or (b) any new file that contains any part of the original Software or previous Modifications. While you retain all rights to any original work authored by you as part of the Modifications, We continue to own all copyright and other intellectual property rights in the Software.
24
24
 
25
25
  3. Restricted Uses.
26
26
 
27
- 3.1 You shall not (and shall not allow any third party to): (a) decompile, disassemble, or otherwise reverse engineer the Software or attempt to reconstruct or discover any source code, underlying ideas, algorithms, file formats or programming interfaces of the Software by any means whatsoever (except and only to the extent that applicable law prohibits or restricts reverse engineering restrictions); (b) distribute, sell, sublicense, rent, lease or use the Software for time sharing, hosting, service provider or like purposes, except as expressly permitted under this Agreement; (c) redistribute the Software or Modifications other than by including the Software or a portion thereof within your own product, which must have substantially different functionality than the Software or Modifications and must not allow any third party to use the Software or Modifications, or any portions thereof, for software development or application development purposes; (d) redistribute the Software as part of a product, "appliance" or "virtual server"; (e) redistribute the Software on any server which is not directly under your control; (f) remove any product identification, proprietary, copyright or other notices contained in the Software; (g) modify any part of the Software, create a derivative work of any part of the Software (except as permitted in Section 4), or incorporate the Software, except to the extent expressly authorized in writing by Synergy Software Solutions; (h) publicly disseminate performance information or analysis (including, without limitation, benchmarks) from any source relating to the Software; (i) utilize any equipment, device, software, or other means designed to circumvent or remove any form of Source URL or copy protection used by Synergy Software Solutions in connection with the Software, or use the Software together with any authorization code, Source URL, serial number, or other copy protection device not supplied by Synergy Software Solutions; (j) use the Software to develop a product which is competitive with any Synergy Software Solutions product offerings; or (k) use unauthorized Source URLS or keycode(s) or distribute or publish Source URLs or keycode(s), except as may be expressly permitted by Synergy Software Solutions in writing. If your unique Source URL is ever published, Synergy Software Solutions reserves the right to terminate your access without notice.
27
+ 3.1 You shall not (and shall not allow any third party to): (a) decompile, disassemble, or otherwise reverse engineer the Software or attempt to reconstruct or discover any source code, underlying ideas, algorithms, file formats or programming interfaces of the Software by any means whatsoever (except and only to the extent that applicable law prohibits or restricts reverse engineering restrictions); (b) distribute, sell, sublicense, rent, lease or use the Software for time sharing, hosting, service provider or like purposes, except as expressly permitted under this Agreement; (c) redistribute the Software or Modifications other than by including the Software or a portion thereof within your own product, which must have substantially different functionality than the Software or Modifications and must not allow any third party to use the Software or Modifications, or any portions thereof, for software development or application development purposes; (d) redistribute the Software as part of an "appliance" or "virtual server"; (e) redistribute the Software on any server which is not directly under your control; (f) remove any product identification, proprietary, copyright or other notices contained in the Software; (g) modify any part of the Software, create a derivative work of any part of the Software (except as permitted in Section 2), or incorporate the Software, except to the extent expressly authorized in writing by Synergy Software Solutions; (h) publicly disseminate performance information or analysis (including, without limitation, benchmarks) from any source relating to the Software; (i) utilize any equipment, device, software, or other means designed to circumvent or remove any form of Source URL or copy protection used by Synergy Software Solutions in connection with the Software, or use the Software together with any authorization code, Source URL, serial number, or other copy protection device not supplied by Synergy Software Solutions; (j) use the Software to develop a product which is competitive with any Synergy Software Solutions product offerings(unless such development is allowed by applicable law); or (k) use unauthorized Source URLS or keycode(s) or distribute or publish Source URLs or keycode(s), except as may be expressly permitted by Synergy Software Solutions in writing. If your unique Source URL is ever published, Synergy Software Solutions reserves the right to terminate your access without notice.
28
28
 
29
29
  3.2 UNDER NO CIRCUMSTANCES MAY YOU USE THE SOFTWARE AS PART OF A PRODUCT OR SERVICE THAT PROVIDES SIMILAR FUNCTIONALITY TO THE SOFTWARE ITSELF.
30
30
 
@@ -34,9 +34,9 @@ under the terms of the GNU Lesser General Public License versions 3.0
34
34
 
35
35
  4. Ownership. Notwithstanding anything to the contrary contained herein, except for the limited license rights expressly provided herein, Synergy Software Solutions and its suppliers have and will retain all rights, title and interest (including, without limitation, all patent, copyright, trademark, trade secret and other intellectual property rights) in and to the Software and all copies, modifications and derivative works thereof (including any changes which incorporate any of your ideas, feedback or suggestions). You acknowledge that you are obtaining only a limited license right to the Software, and that irrespective of any use of the words “purchase”, “sale” or like terms hereunder no ownership rights are being conveyed to you under this Agreement or otherwise.
36
36
 
37
- 5. Fees and Payment. The Software license fees will be due and payable in full as set forth in the applicable invoice or at the time of purchase. If the Software does not function properly within two weeks of purchase, please contact us within those two weeks for a refund. You shall be responsible for all taxes, withholdings, duties and levies arising from the order (excluding taxes based on the net income of Synergy Software Solutions).
37
+ 5. Fees and Payment. The Software license fees will be due and payable in full as set forth in the Invoice or at the time of purchase. If the Software does not function properly within two weeks of purchase, please contact us within those two weeks for a refund. You shall be responsible for all taxes, withholdings, duties and levies arising from the order (excluding taxes based on the net income of Synergy Software Solutions).
38
38
 
39
- 6. Support, Maintenance and Services. Subject to the terms and conditions of this Agreement, as set forth in your invoice, and as set forth on the Trailblazer Enterprise support page (http://enterprise.trailblazer.to), support and maintenance services may be included with the purchase of your license subscription.
39
+ 6. Support, Maintenance and Services. Subject to the terms and conditions of this Agreement, as set forth in the Invoice, and as set forth on the Trailblazer Enterprise support page (http://enterprise.trailblazer.to), support and maintenance services may be included with the purchase of your license subscription.
40
40
 
41
41
  7. Term of Agreement.
42
42
 
@@ -51,26 +51,24 @@ To the maximum extent permitted by applicable law, Synergy Software Solutions di
51
51
 
52
52
  9. Limitation of Liability.
53
53
 
54
- In no event will Synergy Software Solutions be liable for any direct, indirect, consequential, incidental, special, exemplary, or punitive damages or liabilities whatsoever arising from or relating to the Software, the Software content or this Agreement, whether based on contract, tort (including negligence), strict liability or other theory, even if Synergy Software Solutions has been advised of the possibility of such damages.
54
+ To the maximum extent permitted by applicable law, Synergy Software Solutions will not be liable for any direct, indirect, consequential, incidental, special, exemplary, or punitive damages or liabilities whatsoever arising from or relating to the Software, the Software content or this Agreement, whether based on contract, tort (including negligence), strict liability or other theory, even if Synergy Software Solutions has been advised of the possibility of such damages.
55
55
 
56
- In no event will Synergy Software Solutions' liability exceed the Software license price as indicated in the invoice. The existence of more than one claim will not enlarge or extend this limit.
56
+ In no event will Synergy Software Solutions' liability exceed the Software license price as indicated in the Invoice. The existence of more than one claim will not enlarge or extend this limit.
57
57
 
58
58
  10. Remedies. Your exclusive remedy and Synergy Software Solutions’ entire liability for breach of this Agreement shall be limited, at Synergy Software Solutions’ sole and exclusive discretion, to (a) replacement of any defective software or documentation; or (b) refund of the license fee paid to Synergy Software Solutions, payable in accordance with Synergy Software Solutions' refund policy.
59
59
 
60
60
  11. Acknowledgements.
61
61
 
62
- 11.1 Consent to the Use of Data. You agree that Synergy Software Solutions and its affiliates may collect and use technical information gathered as part of the product support services. Synergy Software Solutions may use this information solely to improve products and services and will not disclose this information in a form that personally identifies you.
62
+ Consent to the Use of Data. You agree that Synergy Software Solutions and its affiliates may collect and use technical information gathered as part of the product support services. Synergy Software Solutions may use this information solely to improve products and services and will not disclose this information in a form that personally identifies you.
63
63
 
64
- 11.3 Government End Users. If the Software and related documentation are supplied to or purchased by or on behalf of the United States Government, then the Software is deemed to be "commercial software" as that term is used in the Federal Acquisition Regulation system. Rights of the United States shall not exceed the minimum rights set forth in FAR 52.227-19 for "restricted computer software". All other terms and conditions of this Agreement apply.
65
-
66
- 12. Third Party Software. Examples included in Software may provide links to third party libraries or code (collectively “Third Party Software”) to implement various functions. Third Party Software does not comprise part of the Software. In some cases, access to Third Party Software may be included along with the Software delivery as a convenience for demonstration purposes. Such source code and libraries may be included in the “…/examples” source tree delivered with the Software and do not comprise the Software. Licensee acknowledges (1) that some part of Third Party Software may require additional licensing of copyright and patents from the owners of such, and (2) that distribution of any of the Software referencing or including any portion of a Third Party Software may require appropriate licensing from such third parties.
64
+ 12. Third Party Software. Examples included in Software may provide links to third party libraries or code (collectively “Third Party Software”) to implement various functions. Third Party Software does not comprise part of the Software. In some cases, access to Third Party Software may be included along with the Software Delivery as a convenience for demonstration purposes. Such source code and libraries may be included in the “…/examples” source tree delivered with the Software and do not comprise the Software. Licensee acknowledges (1) that some part of Third Party Software may require additional licensing of copyright and patents from the owners of such, and (2) that distribution of any of the Software referencing or including any portion of a Third Party Software may require appropriate licensing from such third parties.
67
65
 
68
66
 
69
67
  13. Miscellaneous
70
68
 
71
69
  13.1 Entire Agreement. This Agreement sets forth our entire agreement with respect to the Software and the subject matter hereof and supersedes all prior and contemporaneous understandings and agreements whether written or oral.
72
70
 
73
- 13.2 Amendment. Synergy Software Solutions reserves the right, in its sole discretion, to amend this Agreement from time. Amendments to this Agreement can be located at: https://github.com/trailblazer/trailblazer/blob/master/COMM-LICENSE.
71
+ 13.2 Amendment. Synergy Software Solutions reserves the right, in its sole discretion, to amend this Agreement from time to time. Amendments to this Agreement can be located at: https://github.com/trailblazer/trailblazer/blob/master/COMM-LICENSE.
74
72
 
75
73
  13.3 Assignment. You may not assign this Agreement or any of its rights under this Agreement without the prior written consent of Synergy Software Solutions and any attempted assignment without such consent shall be void.
76
74
 
@@ -78,14 +76,16 @@ In no event will Synergy Software Solutions' liability exceed the Software licen
78
76
 
79
77
  13.5 Indemnification. You agree to defend, indemnify, and hold harmless Synergy Software Solutions from and against any lawsuits, claims, losses, damages, fines and expenses (including attorneys' fees and costs) arising out of your use of the Software or breach of this Agreement.
80
78
 
81
- 13.6 Governing Law. This Agreement is governed by the laws of the State of Oregon and the United States without regard to conflicts of laws provisions thereof, and without regard to the United Nations Convention on the International Sale of Goods or the Uniform Computer Information Transactions Act, as currently enacted by any jurisdiction or as may be codified or amended from time to time by any jurisdiction. The jurisdiction and venue for actions related to the subject matter hereof shall be the state of Oregon and United States federal courts located in Portland, Oregon, and both parties hereby submit to the personal jurisdiction of such courts.
79
+ 13.6 Governing Law. This Agreement is governed and construed in accordance with the law of Singapore and shall be subject to the exclusive jurisdiction of the Singapore Courts. The operation of the United Nations Convention on the International Sale of Goods is hereby expressly excluded.
80
+
81
+ 13.7 Dispute Resolution. In the event of any dispute arising from or in connection with this Agreement, the parties undertake to make all their best efforts to settle the dispute amicably through negotiations, failing which either party may submit the dispute for resolution by the Singapore Courts.
82
82
 
83
- 13.7 Attorneys’ Fees and Costs. The prevailing party in any action to enforce this Agreement will be entitled to recover its attorneys’ fees and costs in connection with such action.
83
+ 13.8 Attorneys’ Fees and Costs. The prevailing party in any action to enforce this Agreement will be entitled to recover its attorneys’ fees and costs in connection with such action.
84
84
 
85
- 13.8 Severability. If any provision of this Agreement is held by a court of competent jurisdiction to be invalid, illegal, or unenforceable, the remainder of this Agreement will remain in full force and effect.
85
+ 13.9 Severability. If any provision of this Agreement is held by a court of competent jurisdiction to be invalid, illegal, or unenforceable, the remainder of this Agreement will remain in full force and effect.
86
86
 
87
- 13.9 Waiver. Failure or neglect by either party to enforce at any time any of the provisions of this licence Agreement shall not be construed or deemed to be a waiver of that party's rights under this Agreement.
87
+ 13.10 Waiver. Failure or neglect by either party to enforce at any time any of the provisions of this licence Agreement shall not be construed or deemed to be a waiver of that party's rights under this Agreement.
88
88
 
89
- 13.10 Headings. The headings of sections and paragraphs of this Agreement are for convenience of reference only and are not intended to restrict, affect or be of any weight in the interpretation or construction of the provisions of such sections or paragraphs.
89
+ 13.11 Headings. The headings of sections and paragraphs of this Agreement are for convenience of reference only and are not intended to restrict, affect or be of any weight in the interpretation or construction of the provisions of such sections or paragraphs.
90
90
 
91
91
  14. Contact Information. If you have any questions about this EULA, or if you want to contact Synergy Software Solutions for any reason, please direct correspondence to info@trailblazer.to.
data/Gemfile CHANGED
@@ -22,6 +22,9 @@ gem "dry-validation"
22
22
 
23
23
  # gem "trailblazer-operation", path: "../operation"
24
24
  # gem "pipetree", path: "../pipetree"
25
+ # gem "trailblazer-operation", github: "trailblazer/trailblazer-operation"
26
+ # gem "pipetree", github: "apotonick/pipetree"
27
+
25
28
 
26
29
  gem "minitest-line"
27
30
 
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Trailblazer
2
2
 
3
- _Trailblazer is a thin layer on top of Rails. It gently enforces encapsulation, an intuitive code structure and gives you an object-oriented architecture._
3
+ _Trailblazer provides new high-level abstractions for Ruby frameworks. It gently enforces encapsulation, an intuitive code structure and gives you an object-oriented architecture._
4
4
 
5
5
  [![Gitter Chat](https://badges.gitter.im/trailblazer/chat.svg)](https://gitter.im/trailblazer/chat)
6
6
  [![TRB Newsletter](https://img.shields.io/badge/TRB-newsletter-lightgrey.svg)](http://trailblazer.to/newsletter/)
@@ -32,17 +32,6 @@ Again, you can pick which layers you want. Trailblazer doesn't impose technical
32
32
 
33
33
  Trailblazer is no "complex web of objects and indirection". It solves many problems that have been around for years with a cleanly layered architecture. Only use what you like. And that's the bottom line.
34
34
 
35
- ## Trailblazer Likes 'Em All
36
-
37
- Since Trailblazer decouples the High-Level Stack from the framework, it runs with virtually any Ruby framework. We are constantly working on documenting how to do that.
38
-
39
- * Trailblazer with Rails [Book](http://trailblazer.to/books/trailblazer.html) | [Repository](https://github.com/apotonick/gemgem-trbrb)
40
- * Trailblazer with Sinatra [Guide](http://trailblazer.to/guides/sinatra/getting-started.html) | [Repository](https://github.com/apotonick/gemgem-sinatra)
41
- * Trailblazer with Hanami - coming soon!
42
- * Trailblazer with Roda - coming soon!
43
- * Trailblazer with Grape - coming _very_ soon!
44
-
45
-
46
35
  ## Concepts over Technology
47
36
 
48
37
  Trailblazer offers you a new, more intuitive file layout in applications.
@@ -81,7 +70,7 @@ Trailblazer extends the conventional MVC stack in Rails. Keep in mind that addin
81
70
 
82
71
  The opposite is the case: Controller, view and model become lean endpoints for HTTP, rendering and persistence. Redundant code gets eliminated by putting very little application code into the right layer.
83
72
 
84
- ![The Trailblazer stack.](https://raw.github.com/apotonick/trailblazer/master/doc/Trb-The-Stack.png)
73
+ ![The Trailblazer stack.](https://raw.github.com/apotonick/trailblazer/master/doc/operation-2017.png)
85
74
 
86
75
  ## Routing
87
76
 
@@ -135,13 +124,15 @@ An operation is not just a monolithic replacement for your business code. It's a
135
124
 
136
125
  ```ruby
137
126
  class Comment::Create < Trailblazer::Operation
138
- def process(params)
127
+ step :process!
128
+
129
+ def process!(options)
139
130
  # do whatever you feel like.
140
131
  end
141
132
  end
142
133
  ```
143
134
 
144
- Operations only need to implement `#process` which receives the arguments from the caller.
135
+ Operations only need to define and implement steps, like the `#process!` steps. Those steps receive the arguments from the caller.
145
136
 
146
137
  You cannot instantiate them per design. The only way to invoke them is `call`.
147
138
 
@@ -165,18 +156,17 @@ The operation makes use of the form object using the `#validate` method.
165
156
 
166
157
  ```ruby
167
158
  class Comment::Create < Trailblazer::Operation
159
+ extend Contract::DSL
160
+
168
161
  contract do
169
162
  # this is a Reform::Form class!
170
163
  property :body, validates: {presence: true}
171
164
  end
172
165
 
173
- def process(params)
174
- @model = Comment.new
175
-
176
- validate(params[:comment], @model) do |f|
177
- f.save
178
- end
179
- end
166
+ step Model( Comment, :new )
167
+ step Contract::Build()
168
+ step Contract::Validate( key: :comment )
169
+ step Contract::Persist( )
180
170
  end
181
171
  ```
182
172
 
@@ -184,44 +174,7 @@ The contract (aka _form_) is defined in the `::contract` block. You can implemen
184
174
 
185
175
  In the `#process` method you can define your business logic.
186
176
 
187
- [Learn more.](http://trailblazer.to/gems/operation/api.html)
188
-
189
- ## Callbacks
190
-
191
- Post-processing logic (also known as _callbacks_) is configured in operations.
192
-
193
- Callbacks can be defined in groups. They use the form object's state tracking to find out whether they should be run.
194
-
195
- ```ruby
196
- class Comment::Create < Trailblazer::Operation
197
- include Callback
198
- callback(:after_save) do
199
- on_change :markdownize_body! # this is only run when the form object has changed.
200
- end
201
- end
202
- ```
203
-
204
- Callbacks are never triggered automatically, you have to invoke them! This is called _Imperative Callback_.
205
-
206
- ```ruby
207
- class Comment::Create < Trailblazer::Operation
208
- include Callback
209
- def process(params)
210
- validate(params) do
211
- contract.save
212
- callback!(:after_save) # run markdownize_body!, but only if form changed.
213
- end
214
- end
215
-
216
- def markdownize_body!(comment)
217
- comment.body = Markdownize.(comment.body)
218
- end
219
- end
220
- ```
221
-
222
- No magical triggering of unwanted logic anymore, but explicit invocations where you want it.
223
-
224
- [Learn more.](http://trailblazer.to/gems/operation/callback.html)
177
+ [Learn more.](http://trailblazer.to/gems/operation/2.0/contract.html)
225
178
 
226
179
  ## Models
227
180
 
@@ -259,9 +212,7 @@ The rule is enabled via the `::policy` call.
259
212
 
260
213
  ```ruby
261
214
  class Comment::Create < Trailblazer::Operation
262
- include Policy
263
-
264
- policy Comment::Policy, :create?
215
+ step Policy( Comment::Policy, :create? )
265
216
  end
266
217
  ```
267
218
 
@@ -269,11 +220,6 @@ The policy is evaluated in `#setup!`, raises an exception if `false` and suppres
269
220
 
270
221
  [Learn more.](http://trailblazer.to/gems/operation/policy.html)
271
222
 
272
- ## Pipetree
273
-
274
- The operation code is not supposed to be procedural, but in form of a function pipeline. You can still write procedural code with stacked methods calls where ever you want, e.g. in `process`.
275
-
276
- However, a much smarter way to chain logic is to use the *pipetree*.
277
223
 
278
224
  ## Views
279
225
 
@@ -349,16 +295,8 @@ The obvious needs to be in your `Gemfile`.
349
295
  ```ruby
350
296
  gem "trailblazer"
351
297
  gem "trailblazer-rails" # if you are in rails.
352
- gem "cells"
298
+ gem "trailblazer-cells"
353
299
  ```
354
300
 
355
301
  Cells is _not_ required per default! Add it if you use it, which is highly recommended.
356
302
 
357
- ## The Book
358
-
359
- ![](https://raw.githubusercontent.com/apotonick/trailblazer/master/doc/trb.jpg)
360
-
361
- Please buy it: [Trailblazer - A new architecture for Rails](https://leanpub.com/trailblazer).
362
-
363
- The [demo application](https://github.com/apotonick/gemgem-trbrb) implements what we discuss in the book.
364
-
data/Rakefile CHANGED
@@ -9,7 +9,6 @@ Rake::TestTask.new(:test) do |test|
9
9
  test_files = FileList[%w{
10
10
  test/operation/guard_test.rb
11
11
  test/operation/pundit_test.rb
12
- test/operation/builder_test.rb
13
12
  test/operation/model_test.rb
14
13
  test/operation/contract_test.rb
15
14
  test/operation/persist_test.rb
@@ -24,6 +23,6 @@ Rake::TestTask.new(:test) do |test|
24
23
  test_files = test_files - %w{test/docs/dry_test.rb test/docs/auto_inject_test.rb}
25
24
  end
26
25
 
27
- test.test_files = test_files
26
+ test.test_files = test_files #- ["test/docs/rescue_test.rb"]
28
27
  test.verbose = true
29
28
  end
Binary file
@@ -4,7 +4,6 @@ require "trailblazer/operation/pipetree"
4
4
  require "trailblazer/dsl"
5
5
  require "trailblazer/version"
6
6
 
7
- require "trailblazer/operation/builder"
8
7
  require "trailblazer/operation/model"
9
8
  require "trailblazer/operation/contract"
10
9
  require "trailblazer/operation/validate"
@@ -1,28 +1,21 @@
1
- require "declarative"
2
1
  require "disposable/callback"
3
2
 
4
- # Needs #[], #[]= skill dependency.
5
3
  class Trailblazer::Operation
6
- module Callback
7
- def self.import!(operation, import, group)
8
- import.(:&, ->(input, options) { input.callback!(group) },
9
- name: "callback.#{group}")
4
+ def self.Callback(group)
5
+ step = ->(input, options) { Callback.(group, input, options) }
10
6
 
11
- operation.send :include, self
12
- end
7
+ [ step, name: "callback.#{group}" ]
8
+ end
13
9
 
14
- def callback!(name=:default, options=self) # FIXME: test options.
15
- config = self["callback.#{name}.class"] || raise #.fetch(name) # TODO: test exception
16
- group = config[:group].new(self["contract.default"])
10
+ module Callback
11
+ def self.call(name=:default, operation, options)
12
+ config = options["callback.#{name}.class"] || raise #.fetch(name) # TODO: test exception
13
+ group = config[:group].new(options["contract.default"])
17
14
 
18
- options[:context] ||= (config[:context] == :operation ? self : group)
15
+ options[:context] ||= (config[:context] == :operation ? operation : group)
19
16
  group.(options)
20
17
 
21
- invocations[name] = group
22
- end
23
-
24
- def invocations
25
- @invocations ||= {}
18
+ options["result.callback.#{name}"] = group
26
19
  end
27
20
 
28
21
  module DSL
@@ -39,6 +32,4 @@ class Trailblazer::Operation
39
32
  end
40
33
  end
41
34
  end
42
-
43
- DSL.macro!(:Callback, Callback) # Operation::Callback()
44
35
  end
@@ -8,9 +8,15 @@
8
8
  # Needs #[], #[]= skill dependency.
9
9
  class Trailblazer::Operation
10
10
  module Contract
11
+ def self.Build(name:"default", constant:nil, builder: nil)
12
+ step = ->(input, options) { Build.for(input, options, name: name, constant: constant, builder: builder) }
13
+
14
+ [ step, name: "contract.build" ]
15
+ end
16
+
11
17
  module Build
12
18
  # bla build contract at runtime.
13
- def self.build_contract!(operation, options, name:"default", constant:nil, builder: nil)
19
+ def self.for(operation, options, name:"default", constant:nil, builder: nil)
14
20
  # TODO: we could probably clean this up a bit at some point.
15
21
  contract_class = constant || options["contract.#{name}.class"]
16
22
  model = options["model"] # FIXME: model.default
@@ -19,11 +25,6 @@ class Trailblazer::Operation
19
25
 
20
26
  options["contract.#{name}"] = contract_class.new(model)
21
27
  end
22
-
23
- def self.import!(operation, import, **args)
24
- import.(:>, ->(operation, options) { build_contract!(operation, options, **args) },
25
- name: "contract.build")
26
- end
27
28
  end
28
29
 
29
30
  module DSL
@@ -41,6 +42,4 @@ class Trailblazer::Operation
41
42
  end
42
43
  end # Contract
43
44
  end
44
-
45
- DSL.macro!(:Build, Contract::Build, Contract.singleton_class)
46
45
  end
@@ -3,11 +3,11 @@ require "uber/option"
3
3
 
4
4
  class Trailblazer::Operation
5
5
  module Policy
6
- module Guard
7
- def self.import!(operation, import, user_proc, options={}, insert_options={})
8
- Policy.add!(operation, import, options, insert_options) { Guard.build(user_proc) }
9
- end
6
+ def self.Guard(proc, name: :default, &block)
7
+ Policy.step(Guard.build(proc), name: name)
8
+ end
10
9
 
10
+ module Guard
11
11
  def self.build(callable)
12
12
  value = Uber::Option[callable]
13
13
 
@@ -16,14 +16,5 @@ class Trailblazer::Operation
16
16
  ->(options) { Result.new( !!value.(options), {} ) }
17
17
  end
18
18
  end # Guard
19
-
20
- def self.Guard(proc, name: :default, &block)
21
- options = {
22
- name: name,
23
- path: "policy.#{name}.eval",
24
- }
25
-
26
- [Guard, [proc, options], block]
27
- end
28
19
  end
29
20
  end
@@ -1,55 +1,53 @@
1
1
  class Trailblazer::Operation
2
- module Model
3
- Step = ->(operation, options) { options["model"] = operation.model!(options["params"]) }
2
+ def self.Model(model_class, action=nil)
3
+ step = Model.for(model_class, action)
4
4
 
5
- def self.import!(operation, import, model_class, action=nil)
6
- # configure
7
- operation["model.class"] = model_class
8
- operation["model.action"] = action
5
+ step = Pipetree::Step.new(step, "model.class" => model_class, "model.action" => action)
9
6
 
10
- # add
11
- import.(:&, Step, name: "model.build")
7
+ [ step, name: "model.build" ]
8
+ end
12
9
 
13
- operation.send :include, BuildMethods
14
- end
10
+ module Model
11
+ def self.for(model_class, action)
12
+ builder = Model::Builder.new
15
13
 
16
- # Methods to create the model according to class configuration and params.
17
- module BuildMethods
18
- def model_class
19
- self["model.class"] or raise "[Trailblazer] You didn't call Operation::model."
20
- end
14
+ ->(input, options) do
15
+ options["model"] = model = builder.(options, options["params"])
21
16
 
22
- def action_name
23
- self["model.action"] or :new
24
- end
17
+ options["result.model"] = result = Result.new(!model.nil?, {})
25
18
 
26
- def model!(params)
27
- instantiate_model(params)
19
+ result.success?
28
20
  end
21
+ end
22
+
23
+ class Builder
24
+ def call(options, params)
25
+ deprecate_update!(options)
26
+ action = options["model.action"] || :new
27
+ model_class = options["model.class"]
29
28
 
30
- def instantiate_model(params)
31
- send("#{action_name}_model", params)
29
+ send("#{action}!", model_class, params)
32
30
  end
33
31
 
34
- def new_model(params)
32
+ def new!(model_class, params)
35
33
  model_class.new
36
34
  end
37
35
 
38
- def update_model(params)
36
+ def find!(model_class, params)
39
37
  model_class.find(params[:id])
40
38
  end
41
39
 
42
- alias_method :find_model, :update_model
43
-
44
40
  # Doesn't throw an exception and will return false to divert to Left.
45
- def find_by_model(params)
46
- model = model_class.find_by(id: params[:id])
41
+ def find_by!(model_class, params)
42
+ model_class.find_by(id: params[:id])
43
+ end
47
44
 
48
- self["result.model"] = Result.new(!model.nil?, {})
49
- model
45
+ private
46
+ def deprecate_update!(options) # TODO: remove in 2.1.
47
+ return unless options["model.action"] == :update
48
+ options["model.action"] = :find
49
+ warn "[Trailblazer] Model( .., :update ) is deprecated, please use :find or :find_by."
50
50
  end
51
51
  end
52
52
  end
53
-
54
- DSL.macro!(:Model, Model)
55
53
  end