model_presenter 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
data/.rbenv-version ADDED
@@ -0,0 +1 @@
1
+ 1.9.3-p194
data/README.md CHANGED
@@ -8,6 +8,16 @@ The presenter puts more emphasis on JSON representation of a business model obje
8
8
 
9
9
  The gem is not trying to provide a automagic way to look cool. Rather, it focuses on explicitly expressing the intent of a Presenter class. Please read the usage for the details
10
10
 
11
+ ## What is a presenter
12
+
13
+ A presenter is a bridge between a business model and how it will be presented (as json, as HTML, as text, as PDF, etc.). A presenter covers logic that is necessary for presenting a business model, but such logic should not be put into the business model because it doesn't belong to.
14
+
15
+ For example, what attributes are going to be included in the JSON return is not a business model's concern. Another example, If the front end needs to have a person's gender in a humanly readable way (such as "Male" and "Female"), it is not the business model's concern. The business model knows it's gender in some way, it might choose to represent it as a boolean ```model.male?``` and ```model.female?```. It is the responsibility of a presenter to provide what the front end needs. The Presenter may return the string ```Male``` or ```Female``` in its ```gender``` method.
16
+
17
+ ## What is not a presenter
18
+
19
+ A Presenter is not a place for generating HTML tags and code segments. An HTML file is where you write HTML code in.
20
+
11
21
  ## Installation
12
22
 
13
23
  Add this line to your application's Gemfile:
@@ -1,3 +1,3 @@
1
1
  module ModelPresenter
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
@@ -19,7 +19,6 @@ Gem::Specification.new do |gem|
19
19
  gem.add_development_dependency(%q<minitest-growl>)
20
20
  gem.add_development_dependency(%q<guard-minitest>)
21
21
  gem.add_development_dependency(%q<minitest-wscolor>)
22
- gem.add_development_dependency(%q<cane>)
23
22
  gem.add_development_dependency(%q<rake>)
24
23
  gem.add_development_dependency(%q<mocha>)
25
24
  gem.add_development_dependency(%q<minitest-spec-context>)
@@ -7,7 +7,11 @@ module ModelPresenter
7
7
  keys.each do |key|
8
8
  context "having the key #{key}"
9
9
  it "has the key #{key} with value set to presenter.#{key}" do
10
- result[key].should eq(subject.send(key))
10
+ if result[key].respond_to?(:should)
11
+ result[key].should eq(subject.send(key))
12
+ else
13
+ expect(result[key]).to eq(subject.send(key))
14
+ end
11
15
  end
12
16
  end
13
17
  end
@@ -5,7 +5,12 @@ module ModelPresenter
5
5
  attributes.each do |attribute|
6
6
  describe "##{attribute}" do
7
7
  it "returns the model.#{attribute}" do
8
- subject.send(attribute).should eq(model.send(attribute))
8
+ result = subject.send(attribute)
9
+ if result.respond_to?(:should)
10
+ result.should eq(model.send(attribute))
11
+ else
12
+ expect(result).to eq(model.send(attribute))
13
+ end
9
14
  end
10
15
  end
11
16
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: model_presenter
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-04-10 00:00:00.000000000 Z
12
+ date: 2012-07-19 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: json
@@ -91,22 +91,6 @@ dependencies:
91
91
  - - ! '>='
92
92
  - !ruby/object:Gem::Version
93
93
  version: '0'
94
- - !ruby/object:Gem::Dependency
95
- name: cane
96
- requirement: !ruby/object:Gem::Requirement
97
- none: false
98
- requirements:
99
- - - ! '>='
100
- - !ruby/object:Gem::Version
101
- version: '0'
102
- type: :development
103
- prerelease: false
104
- version_requirements: !ruby/object:Gem::Requirement
105
- none: false
106
- requirements:
107
- - - ! '>='
108
- - !ruby/object:Gem::Version
109
- version: '0'
110
94
  - !ruby/object:Gem::Dependency
111
95
  name: rake
112
96
  requirement: !ruby/object:Gem::Requirement
@@ -164,6 +148,7 @@ extensions: []
164
148
  extra_rdoc_files: []
165
149
  files:
166
150
  - .gitignore
151
+ - .rbenv-version
167
152
  - .rvmrc.template
168
153
  - .travis.yml
169
154
  - Gemfile
@@ -208,7 +193,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
208
193
  version: '0'
209
194
  requirements: []
210
195
  rubyforge_project:
211
- rubygems_version: 1.8.21
196
+ rubygems_version: 1.8.23
212
197
  signing_key:
213
198
  specification_version: 3
214
199
  summary: Provides an implementation of Presenter pattern
@@ -221,3 +206,4 @@ test_files:
221
206
  - test/support/mock_base_class.rb
222
207
  - test/support/mock_model_object.rb
223
208
  - test/test_helper.rb
209
+ has_rdoc: