meta_search 0.9.4 → 0.9.5

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG CHANGED
@@ -1,3 +1,8 @@
1
+ Changes since 0.9.4 (2010-09-18):
2
+ * Rename check_boxes and collection_check_boxes to checks and
3
+ collection_checks. Alias to the old names if not already taken. This
4
+ is to avoid conflicts with SimpleForm.
5
+
1
6
  Changes since 0.9.3 (2010-09-08):
2
7
  * Minor documentation fixes.
3
8
  * Add sort_link helper to FormBuilder, to spare keystrokes if sort_links
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.9.4
1
+ 0.9.5
@@ -6,6 +6,14 @@ module MetaSearch
6
6
  module Helpers
7
7
  module FormBuilder
8
8
 
9
+ def self.included(base)
10
+ # Only take on the check_boxes method names if someone else (Hi, José!) hasn't grabbed them.
11
+ base.class_eval do
12
+ alias_method :check_boxes, :checks unless method_defined?(:check_boxes)
13
+ alias_method :collection_check_boxes, :collection_checks unless method_defined?(:collection_check_boxes)
14
+ end
15
+ end
16
+
9
17
  # Like other form_for field methods (text_field, hidden_field, password_field) etc,
10
18
  # but takes a list of hashes between the +method+ parameter and the trailing option hash,
11
19
  # if any, to specify a number of fields to create in multiparameter fashion.
@@ -70,7 +78,7 @@ module MetaSearch
70
78
  #
71
79
  # <h4>How many heads?</h4>
72
80
  # <ul>
73
- # <% f.check_boxes :number_of_heads_in,
81
+ # <% f.checks :number_of_heads_in,
74
82
  # [['One', 1], ['Two', 2], ['Three', 3]], :class => 'checkboxy' do |check| %>
75
83
  # <li>
76
84
  # <%= check.box %>
@@ -83,10 +91,10 @@ module MetaSearch
83
91
  #
84
92
  # <b>Grouping:</b>
85
93
  #
86
- # Chain <tt>in_groups_of(<num>, false)</tt> on check_boxes like so:
94
+ # Chain <tt>in_groups_of(<num>, false)</tt> on checks like so:
87
95
  # <h4>How many heads?</h4>
88
96
  # <p>
89
- # <% f.check_boxes(:number_of_heads_in,
97
+ # <% f.checks(:number_of_heads_in,
90
98
  # [['One', 1], ['Two', 2], ['Three', 3]],
91
99
  # :class => 'checkboxy').in_groups_of(2, false) do |checks| %>
92
100
  # <% checks.each do |check| %>
@@ -96,23 +104,23 @@ module MetaSearch
96
104
  # <br />
97
105
  # <% end %>
98
106
  # </p>
99
- def check_boxes(method, choices = [], options = {}, &block)
107
+ def checks(method, choices = [], options = {}, &block)
100
108
  unless choices.first.respond_to?(:first) && choices.first.respond_to?(:last)
101
109
  raise ArgumentError, 'invalid choice array specified'
102
110
  end
103
- collection_check_boxes(method, choices, :last, :first, options, &block)
111
+ collection_checks(method, choices, :last, :first, options, &block)
104
112
  end
105
113
 
106
- # Just like +check_boxes+, but this time you can pass in a collection, value, and text method,
114
+ # Just like +checks+, but this time you can pass in a collection, value, and text method,
107
115
  # as with collection_select.
108
116
  #
109
117
  # Example:
110
118
  #
111
- # <% f.collection_check_boxes :head_sizes_in, HeadSize.all,
119
+ # <% f.collection_checks :head_sizes_in, HeadSize.all,
112
120
  # :id, :name, :class => 'headcheck' do |check| %>
113
121
  # <%= check.box %> <%= check.label %>
114
122
  # <% end %>
115
- def collection_check_boxes(method, collection, value_method, text_method, options = {}, &block)
123
+ def collection_checks(method, collection, value_method, text_method, options = {}, &block)
116
124
  check_boxes = []
117
125
  collection.each do |choice|
118
126
  text = choice.send(text_method)
data/meta_search.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{meta_search}
8
- s.version = "0.9.4"
8
+ s.version = "0.9.5"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Ernie Miller"]
12
- s.date = %q{2010-09-18}
12
+ s.date = %q{2010-09-28}
13
13
  s.description = %q{
14
14
  Allows simple search forms to be created against an AR3 model
15
15
  and its associations, has useful view helpers for sort links
@@ -75,7 +75,7 @@ class TestViewHelpers < ActionView::TestCase
75
75
  end
76
76
  end
77
77
 
78
- context "A form using check_boxes with three choices" do
78
+ context "A form using checks with three choices" do
79
79
  setup do
80
80
  @s = Company.search
81
81
  form_for @s do |f|
@@ -84,7 +84,7 @@ class TestViewHelpers < ActionView::TestCase
84
84
  end
85
85
 
86
86
  should "return an array of check boxes without a block" do
87
- assert @f.check_boxes(:id_in, [['One', 1], ['Two', 2], ['Three', 3]]).all?{|c| c.is_a?(MetaSearch::Check)}
87
+ assert @f.checks(:id_in, [['One', 1], ['Two', 2], ['Three', 3]]).all?{|c| c.is_a?(MetaSearch::Check)}
88
88
  end
89
89
 
90
90
  should "generate the expected HTML with a block" do
@@ -104,7 +104,7 @@ class TestViewHelpers < ActionView::TestCase
104
104
  EXPECTED
105
105
  assert_dom_equal expected,
106
106
  render(:to => :string, :inline => <<-ERB)
107
- <%= @f.check_boxes(:id_in, [['One', 1], ['Two', 2], ['Three', 3]]) do |c| -%>
107
+ <%= @f.checks(:id_in, [['One', 1], ['Two', 2], ['Three', 3]]) do |c| -%>
108
108
  <p>
109
109
  <%= c.label %>
110
110
  <%= c.box %>
@@ -114,7 +114,7 @@ class TestViewHelpers < ActionView::TestCase
114
114
  end
115
115
  end
116
116
 
117
- context "A form using check_boxes with three choices and a previous selection" do
117
+ context "A form using checks with three choices and a previous selection" do
118
118
  setup do
119
119
  @s = Company.search
120
120
  @s.id_in = [1, 3]
@@ -124,7 +124,7 @@ class TestViewHelpers < ActionView::TestCase
124
124
  end
125
125
 
126
126
  should "return an array of check boxes without a block" do
127
- assert @f.check_boxes(:id_in, [['One', 1], ['Two', 2], ['Three', 3]]).all?{|c| c.is_a?(MetaSearch::Check)}
127
+ assert @f.checks(:id_in, [['One', 1], ['Two', 2], ['Three', 3]]).all?{|c| c.is_a?(MetaSearch::Check)}
128
128
  end
129
129
 
130
130
  should "generate the expected HTML with a block" do
@@ -144,7 +144,7 @@ class TestViewHelpers < ActionView::TestCase
144
144
  EXPECTED
145
145
  assert_dom_equal expected,
146
146
  render(:to => :string, :inline => <<-ERB)
147
- <%= @f.check_boxes(:id_in, [['One', 1], ['Two', 2], ['Three', 3]]) do |c| -%>
147
+ <%= @f.checks(:id_in, [['One', 1], ['Two', 2], ['Three', 3]]) do |c| -%>
148
148
  <p>
149
149
  <%= c.label %>
150
150
  <%= c.box %>
@@ -154,7 +154,7 @@ class TestViewHelpers < ActionView::TestCase
154
154
  end
155
155
  end
156
156
 
157
- context "A form using collection_check_boxes with companies" do
157
+ context "A form using collection_checks with companies" do
158
158
  setup do
159
159
  @s = Company.search
160
160
  form_for @s do |f|
@@ -163,11 +163,11 @@ class TestViewHelpers < ActionView::TestCase
163
163
  end
164
164
 
165
165
  should "return an array of check boxes without a block" do
166
- assert @f.collection_check_boxes(:id_in, Company.all, :id, :name).all?{|c| c.is_a?(MetaSearch::Check)}
166
+ assert @f.collection_checks(:id_in, Company.all, :id, :name).all?{|c| c.is_a?(MetaSearch::Check)}
167
167
  end
168
168
 
169
169
  should "generate the expected HTML with a block" do
170
- @f.collection_check_boxes(:id_in, Company.all, :id, :name) do |c|
170
+ @f.collection_checks(:id_in, Company.all, :id, :name) do |c|
171
171
  concat render :to => :string, :inline => "<p><%= c.label %> <%= c.box %></p>", :locals => {:c => c}
172
172
  end
173
173
  assert_dom_equal output_buffer,
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 9
8
- - 4
9
- version: 0.9.4
8
+ - 5
9
+ version: 0.9.5
10
10
  platform: ruby
11
11
  authors:
12
12
  - Ernie Miller
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-09-18 00:00:00 -04:00
17
+ date: 2010-09-28 00:00:00 -04:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency