Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
marciotrindade committed Dec 15, 2008
0 parents commit 9459afc
Show file tree
Hide file tree
Showing 10 changed files with 122 additions and 0 deletions.
20 changes: 20 additions & 0 deletions MIT-LICENSE
@@ -0,0 +1,20 @@
Copyright (c) 2008 [name of plugin creator]

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
31 changes: 31 additions & 0 deletions README
@@ -0,0 +1,31 @@
## ShowInColumns

It's a helper to show your content in columns when you use a table.


Attributes
collection => a array of object ex. User.all
collumns => number of columns that will create default is 2
block => a block of code that will repeat You need add a tag <td>


## Example

You can use like this:
<table id="list_users">
<% show_in_columns User.all, 2 do |user| -%>
<td><%=user.name%></td>
<% end -%>
</table>

this code will generate a HTML like this:
<tr>
<td>Name 1</td>
<td>Name 2</td>
</tr>
<tr>
<td>Name 3</td>
</tr>


Copyright (c) 2008 Marcio Trindade (marciotrindade@gmail.com), released under the MIT license
23 changes: 23 additions & 0 deletions Rakefile
@@ -0,0 +1,23 @@
require 'rake'
require 'rake/testtask'
require 'rake/rdoctask'

desc 'Default: run unit tests.'
task :default => :test

desc 'Test the show_in_columns plugin.'
Rake::TestTask.new(:test) do |t|
t.libs << 'lib'
t.libs << 'test'
t.pattern = 'test/**/*_test.rb'
t.verbose = true
end

desc 'Generate documentation for the show_in_columns plugin.'
Rake::RDocTask.new(:rdoc) do |rdoc|
rdoc.rdoc_dir = 'rdoc'
rdoc.title = 'ShowInColumns'
rdoc.options << '--line-numbers' << '--inline-source'
rdoc.rdoc_files.include('README')
rdoc.rdoc_files.include('lib/**/*.rb')
end
2 changes: 2 additions & 0 deletions init.rb
@@ -0,0 +1,2 @@
require 'show_in_columns'
ActionView::Base.send :include, ShowInColumns
1 change: 1 addition & 0 deletions install.rb
@@ -0,0 +1 @@
# Install hook code here
29 changes: 29 additions & 0 deletions lib/show_in_columns.rb
@@ -0,0 +1,29 @@
module ShowInColumns
# show content in <tr>
#
# <table>
# <% show_in_columns @users, 2 do |user| -%>
# <td valign="top"><%=user.name%></td>
# <% end -%>
# </table>
# will generate
# <tr>
# <td>Name 1</td>
# <td>Name 2</td>
# </tr>
# <tr>
# <td>Name 3</td>
# </tr>
def show_in_columns(collection, columns = 2, &proc)
concat("<tr>", proc.binding)
for i in (0..(collection.size + 1))
concat("</tr><tr>", proc.binding) if (i%columns) == 0 && i != 0
proc.call(collection[i])
end
concat("</tr>", proc.binding)
end

def test_marcio
"marcio trindade"
end
end
4 changes: 4 additions & 0 deletions tasks/show_in_columns_tasks.rake
@@ -0,0 +1,4 @@
# desc "Explaining what the task does"
# task :show_in_columns do
# # Task goes here
# end
8 changes: 8 additions & 0 deletions test/show_in_columns_test.rb
@@ -0,0 +1,8 @@
require 'test_helper'

class ShowInColumnsTest < ActiveSupport::TestCase
# Replace this with your real tests.
test "the truth" do
assert true
end
end
3 changes: 3 additions & 0 deletions test/test_helper.rb
@@ -0,0 +1,3 @@
require 'rubygems'
require 'active_support'
require 'active_support/test_case'
1 change: 1 addition & 0 deletions uninstall.rb
@@ -0,0 +1 @@
# Uninstall hook code here

0 comments on commit 9459afc

Please sign in to comment.