list-for 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/README.rdoc ADDED
File without changes
data/Rakefile ADDED
@@ -0,0 +1,22 @@
1
+ require 'rspec/core/rake_task'
2
+
3
+ RSpec::Core::RakeTask.new('spec')
4
+
5
+ # If you want to make this the default task
6
+ task :default => :spec
7
+
8
+ begin
9
+ require 'jeweler'
10
+ Jeweler::Tasks.new do |gemspec|
11
+ gemspec.name = "list-for"
12
+ gemspec.summary = "list-for is a list builder for an array of objects, easily allowing overriding of how any aspect of the list is generated"
13
+ gemspec.description = "list-for is a list builder for an array of objects, easily allowing overriding of how any aspect of the list is generated"
14
+ gemspec.email = "hunterae@gmail.com"
15
+ gemspec.homepage = "http://github.com/hunterae/list-for"
16
+ gemspec.authors = ["Andrew Hunter"]
17
+ gemspec.files = FileList["[A-Z]*", "{lib,spec,app,rails}/**/*"] - FileList["**/*.log", "Gemfile", "Gemfile.lock"]
18
+ end
19
+ Jeweler::GemcutterTasks.new
20
+ rescue LoadError
21
+ puts "Jeweler not available. Install it with: gem install jeweler"
22
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.0.1
@@ -0,0 +1,31 @@
1
+ <%= list.define :item do |options| %>
2
+ <%= options[:field] ? options[:record].send(options[:field]) : options[:record].to_s %>
3
+ <% end %>
4
+
5
+ <%= list.define :items do |options| %>
6
+ <% if records %>
7
+ <% records.each do |record| %>
8
+ <%= content_tag :li, options[:item_html] do %>
9
+ <%= list.use :item, :record => record %>
10
+ <% end %>
11
+ <% end %>
12
+ <% else %>
13
+ <% list.items.each do |item| %>
14
+ <%= content_tag :li, options.merge(item.options)[:item_html] do %>
15
+ <%= list.use item.name %>
16
+ <% end %>
17
+ <% end %>
18
+ <% end %>
19
+ <% end %>
20
+
21
+ <% list.items.each do |item| %>
22
+ <%= list.define item.name, :item => item do |options| %>
23
+ <%= item.name %>
24
+ <% end %>
25
+ <% end %>
26
+
27
+ <%= list.use :list do |options| %>
28
+ <%= content_tag :ul, options[:list_html] do %>
29
+ <%= list.use :items %>
30
+ <% end %>
31
+ <% end %>
data/lib/list-for.rb ADDED
@@ -0,0 +1,13 @@
1
+ require "action_view"
2
+
3
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
4
+
5
+ require "list_for/list_for"
6
+ require "list_for/helper_methods"
7
+ require "list_for/engine"
8
+
9
+ $LOAD_PATH.shift
10
+
11
+ if defined?(ActionView::Base)
12
+ ActionView::Base.send :include, ListFor::HelperMethods
13
+ end
@@ -0,0 +1,7 @@
1
+ require "rails"
2
+
3
+ module ListFor
4
+ class Engine < Rails::Engine
5
+
6
+ end
7
+ end
@@ -0,0 +1,21 @@
1
+ module ListFor
2
+ module HelperMethods
3
+ def list_for_options(options={}, parameters={})
4
+ evaluated_options = {}
5
+ options.each_pair { |k, v| evaluated_options[k] = (v.is_a?(Proc) ? v.call(parameters) : v)}
6
+ evaluated_options
7
+ end
8
+
9
+ def list_for(*args, &block)
10
+ options = args.extract_options!
11
+
12
+ options[:records] = args.first
13
+ options[:template] = "list_for/list_for"
14
+ options[:templates_folder] = "list_for"
15
+ options[:record_variable] = "records"
16
+ options[:variable] = "list"
17
+
18
+ ListFor::Base.new(self, options, &block).render
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,8 @@
1
+ require 'building-blocks'
2
+
3
+ module ListFor
4
+ class Base < BuildingBlocks::Base
5
+ alias items block_positions
6
+ alias item use
7
+ end
8
+ end
data/rails/init.rb ADDED
@@ -0,0 +1 @@
1
+ require 'list-for'
metadata ADDED
@@ -0,0 +1,118 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: list-for
3
+ version: !ruby/object:Gem::Version
4
+ hash: 29
5
+ prerelease: false
6
+ segments:
7
+ - 0
8
+ - 0
9
+ - 1
10
+ version: 0.0.1
11
+ platform: ruby
12
+ authors:
13
+ - Andrew Hunter
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2011-05-16 00:00:00 -04:00
19
+ default_executable:
20
+ dependencies:
21
+ - !ruby/object:Gem::Dependency
22
+ prerelease: false
23
+ type: :runtime
24
+ name: list-for
25
+ version_requirements: &id001 !ruby/object:Gem::Requirement
26
+ none: false
27
+ requirements:
28
+ - - ">="
29
+ - !ruby/object:Gem::Version
30
+ hash: 3
31
+ segments:
32
+ - 0
33
+ version: "0"
34
+ requirement: *id001
35
+ - !ruby/object:Gem::Dependency
36
+ prerelease: false
37
+ type: :runtime
38
+ name: rails
39
+ version_requirements: &id002 !ruby/object:Gem::Requirement
40
+ none: false
41
+ requirements:
42
+ - - ~>
43
+ - !ruby/object:Gem::Version
44
+ hash: 7
45
+ segments:
46
+ - 3
47
+ - 0
48
+ - 0
49
+ version: 3.0.0
50
+ requirement: *id002
51
+ - !ruby/object:Gem::Dependency
52
+ prerelease: false
53
+ type: :runtime
54
+ name: building-blocks
55
+ version_requirements: &id003 !ruby/object:Gem::Requirement
56
+ none: false
57
+ requirements:
58
+ - - ">="
59
+ - !ruby/object:Gem::Version
60
+ hash: 3
61
+ segments:
62
+ - 0
63
+ version: "0"
64
+ requirement: *id003
65
+ description: list-for is a list builder for an array of objects, easily allowing overriding of how any aspect of the list is generated
66
+ email: hunterae@gmail.com
67
+ executables: []
68
+
69
+ extensions: []
70
+
71
+ extra_rdoc_files:
72
+ - README.rdoc
73
+ files:
74
+ - README.rdoc
75
+ - Rakefile
76
+ - VERSION
77
+ - app/views/list_for/_list_for.html.erb
78
+ - lib/list-for.rb
79
+ - lib/list_for/engine.rb
80
+ - lib/list_for/helper_methods.rb
81
+ - lib/list_for/list_for.rb
82
+ - rails/init.rb
83
+ has_rdoc: true
84
+ homepage: http://github.com/hunterae/list-for
85
+ licenses: []
86
+
87
+ post_install_message:
88
+ rdoc_options: []
89
+
90
+ require_paths:
91
+ - lib
92
+ required_ruby_version: !ruby/object:Gem::Requirement
93
+ none: false
94
+ requirements:
95
+ - - ">="
96
+ - !ruby/object:Gem::Version
97
+ hash: 3
98
+ segments:
99
+ - 0
100
+ version: "0"
101
+ required_rubygems_version: !ruby/object:Gem::Requirement
102
+ none: false
103
+ requirements:
104
+ - - ">="
105
+ - !ruby/object:Gem::Version
106
+ hash: 3
107
+ segments:
108
+ - 0
109
+ version: "0"
110
+ requirements: []
111
+
112
+ rubyforge_project:
113
+ rubygems_version: 1.3.7
114
+ signing_key:
115
+ specification_version: 3
116
+ summary: list-for is a list builder for an array of objects, easily allowing overriding of how any aspect of the list is generated
117
+ test_files: []
118
+