fusionary-easel_helpers 0.2.11 → 0.2.12

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -3,7 +3,7 @@ require 'rake/testtask'
3
3
  require 'rake/rdoctask'
4
4
  require 'echoe'
5
5
 
6
- Echoe.new("easel_helpers", "0.2.11") do |p|
6
+ Echoe.new("easel_helpers", "0.2.12") do |p|
7
7
  p.description = "Fusionary Rails View Helpers"
8
8
  p.url = "http://github.com/fusionary/easel_helpers"
9
9
  p.author = "Joshua Clayton"
@@ -2,11 +2,11 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{easel_helpers}
5
- s.version = "0.2.11"
5
+ s.version = "0.2.12"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["Joshua Clayton"]
9
- s.date = %q{2009-06-23}
9
+ s.date = %q{2009-06-28}
10
10
  s.description = %q{Fusionary Rails View Helpers}
11
11
  s.email = %q{joshua.clayton@gmail.com}
12
12
  s.extra_rdoc_files = ["lib/easel_helpers/helpers/date_helper.rb", "lib/easel_helpers/helpers/form_helper.rb", "lib/easel_helpers/helpers/grid_helper.rb", "lib/easel_helpers/helpers/jquery_helper.rb", "lib/easel_helpers/helpers/link_helper.rb", "lib/easel_helpers/helpers/message_helper.rb", "lib/easel_helpers/helpers/rjs_helper.rb", "lib/easel_helpers/helpers/structure_helper.rb", "lib/easel_helpers/helpers/table_helper.rb", "lib/easel_helpers/helpers.rb", "lib/easel_helpers/rails_partial_caching.rb", "lib/easel_helpers.rb", "README.textile", "tasks/easel_helpers_tasks.rake"]
@@ -30,8 +30,20 @@ module EaselHelpers
30
30
  }.freeze
31
31
  MULTIPLE_FRACTIONS = MULTIPLES.keys.map {|key| key.to_s }.freeze
32
32
 
33
+ def self.easel_grid!
34
+ @@last_column = "col-last"
35
+ @@column_prefix = "col"
36
+ end
37
+
38
+ def self.blueprint_grid!
39
+ @@last_column = "last"
40
+ @@column_prefix = "span"
41
+ end
42
+
43
+ easel_grid!
44
+
33
45
  def last_column
34
- "col-last"
46
+ @@last_column
35
47
  end
36
48
 
37
49
  def column(*args, &block)
@@ -45,7 +57,7 @@ module EaselHelpers
45
57
  end
46
58
 
47
59
  def clean_column(classes, &block)
48
- size = classes.scan(/col-(\d+)/).flatten.last
60
+ size = classes.scan(/#{column_prefix}-(\d+)/).flatten.last
49
61
 
50
62
  if size.nil?
51
63
  html = capture(&block)
@@ -79,8 +91,8 @@ module EaselHelpers
79
91
  method_missing_without_easel_widths(call, *args) and return unless found
80
92
 
81
93
  # one of the widths is somewhere in the helper call; let's find it
82
- call.to_s =~ /^((append|prepend|col)_)?(.+)$/
83
- class_name = $2 || "col"
94
+ call.to_s =~ /^((append|prepend|#{column_prefix})_)?(.+)$/
95
+ class_name = $2 || column_prefix
84
96
  class_width = $3
85
97
 
86
98
  if MULTIPLES.keys.include?(class_width.to_sym)
@@ -143,7 +155,7 @@ module EaselHelpers
143
155
 
144
156
  css_classes = [] << options.delete(:class) << args
145
157
  unless options.delete(:suppress_col)
146
- css_classes << "col-#{@_easel_column_count}"
158
+ css_classes << "#{column_prefix}-#{@_easel_column_count}"
147
159
  end
148
160
 
149
161
  if size.to_sym == :full && @_easel_column_count != application_width
@@ -151,11 +163,14 @@ module EaselHelpers
151
163
  end
152
164
 
153
165
  css_classes = clean_css_classes(css_classes, {"last" => last_column})
154
- content_tag(:div,
166
+ content_tag(options[:tag] || :div,
155
167
  capture(&block),
156
168
  {:class => css_classes}.merge(options))
157
169
  end
158
170
 
171
+ def column_prefix
172
+ @@column_prefix
173
+ end
159
174
  end
160
175
  end
161
176
  end
@@ -1,9 +1,9 @@
1
1
  require 'test_helper'
2
2
 
3
3
  class GridHelperTest < EaselHelpers::ViewTestCase
4
-
4
+
5
5
  context "advanced grid structures" do
6
-
6
+
7
7
  should "properly assign classes for a simple column layout" do
8
8
  template = %(
9
9
  <% container do %>
@@ -26,7 +26,7 @@ class GridHelperTest < EaselHelpers::ViewTestCase
26
26
  <% end %>
27
27
  <% end %>
28
28
  )
29
-
29
+
30
30
  show_view template do
31
31
  assert_select ".container", 1
32
32
  assert_select ".col-24", 1
@@ -41,7 +41,7 @@ class GridHelperTest < EaselHelpers::ViewTestCase
41
41
  assert_select "hr", 2
42
42
  end
43
43
  end
44
-
44
+
45
45
  should "properly assign classes for generic helpers" do
46
46
  template = %(
47
47
  <% column do %>
@@ -52,7 +52,7 @@ class GridHelperTest < EaselHelpers::ViewTestCase
52
52
  <% recordset :half, :last do %>table<% end %>
53
53
  <% end %>
54
54
  )
55
-
55
+
56
56
  show_view template do
57
57
  assert_select "div.col-24" do
58
58
  assert_select "fieldset.hform.col-12" do
@@ -63,7 +63,7 @@ class GridHelperTest < EaselHelpers::ViewTestCase
63
63
  end
64
64
  end
65
65
  end
66
-
66
+
67
67
  should "properly assign classes for generic helpers without column wrappers" do
68
68
  template = %(
69
69
  <% fieldset :hform, :half do %>
@@ -84,12 +84,12 @@ class GridHelperTest < EaselHelpers::ViewTestCase
84
84
  <% end %>
85
85
  <% recordset :one_sixth, :last do %>table<% end %>
86
86
  )
87
-
87
+
88
88
  show_view template do
89
89
  assert_select "fieldset.hform.col-12" do
90
90
  assert_select "div.col-4", "text"
91
91
  assert_select "div.col-8.col-last", "more text"
92
-
92
+
93
93
  assert_select "div.col-12.col-last" do
94
94
  assert_select "div.col-4", "one third"
95
95
  assert_select "div.col-8.col-last" do
@@ -106,7 +106,7 @@ class GridHelperTest < EaselHelpers::ViewTestCase
106
106
  assert_select "table.col-4.col-last", "table"
107
107
  end
108
108
  end
109
-
109
+
110
110
  should "properly assign classes for a deeply-nested view" do
111
111
  template = %(
112
112
  <% container do %>
@@ -125,7 +125,7 @@ class GridHelperTest < EaselHelpers::ViewTestCase
125
125
  <% end %>
126
126
  <% end %>
127
127
  )
128
-
128
+
129
129
  show_view template do
130
130
  assert_select "div.container" do
131
131
  assert_select "div.col-12" do
@@ -135,9 +135,9 @@ class GridHelperTest < EaselHelpers::ViewTestCase
135
135
  end
136
136
  assert_select "table.col-6.col-last", "table"
137
137
  end
138
-
138
+
139
139
  assert_select "div.col-8", "one third!"
140
-
140
+
141
141
  assert_select "div.col-4.col-last" do
142
142
  assert_select "fieldset.vform.col-4.col-last" do
143
143
  assert_select "div", "text"
@@ -146,17 +146,55 @@ class GridHelperTest < EaselHelpers::ViewTestCase
146
146
  end
147
147
  end
148
148
  end
149
-
149
+
150
+ should "properly assign classes when using Blueprint grid" do
151
+ template = %(
152
+ <% container do %>
153
+ <% column do %>
154
+ <% column :half, :id => "primary" do %>
155
+ <% column :one_third do %>
156
+ one third of one half of 24 is 4
157
+ <% end %>
158
+ <% column :one_third, :last, prepend_one_third do %>
159
+ one third of one half of 24 is 4 (but prepended 4 as well)
160
+ <% end %>
161
+ <hr/>
162
+ more text
163
+ <% end %>
164
+ <% column :half, :last, :id => "secondary" do %>
165
+ second column
166
+ <% end %>
167
+ <hr/>
168
+ text
169
+ <% end %>
170
+ <% end %>
171
+ )
172
+ EaselHelpers::Helpers::GridHelper.blueprint_grid!
173
+ show_view template do
174
+ assert_select ".container", 1
175
+ assert_select ".span-24", 1
176
+ assert_select ".span-12", 2
177
+ assert_select ".span-12#primary", 1
178
+ assert_select ".span-12#secondary", 1
179
+ assert_select ".span-4", 2
180
+ assert_select ".prepend-4", 1
181
+ assert_select ".span-24.last", 0
182
+ assert_select ".span-12.last", 1
183
+ assert_select ".span-4.last", 1
184
+ assert_select "hr", 2
185
+ end
186
+ EaselHelpers::Helpers::GridHelper.easel_grid!
187
+ end
150
188
  end
151
-
189
+
152
190
  context "column" do
153
-
191
+
154
192
  should "allow assigning options hash without having to define a width" do
155
193
  show_view %(<% column :id => "my-custom-id", :class => "content" do %>words<% end %>) do
156
194
  assert_select "div.col-24.content#my-custom-id", "words"
157
195
  end
158
196
  end
159
-
197
+
160
198
  should "allow explicit column assignment" do
161
199
  show_view %(
162
200
  <% column 6, :sidebar do %>
@@ -174,6 +212,11 @@ class GridHelperTest < EaselHelpers::ViewTestCase
174
212
  end
175
213
  end
176
214
  end
177
-
215
+
216
+ should "allow tag overriding" do
217
+ show_view %(<% column :tag => :section do %>content<% end %>) do
218
+ assert_select "section.col-24", "content"
219
+ end
220
+ end
178
221
  end
179
- end
222
+ end
@@ -1,15 +1,15 @@
1
1
  require 'test_helper'
2
2
 
3
3
  class StructureHelperTest < EaselHelpers::ViewTestCase
4
-
4
+
5
5
  context "blockquote" do
6
-
6
+
7
7
  should "default with the correct structure" do
8
8
  show_view "<% blockquote do %>My quoted text<% end %>" do
9
9
  assert_select "blockquote", "My quoted text"
10
10
  end
11
11
  end
12
-
12
+
13
13
  should "default with the correct structure when an author is set" do
14
14
  show_view "<% blockquote :author => 'W. Shakespeare' do %>All the world's a stage<% end %>" do
15
15
  assert_select "div.quote-cited" do
@@ -18,11 +18,11 @@ class StructureHelperTest < EaselHelpers::ViewTestCase
18
18
  end
19
19
  end
20
20
  end
21
-
21
+
22
22
  end
23
-
23
+
24
24
  context "body" do
25
-
25
+
26
26
  should "allow passing a block structure" do
27
27
  show_view %(
28
28
  <% body do %>body goes here<% end %>
@@ -30,7 +30,7 @@ class StructureHelperTest < EaselHelpers::ViewTestCase
30
30
  assert_select "body", "body goes here"
31
31
  end
32
32
  end
33
-
33
+
34
34
  should "allow passing arguments" do
35
35
  show_view %(
36
36
  <% body :home, 'home-index', 'logged-in', :id => 'application' do %>body goes here<% end %>
@@ -38,7 +38,7 @@ class StructureHelperTest < EaselHelpers::ViewTestCase
38
38
  assert_select "body#application.home.home-index.logged-in", "body goes here"
39
39
  end
40
40
  end
41
-
41
+
42
42
  should "allow multiple body definitions that set attributes" do
43
43
  show_view %(
44
44
  <% body :home, 'logged-in' %>
@@ -48,7 +48,7 @@ class StructureHelperTest < EaselHelpers::ViewTestCase
48
48
  assert_select "body#application-override.home.home-index.logged-in", "body goes here"
49
49
  end
50
50
  end
51
-
51
+
52
52
  end
53
-
54
- end
53
+
54
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fusionary-easel_helpers
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.11
4
+ version: 0.2.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joshua Clayton
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-06-23 00:00:00 -07:00
12
+ date: 2009-06-28 00:00:00 -07:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency