boring_presenters 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: 9663b7244fabad34f7b95cdb5ff6c8894ded0632
4
- data.tar.gz: 915e1ff891f18232161e47784041d04a7d5a3625
3
+ metadata.gz: 6100cc5db1af654bd699a54ffcfc6ebad97ed31e
4
+ data.tar.gz: c038f3d7f3c3ce2deb1196340c2beb7e722986d4
5
5
  SHA512:
6
- metadata.gz: 39b4c0830ca7e3a94fc668b87c033d652370078294310c3e16746e10655310a01304582057d6f048a78f43bf8cb842778e7060fc4358df1c3f511347588f6402
7
- data.tar.gz: 1791d3606fafa05d3bb414221c17c0271bbc6f92e0dfa9eae101a3b8f603bacdc8b5c6d789300452804d0371dd5b47af008615838d7bf47a4036e9aab994542b
6
+ metadata.gz: 81873f9ecddc312e815a3b488691daad0d72795ec373db8e8aa08bd051ac3b8c4bc43204f891ab9b73061ecfba35eaaa5d933f945da064122d8f0e6cdc3ae177
7
+ data.tar.gz: 1c6b9baef17ca579a7297d9645f3fb589d67922174b3281ec5094711218bea088603eff8ffce15882d4aceb16670e7cf5bf9bb74d79a013c981553d280430011
data/.gitignore CHANGED
@@ -1,7 +1,17 @@
1
+ *.gem
2
+ *.DS_Store
3
+
4
+ .rvmrc
5
+ .ruby-version
6
+ .ruby-gemset
7
+ .bundle
8
+
9
+ coverage.data
10
+ coverage/*
11
+
1
12
  /.bundle/
2
13
  /.yardoc
3
14
  /_yardoc/
4
- /coverage/
5
15
  /doc/
6
16
  /pkg/
7
17
  /spec/reports/
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- boring (0.1.0)
4
+ boring_presenters (0.1.1)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -26,7 +26,7 @@ PLATFORMS
26
26
  ruby
27
27
 
28
28
  DEPENDENCIES
29
- boring!
29
+ boring_presenters!
30
30
  bundler (~> 1.16)
31
31
  rake (~> 10.0)
32
32
  rspec (~> 3.0)
data/README.md CHANGED
@@ -1,28 +1,59 @@
1
1
  # Boring
2
+ ## Because your presentation layer shouldn't be interesting
2
3
 
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/boring`. To experiment with that code, run `bin/console` for an interactive prompt.
4
+ [![Gem Version](https://badge.fury.io/rb/boring_presenters.svg)](https://badge.fury.io/rb/boring_presenters) [![Build Status](https://travis-ci.org/apsislabs/boring.svg?branch=master)](https://travis-ci.org/apsislabs/boring) [![Inline docs](http://inch-ci.org/github/apsislabs/boring.svg?branch=master)](http://inch-ci.org/github/apsislabs/boring)
4
5
 
5
- TODO: Delete this and the text above, and describe your gem
6
+ **Note:** while we're actively using `boring` in production, it is still actively under development, and you should expect breaking changes.
6
7
 
7
- ## Installation
8
+ ## Usage
8
9
 
9
- Add this line to your application's Gemfile:
10
+ Below is an example of usage for a classic Rails controller/view pattern.
10
11
 
11
12
  ```ruby
12
- gem 'boring'
13
- ```
13
+ # presenters/user_presenter.rb
14
14
 
15
- And then execute:
15
+ class UserPresenter < Boring::Presenter
16
+ # Declare the arguments needed to bind to presenter and their type
17
+ arguments user: User
16
18
 
17
- $ bundle
19
+ # Declare pass-through methods
20
+ delegate :birth_date, to: :user
18
21
 
19
- Or install it yourself as:
22
+ # Methods to be handled by the presenter
23
+ def name
24
+ "#{user.first_name} #{user.last_name}".strip
25
+ end
26
+ end
20
27
 
21
- $ gem install boring
28
+ # controllers/users_controller.rb
22
29
 
23
- ## Usage
30
+ class UsersController < ApplicationController
31
+ def index
32
+ @users = User.all
33
+ @user_presenter = UsersPresenter.new
34
+ end
35
+ end
36
+ ```
37
+
38
+ ```erb
39
+ # views/users/index.html.erb
40
+
41
+ <ul>
42
+ <% @users.each do |user| %>
43
+ <% @user_presenter.bind(user: user) %>
44
+ <li>
45
+ <p>Full Name: <%= @user_presenter.name %></p>
46
+ <p>Birthday: <%= @user_presenter.birth_date %></p>
47
+ </li>
48
+ <% end %>
49
+ </ul>
50
+ ```
51
+
52
+ Some things worth noting that set `boring` apart from other presentation layers:
24
53
 
25
- TODO: Write usage instructions here
54
+ 1. **Explicit Delegation**: only methods intended for presentation layer should be allowed in the presenter. `boring` will never pass `super_dangerous_method!` through to your bound object unless you _want_ it to.
55
+ 2. **Type-Safe Bindings**: the `arguments` method in the `Boring::Presenter` class lets you set up type checking for the arguments passed to the `bind` method. If you try to bind a `Foo` to your `BarPresenter`, we'll raise an exception.
56
+ 3. **Separate Objects**: The presenter doesn't take over for your bound object; whether that bound object is available to your view is up to you, but you should never be unsure if you're dealing with a `Foo` or a `FooPresenter`.
26
57
 
27
58
  ## Development
28
59
 
@@ -1,3 +1,3 @@
1
1
  module Boring
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
File without changes
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: boring_presenters
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
  - Wyatt Kirby
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: exe
11
11
  cert_chain: []
12
- date: 2018-02-10 00:00:00.000000000 Z
12
+ date: 2018-05-29 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler
@@ -72,10 +72,10 @@ files:
72
72
  - bin/console
73
73
  - bin/setup
74
74
  - boring.gemspec
75
- - lib/boring.rb
76
75
  - lib/boring/exceptions.rb
77
76
  - lib/boring/presenter.rb
78
77
  - lib/boring/version.rb
78
+ - lib/boring_presenters.rb
79
79
  homepage: http://www.apsis.io
80
80
  licenses:
81
81
  - MIT