fusionary-easel_helpers 0.1.5 → 0.1.6
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.
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.1.
|
6
|
+
Echoe.new("easel_helpers", "0.1.6") 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"
|
@@ -12,9 +12,6 @@ Echoe.new("easel_helpers", "0.1.5") do |p|
|
|
12
12
|
p.development_dependencies = ["actionview >= 2.1.0", "activesupport >= 2.1.0", "hpricot >= 0.8.1"]
|
13
13
|
end
|
14
14
|
|
15
|
-
desc 'Default: run unit tests.'
|
16
|
-
task :default => :test
|
17
|
-
|
18
15
|
desc 'Test the easel_helpers plugin.'
|
19
16
|
Rake::TestTask.new(:test) do |t|
|
20
17
|
t.libs << 'lib'
|
data/easel_helpers.gemspec
CHANGED
@@ -2,15 +2,15 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = %q{easel_helpers}
|
5
|
-
s.version = "0.1.
|
5
|
+
s.version = "0.1.6"
|
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-05-
|
9
|
+
s.date = %q{2009-05-07}
|
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/link_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"]
|
13
|
-
s.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/link_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", "Manifest", "MIT-LICENSE", "rails/init.rb", "Rakefile", "README.textile", "tasks/easel_helpers_tasks.rake", "
|
13
|
+
s.files = ["easel_helpers.gemspec", "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/link_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", "Manifest", "MIT-LICENSE", "rails/init.rb", "Rakefile", "README.textile", "tasks/easel_helpers_tasks.rake", "test/date_helper_test.rb", "test/form_helper_test.rb", "test/grid_helper_test.rb", "test/link_helper_test.rb", "test/structure_helper_test.rb", "test/table_helper_test.rb", "test/test_helper.rb"]
|
14
14
|
s.has_rdoc = true
|
15
15
|
s.homepage = %q{http://github.com/fusionary/easel_helpers}
|
16
16
|
s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Easel_helpers", "--main", "README.textile"]
|
@@ -11,9 +11,14 @@ module EaselHelpers
|
|
11
11
|
def set(*args, &block)
|
12
12
|
options = args.extract_options!
|
13
13
|
css_classes = [] << options.delete(:class) << args
|
14
|
-
css_classes << "text" unless other_than_grid?(args - ["last", last_column])
|
14
|
+
css_classes << "text" unless other_than_grid?(args.map(&:to_s) - ["last", last_column.to_s])
|
15
|
+
|
16
|
+
css_classes = clean_css_classes(css_classes, {"last" => last_column})
|
17
|
+
|
18
|
+
html = clean_column css_classes do
|
19
|
+
content_tag(:div, capture(&block), options.merge(:class => css_classes))
|
20
|
+
end
|
15
21
|
|
16
|
-
html = content_tag(:div, capture(&block), options.merge(:class => clean_css_classes(css_classes, {"last" => last_column})))
|
17
22
|
concat(html)
|
18
23
|
end
|
19
24
|
|
@@ -30,7 +35,12 @@ module EaselHelpers
|
|
30
35
|
{:class => clean_css_classes([options[:legend].delete(:class)] << "legend")}.merge(options[:legend]))
|
31
36
|
end
|
32
37
|
|
33
|
-
|
38
|
+
css_classes = clean_css_classes(css_classes, {"last" => last_column})
|
39
|
+
|
40
|
+
html = clean_column css_classes do
|
41
|
+
content_tag(:fieldset, legend + capture(&block), options.merge(:class => css_classes))
|
42
|
+
end
|
43
|
+
|
34
44
|
concat(html)
|
35
45
|
end
|
36
46
|
|
@@ -44,6 +44,31 @@ module EaselHelpers
|
|
44
44
|
column(size, *args, &block)
|
45
45
|
end
|
46
46
|
|
47
|
+
def clean_column(classes, &block)
|
48
|
+
size = classes.scan(/col-(\d+)/).flatten.last
|
49
|
+
|
50
|
+
if size.nil?
|
51
|
+
html = capture(&block)
|
52
|
+
if block_given? && block_is_within_action_view?(block)
|
53
|
+
concat(html)
|
54
|
+
else
|
55
|
+
html
|
56
|
+
end
|
57
|
+
else
|
58
|
+
size = size.to_i
|
59
|
+
increase_depth(size)
|
60
|
+
html = capture(&block)
|
61
|
+
|
62
|
+
if block_given? && block_is_within_action_view?(block)
|
63
|
+
concat(html)
|
64
|
+
decrease_depth(size)
|
65
|
+
else
|
66
|
+
decrease_depth(size)
|
67
|
+
html
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
47
72
|
def method_missing_with_easel_widths(call, *args)
|
48
73
|
# filter out any initial helper calls
|
49
74
|
found = false
|
@@ -72,13 +97,14 @@ module EaselHelpers
|
|
72
97
|
def application_width; 24; end
|
73
98
|
|
74
99
|
def increase_depth(size)
|
75
|
-
@_easel_current_width
|
100
|
+
@_easel_current_width ||= []
|
101
|
+
@_easel_current_width.push @_easel_column_count.to_s
|
76
102
|
@_easel_column_count = size.to_s =~ /^\d+$/ ? size.to_s.to_i : (@_easel_column_count*MULTIPLES[size]).to_i
|
77
103
|
end
|
78
104
|
|
79
105
|
def decrease_depth(size)
|
80
|
-
@_easel_column_count = size.is_a?(Integer) ? @_easel_current_width.to_i : (@_easel_column_count/MULTIPLES[size]).to_i
|
81
|
-
@_easel_current_width
|
106
|
+
@_easel_column_count = size.is_a?(Integer) ? @_easel_current_width.last.to_i : (@_easel_column_count/MULTIPLES[size]).to_i
|
107
|
+
@_easel_current_width.pop
|
82
108
|
end
|
83
109
|
|
84
110
|
def col(size=nil, *args, &block)
|
@@ -37,9 +37,12 @@ module EaselHelpers
|
|
37
37
|
|
38
38
|
table_css_classes = ["recordset"] << options[:table].delete(:class) << args
|
39
39
|
|
40
|
-
|
41
|
-
|
42
|
-
|
40
|
+
css_classes = clean_css_classes(table_css_classes, {"last" => last_column})
|
41
|
+
html = clean_column css_classes do
|
42
|
+
content_tag(:table,
|
43
|
+
content_tag(:thead, content_tag(:tr, headers.to_s)) + capture(&block),
|
44
|
+
options[:table].merge(:class => css_classes))
|
45
|
+
end
|
43
46
|
|
44
47
|
reset_cycle
|
45
48
|
concat(html)
|
data/test/form_helper_test.rb
CHANGED
@@ -56,6 +56,12 @@ class FormHelperTest < EaselHelpers::ViewTestCase
|
|
56
56
|
end
|
57
57
|
end
|
58
58
|
|
59
|
+
should "assign default class if last class is passed as the only class" do
|
60
|
+
show_view "<% set :half, :last do %>words<% end %>" do
|
61
|
+
assert_select "div.col-12.text.col-last", "words"
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
59
65
|
end
|
60
66
|
|
61
67
|
context "fieldset" do
|
data/test/grid_helper_test.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'test_helper'
|
2
2
|
|
3
3
|
class GridHelperTest < EaselHelpers::ViewTestCase
|
4
|
-
|
4
|
+
should "properly assign classes for a simple column layout" do
|
5
5
|
template = %(
|
6
6
|
<% container do %>
|
7
7
|
<% column do %>
|
@@ -36,4 +36,67 @@ class GridHelperTest < EaselHelpers::ViewTestCase
|
|
36
36
|
assert_select "hr", 2
|
37
37
|
end
|
38
38
|
end
|
39
|
+
|
40
|
+
should "properly assign classes for generic helpers" do
|
41
|
+
template = %(
|
42
|
+
<% column do %>
|
43
|
+
<% fieldset :hform, :half do %>
|
44
|
+
<% set :one_third do %>text<% end %>
|
45
|
+
<% set :two_thirds, :last do %>more text<% end %>
|
46
|
+
<% end %>
|
47
|
+
<% recordset :half, :last do %>table<% end %>
|
48
|
+
<% end %>
|
49
|
+
)
|
50
|
+
|
51
|
+
show_view template do
|
52
|
+
assert_select "div.col-24" do
|
53
|
+
assert_select "fieldset.hform.col-12" do
|
54
|
+
assert_select "div.col-4", "text"
|
55
|
+
assert_select "div.col-8.col-last", "more text"
|
56
|
+
end
|
57
|
+
assert_select "table.col-12.col-last", "table"
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
should "properly assign classes for a deeply-nested view" do
|
63
|
+
template = %(
|
64
|
+
<% container do %>
|
65
|
+
<% column :half do %>
|
66
|
+
<% fieldset :hform, :half do %>
|
67
|
+
<% set :one_third do %>text<% end %>
|
68
|
+
<% set :two_thirds, :last do %>more text<% end %>
|
69
|
+
<% end %>
|
70
|
+
<% recordset :half, :last do %>table<% end %>
|
71
|
+
<% end %>
|
72
|
+
<% column :one_third do %>one third!<% end %>
|
73
|
+
<% column :one_sixth, :last do %>
|
74
|
+
<% fieldset :vform, :full, :last do %>
|
75
|
+
<% set do %>text<% end %>
|
76
|
+
<% end %>
|
77
|
+
<% end %>
|
78
|
+
<% end %>
|
79
|
+
)
|
80
|
+
|
81
|
+
show_view template do
|
82
|
+
assert_select "div.container" do
|
83
|
+
assert_select "div.col-12" do
|
84
|
+
assert_select "fieldset.hform.col-6" do
|
85
|
+
assert_select "div.col-2", "text"
|
86
|
+
assert_select "div.col-4.col-last", "more text"
|
87
|
+
end
|
88
|
+
assert_select "table.col-6.col-last", "table"
|
89
|
+
end
|
90
|
+
|
91
|
+
assert_select "div.col-8", "one third!"
|
92
|
+
|
93
|
+
assert_select "div.col-4.col-last" do
|
94
|
+
assert_select "fieldset.vform.col-4.col-last" do
|
95
|
+
assert_select "div", "text"
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
end
|
100
|
+
end
|
101
|
+
end
|
39
102
|
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.1.
|
4
|
+
version: 0.1.6
|
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-05-
|
12
|
+
date: 2009-05-07 00:00:00 -07:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -70,6 +70,7 @@ extra_rdoc_files:
|
|
70
70
|
- README.textile
|
71
71
|
- tasks/easel_helpers_tasks.rake
|
72
72
|
files:
|
73
|
+
- easel_helpers.gemspec
|
73
74
|
- lib/easel_helpers/helpers/date_helper.rb
|
74
75
|
- lib/easel_helpers/helpers/form_helper.rb
|
75
76
|
- lib/easel_helpers/helpers/grid_helper.rb
|
@@ -85,7 +86,6 @@ files:
|
|
85
86
|
- Rakefile
|
86
87
|
- README.textile
|
87
88
|
- tasks/easel_helpers_tasks.rake
|
88
|
-
- easel_helpers.gemspec
|
89
89
|
- test/date_helper_test.rb
|
90
90
|
- test/form_helper_test.rb
|
91
91
|
- test/grid_helper_test.rb
|