hobo 1.1.0.pre0 → 1.1.0.pre2

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.
@@ -14,6 +14,32 @@ likely to cause conflicts, so it is highly recommended that you have
14
14
  your code backed up and in a change control system such as git or
15
15
  subversion.
16
16
 
17
+ === Hobo 1.0.2 ===
18
+
19
+ This release is almost identical to 1.0.1 except that it updates the
20
+ version requirements to exclude Rails3. Hobo does not currently work
21
+ with Rails3, although we are working on it.
22
+
23
+ This release silences some warnings produced when running with Rails
24
+ 2.3.10.
25
+
26
+ This release contains preliminary support for Ruby 1.9.2, although you
27
+ may encounter problems if you use Single Type Inheritance (STI)
28
+ models.
29
+
30
+ A few very minor bug fixes have also been included. See the [github
31
+ log](https://github.com/tablatom/hobo/compare/v1.0.1...v1.0.2) for
32
+ more details.
33
+
34
+ === Hobo 1.0.1 ===
35
+
36
+ This version contains two speedups: one fix that reduces the number of
37
+ database accesses by Matt Jones and one that speeds up compilation of
38
+ DRYML by Petteri Räty.
39
+
40
+ This version also contains several bug fixes. See the [github
41
+ log](http://github.com/tablatom/hobo/tree/v1.0.1) for more details.
42
+
17
43
  === Hobo 1.0.0 ===
18
44
 
19
45
  Drumm-roll! Trumpets! Fanfare!
data/Rakefile CHANGED
@@ -59,8 +59,8 @@ Jeweler::Tasks.new do |gemspec|
59
59
  gemspec.executables = ['hobo']
60
60
  gemspec.default_executable = 'hobo'
61
61
  gemspec.rubyforge_project = "hobo"
62
- gemspec.add_dependency("rails", [">= 2.2.2"])
63
- gemspec.add_dependency("will_paginate", [">= 2.3.11"])
62
+ gemspec.add_dependency("rails", [">= 2.2.2", "< 3.0.0"])
63
+ gemspec.add_dependency("will_paginate", [">= 2.3.11", "~> 2"])
64
64
  gemspec.add_dependency("hobosupport", ["= #{Hobo::VERSION}"])
65
65
  gemspec.add_dependency("hobofields", ["= #{Hobo::VERSION}"])
66
66
  gemspec.add_dependency("dryml", ["= #{Hobo::VERSION}"])
@@ -34,6 +34,7 @@ Contents
34
34
  >> $:.unshift File.join(File.expand_path(File.dirname(__FILE__)), '../../hobofields/lib')
35
35
  >> $:.unshift File.join(File.expand_path(File.dirname(__FILE__)), '../../hobosupport/lib')
36
36
  >> $:.unshift File.join(File.expand_path(File.dirname(__FILE__)), '../../hobo/lib')
37
+ >> gem 'will_paginate', '~> 2'
37
38
  >> require 'will_paginate'
38
39
  >> require 'will_paginate/finder'
39
40
  >> require 'hobosupport'
@@ -31,6 +31,7 @@ Contents
31
31
  >> $:.unshift File.join(File.expand_path(File.dirname(__FILE__)), '../../hobofields/lib')
32
32
  >> $:.unshift File.join(File.expand_path(File.dirname(__FILE__)), '../../hobosupport/lib')
33
33
  >> $:.unshift File.join(File.expand_path(File.dirname(__FILE__)), '../../hobo/lib')
34
+ >> gem 'will_paginate', '~> 2'
34
35
  >> require 'will_paginate'
35
36
  >> require 'will_paginate/finder'
36
37
  >> require 'hobosupport'
@@ -74,6 +74,7 @@ Some load path manipulation:
74
74
  And we'll require hobo:
75
75
  {.hidden}
76
76
 
77
+ >> gem 'will_paginate', '~> 2'
77
78
  >> require 'will_paginate'
78
79
  >> require 'will_paginate/finder'
79
80
  >> require 'hobosupport'
@@ -2,12 +2,18 @@
2
2
  require 'hobosupport'
3
3
  require 'hobofields'
4
4
  begin
5
+ gem 'will_paginate', '~> 2'
5
6
  require 'will_paginate'
7
+ require 'will_paginate/finder'
6
8
  rescue MissingSourceFile
7
9
  # OK, Hobo won't do pagination then
8
10
  end
9
11
 
10
- ActiveSupport::Dependencies.load_paths |= [ File.dirname(__FILE__)]
12
+ if ActiveSupport::Dependencies.respond_to?(:autoload_paths)
13
+ ActiveSupport::Dependencies.autoload_paths |= [ File.dirname(__FILE__)]
14
+ else
15
+ ActiveSupport::Dependencies.load_paths |= [ File.dirname(__FILE__)]
16
+ end
11
17
 
12
18
  # Hobo can be installed in /vendor/hobo, /vendor/plugins/hobo, vendor/plugins/hobo/hobo, etc.
13
19
  ::HOBO_ROOT = File.expand_path(File.dirname(__FILE__) + "/..")
@@ -16,7 +22,7 @@ class HoboError < RuntimeError; end
16
22
 
17
23
  module Hobo
18
24
 
19
- VERSION = "1.1.0.pre0"
25
+ VERSION = "1.1.0.pre2"
20
26
 
21
27
  class PermissionDeniedError < RuntimeError; end
22
28
 
@@ -115,7 +121,11 @@ module Hobo
115
121
 
116
122
  HoboFields.never_wrap(Hobo::Undefined) if defined? HoboFields
117
123
 
118
- ActiveSupport::Dependencies.load_paths |= [ "#{RAILS_ROOT}/app/viewhints" ]
124
+ if ActiveSupport::Dependencies.respond_to?(:autoload_paths)
125
+ ActiveSupport::Dependencies.autoload_paths |= [ "#{RAILS_ROOT}/app/viewhints" ]
126
+ else
127
+ ActiveSupport::Dependencies.load_paths |= [ "#{RAILS_ROOT}/app/viewhints" ]
128
+ end
119
129
  end
120
130
 
121
131
  end
@@ -9,7 +9,11 @@ module Hobo
9
9
 
10
10
  array = params_hash_to_array(array_or_hash)
11
11
  array.map! do |record_hash_or_string|
12
- finder = association.member_class.scoped :conditions => association.conditions
12
+ if association.conditions.nil?
13
+ finder = association.member_class
14
+ else
15
+ finder = association.member_class.scoped :conditions => association.conditions
16
+ end
13
17
  find_or_create_and_update(owner, association_name, finder, record_hash_or_string) do |id|
14
18
  # The block is required to either locate find an existing record in the collection, or build a new one
15
19
  if id
@@ -24,45 +24,36 @@ module Hobo
24
24
 
25
25
  def self.def_state(name, on_enter)
26
26
  name = name.to_sym
27
- returning(Lifecycles::State.new(name, on_enter)) do |s|
28
- states[name] = s
29
- class_eval "def #{name}_state?; state_name == :#{name} end"
30
- end
27
+ class_eval "def #{name}_state?; state_name == :#{name} end"
28
+ states[name] = Lifecycles::State.new(name, on_enter)
31
29
  end
32
30
 
33
31
 
34
32
  def self.def_creator(name, on_create, options)
35
- name = name.to_sym
36
- returning(Creator.new(self, name, on_create, options)) do |creator|
37
-
38
- class_eval %{
39
- def self.#{name}(user, attributes=nil)
40
- create(:#{name}, user, attributes)
41
- end
42
- def self.can_#{name}?(user, attributes=nil)
43
- can_create?(:#{name}, user)
44
- end
45
- }
46
-
47
- end
33
+ class_eval %{
34
+ def self.#{name}(user, attributes=nil)
35
+ create(:#{name}, user, attributes)
36
+ end
37
+ def self.can_#{name}?(user, attributes=nil)
38
+ can_create?(:#{name}, user)
39
+ end
40
+ }
41
+ Creator.new(self, name.to_s, on_create, options)
48
42
  end
49
43
 
50
44
  def self.def_transition(name, start_state, end_states, on_transition, options)
51
- returning(Transition.new(self, name.to_s, start_state, end_states, on_transition, options)) do |t|
52
-
53
- class_eval %{
54
- def #{name}!(user, attributes=nil)
55
- transition(:#{name}, user, attributes)
56
- end
57
- def can_#{name}?(user, attributes=nil)
58
- can_transition?(:#{name}, user)
59
- end
60
- def valid_for_#{name}?
61
- valid_for_transition?(:#{name})
62
- end
63
- }
64
-
65
- end
45
+ class_eval %{
46
+ def #{name}!(user, attributes=nil)
47
+ transition(:#{name}, user, attributes)
48
+ end
49
+ def can_#{name}?(user, attributes=nil)
50
+ can_transition?(:#{name}, user)
51
+ end
52
+ def valid_for_#{name}?
53
+ valid_for_transition?(:#{name})
54
+ end
55
+ }
56
+ Transition.new(self, name.to_s, start_state, end_states, on_transition, options)
66
57
  end
67
58
 
68
59
  def self.state_names
@@ -14,8 +14,6 @@ module Hobo
14
14
 
15
15
  register_model(base)
16
16
 
17
- patch_will_paginate
18
-
19
17
  base.class_eval do
20
18
  inheriting_cattr_reader :default_order
21
19
  alias_method_chain :attributes=, :hobo_type_conversion
@@ -42,7 +40,9 @@ module Hobo
42
40
  end
43
41
  end
44
42
  end
45
-
43
+
44
+ # https://hobo.lighthouseapp.com/projects/8324/tickets/762-hobo_model-outside-a-full-rails-env-can-lead-to-stack-level-too-deep
45
+ raise HoboError, "HoboFields.enable has not been called" unless base.respond_to?(:fields)
46
46
  base.fields(false) # force hobofields to load
47
47
 
48
48
  included_in_class_callbacks(base)
@@ -57,11 +57,11 @@ module Hobo
57
57
 
58
58
  WillPaginate::Finder::ClassMethods.class_eval do
59
59
  def paginate_with_hobo_metadata(*args, &block)
60
- returning paginate_without_hobo_metadata(*args, &block) do |collection|
61
- collection.member_class = self
62
- collection.origin = try.proxy_owner
63
- collection.origin_attribute = try.proxy_reflection._?.name
64
- end
60
+ collection = paginate_without_hobo_metadata(*args, &block)
61
+ collection.member_class = self
62
+ collection.origin = try.proxy_owner
63
+ collection.origin_attribute = try.proxy_reflection._?.name
64
+ collection
65
65
  end
66
66
  alias_method_chain :paginate, :hobo_metadata
67
67
 
@@ -78,7 +78,7 @@ module Hobo
78
78
 
79
79
 
80
80
  def self.all_models
81
- # Load every controller in app/controllers...
81
+ # Load every model in app/models...
82
82
  unless @models_loaded
83
83
  Dir.entries("#{RAILS_ROOT}/app/models/").each do |f|
84
84
  f =~ /^[a-zA-Z_][a-zA-Z0-9_]*\.rb$/ and f.sub(/.rb$/, '').camelize.constantize
@@ -132,6 +132,8 @@ module Hobo
132
132
 
133
133
  Hobo::Permissions.enable
134
134
  end
135
+
136
+ patch_will_paginate
135
137
  end
136
138
 
137
139
 
@@ -268,7 +268,7 @@ module Hobo
268
268
  type = klass.attr_type(field)
269
269
  if type.nil? #a virtual attribute from an SQL alias, e.g., 'total' from 'COUNT(*) AS total'
270
270
  colspec = "#{field}" # don't prepend the table name
271
- elsif type.respond_to?(:table_name) && (name = type.name_attribute)
271
+ elsif type.respond_to?(:name_attribute) && (name = type.name_attribute)
272
272
  include = field
273
273
  colspec = "#{type.table_name}.#{name}"
274
274
  else
@@ -13,7 +13,7 @@ module ActiveRecord
13
13
  private
14
14
 
15
15
  def method_missing(method, *args, &block)
16
- if respond_to?(method) && scopes.include?(method)
16
+ if scopes.include?(method)
17
17
  scopes[method].call(self, *args)
18
18
  else
19
19
  with_scope :find => proxy_options do
@@ -13,8 +13,8 @@ module Hobo
13
13
  end
14
14
 
15
15
  filter_parameter_logging "password"
16
- skip_before_filter :login_required, :only => [:login, :signup, :forgot_password, :reset_password, :do_reset_password,
17
- :accept_invitation, :do_accept_invitation]
16
+ skip_before_filter :login_required, :only => [:login, :signup, :do_signup, :forgot_password, :reset_password,
17
+ :do_reset_password, :accept_invitation, :do_accept_invitation]
18
18
 
19
19
  include_taglib "rapid_user_pages", :plugin => "hobo"
20
20
 
@@ -3,7 +3,11 @@ module Hobo
3
3
  class ViewHints
4
4
 
5
5
  def self.enable
6
- ActiveSupport::Dependencies.load_paths |= ["#{RAILS_ROOT}/app/viewhints"]
6
+ if ActiveSupport::Dependencies.respond_to?(:autoload_paths)
7
+ ActiveSupport::Dependencies.autoload_paths |= [ "#{RAILS_ROOT}/app/viewhints" ]
8
+ else
9
+ ActiveSupport::Dependencies.load_paths |= [ "#{RAILS_ROOT}/app/viewhints" ]
10
+ end
7
11
  end
8
12
 
9
13
  def self.setter(name, default=nil, &block)
@@ -1,4 +1,3 @@
1
- <!-- Core Rapid tags and tags that don't belong anywhere else. -->
2
1
 
3
2
  <!-- Renders a table with one row per field, where each row contains a `<th>` with the field name, and a `<td>` with (by default)
4
3
  a `<view>` of the field.
@@ -415,7 +414,7 @@ Assuming the context is a blog post...
415
414
  <view:created_at no-wrapper/> -> June 09, 2008 15:36
416
415
  -->
417
416
  <def tag="view" attrs="inline, block, if-blank, no-wrapper, truncate"><%=
418
- raise HoboError, "view of non-viewable field '#{this_field}' of #{this_parent.typed_id rescue this_parent}" unless
417
+ raise Hobo::PermissionDeniedError, "view of non-viewable field '#{this_field}' of #{this_parent.typed_id rescue this_parent}" unless
419
418
  can_view?
420
419
 
421
420
  res = if this.nil? && if_blank.nil?
@@ -102,8 +102,6 @@ AJAX based submission can be enabled by simply adding an `update` attribute. e.g
102
102
  <div part="comments"><collection:comments/></div>
103
103
  <form with="&Comment.new" update="comments"/>
104
104
 
105
- `<form>` support all of the standard ajax attributes.
106
-
107
105
  ### Additional Notes
108
106
 
109
107
  - Hobo automatically inserts an `auth_token` hidden field if forgery protection is enabled
@@ -112,6 +110,19 @@ AJAX based submission can be enabled by simply adding an `update` attribute. e.g
112
110
  validation error occurs.
113
111
 
114
112
  - `<form>` supports all of the standrd ajax attributes - (see the main taglib docs for Rapid Forms)
113
+
114
+ - `<form>` resets `last_if` if it does not have permission to display the form. The `<else>` clause may be used to display alternate content. For example:
115
+
116
+ <form>...</form>
117
+ <else>You do not have permission to edit this form</else>
118
+
119
+ or on a standard generated page using a default form:
120
+
121
+ <some-page>
122
+ <after-form:>
123
+ <else>You do not have permission to edit this form</else>
124
+ </after-form:>
125
+ </some-page>
115
126
 
116
127
  ### Attributes
117
128
 
@@ -640,7 +651,7 @@ For situations where there are too many target records to practically include in
640
651
 
641
652
  -->
642
653
  <def tag="select-one" attrs="include-none, blank-message, options, sort, limit, text-method"><%
643
- raise HoboError.new("Not allowed to edit #{this_field}") if !attributes[:disabled] && !can_edit?
654
+ raise Hobo::PermissionDeniedError.new("Not allowed to edit #{this_field}") if !attributes[:disabled] && !can_edit?
644
655
 
645
656
  blank_message ||= ht("#{this_type.name.underscore}.message.no", :default=>"(No #{this_type.view_hints.model_name})")
646
657
  limit ||= 100
@@ -1008,8 +1019,8 @@ end
1008
1019
  <input type="hidden" class="empty-input" id="#{underize param_name_for_this}" name="#{param_name_for_this}" value="" disabled="&(!this.empty? || minimum>0)" />
1009
1020
  <fake-field-context fake-field="-1" context="&template">
1010
1021
  <div param="empty-message">
1011
- <ht key="#{this.class.class_name.tableize}.collection.empty_message">
1012
- No <%= this.class.class_name.titleize.downcase.pluralize %>.
1022
+ <ht key="#{this.class.name.tableize}.collection.empty_message">
1023
+ No <%= this.class.name.titleize.downcase.pluralize %>.
1013
1024
  </ht>
1014
1025
  </div>
1015
1026
  <div class="buttons">
@@ -21,6 +21,15 @@ An [worked example](/tutorials/agility#improve_the_project_page_with_a_searchabl
21
21
  </form>
22
22
  </div>
23
23
  </div>
24
+ <%
25
+ page_path = if (request.post? || request.put?) && params[:page_path]
26
+ params[:page_path]
27
+ else
28
+ view_name.sub(Dryml::EMPTY_PAGE, params[:action] || '')
29
+ end
30
+ controller, action = page_path.split('/')
31
+ %>
32
+
24
33
 
25
34
  <table merge-attrs="&attributes & (attrs_for(:table) + attrs_for(:with_fields))" empty merge-params>
26
35
  <field-heading-row:>
@@ -28,7 +37,7 @@ An [worked example](/tutorials/agility#improve_the_project_page_with_a_searchabl
28
37
  <% col = sort_columns[scope.field_path] || scope.field_path
29
38
  sort = sort_field == col && sort_direction == 'asc' ?
30
39
  "-#{col}" : col
31
- sort_url = url_for(params.merge(:sort => sort) - [:page])
40
+ sort_url = url_for(params.merge(:sort => sort, :controller => controller, :action => action) - [:page])
32
41
  col_heading_name = this.member_class.try.view_hints.try.field_name(scope.field_name) || scope.field_name.titleize %>
33
42
 
34
43
  <th param="#{scope.field-name}-heading">
@@ -46,7 +55,7 @@ An [worked example](/tutorials/agility#improve_the_project_page_with_a_searchabl
46
55
  <do param="empty-message" if="empty?"><ht key="hobo.table_plus.empty" model="#{name.downcase}">No <collection-name lowercase/> to display</ht></do>
47
56
 
48
57
 
49
- <page-nav param if="&this.respond_to?(:page_count) || this.respond_to?(:total_pages)"/>
58
+ <page-nav param params="&{:action=>action, :controller=>controller}" if="&this.respond_to?(:page_count) || this.respond_to?(:total_pages)"/>
50
59
  </div>
51
60
  </def>
52
61
 
@@ -281,7 +281,7 @@
281
281
  <!-- given a column in the context and the model as an attribute, returns the comment for the column. It returns the SQL comment if that is available (using the activerecord-comments plugin). If that is not available, it returns the HoboFields comment. -->
282
282
 
283
283
  <def tag="model-column-comment" attrs="model">
284
- <%= this.try.comment || model.try.field_specs.try.get(this.name).try.comment -%>
284
+ <%= this.try.comment || model.try.field_specs.try.get(this.name).try.first.try.comment -%>
285
285
  </def>
286
286
 
287
287
  <!-- given a model, repeats on the associations -->
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hobo
3
3
  version: !ruby/object:Gem::Version
4
- hash: -1876988165
4
+ hash: -1876988167
5
5
  prerelease: true
6
6
  segments:
7
7
  - 1
8
8
  - 1
9
9
  - 0
10
- - pre0
11
- version: 1.1.0.pre0
10
+ - pre2
11
+ version: 1.1.0.pre2
12
12
  platform: ruby
13
13
  authors:
14
14
  - Tom Locke
@@ -33,6 +33,14 @@ dependencies:
33
33
  - 2
34
34
  - 2
35
35
  version: 2.2.2
36
+ - - <
37
+ - !ruby/object:Gem::Version
38
+ hash: 7
39
+ segments:
40
+ - 3
41
+ - 0
42
+ - 0
43
+ version: 3.0.0
36
44
  type: :runtime
37
45
  version_requirements: *id001
38
46
  - !ruby/object:Gem::Dependency
@@ -49,6 +57,12 @@ dependencies:
49
57
  - 3
50
58
  - 11
51
59
  version: 2.3.11
60
+ - - ~>
61
+ - !ruby/object:Gem::Version
62
+ hash: 7
63
+ segments:
64
+ - 2
65
+ version: "2"
52
66
  type: :runtime
53
67
  version_requirements: *id002
54
68
  - !ruby/object:Gem::Dependency
@@ -59,13 +73,13 @@ dependencies:
59
73
  requirements:
60
74
  - - "="
61
75
  - !ruby/object:Gem::Version
62
- hash: -1876988165
76
+ hash: -1876988167
63
77
  segments:
64
78
  - 1
65
79
  - 1
66
80
  - 0
67
- - pre0
68
- version: 1.1.0.pre0
81
+ - pre2
82
+ version: 1.1.0.pre2
69
83
  type: :runtime
70
84
  version_requirements: *id003
71
85
  - !ruby/object:Gem::Dependency
@@ -76,13 +90,13 @@ dependencies:
76
90
  requirements:
77
91
  - - "="
78
92
  - !ruby/object:Gem::Version
79
- hash: -1876988165
93
+ hash: -1876988167
80
94
  segments:
81
95
  - 1
82
96
  - 1
83
97
  - 0
84
- - pre0
85
- version: 1.1.0.pre0
98
+ - pre2
99
+ version: 1.1.0.pre2
86
100
  type: :runtime
87
101
  version_requirements: *id004
88
102
  - !ruby/object:Gem::Dependency
@@ -93,13 +107,13 @@ dependencies:
93
107
  requirements:
94
108
  - - "="
95
109
  - !ruby/object:Gem::Version
96
- hash: -1876988165
110
+ hash: -1876988167
97
111
  segments:
98
112
  - 1
99
113
  - 1
100
114
  - 0
101
- - pre0
102
- version: 1.1.0.pre0
115
+ - pre2
116
+ version: 1.1.0.pre2
103
117
  type: :runtime
104
118
  version_requirements: *id005
105
119
  description: