draper 0.7.2 → 0.7.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ rvm:
2
+ - 1.8.7
3
+ - 1.9.2
4
+ - rbx
5
+ - rbx-2.0
6
+ - ree
7
+ - jruby
data/Gemfile CHANGED
@@ -1,3 +1,13 @@
1
1
  source :rubygems
2
- gem 'actionpack', "~> 3.0.9", :require => 'action_view'
3
- gemspec
2
+
3
+ gem 'rake'
4
+ gem 'rspec', '~> 2.0.1'
5
+ gem 'activesupport', '~> 3.0.10'
6
+ gem 'actionpack', "~> 3.0.10", :require => 'action_view'
7
+ gem 'guard'
8
+ gem 'guard-rspec'
9
+ gem 'launchy'
10
+ gem 'rcov', :platforms => [:mri_18]
11
+ gem 'cover_me', '>= 1.0.0.rc6', :platforms => [:mri_19]
12
+
13
+ gemspec
@@ -51,7 +51,7 @@ Or, in the course of formatting this data, did you wish you could access `curren
51
51
 
52
52
  How would you handle this in the model layer? You'd probably pass the `current_user` or some role/flag down to `to_json`. That should still feel slimy.
53
53
 
54
- When you use a decorator you have the power of a Ruby object but it's a part of the view layer. This is where your `to_xml` belongs. You can access your `current_user` helper method using the `h` proxy available in the decorator:
54
+ When you use a decorator you have the power of a Ruby object but it's a part of the view layer. This is where your `to_json` belongs. You can access your `current_user` helper method using the `h` proxy available in the decorator:
55
55
 
56
56
  ```ruby
57
57
  class ArticleDecorator < ApplicationDecorator
@@ -59,9 +59,9 @@ class ArticleDecorator < ApplicationDecorator
59
59
  ADMIN_VISIBLE_ATTRIBUTES = [:title, :body, :author, :status]
60
60
  PUBLIC_VISIBLE_ATTRIBUTES = [:title, :body]
61
61
 
62
- def to_xml
62
+ def to_json
63
63
  attr_set = h.current_user.admin? ? ADMIN_VISIBLE_ATTRIBUTES : PUBLIC_VISIBLE_ATTRIBUTES
64
- model.to_xml(:only => attr_set)
64
+ model.to_json(:only => attr_set)
65
65
  end
66
66
  end
67
67
  ```
@@ -84,9 +84,9 @@ end
84
84
  Then, to test it:
85
85
 
86
86
  ```irb
87
- ruby-1.9.2-p290 :001 > ad = ArticleDecorator.find(1)
87
+ > ad = ArticleDecorator.find(1)
88
88
  => #<ArticleDecorator:0x000001020d7728 @model=#<Article id: 1, title: "Hello, World">>
89
- ruby-1.9.2-p290 :002 > ad.title
89
+ > ad.title
90
90
  NoMethodError: undefined method `title' for #<ArticleDecorator:0x000001020d7728>
91
91
  ```
92
92
 
@@ -102,11 +102,11 @@ end
102
102
  ```
103
103
 
104
104
  ```irb
105
- ruby-1.9.2-p290 :001 > ad = ArticleDecorator.find(1)
105
+ > ad = ArticleDecorator.find(1)
106
106
  => #<ArticleDecorator:0x000001020d7728 @model=#<Article id: 1, title: "Hello, World">>
107
- ruby-1.9.2-p290 :002 > ad.title
107
+ > ad.title
108
108
  => "Hello, World"
109
- ruby-1.9.2-p290 :003 > ad.created_at
109
+ > ad.created_at
110
110
  NoMethodError: undefined method `created_at' for #<ArticleDecorator:0x000001020d7728>
111
111
  ```
112
112
 
@@ -296,7 +296,6 @@ end
296
296
  ## Issues / Pending
297
297
 
298
298
  * Documentation
299
- * Keep revising Readme for better organization/clarity
300
299
  * Add more information about using "context"
301
300
  * Add information about the `.decorator` method
302
301
  * Make clear the pattern of overriding accessor methods of the wrapped model
@@ -17,20 +17,4 @@ Gem::Specification.new do |s|
17
17
  s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
18
18
  s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
19
19
  s.require_paths = ["lib"]
20
-
21
- s.add_development_dependency "rake", ["0.8.7"]
22
- s.add_development_dependency "rspec", ["~> 2.0.1"]
23
- s.add_development_dependency "activesupport", ["~> 3.0.9"]
24
- s.add_development_dependency "actionpack", ["~> 3.0.9"]
25
- s.add_development_dependency "guard"
26
- s.add_development_dependency "guard-rspec"
27
- s.add_development_dependency "rb-fsevent"
28
- if RUBY_VERSION.to_f == 1.8
29
- s.add_development_dependency "ruby-debug"
30
- s.add_development_dependency "rcov"
31
- s.add_development_dependency "launchy"
32
- else
33
- s.add_development_dependency "ruby-debug19"
34
- s.add_development_dependency 'cover_me', ['>= 1.0.0.rc6']
35
- end
36
20
  end
@@ -1,3 +1,3 @@
1
1
  module Draper
2
- VERSION = "0.7.2"
2
+ VERSION = "0.7.3"
3
3
  end
@@ -1,25 +1,8 @@
1
1
  require 'rubygems'
2
- require 'bundler'
3
-
4
- require 'rspec'
5
- begin
6
- require 'cover_me'
7
- rescue LoadError
8
- # Silently fail
9
- end
10
- require './spec/samples/application_helper.rb'
11
- Bundler.require
12
- Dir.glob('./spec/samples/*') {|file| require file}
13
- require 'active_support'
14
- require 'action_view'
15
2
  require 'bundler/setup'
16
-
3
+ Bundler.require
17
4
  require 'draper'
18
-
19
- Dir["spec/support/**/*.rb"].each do |file|
20
- require "./" + file
21
- end
22
-
23
- RSpec.configure do |config|
24
-
5
+ require './spec/samples/application_helper.rb'
6
+ Dir.glob(['./spec/samples/*.rb', './spec/support/*.rb']) do |file|
7
+ require file
25
8
  end
metadata CHANGED
@@ -1,124 +1,35 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: draper
3
- version: !ruby/object:Gem::Version
4
- version: 0.7.2
3
+ version: !ruby/object:Gem::Version
4
+ hash: 5
5
5
  prerelease:
6
+ segments:
7
+ - 0
8
+ - 7
9
+ - 3
10
+ version: 0.7.3
6
11
  platform: ruby
7
- authors:
12
+ authors:
8
13
  - Jeff Casimir
9
14
  autorequire:
10
15
  bindir: bin
11
16
  cert_chain: []
12
- date: 2011-08-28 00:00:00.000000000Z
13
- dependencies:
14
- - !ruby/object:Gem::Dependency
15
- name: rake
16
- requirement: &70298759756220 !ruby/object:Gem::Requirement
17
- none: false
18
- requirements:
19
- - - =
20
- - !ruby/object:Gem::Version
21
- version: 0.8.7
22
- type: :development
23
- prerelease: false
24
- version_requirements: *70298759756220
25
- - !ruby/object:Gem::Dependency
26
- name: rspec
27
- requirement: &70298759755700 !ruby/object:Gem::Requirement
28
- none: false
29
- requirements:
30
- - - ~>
31
- - !ruby/object:Gem::Version
32
- version: 2.0.1
33
- type: :development
34
- prerelease: false
35
- version_requirements: *70298759755700
36
- - !ruby/object:Gem::Dependency
37
- name: activesupport
38
- requirement: &70298759755200 !ruby/object:Gem::Requirement
39
- none: false
40
- requirements:
41
- - - ~>
42
- - !ruby/object:Gem::Version
43
- version: 3.0.9
44
- type: :development
45
- prerelease: false
46
- version_requirements: *70298759755200
47
- - !ruby/object:Gem::Dependency
48
- name: actionpack
49
- requirement: &70298759754680 !ruby/object:Gem::Requirement
50
- none: false
51
- requirements:
52
- - - ~>
53
- - !ruby/object:Gem::Version
54
- version: 3.0.9
55
- type: :development
56
- prerelease: false
57
- version_requirements: *70298759754680
58
- - !ruby/object:Gem::Dependency
59
- name: guard
60
- requirement: &70298759754180 !ruby/object:Gem::Requirement
61
- none: false
62
- requirements:
63
- - - ! '>='
64
- - !ruby/object:Gem::Version
65
- version: '0'
66
- type: :development
67
- prerelease: false
68
- version_requirements: *70298759754180
69
- - !ruby/object:Gem::Dependency
70
- name: guard-rspec
71
- requirement: &70298759739500 !ruby/object:Gem::Requirement
72
- none: false
73
- requirements:
74
- - - ! '>='
75
- - !ruby/object:Gem::Version
76
- version: '0'
77
- type: :development
78
- prerelease: false
79
- version_requirements: *70298759739500
80
- - !ruby/object:Gem::Dependency
81
- name: rb-fsevent
82
- requirement: &70298759738820 !ruby/object:Gem::Requirement
83
- none: false
84
- requirements:
85
- - - ! '>='
86
- - !ruby/object:Gem::Version
87
- version: '0'
88
- type: :development
89
- prerelease: false
90
- version_requirements: *70298759738820
91
- - !ruby/object:Gem::Dependency
92
- name: ruby-debug19
93
- requirement: &70298759738380 !ruby/object:Gem::Requirement
94
- none: false
95
- requirements:
96
- - - ! '>='
97
- - !ruby/object:Gem::Version
98
- version: '0'
99
- type: :development
100
- prerelease: false
101
- version_requirements: *70298759738380
102
- - !ruby/object:Gem::Dependency
103
- name: cover_me
104
- requirement: &70298759737840 !ruby/object:Gem::Requirement
105
- none: false
106
- requirements:
107
- - - ! '>='
108
- - !ruby/object:Gem::Version
109
- version: 1.0.0.rc6
110
- type: :development
111
- prerelease: false
112
- version_requirements: *70298759737840
113
- description: Draper reimagines the role of helpers in the view layer of a Rails application,
114
- allowing an object-oriented approach rather than procedural.
115
- email:
17
+
18
+ date: 2011-08-29 00:00:00 Z
19
+ dependencies: []
20
+
21
+ description: Draper reimagines the role of helpers in the view layer of a Rails application, allowing an object-oriented approach rather than procedural.
22
+ email:
116
23
  - jeff@casimircreative.com
117
24
  executables: []
25
+
118
26
  extensions: []
27
+
119
28
  extra_rdoc_files: []
120
- files:
29
+
30
+ files:
121
31
  - .gitignore
32
+ - .travis.yml
122
33
  - Gemfile
123
34
  - Guardfile
124
35
  - Rakefile
@@ -148,29 +59,38 @@ files:
148
59
  - spec/spec_helper.rb
149
60
  homepage: http://github.com/jcasimir/draper
150
61
  licenses: []
62
+
151
63
  post_install_message:
152
64
  rdoc_options: []
153
- require_paths:
65
+
66
+ require_paths:
154
67
  - lib
155
- required_ruby_version: !ruby/object:Gem::Requirement
68
+ required_ruby_version: !ruby/object:Gem::Requirement
156
69
  none: false
157
- requirements:
158
- - - ! '>='
159
- - !ruby/object:Gem::Version
160
- version: '0'
161
- required_rubygems_version: !ruby/object:Gem::Requirement
70
+ requirements:
71
+ - - ">="
72
+ - !ruby/object:Gem::Version
73
+ hash: 3
74
+ segments:
75
+ - 0
76
+ version: "0"
77
+ required_rubygems_version: !ruby/object:Gem::Requirement
162
78
  none: false
163
- requirements:
164
- - - ! '>='
165
- - !ruby/object:Gem::Version
166
- version: '0'
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ hash: 3
83
+ segments:
84
+ - 0
85
+ version: "0"
167
86
  requirements: []
87
+
168
88
  rubyforge_project: draper
169
- rubygems_version: 1.8.10
89
+ rubygems_version: 1.8.6
170
90
  signing_key:
171
91
  specification_version: 3
172
92
  summary: Decorator pattern implmentation for Rails.
173
- test_files:
93
+ test_files:
174
94
  - spec/base_spec.rb
175
95
  - spec/draper/model_support_spec.rb
176
96
  - spec/samples/active_record.rb