pakyow-presenter 0.7.0 → 0.7.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,20 @@
1
+ = 0.7.1 / 2012-01-08
2
+
3
+ * View caching fixes
4
+ * Changed binder to allow definition for multiple endpoints
5
+ * Changed in_context to accept context as block argument
6
+ * Changed action binder to add leading slash if needed
7
+ * Change to allow a view's content to be set to nil
8
+ * Fixed Views#find method
9
+
10
+ = 0.7.0 / 2011-11-19
11
+
12
+ * Cleaned up core/presenter interface
13
+ * Optimized view caching
14
+ * Binding occurs on the label an object is being bound to, not the object type
15
+ * Root view override in index directories no longer specify a root view for siblings
16
+ * Fixed problem binding to a checkbox who’s value attribute is not set
17
+
1
18
  = 0.6.3 / 2011-09-13
2
19
 
3
20
  * Fixes binding to bindings defined by HTML 'name' attribute
@@ -1,11 +1,11 @@
1
+ require 'presenter/view_lookup_store'
2
+ require 'presenter/view'
3
+ require 'presenter/lazy_view'
4
+ require 'presenter/binder'
5
+ require 'presenter/views'
6
+ require 'presenter/view_context'
7
+
1
8
  module Pakyow
2
9
  module Presenter
3
- autoload :PresenterBase, 'core/presenter_base'
4
- autoload :ViewLookupStore, 'presenter/view_lookup_store'
5
- autoload :View, 'presenter/view'
6
- autoload :LazyView, 'presenter/lazy_view'
7
- autoload :Binder, 'presenter/binder'
8
- autoload :Views, 'presenter/views'
9
- autoload :ViewContext, 'presenter/view_context'
10
10
  end
11
11
  end
@@ -6,9 +6,9 @@ module Pakyow
6
6
  class << self
7
7
  attr_accessor :options
8
8
 
9
- def binder_for(klass)
10
- View.binders = {} unless View.binders
11
- View.binders[klass.to_s.to_sym] = self
9
+ def binder_for(*args)
10
+ View.binders ||= {}
11
+ args.each { |klass| View.binders[klass.to_s.to_sym] = self }
12
12
  end
13
13
 
14
14
  def options_for(*args)
@@ -53,7 +53,7 @@ module Pakyow
53
53
  method = "post"
54
54
  end
55
55
 
56
- return { :action => action, :method => method }
56
+ return { :action => File.join('/', action), :method => method }
57
57
  end
58
58
  end
59
59
  end
@@ -128,7 +128,8 @@ module Pakyow
128
128
  #
129
129
 
130
130
  def with_container(container, &block)
131
- ViewContext.new(self.view.find("##{container}").first).instance_eval(&block)
131
+ v = self.view.find("##{container}").first
132
+ ViewContext.new(v).instance_exec(v, &block)
132
133
  end
133
134
 
134
135
  #
@@ -166,18 +167,17 @@ module Pakyow
166
167
  end
167
168
  return unless v_p
168
169
 
170
+ return unless view_info = @view_lookup_store.view_info(v_p)
171
+ @root_path ||= view_info[:root_view]
172
+
169
173
  if Configuration::Base.presenter.view_caching
170
- r_v = @populated_root_view_cache[v_p]
171
- if r_v then
174
+ r_v = @populated_root_view_cache.get([v_p, @root_path]) {
175
+ populate_view(LazyView.new(@root_path, true), view_info[:views])
176
+ }
172
177
  @root_view = r_v.dup
173
178
  @presented = true
174
- end
175
179
  else
176
- return unless view_info = @view_lookup_store.view_info(v_p)
177
- @root_path ||= view_info[:root_view]
178
- @root_view = LazyView.new(@root_path, true)
179
- views = view_info[:views]
180
- populate_view(self.view, views)
180
+ @root_view = populate_view(LazyView.new(@root_path, true), view_info[:views])
181
181
  @presented = true
182
182
  end
183
183
  end
@@ -198,13 +198,14 @@ module Pakyow
198
198
  end
199
199
 
200
200
  def build_root_view_cache(view_info)
201
- r_v_c = {}
201
+ cache = Pakyow::Cache.new
202
202
  view_info.each{|dir,info|
203
203
  r_v = LazyView.new(info[:root_view], true)
204
204
  populate_view(r_v, info[:views])
205
- r_v_c[dir] = r_v
205
+ key = [dir, info[:root_view]]
206
+ cache.put(key, r_v)
206
207
  }
207
- r_v_c
208
+ cache
208
209
  end
209
210
 
210
211
  # populates the top_view using view_store data by recursively building
@@ -85,7 +85,7 @@ module Pakyow
85
85
  end
86
86
 
87
87
  def in_context(&block)
88
- ViewContext.new(self).instance_eval(&block)
88
+ ViewContext.new(self).instance_exec(self, &block)
89
89
  end
90
90
 
91
91
  def bind(object, opts = {})
@@ -122,7 +122,7 @@ module Pakyow
122
122
  objects.each do |object|
123
123
  view = View.new(self)
124
124
  view.bind(object, opts)
125
- ViewContext.new(view).instance_exec(object, &block) if block_given?
125
+ ViewContext.new(view).instance_exec(object, view, &block) if block_given?
126
126
 
127
127
  o.add_previous_sibling(view.doc)
128
128
  end
@@ -219,10 +219,9 @@ module Pakyow
219
219
  alias :html :content
220
220
 
221
221
  def content=(content)
222
- return unless content
223
222
  self.doc.inner_html = Nokogiri::HTML.fragment(content.to_s)
224
223
  end
225
-
224
+
226
225
  alias :html= :content=
227
226
 
228
227
  def append(content)
@@ -12,7 +12,7 @@ module Pakyow
12
12
  end
13
13
 
14
14
  def in_context(&block)
15
- ViewContext.new(self).instance_eval(&block)
15
+ ViewContext.new(self).instance_exec(self, &block)
16
16
  end
17
17
 
18
18
  def attributes(*args)
@@ -102,9 +102,10 @@ module Pakyow
102
102
  self.each {|e| e.bind(object, opts)}
103
103
  end
104
104
 
105
- def find(element)
105
+ def find(element, &block)
106
106
  views = Views.new
107
107
  self.each {|e| e.find(element, &block).each { |v| views << v }}
108
+ views
108
109
  end
109
110
  end
110
111
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pakyow-presenter
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.0
4
+ version: 0.7.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,22 +10,22 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2011-11-19 00:00:00.000000000Z
13
+ date: 2012-01-08 00:00:00.000000000Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: pakyow-core
17
- requirement: &70363184265360 !ruby/object:Gem::Requirement
17
+ requirement: &70243486230860 !ruby/object:Gem::Requirement
18
18
  none: false
19
19
  requirements:
20
20
  - - =
21
21
  - !ruby/object:Gem::Version
22
- version: 0.7.0
22
+ version: 0.7.1
23
23
  type: :runtime
24
24
  prerelease: false
25
- version_requirements: *70363184265360
25
+ version_requirements: *70243486230860
26
26
  - !ruby/object:Gem::Dependency
27
27
  name: nokogiri
28
- requirement: &70363184264680 !ruby/object:Gem::Requirement
28
+ requirement: &70243486229100 !ruby/object:Gem::Requirement
29
29
  none: false
30
30
  requirements:
31
31
  - - ~>
@@ -33,10 +33,10 @@ dependencies:
33
33
  version: '1.5'
34
34
  type: :runtime
35
35
  prerelease: false
36
- version_requirements: *70363184264680
36
+ version_requirements: *70243486229100
37
37
  - !ruby/object:Gem::Dependency
38
38
  name: shoulda
39
- requirement: &70363184263960 !ruby/object:Gem::Requirement
39
+ requirement: &70243486228220 !ruby/object:Gem::Requirement
40
40
  none: false
41
41
  requirements:
42
42
  - - ~>
@@ -44,7 +44,7 @@ dependencies:
44
44
  version: '2.11'
45
45
  type: :development
46
46
  prerelease: false
47
- version_requirements: *70363184263960
47
+ version_requirements: *70243486228220
48
48
  description: pakyow-presenter
49
49
  email: bryan@metabahn.com
50
50
  executables: []