outbacker 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +3 -0
- data/README.md +4 -3
- data/examples/README.md +10 -0
- data/examples/app/controllers/appointments_controller.rb +3 -6
- data/examples/app/domain/appointment_calendar.rb +5 -1
- data/examples/config/initializers/outbacker.rb +4 -0
- data/examples/test/controllers/appointments_controller_test.rb +6 -0
- data/lib/outbacker/version.rb +1 -1
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 75b6426d3f64c62516541550bd341193474249e7
|
4
|
+
data.tar.gz: 57a542ea46bf9c35e4b6e2a353640f78a74f6aea
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f6c04602dee484578e756c6c8f6c663af69fddd4f398b73a4e386b42ea6ad983405b7e479f492c5c713dd85f3ddd1e73932f7eacaa02f367e226a3d178a238f6
|
7
|
+
data.tar.gz: 71ee9b9aef806fed79fc4f81e1bc37368125f37d877277387e310e731a678fe5c0dfb50616e4e67c0ea88932eeb2d813fcd0b2b40dfd51900eb4e912eaff5fc3
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -3,16 +3,17 @@
|
|
3
3
|
[![Build Status](https://travis-ci.org/polypressure/outbacker.svg?branch=master)](https://travis-ci.org/polypressure/outbacker)
|
4
4
|
[![Code Climate](https://codeclimate.com/github/polypressure/outbacker/badges/gpa.svg)](https://codeclimate.com/github/polypressure/outbacker)
|
5
5
|
[![Test Coverage](https://codeclimate.com/github/polypressure/outbacker/badges/coverage.svg)](https://codeclimate.com/github/polypressure/outbacker/coverage)
|
6
|
+
[![Gem Version](https://badge.fury.io/rb/outbacker.svg)](http://badge.fury.io/rb/outbacker)
|
6
7
|
|
7
8
|
Rails developers have long known how important it is to keep controllers "skinny" and free of business logic. Our controllers are supposed to be dumb dispatchers that take results from the model layer and turn them into redirects, flash messages, form re-renderings, session state updates, JSON responses, HTTP status codes, and so on.
|
8
9
|
|
9
|
-
But far too often, the conditional logic in typical Rails controllers to act on results from models and decide what to do next
|
10
|
+
But far too often, the conditional logic in typical Rails controllers—the logic to act on results from models and decide what to do next—spirals out of control, attracting and trapping business logic, and making testing and reuse difficult. Complexity sneaks into our controllers as we add code to handle new features, stories, and special cases. And the cultural and process controls we put in place to enforce good code hygiene chronically break down in the face of schedule pressure, growing teams, emergency fixes, etc.
|
10
11
|
|
11
|
-
**Outbacker** ("outcome callbacks") is a very simple micro library that makes it easy to keep controllers free of this conditional logic. Controllers become simple, declarative mappings of business logic results to the redirects, flash messages, session state updates, HTTP status codes, and other actions that deliver results to the user.
|
12
|
+
**Outbacker** ("outcome callbacks") is a very simple micro library that makes it easy to keep controllers free of this conditional logic. Controllers become simple, declarative mappings of business logic results to the redirects, flash messages, session state updates, HTTP status codes, and other actions that deliver results to the user. Conditional controller logic can't grow into complicated business logic—because our controllers no longer have conditional logic in the first place.
|
12
13
|
|
13
14
|
It turns out that not only is Outbacker a prophylaxis against fat, complicated controllers, it more generally supports a very simple, low-ceremony way to write intention-revealing Rails code with both skinny controllers _and_ skinny models. If you feel these are worthwhile aims for your Ruby/Rails code—but you've found many approaches to accomplish this ineffective or not worth the trouble—then you might find Outbacker valuable.
|
14
15
|
|
15
|
-
**Note:** The README that follows has a lot of
|
16
|
+
**Note:** The README that follows has a lot of explanation about rationale and motivation—maybe excessively, logorrheically so for such a simple library. If you're impatient, you can go straight to some [code examples](https://github.com/polypressure/outbacker/tree/master/examples/README.md). Hopefully, these examples are sufficient for you to get an understanding of what Outbacker provides, and how to use it. If not, you can always come back to this readme.
|
16
17
|
|
17
18
|
## A Typical Rails Controller
|
18
19
|
|
data/examples/README.md
ADDED
@@ -0,0 +1,10 @@
|
|
1
|
+
# Outbacker Examples
|
2
|
+
|
3
|
+
Quick examples of how to use Outbacker. Please look at them in this order:
|
4
|
+
|
5
|
+
1. A [controller](https://github.com/polypressure/outbacker/blob/master/examples/app/controllers/appointments_controller.rb) that uses Outbacker.
|
6
|
+
1. A [business logic PORO](https://github.com/polypressure/outbacker/blob/master/examples/app/domain/appointment_calendar.rb) that uses Outbacker.
|
7
|
+
1. A [controller test using OutbackerStub](https://github.com/polypressure/outbacker/blob/master/examples/test/controllers/appointments_controller_test.rb) to "stub" outcomes.
|
8
|
+
1. The Outbacker [gem initializer file](https://github.com/polypressure/outbacker/blob/master/examples/config/initializers/outbacker.rb), to configure your policy specifying where the Outbacker module can be included.
|
9
|
+
|
10
|
+
If you need more details, you can go back to the main [ README](https://github.com/polypressure/outbacker/blob/master/README.md) file.
|
@@ -1,14 +1,11 @@
|
|
1
1
|
#
|
2
|
-
#
|
3
|
-
#
|
4
|
-
# * examples/app/config/outbacker.rb
|
5
|
-
# * examples/test/controllers/appointments_controller_test.rb
|
6
|
-
# * examples/test/test_helper.rb
|
2
|
+
# Conventional Rails controller, with the create method
|
3
|
+
# implemented twice: before and after using Outbacker.
|
7
4
|
#
|
8
5
|
class AppointmentsController < ApplicationController
|
9
6
|
|
10
7
|
#
|
11
|
-
# A conventional controller method:
|
8
|
+
# A conventional controller method, before using Outbacker:
|
12
9
|
#
|
13
10
|
def create
|
14
11
|
@appointment = Appointment.new(appointment_params)
|
@@ -8,7 +8,11 @@ class AppointmentCalendar
|
|
8
8
|
|
9
9
|
#
|
10
10
|
# Include the Outbacker module. See config/initializers/outbacker.rb
|
11
|
-
# for the restrictions on where you can include this.
|
11
|
+
# for the restrictions on where you can include this. By default,
|
12
|
+
# if you try to include Outbacker in an ActiveRecord or ActionController
|
13
|
+
# subclass, an exception will be raised.
|
14
|
+
#
|
15
|
+
# This helps to ensure both your models (and controllers) are skinny.
|
12
16
|
#
|
13
17
|
include Outbacker
|
14
18
|
|
@@ -6,6 +6,12 @@ require 'outbacker'
|
|
6
6
|
require 'test_support/outbacker_stub'
|
7
7
|
|
8
8
|
|
9
|
+
#
|
10
|
+
# A controller test for the AppointmentsController.
|
11
|
+
# This shows how to use Outbacker::OutbackerStub to "stub"
|
12
|
+
# outcomes, since standard mocking/stubbing libraries
|
13
|
+
# can't provide this.
|
14
|
+
#
|
9
15
|
class AppointmentsControllerTest < ActionController::TestCase
|
10
16
|
|
11
17
|
|
data/lib/outbacker/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: outbacker
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Anthony Garcia
|
@@ -125,6 +125,7 @@ files:
|
|
125
125
|
- LICENSE.txt
|
126
126
|
- README.md
|
127
127
|
- Rakefile
|
128
|
+
- examples/README.md
|
128
129
|
- examples/app/controllers/appointments_controller.rb
|
129
130
|
- examples/app/domain/appointment_calendar.rb
|
130
131
|
- examples/config/initializers/outbacker.rb
|