presenting 2.0.1 → 2.0.2

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.
@@ -9,7 +9,7 @@ module Presentation
9
9
  attr_accessor :presentable
10
10
 
11
11
  attr_accessor :controller
12
- delegate :request, :form_authenticity_token, :url_for, :params, :to => 'controller'
12
+ delegate :request, :form_authenticity_token, :url_for, :params, :_prefixes, :to => 'controller'
13
13
 
14
14
  protected
15
15
 
@@ -122,10 +122,13 @@ module Presentation
122
122
  attr_writer :value
123
123
 
124
124
  def value_from(obj) #:nodoc:
125
- v = case value
126
- when Symbol: obj.send(value)
127
- when String: value
128
- when Proc: value.call(obj)
125
+ case value
126
+ when Symbol
127
+ obj.send(value)
128
+ when String
129
+ value
130
+ when Proc
131
+ value.call(obj)
129
132
  end
130
133
  end
131
134
 
@@ -59,9 +59,9 @@ module Presentation
59
59
  # Field.new(:sortable => false)
60
60
  def sortable=(val)
61
61
  @sort_name = case val
62
- when TrueClass, FalseClass, NilClass
62
+ when TrueClass, FalseClass, NilClass
63
63
  val
64
- else
64
+ else
65
65
  val.to_s
66
66
  end
67
67
  end
@@ -32,9 +32,12 @@ module Presenting
32
32
 
33
33
  def value_from(obj) #:nodoc:
34
34
  case value
35
- when Symbol: obj.is_a?(Hash) ? obj[value] : obj.send(value)
36
- when String: value
37
- when Proc: value.call(obj)
35
+ when Symbol
36
+ obj.is_a?(Hash) ? obj[value] : obj.send(value)
37
+ when String
38
+ value
39
+ when Proc
40
+ value.call(obj)
38
41
  end
39
42
  end
40
43
 
@@ -84,14 +84,14 @@ module Presenting
84
84
 
85
85
  def present_by_class(object, options = {})
86
86
  case object
87
- when Array
87
+ when Array
88
88
  content_tag "ol" do
89
89
  object.collect do |i|
90
90
  content_tag "li", present(i, options)
91
91
  end.join.html_safe
92
92
  end
93
93
 
94
- when Hash
94
+ when Hash
95
95
  # sort by keys
96
96
  content_tag "dl" do
97
97
  object.keys.sort.collect do |k|
@@ -100,13 +100,13 @@ module Presenting
100
100
  end.join.html_safe
101
101
  end
102
102
 
103
- when TrueClass, FalseClass
103
+ when TrueClass, FalseClass
104
104
  object ? "True" : "False"
105
105
 
106
- when Date, Time, DateTime
106
+ when Date, Time, DateTime
107
107
  l(object, :format => :default)
108
108
 
109
- else
109
+ else
110
110
  options[:raw] ? object.to_s.html_safe : object.to_s
111
111
  end
112
112
  end
@@ -5,13 +5,13 @@ module Presenting::Sanitize
5
5
  # escape but preserve Arrays and Hashes
6
6
  def h(val)
7
7
  case val
8
- when Array
8
+ when Array
9
9
  val.map{|i| h(i)}
10
10
 
11
- when Hash
11
+ when Hash
12
12
  val.clone.each{|k, v| val[h(k)] = h(v)}
13
13
 
14
- else
14
+ else
15
15
  html_escape(val)
16
16
  end
17
17
  end
@@ -19,10 +19,10 @@ module Presenting
19
19
  # })
20
20
  def fields=(obj)
21
21
  case obj
22
- when Array
22
+ when Array
23
23
  obj.each do |name| fields << name end
24
24
 
25
- when Hash
25
+ when Hash
26
26
  obj.each do |k, v|
27
27
  fields << {k => v}
28
28
  end
@@ -166,17 +166,17 @@ module Presenting
166
166
 
167
167
  def typecast(val)
168
168
  case type
169
- when :date
169
+ when :date
170
170
  val.is_a?(String) ?
171
171
  (Time.zone ? Time.zone.parse(val) : Time.parse(val)).to_date :
172
172
  val
173
173
 
174
- when :time, :datetime
174
+ when :time, :datetime
175
175
  val.is_a?(String) ?
176
176
  (Time.zone ? Time.zone.parse(val) : Time.parse(val)) :
177
177
  val
178
178
 
179
- else
179
+ else
180
180
  val.to_s.strip
181
181
  end
182
182
  end
@@ -12,10 +12,10 @@ module Presenting
12
12
  # })
13
13
  def fields=(obj)
14
14
  case obj
15
- when Array
15
+ when Array
16
16
  obj.each do |name| fields << name end
17
17
 
18
- when Hash
18
+ when Hash
19
19
  obj.each do |k, v|
20
20
  fields << {k => v}
21
21
  end
data/lib/presenting.rb CHANGED
@@ -20,7 +20,7 @@ module Presenting
20
20
  presenting_dir = __FILE__.sub(/\/lib\/.*/, '') # there must be a better way
21
21
  %w(stylesheets javascripts).each do |asset_type|
22
22
  source_dir = File.join(presenting_dir, 'app', 'assets', asset_type)
23
- target_dir = File.join(Rails.application.paths.public.send(asset_type).first, 'presenting')
23
+ target_dir = File.join(Rails.application.paths["public/#{asset_type}"].first, 'presenting')
24
24
  FileUtils.mkdir_p(target_dir)
25
25
 
26
26
  Dir[File.join(source_dir, '*')].each do |asset|
data/test/form_test.rb CHANGED
@@ -165,12 +165,13 @@ class FormRenderingTest < Presentation::RenderTest
165
165
  end
166
166
 
167
167
  def test_rendering_a_password_field
168
- @presentation.presentable = User.new(:name => 'bob smith')
168
+ @presentation.presentable = User.new(:name => 'secret')
169
169
  @presentation.fields = [{:name => :password}]
170
-
170
+
171
171
  assert_select 'form div.field' do
172
172
  assert_select 'label', 'Name'
173
- assert_select "input[type=password][name='user[name]'][value='bob smith']"
173
+ assert_select "input[type=password][name='user[name]']", true
174
+ assert_select "input[type=password][name='user[name]'][value='secret']", false
174
175
  end
175
176
  end
176
177
 
@@ -300,17 +301,8 @@ class FormRenderingTest < Presentation::RenderTest
300
301
  ##
301
302
 
302
303
  extend ActiveModel::Naming
303
-
304
- # i actually want this model's name to not include the FormRenderingTest namespace
305
- # so i'm stubbing out the ActiveModel::Name with my own structure
306
304
  def self.model_name
307
- @_model_name ||= Name.new(:plural => 'users', :singular => 'user')
308
- end
309
- class Name
310
- attr_accessor :plural, :singular
311
- def initialize(hash)
312
- hash.each { |k, v| self.instance_variable_set("@#{k}", v) }
313
- end
305
+ @_model_name ||= ActiveModel::Name.new(self, FormRenderingTest)
314
306
  end
315
307
  end
316
308
  end
data/test/grid_test.rb CHANGED
@@ -239,7 +239,7 @@ class GridRenderTest < Presentation::RenderTest
239
239
  @presentation.controller.request.env['QUERY_STRING'] = 'sort[name]=desc'
240
240
 
241
241
  assert_select "#users thead" do
242
- assert_select "th a.sortable[href='?sort[name]=asc']", "Name"
242
+ assert_select "th a.sortable[href='?sort%5Bname%5D=asc']", "Name"
243
243
  end
244
244
  end
245
245
  end
data/test/helpers_test.rb CHANGED
@@ -33,11 +33,11 @@ class Presenting::HelpersTest < ActionView::TestCase
33
33
  end
34
34
 
35
35
  def test_presenting_a_time
36
- assert_equal 'Fri, 13 Feb 2009 02:31:00 +0000', present(Time.parse('02/13/2009 02:31 AM UTC').to_time)
36
+ assert_equal 'Fri, 13 Feb 2009 02:31:00 +0000', present(Time.zone.parse('2009-02-13 02:31 AM UTC'))
37
37
  end
38
38
 
39
39
  def test_presenting_a_date
40
- assert_equal '2009-02-13', present(Time.parse('02/13/2009 02:31 AM').to_date)
40
+ assert_equal '2009-02-13', present(Time.zone.parse('2009-02-13 02:31 AM UTC').to_date)
41
41
  end
42
42
 
43
43
  def test_presenting_a_string
data/test/r3/Gemfile CHANGED
@@ -1,7 +1,11 @@
1
1
  source 'http://rubygems.org'
2
2
 
3
- gem 'rails', '3.0.10'
3
+ gem 'rails', '3.2.5'
4
4
  gem 'sqlite3'
5
5
 
6
6
  gem 'presenting', :path => File.dirname(__FILE__) + '/../../'
7
7
  gem 'will_paginate', '~>3.0.0'
8
+
9
+ group :test do
10
+ gem 'mocha', :require => nil
11
+ end
data/test/r3/Gemfile.lock CHANGED
@@ -6,81 +6,94 @@ PATH
6
6
  GEM
7
7
  remote: http://rubygems.org/
8
8
  specs:
9
- abstract (1.0.0)
10
- actionmailer (3.0.10)
11
- actionpack (= 3.0.10)
12
- mail (~> 2.2.19)
13
- actionpack (3.0.10)
14
- activemodel (= 3.0.10)
15
- activesupport (= 3.0.10)
16
- builder (~> 2.1.2)
17
- erubis (~> 2.6.6)
18
- i18n (~> 0.5.0)
19
- rack (~> 1.2.1)
20
- rack-mount (~> 0.6.14)
21
- rack-test (~> 0.5.7)
22
- tzinfo (~> 0.3.23)
23
- activemodel (3.0.10)
24
- activesupport (= 3.0.10)
25
- builder (~> 2.1.2)
26
- i18n (~> 0.5.0)
27
- activerecord (3.0.10)
28
- activemodel (= 3.0.10)
29
- activesupport (= 3.0.10)
30
- arel (~> 2.0.10)
31
- tzinfo (~> 0.3.23)
32
- activeresource (3.0.10)
33
- activemodel (= 3.0.10)
34
- activesupport (= 3.0.10)
35
- activesupport (3.0.10)
36
- arel (2.0.10)
37
- builder (2.1.2)
38
- erubis (2.6.6)
39
- abstract (>= 1.0.0)
40
- i18n (0.5.0)
41
- json (1.6.1)
42
- mail (2.2.19)
43
- activesupport (>= 2.3.6)
9
+ actionmailer (3.2.5)
10
+ actionpack (= 3.2.5)
11
+ mail (~> 2.4.4)
12
+ actionpack (3.2.5)
13
+ activemodel (= 3.2.5)
14
+ activesupport (= 3.2.5)
15
+ builder (~> 3.0.0)
16
+ erubis (~> 2.7.0)
17
+ journey (~> 1.0.1)
18
+ rack (~> 1.4.0)
19
+ rack-cache (~> 1.2)
20
+ rack-test (~> 0.6.1)
21
+ sprockets (~> 2.1.3)
22
+ activemodel (3.2.5)
23
+ activesupport (= 3.2.5)
24
+ builder (~> 3.0.0)
25
+ activerecord (3.2.5)
26
+ activemodel (= 3.2.5)
27
+ activesupport (= 3.2.5)
28
+ arel (~> 3.0.2)
29
+ tzinfo (~> 0.3.29)
30
+ activeresource (3.2.5)
31
+ activemodel (= 3.2.5)
32
+ activesupport (= 3.2.5)
33
+ activesupport (3.2.5)
34
+ i18n (~> 0.6)
35
+ multi_json (~> 1.0)
36
+ arel (3.0.2)
37
+ builder (3.0.0)
38
+ erubis (2.7.0)
39
+ hike (1.2.1)
40
+ i18n (0.6.0)
41
+ journey (1.0.3)
42
+ json (1.7.3)
43
+ mail (2.4.4)
44
44
  i18n (>= 0.4.0)
45
45
  mime-types (~> 1.16)
46
46
  treetop (~> 1.4.8)
47
- mime-types (1.17.2)
47
+ metaclass (0.0.1)
48
+ mime-types (1.18)
49
+ mocha (0.11.3)
50
+ metaclass (~> 0.0.1)
51
+ multi_json (1.3.6)
48
52
  polyglot (0.3.3)
49
- rack (1.2.4)
50
- rack-mount (0.6.14)
51
- rack (>= 1.0.0)
52
- rack-test (0.5.7)
53
+ rack (1.4.1)
54
+ rack-cache (1.2)
55
+ rack (>= 0.4)
56
+ rack-ssl (1.3.2)
57
+ rack
58
+ rack-test (0.6.1)
53
59
  rack (>= 1.0)
54
- rails (3.0.10)
55
- actionmailer (= 3.0.10)
56
- actionpack (= 3.0.10)
57
- activerecord (= 3.0.10)
58
- activeresource (= 3.0.10)
59
- activesupport (= 3.0.10)
60
+ rails (3.2.5)
61
+ actionmailer (= 3.2.5)
62
+ actionpack (= 3.2.5)
63
+ activerecord (= 3.2.5)
64
+ activeresource (= 3.2.5)
65
+ activesupport (= 3.2.5)
60
66
  bundler (~> 1.0)
61
- railties (= 3.0.10)
62
- railties (3.0.10)
63
- actionpack (= 3.0.10)
64
- activesupport (= 3.0.10)
67
+ railties (= 3.2.5)
68
+ railties (3.2.5)
69
+ actionpack (= 3.2.5)
70
+ activesupport (= 3.2.5)
71
+ rack-ssl (~> 1.3.2)
65
72
  rake (>= 0.8.7)
66
73
  rdoc (~> 3.4)
67
- thor (~> 0.14.4)
74
+ thor (>= 0.14.6, < 2.0)
68
75
  rake (0.9.2.2)
69
- rdoc (3.11)
76
+ rdoc (3.12)
70
77
  json (~> 1.4)
71
- sqlite3 (1.3.3)
72
- thor (0.14.6)
78
+ sprockets (2.1.3)
79
+ hike (~> 1.2)
80
+ rack (~> 1.0)
81
+ tilt (~> 1.1, != 1.3.0)
82
+ sqlite3 (1.3.6)
83
+ thor (0.15.2)
84
+ tilt (1.3.3)
73
85
  treetop (1.4.10)
74
86
  polyglot
75
87
  polyglot (>= 0.3.1)
76
- tzinfo (0.3.31)
77
- will_paginate (3.0.0)
88
+ tzinfo (0.3.33)
89
+ will_paginate (3.0.3)
78
90
 
79
91
  PLATFORMS
80
92
  ruby
81
93
 
82
94
  DEPENDENCIES
95
+ mocha
83
96
  presenting!
84
- rails (= 3.0.10)
97
+ rails (= 3.2.5)
85
98
  sqlite3
86
99
  will_paginate (~> 3.0.0)
@@ -0,0 +1,2 @@
1
+ DEPRECATION WARNING: ActionDispatch::ShowExceptions.rescue_responses is deprecated. Please configure your exceptions using a railtie or in your application config instead. (called from /Users/cainlevy/Code/presenting/test/r3/config/environment.rb:5)
2
+ Connecting to database specified by database.yml