liaison 0.0.2 → 0.0.3

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.
data/ChangeLog CHANGED
@@ -1,4 +1,26 @@
1
- 2011-09-20 Mike Burns <mburns@thoughtbot.com>
1
+ 2011-10-20 Mike Burns <mburns@thoughtbot.com>
2
+
3
+ * presenter.rb, presenter_spec.rc: Don't name the struct so that we can
4
+ avoid redefining a constant.
5
+
6
+ 2011-09-21 Mike Burns <mburns@thoughtbot.com>
7
+
8
+ * ChangeLog, NEWS: Retroactively update the docs based on git history.
9
+ * README.md:
10
+ Link to the raw NEWS, ChangeLog, and Ruby docs at the top of the docs.
11
+ Mention the raw license in the contact section.
12
+ Demand that pull requests update the ChangeLog and NEWS.
13
+ Mention the GNU ChangeLog format.
14
+
15
+ 2011-09-21 Matt Gillooly <matt@mattgillooly.com>
16
+
17
+ * README.md: Fix the 'tutorial' misspelling.
18
+
19
+ 2011-09-21 Dan Croak <dcroak@thoughtbot.com>
20
+
21
+ * README.md: The validator class is passed, not an instance.
22
+
23
+ 2011-09-20 Mike Burns <mburns@thoughtbot.com>
2
24
 
3
25
  * presenter.rb, presenter_spec.rb:
4
26
  Include the Enumerable module to the Presenter class, with a test.
@@ -7,3 +29,17 @@
7
29
  Add an overview NEWS file and a more detailed ChangeLog file.
8
30
 
9
31
  * version.rb: Bump version to 0.0.2.
32
+
33
+ 2011-09-10 Mike Burns <mburns@thoughtbot.com>
34
+
35
+ * presenter.rb (model_name):
36
+ Use a struct as the model namer for ActiveModel::Name.
37
+
38
+ * README.md: Add a quick start guide.
39
+
40
+ * presenter.rb (model_name, persisted?):
41
+ Explain why these exist but are undocumented.
42
+ (with_params, each):
43
+ Be more explicit in the documentation about how to use these and what the
44
+ classes are.
45
+ (instance_validations): Make this protected.
data/NEWS CHANGED
@@ -1,4 +1,11 @@
1
+ New in 0.0.3:
2
+
3
+ * Take care of a warning based on using a struct for the model_name.
4
+
1
5
  New in 0.0.2:
2
6
 
7
+ * The #instance_validations method, part of the plumbing to make the
8
+ validations work transparently with Rails, is protected. This would be of no
9
+ use to you anyway, ideally.
3
10
  * The Presenter class now includes the Enumerable class. This means you can
4
11
  use #map, #reject, #sort, and so on, on the Presenter data object.
data/README.md CHANGED
@@ -3,6 +3,8 @@ Liaison
3
3
 
4
4
  A Rails presenter class.
5
5
 
6
+ Experienced devs will be interested in the [NEWS](https://raw.github.com/mike-burns/liaison/master/NEWS), [ChangeLog](https://raw.github.com/mike-burns/liaison/master/ChangeLog), and [reference documentation](http://rubydoc.info/gems/liaison/0.0.2/frames).
7
+
6
8
  How to Use Liaison
7
9
  ------------------
8
10
 
@@ -22,7 +24,7 @@ The business logic classes (`SignUp` in the below example) live under `app/model
22
24
 
23
25
  Validator classes (`SignUpValidator` in the below example) live under `lib` and must either descend from `ActiveModel::Validator` or implement the same interface (`.kind`, `#kind`, `#validate` that takes a record, and a constructor that takes a hash of options). They are also unit tested like normal and can likely get away with just requiring `rspec` instead of `spec_helper`. Sadly, in order to hook into the `ActiveModel::Validations` framework, you must pass the validator class itself instead of an object (`SignUpValidator` vs `SignUpValidator.new`).
24
26
 
25
- Turorial and Thought Process
27
+ Tutorial and Thought Process
26
28
  ----------------------------
27
29
 
28
30
  A major idea of [the presenter pattern](http://blog.jayfields.com/2007/03/rails-presenter-pattern.html) is to break off the business logic from the view object, letting the view logic be a dumb instance that knows how to get, set, and validate values. The business logic can then query the presenter object for the values as needed.
@@ -82,7 +84,7 @@ Now you need to know how to use a `Presenter` object, so this is what the contro
82
84
  def presenter
83
85
  Presenter.new('sign_up',
84
86
  :fields => [:email, :password, :account_name],
85
- :validator => SignUpValidator.new)
87
+ :validator => SignUpValidator)
86
88
  end
87
89
  end
88
90
 
@@ -128,6 +130,6 @@ When writing your unit tests it'll be handy to have a mock presenter around, whi
128
130
  Contact
129
131
  -------
130
132
 
131
- Copyright 2011 [Mike Burns](http://mike-burns.com/).
133
+ Copyright 2011 [Mike Burns](http://mike-burns.com/). Distributed under [the three-clause BSD license](https://raw.github.com/mike-burns/liaison/master/LICENSE).
132
134
 
133
- Please [open a pull request on Github](https://github.com/mike-burns/liaison/pulls) as needed.
135
+ Please [open a pull request on Github](https://github.com/mike-burns/liaison/pulls) as needed. Be sure to update the ChangeLog and, if needed, the NEWS. We follow [the GNU ChangeLog format](http://www.gnu.org/prep/standards/html_node/Change-Logs.html).
@@ -27,7 +27,7 @@ class Presenter
27
27
 
28
28
  # This only exists for ActiveModel::Naming
29
29
  def self.model_name # :nodoc:
30
- model_namer = Struct.new("ModelNamer", :name).new(@@model_name)
30
+ model_namer = Struct.new(:name).new(@@model_name)
31
31
  ActiveModel::Name.new(model_namer)
32
32
  end
33
33
 
@@ -1,3 +1,3 @@
1
1
  module Liaison
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
@@ -15,6 +15,11 @@ describe Presenter do
15
15
  subject.to_key.should be_nil
16
16
  subject.to_param.should be_nil
17
17
  end
18
+
19
+ it "does not mind having a bunch of them" do
20
+ Presenter.new("another_model_name").class.model_name
21
+ # The result is that this should have no warning in the test output
22
+ end
18
23
  end
19
24
 
20
25
  describe Presenter, 'validations' do
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: liaison
3
3
  version: !ruby/object:Gem::Version
4
- hash: 27
4
+ hash: 25
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 2
10
- version: 0.0.2
9
+ - 3
10
+ version: 0.0.3
11
11
  platform: ruby
12
12
  authors:
13
13
  - Mike Burns
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-09-20 00:00:00 Z
18
+ date: 2011-10-20 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  name: activemodel