djanowski-rails_basic_helpers 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/README ADDED
@@ -0,0 +1 @@
1
+ A Ruby on Rails plugin providing some super simple helpers.
@@ -0,0 +1,235 @@
1
+ <?xml version="1.0" encoding="iso-8859-1"?>
2
+ <!DOCTYPE html
3
+ PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
4
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
5
+
6
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
7
+ <head>
8
+ <title>Module: BasicHelpers</title>
9
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
10
+ <meta http-equiv="Content-Script-Type" content="text/javascript" />
11
+ <link rel="stylesheet" href=".././rdoc-style.css" type="text/css" media="screen" />
12
+ <script type="text/javascript">
13
+ // <![CDATA[
14
+
15
+ function popupCode( url ) {
16
+ window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
17
+ }
18
+
19
+ function toggleCode( id ) {
20
+ if ( document.getElementById )
21
+ elem = document.getElementById( id );
22
+ else if ( document.all )
23
+ elem = eval( "document.all." + id );
24
+ else
25
+ return false;
26
+
27
+ elemStyle = elem.style;
28
+
29
+ if ( elemStyle.display != "block" ) {
30
+ elemStyle.display = "block"
31
+ } else {
32
+ elemStyle.display = "none"
33
+ }
34
+
35
+ return true;
36
+ }
37
+
38
+ // Make codeblocks hidden by default
39
+ document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
40
+
41
+ // ]]>
42
+ </script>
43
+
44
+ </head>
45
+ <body>
46
+
47
+
48
+
49
+ <div id="classHeader">
50
+ <table class="header-table">
51
+ <tr class="top-aligned-row">
52
+ <td><strong>Module</strong></td>
53
+ <td class="class-name-in-header">BasicHelpers</td>
54
+ </tr>
55
+ <tr class="top-aligned-row">
56
+ <td><strong>In:</strong></td>
57
+ <td>
58
+ <a href="../files/lib/basic_helpers_rb.html">
59
+ lib/basic_helpers.rb
60
+ </a>
61
+ <br />
62
+ </td>
63
+ </tr>
64
+
65
+ </table>
66
+ </div>
67
+ <!-- banner header -->
68
+
69
+ <div id="bodyContent">
70
+
71
+
72
+
73
+ <div id="contextContent">
74
+
75
+
76
+
77
+ </div>
78
+
79
+ <div id="method-list">
80
+ <h3 class="section-bar">Methods</h3>
81
+
82
+ <div class="name-list">
83
+ <a href="#M000001">table</a>&nbsp;&nbsp;
84
+ <a href="#M000002">table_for</a>&nbsp;&nbsp;
85
+ </div>
86
+ </div>
87
+
88
+ </div>
89
+
90
+
91
+ <!-- if includes -->
92
+
93
+ <div id="section">
94
+
95
+
96
+
97
+
98
+
99
+
100
+
101
+
102
+ <!-- if method_list -->
103
+ <div id="methods">
104
+ <h3 class="section-bar">Public Instance methods</h3>
105
+
106
+ <div id="method-M000001" class="method-detail">
107
+ <a name="M000001"></a>
108
+
109
+ <div class="method-heading">
110
+ <a href="BasicHelpers.src/M000001.html" target="Code" class="method-signature"
111
+ onclick="popupCode('BasicHelpers.src/M000001.html');return false;">
112
+ <span class="method-name">table</span><span class="method-args">(source, options = {})</span>
113
+ </a>
114
+ </div>
115
+
116
+ <div class="method-description">
117
+ <p>
118
+ Produces a basic HTML <a href="BasicHelpers.html#M000001">table</a> given
119
+ an enumerable <tt>source</tt>.
120
+ </p>
121
+ <h3>Examples</h3>
122
+ <pre>
123
+ rows =
124
+ [
125
+ %w{John john@domain.com},
126
+ %w{Doe doe@domain.com}
127
+ ]
128
+
129
+ table(rows)
130
+
131
+ # &lt;table&gt;
132
+ # &lt;tr&gt;
133
+ # &lt;td&gt;John&lt;/td&gt;
134
+ # &lt;td&gt;john@domain.com&lt;/td&gt;
135
+ # &lt;/tr&gt;
136
+ # &lt;tr&gt;
137
+ # &lt;td&gt;Doe&lt;/td&gt;
138
+ # &lt;td&gt;doe@domain.com&lt;/td&gt;
139
+ # &lt;/tr&gt;
140
+ # &lt;/table&gt;
141
+
142
+ table([%w{Name E-mail}] + rows, :headers =&gt; true)
143
+ table(rows, :headers =&gt; %w{Name E-mail})
144
+
145
+ # &lt;table&gt;
146
+ # &lt;thead&gt;
147
+ # &lt;tr&gt;
148
+ # &lt;th&gt;Name&lt;/th&gt;
149
+ # &lt;th&gt;E-mail&lt;/th&gt;
150
+ # &lt;/tr&gt;
151
+ # &lt;/thead&gt;
152
+ # &lt;tr&gt;
153
+ # &lt;td&gt;John&lt;/td&gt;
154
+ # &lt;td&gt;john@domain.com&lt;/td&gt;
155
+ # &lt;/tr&gt;
156
+ # &lt;tr&gt;
157
+ # &lt;td&gt;Doe&lt;/td&gt;
158
+ # &lt;td&gt;doe@domain.com&lt;/td&gt;
159
+ # &lt;/tr&gt;
160
+ # &lt;/table&gt;
161
+ </pre>
162
+ </div>
163
+ </div>
164
+
165
+ <div id="method-M000002" class="method-detail">
166
+ <a name="M000002"></a>
167
+
168
+ <div class="method-heading">
169
+ <a href="BasicHelpers.src/M000002.html" target="Code" class="method-signature"
170
+ onclick="popupCode('BasicHelpers.src/M000002.html');return false;">
171
+ <span class="method-name">table_for</span><span class="method-args">(source, attrs = nil, options = {})</span>
172
+ </a>
173
+ </div>
174
+
175
+ <div class="method-description">
176
+ <p>
177
+ Produces a simple <a href="BasicHelpers.html#M000001">table</a> for a given
178
+ collection of arbitrary objects.
179
+ </p>
180
+ <h3>Examples</h3>
181
+ <pre>
182
+ @people =
183
+ [
184
+ Person.new('John', 'john@domain.com'),
185
+ Person.new('Doe', 'doe@domain.com')
186
+ ]
187
+
188
+ table(:people, %w{name email})
189
+
190
+ # &lt;table&gt;
191
+ # &lt;tr&gt;
192
+ # &lt;td&gt;John&lt;/td&gt;
193
+ # &lt;td&gt;john@domain.com&lt;/td&gt;
194
+ # &lt;/tr&gt;
195
+ # &lt;tr&gt;
196
+ # &lt;td&gt;Doe&lt;/td&gt;
197
+ # &lt;td&gt;doe@domain.com&lt;/td&gt;
198
+ # &lt;/tr&gt;
199
+ # &lt;/table&gt;
200
+
201
+ table(rows, [:name, :email], :headers =&gt; true)
202
+
203
+ # &lt;table&gt;
204
+ # &lt;thead&gt;
205
+ # &lt;tr&gt;
206
+ # &lt;th&gt;Name&lt;/th&gt;
207
+ # &lt;th&gt;Email&lt;/th&gt;
208
+ # &lt;/tr&gt;
209
+ # &lt;/thead&gt;
210
+ # &lt;tr&gt;
211
+ # &lt;td&gt;John&lt;/td&gt;
212
+ # &lt;td&gt;john@domain.com&lt;/td&gt;
213
+ # &lt;/tr&gt;
214
+ # &lt;tr&gt;
215
+ # &lt;td&gt;Doe&lt;/td&gt;
216
+ # &lt;td&gt;doe@domain.com&lt;/td&gt;
217
+ # &lt;/tr&gt;
218
+ # &lt;/table&gt;
219
+ </pre>
220
+ </div>
221
+ </div>
222
+
223
+
224
+ </div>
225
+
226
+
227
+ </div>
228
+
229
+
230
+ <div id="validator-badges">
231
+ <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
232
+ </div>
233
+
234
+ </body>
235
+ </html>
@@ -0,0 +1,34 @@
1
+ <?xml version="1.0" encoding="iso-8859-1"?>
2
+ <!DOCTYPE html
3
+ PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
4
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
5
+
6
+ <html>
7
+ <head>
8
+ <title>table (BasicHelpers)</title>
9
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
10
+ <link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
11
+ </head>
12
+ <body class="standalone-code">
13
+ <pre><span class="ruby-comment cmt"># File lib/basic_helpers.rb, line 44</span>
14
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">table</span>(<span class="ruby-identifier">source</span>, <span class="ruby-identifier">options</span> = {})
15
+ <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">nil</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">source</span>.<span class="ruby-identifier">blank?</span>
16
+
17
+ <span class="ruby-identifier">html</span> = <span class="ruby-value str">''</span>
18
+
19
+ <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">headers</span> = <span class="ruby-identifier">options</span>.<span class="ruby-identifier">delete</span>(<span class="ruby-identifier">:headers</span>)
20
+ <span class="ruby-identifier">html</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">content_tag</span>(<span class="ruby-identifier">:thead</span>,
21
+ <span class="ruby-identifier">content_tag</span>(<span class="ruby-identifier">:tr</span>,
22
+ (<span class="ruby-identifier">headers</span> <span class="ruby-operator">==</span> <span class="ruby-keyword kw">true</span> <span class="ruby-operator">?</span> <span class="ruby-identifier">source</span>.<span class="ruby-identifier">delete_at</span>(<span class="ruby-value">0</span>) <span class="ruby-operator">:</span> <span class="ruby-identifier">headers</span>).<span class="ruby-identifier">map</span> {<span class="ruby-operator">|</span><span class="ruby-identifier">col</span><span class="ruby-operator">|</span> <span class="ruby-identifier">content_tag</span>(<span class="ruby-identifier">:th</span>, <span class="ruby-identifier">col</span>) }
23
+ )
24
+ )
25
+ <span class="ruby-keyword kw">end</span>
26
+
27
+ <span class="ruby-identifier">source</span>.<span class="ruby-identifier">inject</span>(<span class="ruby-identifier">html</span>) <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">buffer</span>,<span class="ruby-identifier">row</span><span class="ruby-operator">|</span>
28
+ <span class="ruby-identifier">buffer</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">content_tag</span>(<span class="ruby-identifier">:tr</span>, <span class="ruby-identifier">row</span>.<span class="ruby-identifier">map</span> {<span class="ruby-operator">|</span><span class="ruby-identifier">col</span><span class="ruby-operator">|</span> <span class="ruby-identifier">content_tag</span>(<span class="ruby-identifier">:td</span>, <span class="ruby-operator">*</span>(<span class="ruby-constant">Array</span>(<span class="ruby-identifier">col</span>))) })
29
+ <span class="ruby-keyword kw">end</span>
30
+
31
+ <span class="ruby-identifier">content_tag</span>(<span class="ruby-identifier">:table</span>, <span class="ruby-identifier">html</span>, <span class="ruby-identifier">options</span>)
32
+ <span class="ruby-keyword kw">end</span></pre>
33
+ </body>
34
+ </html>
@@ -0,0 +1,37 @@
1
+ <?xml version="1.0" encoding="iso-8859-1"?>
2
+ <!DOCTYPE html
3
+ PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
4
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
5
+
6
+ <html>
7
+ <head>
8
+ <title>table_for (BasicHelpers)</title>
9
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
10
+ <link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
11
+ </head>
12
+ <body class="standalone-code">
13
+ <pre><span class="ruby-comment cmt"># File lib/basic_helpers.rb, line 106</span>
14
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">table_for</span>(<span class="ruby-identifier">source</span>, <span class="ruby-identifier">attrs</span> = <span class="ruby-keyword kw">nil</span>, <span class="ruby-identifier">options</span> = {})
15
+ <span class="ruby-identifier">source</span> = <span class="ruby-identifier">instance_variable_get</span>(<span class="ruby-node">&quot;@#{source}&quot;</span>) <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">source</span>.<span class="ruby-identifier">kind_of?</span>(<span class="ruby-constant">Symbol</span>)
16
+
17
+ <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">attrs</span>.<span class="ruby-identifier">blank?</span>
18
+ <span class="ruby-identifier">rows</span> = <span class="ruby-identifier">source</span>.<span class="ruby-identifier">map</span> {<span class="ruby-operator">|</span><span class="ruby-identifier">x</span><span class="ruby-operator">|</span> [<span class="ruby-identifier">x</span>.<span class="ruby-identifier">to_s</span>] }
19
+ <span class="ruby-keyword kw">else</span>
20
+ <span class="ruby-identifier">rows</span> = <span class="ruby-identifier">source</span>.<span class="ruby-identifier">map</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">x</span><span class="ruby-operator">|</span>
21
+ <span class="ruby-identifier">attrs</span>.<span class="ruby-identifier">map</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">att</span><span class="ruby-operator">|</span>
22
+ <span class="ruby-keyword kw">case</span> <span class="ruby-identifier">att</span>
23
+ <span class="ruby-keyword kw">when</span> <span class="ruby-constant">Proc</span>
24
+ <span class="ruby-identifier">att</span>.<span class="ruby-identifier">call</span>(<span class="ruby-identifier">x</span>)
25
+ <span class="ruby-keyword kw">else</span>
26
+ <span class="ruby-identifier">x</span>.<span class="ruby-identifier">send</span>(<span class="ruby-identifier">att</span>)
27
+ <span class="ruby-keyword kw">end</span>
28
+ <span class="ruby-keyword kw">end</span>
29
+ <span class="ruby-keyword kw">end</span>
30
+ <span class="ruby-keyword kw">end</span>
31
+
32
+ <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:headers</span>] = <span class="ruby-identifier">attrs</span>.<span class="ruby-identifier">map</span> {<span class="ruby-operator">|</span><span class="ruby-identifier">att</span><span class="ruby-operator">|</span> <span class="ruby-identifier">att</span>.<span class="ruby-identifier">to_s</span>.<span class="ruby-identifier">humanize</span> } <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:headers</span>] <span class="ruby-operator">==</span> <span class="ruby-keyword kw">true</span>
33
+
34
+ <span class="ruby-identifier">table</span>(<span class="ruby-identifier">rows</span>, <span class="ruby-identifier">options</span>)
35
+ <span class="ruby-keyword kw">end</span></pre>
36
+ </body>
37
+ </html>
data/doc/created.rid ADDED
@@ -0,0 +1 @@
1
+ Wed, 25 Jun 2008 17:47:25 -0300
@@ -0,0 +1,101 @@
1
+ <?xml version="1.0" encoding="iso-8859-1"?>
2
+ <!DOCTYPE html
3
+ PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
4
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
5
+
6
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
7
+ <head>
8
+ <title>File: basic_helpers.rb</title>
9
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
10
+ <meta http-equiv="Content-Script-Type" content="text/javascript" />
11
+ <link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
12
+ <script type="text/javascript">
13
+ // <![CDATA[
14
+
15
+ function popupCode( url ) {
16
+ window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
17
+ }
18
+
19
+ function toggleCode( id ) {
20
+ if ( document.getElementById )
21
+ elem = document.getElementById( id );
22
+ else if ( document.all )
23
+ elem = eval( "document.all." + id );
24
+ else
25
+ return false;
26
+
27
+ elemStyle = elem.style;
28
+
29
+ if ( elemStyle.display != "block" ) {
30
+ elemStyle.display = "block"
31
+ } else {
32
+ elemStyle.display = "none"
33
+ }
34
+
35
+ return true;
36
+ }
37
+
38
+ // Make codeblocks hidden by default
39
+ document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
40
+
41
+ // ]]>
42
+ </script>
43
+
44
+ </head>
45
+ <body>
46
+
47
+
48
+
49
+ <div id="fileHeader">
50
+ <h1>basic_helpers.rb</h1>
51
+ <table class="header-table">
52
+ <tr class="top-aligned-row">
53
+ <td><strong>Path:</strong></td>
54
+ <td>lib/basic_helpers.rb
55
+ </td>
56
+ </tr>
57
+ <tr class="top-aligned-row">
58
+ <td><strong>Last Update:</strong></td>
59
+ <td>Wed Jun 25 17:44:15 -0300 2008</td>
60
+ </tr>
61
+ </table>
62
+ </div>
63
+ <!-- banner header -->
64
+
65
+ <div id="bodyContent">
66
+
67
+
68
+
69
+ <div id="contextContent">
70
+
71
+
72
+
73
+ </div>
74
+
75
+
76
+ </div>
77
+
78
+
79
+ <!-- if includes -->
80
+
81
+ <div id="section">
82
+
83
+
84
+
85
+
86
+
87
+
88
+
89
+
90
+ <!-- if method_list -->
91
+
92
+
93
+ </div>
94
+
95
+
96
+ <div id="validator-badges">
97
+ <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
98
+ </div>
99
+
100
+ </body>
101
+ </html>
@@ -0,0 +1,27 @@
1
+
2
+ <?xml version="1.0" encoding="iso-8859-1"?>
3
+ <!DOCTYPE html
4
+ PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
5
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
6
+
7
+ <!--
8
+
9
+ Classes
10
+
11
+ -->
12
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
13
+ <head>
14
+ <title>Classes</title>
15
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
16
+ <link rel="stylesheet" href="rdoc-style.css" type="text/css" />
17
+ <base target="docwin" />
18
+ </head>
19
+ <body>
20
+ <div id="index">
21
+ <h1 class="section-bar">Classes</h1>
22
+ <div id="index-entries">
23
+ <a href="classes/BasicHelpers.html">BasicHelpers</a><br />
24
+ </div>
25
+ </div>
26
+ </body>
27
+ </html>
@@ -0,0 +1,27 @@
1
+
2
+ <?xml version="1.0" encoding="iso-8859-1"?>
3
+ <!DOCTYPE html
4
+ PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
5
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
6
+
7
+ <!--
8
+
9
+ Files
10
+
11
+ -->
12
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
13
+ <head>
14
+ <title>Files</title>
15
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
16
+ <link rel="stylesheet" href="rdoc-style.css" type="text/css" />
17
+ <base target="docwin" />
18
+ </head>
19
+ <body>
20
+ <div id="index">
21
+ <h1 class="section-bar">Files</h1>
22
+ <div id="index-entries">
23
+ <a href="files/lib/basic_helpers_rb.html">lib/basic_helpers.rb</a><br />
24
+ </div>
25
+ </div>
26
+ </body>
27
+ </html>
@@ -0,0 +1,28 @@
1
+
2
+ <?xml version="1.0" encoding="iso-8859-1"?>
3
+ <!DOCTYPE html
4
+ PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
5
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
6
+
7
+ <!--
8
+
9
+ Methods
10
+
11
+ -->
12
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
13
+ <head>
14
+ <title>Methods</title>
15
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
16
+ <link rel="stylesheet" href="rdoc-style.css" type="text/css" />
17
+ <base target="docwin" />
18
+ </head>
19
+ <body>
20
+ <div id="index">
21
+ <h1 class="section-bar">Methods</h1>
22
+ <div id="index-entries">
23
+ <a href="classes/BasicHelpers.html#M000001">table (BasicHelpers)</a><br />
24
+ <a href="classes/BasicHelpers.html#M000002">table_for (BasicHelpers)</a><br />
25
+ </div>
26
+ </div>
27
+ </body>
28
+ </html>
data/doc/index.html ADDED
@@ -0,0 +1,24 @@
1
+ <?xml version="1.0" encoding="iso-8859-1"?>
2
+ <!DOCTYPE html
3
+ PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN"
4
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">
5
+
6
+ <!--
7
+
8
+ RDoc Documentation
9
+
10
+ -->
11
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
12
+ <head>
13
+ <title>RDoc Documentation</title>
14
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
15
+ </head>
16
+ <frameset rows="20%, 80%">
17
+ <frameset cols="25%,35%,45%">
18
+ <frame src="fr_file_index.html" title="Files" name="Files" />
19
+ <frame src="fr_class_index.html" name="Classes" />
20
+ <frame src="fr_method_index.html" name="Methods" />
21
+ </frameset>
22
+ <frame src="files/lib/basic_helpers_rb.html" name="docwin" />
23
+ </frameset>
24
+ </html>
@@ -0,0 +1,208 @@
1
+
2
+ body {
3
+ font-family: Verdana,Arial,Helvetica,sans-serif;
4
+ font-size: 90%;
5
+ margin: 0;
6
+ margin-left: 40px;
7
+ padding: 0;
8
+ background: white;
9
+ }
10
+
11
+ h1,h2,h3,h4 { margin: 0; color: #efefef; background: transparent; }
12
+ h1 { font-size: 150%; }
13
+ h2,h3,h4 { margin-top: 1em; }
14
+
15
+ a { background: #eef; color: #039; text-decoration: none; }
16
+ a:hover { background: #039; color: #eef; }
17
+
18
+ /* Override the base stylesheet's Anchor inside a table cell */
19
+ td > a {
20
+ background: transparent;
21
+ color: #039;
22
+ text-decoration: none;
23
+ }
24
+
25
+ /* and inside a section title */
26
+ .section-title > a {
27
+ background: transparent;
28
+ color: #eee;
29
+ text-decoration: none;
30
+ }
31
+
32
+ /* === Structural elements =================================== */
33
+
34
+ div#index {
35
+ margin: 0;
36
+ margin-left: -40px;
37
+ padding: 0;
38
+ font-size: 90%;
39
+ }
40
+
41
+
42
+ div#index a {
43
+ margin-left: 0.7em;
44
+ }
45
+
46
+ div#index .section-bar {
47
+ margin-left: 0px;
48
+ padding-left: 0.7em;
49
+ background: #ccc;
50
+ font-size: small;
51
+ }
52
+
53
+
54
+ div#classHeader, div#fileHeader {
55
+ width: auto;
56
+ color: white;
57
+ padding: 0.5em 1.5em 0.5em 1.5em;
58
+ margin: 0;
59
+ margin-left: -40px;
60
+ border-bottom: 3px solid #006;
61
+ }
62
+
63
+ div#classHeader a, div#fileHeader a {
64
+ background: inherit;
65
+ color: white;
66
+ }
67
+
68
+ div#classHeader td, div#fileHeader td {
69
+ background: inherit;
70
+ color: white;
71
+ }
72
+
73
+
74
+ div#fileHeader {
75
+ background: #057;
76
+ }
77
+
78
+ div#classHeader {
79
+ background: #048;
80
+ }
81
+
82
+
83
+ .class-name-in-header {
84
+ font-size: 180%;
85
+ font-weight: bold;
86
+ }
87
+
88
+
89
+ div#bodyContent {
90
+ padding: 0 1.5em 0 1.5em;
91
+ }
92
+
93
+ div#description {
94
+ padding: 0.5em 1.5em;
95
+ background: #efefef;
96
+ border: 1px dotted #999;
97
+ }
98
+
99
+ div#description h1,h2,h3,h4,h5,h6 {
100
+ color: #125;;
101
+ background: transparent;
102
+ }
103
+
104
+ div#validator-badges {
105
+ text-align: center;
106
+ }
107
+ div#validator-badges img { border: 0; }
108
+
109
+ div#copyright {
110
+ color: #333;
111
+ background: #efefef;
112
+ font: 0.75em sans-serif;
113
+ margin-top: 5em;
114
+ margin-bottom: 0;
115
+ padding: 0.5em 2em;
116
+ }
117
+
118
+
119
+ /* === Classes =================================== */
120
+
121
+ table.header-table {
122
+ color: white;
123
+ font-size: small;
124
+ }
125
+
126
+ .type-note {
127
+ font-size: small;
128
+ color: #DEDEDE;
129
+ }
130
+
131
+ .xxsection-bar {
132
+ background: #eee;
133
+ color: #333;
134
+ padding: 3px;
135
+ }
136
+
137
+ .section-bar {
138
+ color: #333;
139
+ border-bottom: 1px solid #999;
140
+ margin-left: -20px;
141
+ }
142
+
143
+
144
+ .section-title {
145
+ background: #79a;
146
+ color: #eee;
147
+ padding: 3px;
148
+ margin-top: 2em;
149
+ margin-left: -30px;
150
+ border: 1px solid #999;
151
+ }
152
+
153
+ .top-aligned-row { vertical-align: top }
154
+ .bottom-aligned-row { vertical-align: bottom }
155
+
156
+ /* --- Context section classes ----------------------- */
157
+
158
+ .context-row { }
159
+ .context-item-name { font-family: monospace; font-weight: bold; color: black; }
160
+ .context-item-value { font-size: small; color: #448; }
161
+ .context-item-desc { color: #333; padding-left: 2em; }
162
+
163
+ /* --- Method classes -------------------------- */
164
+ .method-detail {
165
+ background: #efefef;
166
+ padding: 0;
167
+ margin-top: 0.5em;
168
+ margin-bottom: 1em;
169
+ border: 1px dotted #ccc;
170
+ }
171
+ .method-heading {
172
+ color: black;
173
+ background: #ccc;
174
+ border-bottom: 1px solid #666;
175
+ padding: 0.2em 0.5em 0 0.5em;
176
+ }
177
+ .method-signature { color: black; background: inherit; }
178
+ .method-name { font-weight: bold; }
179
+ .method-args { font-style: italic; }
180
+ .method-description { padding: 0 0.5em 0 0.5em; }
181
+
182
+ /* --- Source code sections -------------------- */
183
+
184
+ a.source-toggle { font-size: 90%; }
185
+ div.method-source-code {
186
+ background: #262626;
187
+ color: #ffdead;
188
+ margin: 1em;
189
+ padding: 0.5em;
190
+ border: 1px dashed #999;
191
+ overflow: hidden;
192
+ }
193
+
194
+ div.method-source-code pre { color: #ffdead; overflow: hidden; }
195
+
196
+ /* --- Ruby keyword styles --------------------- */
197
+
198
+ .standalone-code { background: #221111; color: #ffdead; overflow: hidden; }
199
+
200
+ .ruby-constant { color: #7fffd4; background: transparent; }
201
+ .ruby-keyword { color: #00ffff; background: transparent; }
202
+ .ruby-ivar { color: #eedd82; background: transparent; }
203
+ .ruby-operator { color: #00ffee; background: transparent; }
204
+ .ruby-identifier { color: #ffdead; background: transparent; }
205
+ .ruby-node { color: #ffa07a; background: transparent; }
206
+ .ruby-comment { color: #b22222; font-weight: bold; background: transparent; }
207
+ .ruby-regexp { color: #ffa07a; background: transparent; }
208
+ .ruby-value { color: #7fffd4; background: transparent; }
@@ -0,0 +1,128 @@
1
+ module BasicHelpers
2
+ # Produces a basic HTML table given an enumerable +source+.
3
+ #
4
+ # === Examples
5
+ #
6
+ # rows =
7
+ # [
8
+ # %w{John john@domain.com},
9
+ # %w{Doe doe@domain.com}
10
+ # ]
11
+ #
12
+ # table(rows)
13
+ #
14
+ # # <table>
15
+ # # <tr>
16
+ # # <td>John</td>
17
+ # # <td>john@domain.com</td>
18
+ # # </tr>
19
+ # # <tr>
20
+ # # <td>Doe</td>
21
+ # # <td>doe@domain.com</td>
22
+ # # </tr>
23
+ # # </table>
24
+ #
25
+ # table([%w{Name E-mail}] + rows, :headers => true)
26
+ # table(rows, :headers => %w{Name E-mail})
27
+ #
28
+ # # <table>
29
+ # # <thead>
30
+ # # <tr>
31
+ # # <th>Name</th>
32
+ # # <th>E-mail</th>
33
+ # # </tr>
34
+ # # </thead>
35
+ # # <tr>
36
+ # # <td>John</td>
37
+ # # <td>john@domain.com</td>
38
+ # # </tr>
39
+ # # <tr>
40
+ # # <td>Doe</td>
41
+ # # <td>doe@domain.com</td>
42
+ # # </tr>
43
+ # # </table>
44
+ def table(source, options = {})
45
+ return nil if source.blank?
46
+
47
+ html = ''
48
+
49
+ if headers = options.delete(:headers)
50
+ html << content_tag(:thead,
51
+ content_tag(:tr,
52
+ (headers == true ? source.delete_at(0) : headers).map {|col| content_tag(:th, col) }
53
+ )
54
+ )
55
+ end
56
+
57
+ source.inject(html) do |buffer,row|
58
+ buffer << content_tag(:tr, row.map {|col| content_tag(:td, *(Array(col))) })
59
+ end
60
+
61
+ content_tag(:table, html, options)
62
+ end
63
+
64
+ # Produces a simple table for a given
65
+ # collection of arbitrary objects.
66
+ #
67
+ # === Examples
68
+ #
69
+ # @people =
70
+ # [
71
+ # Person.new('John', 'john@domain.com'),
72
+ # Person.new('Doe', 'doe@domain.com')
73
+ # ]
74
+ #
75
+ # table(:people, %w{name email})
76
+ #
77
+ # # <table>
78
+ # # <tr>
79
+ # # <td>John</td>
80
+ # # <td>john@domain.com</td>
81
+ # # </tr>
82
+ # # <tr>
83
+ # # <td>Doe</td>
84
+ # # <td>doe@domain.com</td>
85
+ # # </tr>
86
+ # # </table>
87
+ #
88
+ # table(rows, [:name, :email], :headers => true)
89
+ #
90
+ # # <table>
91
+ # # <thead>
92
+ # # <tr>
93
+ # # <th>Name</th>
94
+ # # <th>Email</th>
95
+ # # </tr>
96
+ # # </thead>
97
+ # # <tr>
98
+ # # <td>John</td>
99
+ # # <td>john@domain.com</td>
100
+ # # </tr>
101
+ # # <tr>
102
+ # # <td>Doe</td>
103
+ # # <td>doe@domain.com</td>
104
+ # # </tr>
105
+ # # </table>
106
+ def table_for(source, attrs = nil, options = {})
107
+ source = instance_variable_get("@#{source}") if source.kind_of?(Symbol)
108
+
109
+ if attrs.blank?
110
+ rows = source.map {|x| [x.to_s] }
111
+ else
112
+ rows = source.map do |x|
113
+ attrs.map do |att|
114
+ case att
115
+ when Proc
116
+ att.call(x)
117
+ else
118
+ x.send(att)
119
+ end
120
+ end
121
+ end
122
+ end
123
+
124
+ options[:headers] = attrs.map {|att| att.to_s.humanize } if options[:headers] == true
125
+
126
+ table(rows, options)
127
+ end
128
+ end
data/lib/rails/init.rb ADDED
@@ -0,0 +1 @@
1
+ ActionView::Base.send(:include, BasicHelpers)
metadata ADDED
@@ -0,0 +1,72 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: djanowski-rails_basic_helpers
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Damian Janowski
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2008-06-25 00:00:00 -07:00
13
+ default_executable:
14
+ dependencies: []
15
+
16
+ description: ""
17
+ email: damian.janowski@gmail.com
18
+ executables: []
19
+
20
+ extensions: []
21
+
22
+ extra_rdoc_files:
23
+ - README
24
+ files:
25
+ - lib/basic_helpers.rb
26
+ - lib/rails/init.rb
27
+ - README
28
+ - doc/classes/BasicHelpers.html
29
+ - doc/classes/BasicHelpers.src
30
+ - doc/classes/BasicHelpers.src/M000001.html
31
+ - doc/classes/BasicHelpers.src/M000002.html
32
+ - doc/created.rid
33
+ - doc/files/lib/basic_helpers_rb.html
34
+ - doc/fr_class_index.html
35
+ - doc/fr_file_index.html
36
+ - doc/fr_method_index.html
37
+ - doc/index.html
38
+ - doc/rdoc-style.css
39
+ has_rdoc: true
40
+ homepage:
41
+ post_install_message:
42
+ rdoc_options:
43
+ - --line-numbers
44
+ - --inline-source
45
+ - --title
46
+ - rails_basic_helpers
47
+ - --main
48
+ - README
49
+ require_paths:
50
+ - lib
51
+ - lib/rails
52
+ required_ruby_version: !ruby/object:Gem::Requirement
53
+ requirements:
54
+ - - ">="
55
+ - !ruby/object:Gem::Version
56
+ version: "0"
57
+ version:
58
+ required_rubygems_version: !ruby/object:Gem::Requirement
59
+ requirements:
60
+ - - ">="
61
+ - !ruby/object:Gem::Version
62
+ version: "0"
63
+ version:
64
+ requirements: []
65
+
66
+ rubyforge_project:
67
+ rubygems_version: 1.2.0
68
+ signing_key:
69
+ specification_version: 2
70
+ summary: rails_basic_helpers
71
+ test_files: []
72
+