g_sectioned_shower 1.0.6

Sign up to get free protection for your applications and to get access to all the features.
data/History.txt ADDED
@@ -0,0 +1,20 @@
1
+ == 1.0.6 2009-10-29
2
+
3
+ * Fixed bug with associated objects that are nil still trying to send methods to get values back.
4
+
5
+
6
+ == 1.0.3 2009-04-07
7
+
8
+ * Refactored to use the Guilded rest path helper resolvers
9
+ * Took out the :link_helper option for now to gain some efficiency
10
+ * Added a scoped_by option for the show action object and any associated objects that need are deeply nested
11
+
12
+
13
+ == 1.0.2 2009-03-18
14
+
15
+ * Updated a Rails helpers
16
+
17
+
18
+ == 1.0.0 2009-03-12
19
+
20
+ * Initial release (ported from plugin)
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ (The MIT License)
2
+
3
+ Copyright (c) 2009 C. Jason Harrelson (midas)
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ 'Software'), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
20
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
21
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
22
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.rdoc ADDED
@@ -0,0 +1,78 @@
1
+ = g_sectioned_shower
2
+
3
+ http://github.com/midas/g_sectioned_shower/tree/master
4
+
5
+
6
+ == DESCRIPTION:
7
+
8
+ A Guilded (http://github.com/midas/guilded/tree/master) component that creates adaptable show (detail) views of a single
9
+ ActiveRecord object.
10
+
11
+
12
+ == FEATURES:
13
+
14
+ * Generates a detail view of an ActiveRecord object using a XHTML data list
15
+ * Can generate a status field (to integrate with AASM, etc)
16
+ * Adaptable title section
17
+ * Generates one main section and zero too many other sections
18
+ * Can generate different sections of the detail (not necessarily divided by domain model)
19
+ * Can pull details from associated has_one or belongs_to record
20
+ * Can generate link to associated has_one or belongs_to record
21
+ * Can pull details from associated has_many records (allows you to specify max and generates an efficient query)
22
+ * Can generate link to associated has_many records and the associations list page
23
+ * Can configure sections to dynamically display based on any conditions
24
+
25
+
26
+ == INSTALL:
27
+
28
+ sudo gem install midas-g_sectioned_shower
29
+
30
+ In Rails environement.rb file:
31
+
32
+ config.gem 'midas-g_sectioned_shower', :version => '1.0.3', :lib => 'g_sectioned_shower', :source => 'http://gems.github.com'
33
+
34
+
35
+ == USAGE:
36
+
37
+ View:
38
+
39
+ <%= g_sectioned_shower @item, :title_attr => :name, :date_format => :us_long, :status => @ticket.status,
40
+ :id => 'item-detail', :sections => [ { :attributes => [:is_active, :created_at, :updated_at },
41
+ { :title => 'Owner', :attributes => [:person], :person_attributes => [:first_name, :last_name, :address => 'Street Address'] } ]
42
+ %>
43
+
44
+ Results in:
45
+
46
+ coming soon ...
47
+
48
+
49
+ == REQUIREMENTS:
50
+
51
+ * Rails >= 2.2.0
52
+ * Guilded >= 0.0.9 (http://github.com/midas/guilded/tree/master)
53
+
54
+
55
+ == LICENSE:
56
+
57
+ (The MIT License)
58
+
59
+ Copyright (c) 2009 C. Jason Harrelson (midas)
60
+
61
+ Permission is hereby granted, free of charge, to any person obtaining
62
+ a copy of this software and associated documentation files (the
63
+ 'Software'), to deal in the Software without restriction, including
64
+ without limitation the rights to use, copy, modify, merge, publish,
65
+ distribute, sublicense, and/or sell copies of the Software, and to
66
+ permit persons to whom the Software is furnished to do so, subject to
67
+ the following conditions:
68
+
69
+ The above copyright notice and this permission notice shall be
70
+ included in all copies or substantial portions of the Software.
71
+
72
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
73
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
74
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
75
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
76
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
77
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
78
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/Rakefile ADDED
@@ -0,0 +1,58 @@
1
+ require 'rubygems'
2
+ require 'rake'
3
+
4
+ begin
5
+ require 'jeweler'
6
+ Jeweler::Tasks.new do |gem|
7
+ gem.name = "g_sectioned_shower"
8
+ gem.summary = %Q{A Guilded (http://github.com/midas/guilded/tree/master) component that creates adaptable show (detail) views of a single ActiveRecord object.}
9
+ gem.description = %Q{A Guilded (http://github.com/midas/guilded/tree/master) component that creates adaptable show (detail) views of a single ActiveRecord object.}
10
+ gem.email = "jason@lookforwardenterprises.com"
11
+ gem.homepage = "http://github.com/midas/tester"
12
+ gem.authors = ["C. Jason Harrelson (midas)"]
13
+ gem.add_dependency 'rails', ">= 2.2.0"
14
+ gem.add_dependency 'guilded', ">= 1.0.0"
15
+ gem.add_development_dependency "shoulda"
16
+ end
17
+ Jeweler::GemcutterTasks.new
18
+ rescue LoadError
19
+ puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
20
+ end
21
+
22
+ require 'rake/testtask'
23
+ Rake::TestTask.new(:test) do |test|
24
+ test.libs << 'lib' << 'test'
25
+ test.pattern = 'test/**/*_test.rb'
26
+ test.verbose = true
27
+ end
28
+
29
+ begin
30
+ require 'rcov/rcovtask'
31
+ Rcov::RcovTask.new do |test|
32
+ test.libs << 'test'
33
+ test.pattern = 'test/**/*_test.rb'
34
+ test.verbose = true
35
+ end
36
+ rescue LoadError
37
+ task :rcov do
38
+ abort "RCov is not available. In order to run rcov, you must: sudo gem install spicycode-rcov"
39
+ end
40
+ end
41
+
42
+ task :test => :check_dependencies
43
+
44
+ task :default => :test
45
+
46
+ require 'rake/rdoctask'
47
+ Rake::RDocTask.new do |rdoc|
48
+ if File.exist?('VERSION')
49
+ version = File.read('VERSION')
50
+ else
51
+ version = ""
52
+ end
53
+
54
+ rdoc.rdoc_dir = 'rdoc'
55
+ rdoc.title = "tester #{version}"
56
+ rdoc.rdoc_files.include('README*')
57
+ rdoc.rdoc_files.include('lib/**/*.rb')
58
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 1.0.6
@@ -0,0 +1,59 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run `rake gemspec`
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = %q{g_sectioned_shower}
8
+ s.version = "1.0.6"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["C. Jason Harrelson (midas)"]
12
+ s.date = %q{2009-10-29}
13
+ s.description = %q{A Guilded (http://github.com/midas/guilded/tree/master) component that creates adaptable show (detail) views of a single ActiveRecord object.}
14
+ s.email = %q{jason@lookforwardenterprises.com}
15
+ s.extra_rdoc_files = [
16
+ "LICENSE",
17
+ "README.rdoc"
18
+ ]
19
+ s.files = [
20
+ "History.txt",
21
+ "README.rdoc",
22
+ "Rakefile",
23
+ "VERSION",
24
+ "g_sectioned_shower.gemspec",
25
+ "lib/g_sectioned_shower.rb",
26
+ "lib/g_sectioned_shower/view_helpers.rb",
27
+ "script/console",
28
+ "script/destroy",
29
+ "script/generate",
30
+ "tasks/rspec.rake"
31
+ ]
32
+ s.homepage = %q{http://github.com/midas/tester}
33
+ s.rdoc_options = ["--charset=UTF-8"]
34
+ s.require_paths = ["lib"]
35
+ s.rubygems_version = %q{1.3.5}
36
+ s.summary = %q{A Guilded (http://github.com/midas/guilded/tree/master) component that creates adaptable show (detail) views of a single ActiveRecord object.}
37
+ s.test_files = [
38
+ "test/test_helper.rb"
39
+ ]
40
+
41
+ if s.respond_to? :specification_version then
42
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
43
+ s.specification_version = 3
44
+
45
+ if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
46
+ s.add_runtime_dependency(%q<rails>, [">= 2.2.0"])
47
+ s.add_runtime_dependency(%q<guilded>, [">= 1.0.0"])
48
+ s.add_development_dependency(%q<shoulda>, [">= 0"])
49
+ else
50
+ s.add_dependency(%q<rails>, [">= 2.2.0"])
51
+ s.add_dependency(%q<guilded>, [">= 1.0.0"])
52
+ s.add_dependency(%q<shoulda>, [">= 0"])
53
+ end
54
+ else
55
+ s.add_dependency(%q<rails>, [">= 2.2.0"])
56
+ s.add_dependency(%q<guilded>, [">= 1.0.0"])
57
+ s.add_dependency(%q<shoulda>, [">= 0"])
58
+ end
59
+ end
@@ -0,0 +1,275 @@
1
+ module GSectionedShower
2
+ module ViewHelpers
3
+
4
+ # GUIlded component.
5
+ #
6
+ # *parameters*
7
+ # ar_obj:: The ActiveRecord object containing the information.
8
+ #
9
+ # *options*
10
+ # id:: (required) The id of the element. Must be unique on the page.
11
+ # class::
12
+ # title_attr:: The attribute to use in the title.
13
+ # title_pre:: A string to override the first part of the title. defaults to the name
14
+ # of the active record object's class.
15
+ # date_format:: A symbol representing the date format to use. Defaults to :default.
16
+ # attributes:: A list of attributes to include in the main section.
17
+ # status:: True to include a status section.
18
+ # namespace:: A namespace to append onto all path helpers that are not overridden.
19
+ # sections::
20
+ # title:: The title for this section.
21
+ # attributes:: List of attibutes to include in this section.
22
+ # {associated_attribute_name}_attributes:: List of attributes from associated attribute to include.
23
+ # {associated_attribute_name}_max:: The max number of associated records to show. This will load
24
+ # all and display max unless you define a limited named scope on the respective model, allowing
25
+ # the association to be limited to the max, not returning items that will not be displayed.
26
+ # links:: A list of fields or field => path_helper to generate links to this item in the associated
27
+ # object.
28
+ # list_link:: (Boolean, string, or symbol)
29
+ #
30
+ def g_sectioned_shower( ar_obj, *args )
31
+
32
+ options = args.extract_options!
33
+ raise ArgumentError, "'title_attr' option required" unless options.include?( :title_attr )
34
+ raise ArgumentError, "'sections' option required" unless options.include?( :sections )
35
+ options.merge! :class => "shower" unless options.include?( :class )
36
+ options.merge! :exclude_css => true, :exclude_js => true
37
+ Guilded::Guilder.instance.add( :sectioned_shower, options )
38
+ html = ""
39
+
40
+ html << "<div class=\"status #{options[:status]}\">#{options[:status].to_s.humanize}</div>" if options[:status]
41
+
42
+ title_pre = options[:title_pre] || "#{ar_obj.class.to_s.underscore.humanize} |"
43
+ html << "<h2>#{title_pre} #{ar_obj.send( options[:title_attr].to_sym )}</h2>"
44
+
45
+ # Resolve sections and meta data there-in
46
+ sections = options[:sections]
47
+ reflections = ar_obj.class.inheritable_attributes[:reflections]
48
+
49
+ # Resolve main section
50
+ main_section = sections[0]
51
+ raise ArgumentError, "'attributes' option required within main section configuration" unless main_section.include?( :attributes )
52
+
53
+ methods, titles = Guilded::Rails::Helpers.resolve_field_methods_and_titles( main_section[:attributes], ar_obj )
54
+
55
+ html << "<div class=\"infoItem tableDisplay\"><dl>"
56
+
57
+ methods.each_with_index do |method, i|
58
+
59
+ # Handle associative relationships
60
+ if !reflections.nil? && reflections.has_key?( method.to_sym )
61
+ handle_associated( html, ar_obj, main_section, reflections, methods, i )
62
+ else
63
+ # Normal attribute from this model
64
+ html << "<dt>#{titles[i]}</dt>"
65
+ translate_method = "translate_#{method}".to_sym
66
+ val = ar_obj.send( method )
67
+ if respond_to?( translate_method )
68
+ html << "<dd>#{h( send( translate_method, val ) )}</dd>"
69
+ else
70
+ val = val.to_formatted_s( options[:date_format] || :default ) if val.respond_to?( :to_formatted_s )
71
+ html << "<dd>#{h( val )}</dd>"
72
+ end
73
+ end
74
+
75
+ end
76
+
77
+ html << "</dl><div class=\"clear\"></div></div>"
78
+
79
+ # Get rid of the main section as it was already handled
80
+ sections.delete_at( 0 )
81
+
82
+ # Resolve other sections
83
+ sections.each do |section|
84
+
85
+ raise ArgumentError, "'attributes' option required within main section configuration" unless section.include?( :attributes )
86
+ raise ArgumentError, "'title' option required within all section configurations except the main section" unless section.include?( :title )
87
+
88
+ methods, titles = Guilded::Rails::Helpers.resolve_field_methods_and_titles( section[:attributes], ar_obj )
89
+ html << "<div class=\"infoItem tableDisplay\"><h3>#{section[:title]}</h3><dl>"
90
+
91
+ methods.each_with_index do |method, i|
92
+
93
+ # Handle associative relationships
94
+ if !reflections.nil? && reflections.has_key?( method.to_sym )
95
+ handle_associated( html, ar_obj, section, reflections, methods, i )
96
+ else
97
+ # Normal attribute from this model
98
+ html << "<dt>#{titles[i]}</dt>"
99
+ translate_method = "translate_#{method}".to_sym
100
+ val = ar_obj.send( method )
101
+ if respond_to?( translate_method )
102
+ "<dd>#{h( send( translate_method, val ) )}</dd>"
103
+ else
104
+ html << "<dd>#{h( val )}</dd>"
105
+ end
106
+ end
107
+
108
+ end
109
+
110
+ html << "</dl><div class=\"clear\"></div></div>"
111
+
112
+ end
113
+
114
+ html
115
+ end
116
+
117
+ protected
118
+
119
+ def handle_associated( html, ar_obj, section, reflections, methods, index )
120
+ #TODO handle translation helpers if they exist.
121
+ reflection = reflections[methods[index].to_sym]
122
+
123
+ # Handle many relationships
124
+ if ['has_many', 'has_and_belongs_to_many'].include?( reflection.macro.to_s )
125
+ handle_associated_many( html, ar_obj, reflection, section, methods, index )
126
+ elsif ['belongs_to', 'has_one'].include?( reflection.macro.to_s ) # Handle single relationships
127
+ handle_associated_single( html, ar_obj, reflection, section, methods, index )
128
+ end
129
+
130
+ end
131
+
132
+ def handle_associated_single( html, ar_obj, reflection, section, methods, index )
133
+
134
+ assoc_obj_output = ""
135
+
136
+ if section.has_key?( "#{reflection.name.to_s.singularize}_attributes".to_sym )
137
+ # Handle object output if fields specified explicitly
138
+
139
+ attrs = section[ "#{reflection.name.to_s.singularize}_attributes".to_sym ]
140
+ scoped_by = section[ "#{reflection.name.to_s.singularize}_scoped_by".to_sym ]
141
+ rel_methods, rel_titles = Guilded::Rails::Helpers.resolve_field_methods_and_titles( attrs, ar_obj.send( reflection.name.to_s.to_sym ) )
142
+ assoc_obj = ar_obj.send( methods[index] )
143
+
144
+ rel_methods.each_with_index do |rel_method, rel_i|
145
+
146
+ method_output = h( assoc_obj.send( rel_method ) ) unless assoc_obj.nil?
147
+
148
+ links = section[:links]
149
+ throw "The 'links' option must have values in it, or be left out of the options for the section." if !links.nil? && links.empty?
150
+ unless links.nil?
151
+ link_entry = find_link_entry( links, rel_method ) # section.has_key?( :links )
152
+ opts = Hash.new
153
+ opts.merge!( :scoped_by => scoped_by ) unless scoped_by.nil?
154
+ path_helpers = Guilded::Rails::Helpers.resolve_rest_path_helpers( assoc_obj, opts )
155
+ end
156
+
157
+ if !link_entry.nil? #&& ( link_entry.is_a?( Symbol ) || link_entry.is_a?( String ) )
158
+ assoc_obj_link = @controller.send( path_helpers[:show_rest_helper], *(path_helpers[:show_rest_args] + [assoc_obj]) )
159
+ assoc_obj_output << "<dt>#{rel_titles[rel_i]}</dt><dd>#{link_to( method_output, assoc_obj_link )}</dd>"
160
+ #elsif !link_entry.nil? && link_entry.is_a?( Hash )
161
+ else
162
+ assoc_obj_output << "<dt>#{rel_titles[rel_i]}</dt><dd>#{h( method_output )}</dd>"
163
+ end
164
+
165
+ end
166
+
167
+ else
168
+ # Otherwise just use to_s for the object
169
+ assoc_obj_output = ar_obj.send( methods[index] ).to_s
170
+ end
171
+
172
+ html << assoc_obj_output
173
+ end
174
+
175
+ def handle_associated_many( html, ar_obj, reflection, section, methods, index )
176
+ reflected_name = reflection.name.to_s
177
+ reflected_singular_name = reflected_name.singularize
178
+ reflected_humanized_name = reflected_name.humanize
179
+ attrs_name = "#{reflected_singular_name}_attributes"
180
+ attrs = section[ attrs_name.to_sym ]
181
+ scoped_by = section[ "#{reflection.name.to_s.singularize}_scoped_by".to_sym ]
182
+ max_name = "#{reflected_singular_name}_max"
183
+ max = section[ max_name.to_sym ]
184
+ showing_less_than_all = max && max < ar_obj.send( methods[index] ).count
185
+ empty_embedded_ar_obj = reflection.klass.new
186
+ rel_methods, rel_titles = Guilded::Rails::Helpers.resolve_field_methods_and_titles( attrs, empty_embedded_ar_obj ) unless attrs.nil? || attrs.empty?
187
+
188
+ # Handle creating a link to the associated many objects list
189
+ # if section[:list_link]
190
+ #
191
+ # if section[:list_link].is_a?( Symbol )
192
+ # assoc_obj_index_path_helper = section[:list_link].to_s
193
+ # elsif section[:list_link].is_a?( String )
194
+ # assoc_obj_index_path_helper = section[:list_link]
195
+ # elsif section[:list_link] == true
196
+ # non_namespaced_index_path_helper = "#{ar_obj.class.to_s.tableize.singularize}_#{reflection.name.to_s}_path"
197
+ # if options[:namespace]
198
+ # assoc_obj_index_path_helper = "#{options[:namespace].to_s}_#{non_namespaced_index_path_helper}"
199
+ # else
200
+ # assoc_obj_index_path_helper = non_namespaced_index_path_helper
201
+ # end
202
+ # else
203
+ # throw "The 'list_link' parameter must be a String, Symbol or true"
204
+ # end
205
+ #
206
+ # if showing_less_than_all
207
+ # index_link = link_to( "More #{reflected_humanized_name}...", @controller.send( assoc_obj_index_path_helper, ar_obj ) )
208
+ # else
209
+ # index_link = link_to( "Jump to #{reflected_humanized_name}", @controller.send( assoc_obj_index_path_helper, ar_obj ) )
210
+ # end
211
+ #
212
+ # html << "<dt>#{index_link}</dt><dd></dd>"
213
+ #
214
+ # end
215
+
216
+ embedded_collection = (max && ar_obj.send( methods[index] ).respond_to?( :limited )) ? ar_obj.send( methods[index] ).limited( max ) : ar_obj.send( methods[index] )
217
+
218
+ # Loop through the collection of embeddeds
219
+ embedded_collection.each_with_index do |assoc_ar_obj, i|
220
+
221
+ break if max && i == max # Only display the max number specified (only necessary for when limited is not defined on AR class)
222
+ assoc_obj_output = ""
223
+
224
+ if section.has_key?( "#{reflected_singular_name}_attributes".to_sym )
225
+ # Handle object output if fields specified explicitly
226
+
227
+ rel_methods.each_with_index do |rel_method, rel_i|
228
+
229
+ method_output = h( assoc_ar_obj.send( rel_method ) ) unless assoc_obj.nil?
230
+
231
+ links = section[:links]
232
+ throw "The 'links' option must have values in it, or be left out of the options for the section." if !links.nil? && links.empty?
233
+ unless links.nil?
234
+ link_entry = find_link_entry( links, rel_method ) # section.has_key?( :links )
235
+ opts = Hash.new
236
+ opts.merge!( :scoped_by => scoped_by ) unless scoped_by.nil?
237
+ path_helpers = Guilded::Rails::Helpers.resolve_rest_path_helpers( assoc_ar_obj, opts )
238
+ end
239
+
240
+ if !link_entry.nil? #&& ( link_entry.is_a?( Symbol ) || link_entry.is_a?( String ) )
241
+ assoc_obj_link = @controller.send( path_helpers[:show_rest_helper], *(path_helpers[:show_rest_args] + [assoc_ar_obj]) )
242
+ assoc_obj_output << "<dt>#{rel_titles[rel_i]}</dt><dd>#{link_to( method_output, assoc_obj_link )}</dd>"
243
+ #elsif !link_entry.nil? && link_entry.is_a?( Hash )
244
+ else
245
+ assoc_obj_output << "<dt>#{rel_titles[rel_i]}</dt><dd>#{h( method_output )}</dd>"
246
+ end
247
+
248
+ end
249
+
250
+ else
251
+ # Otherwise just use to_s for the object
252
+ assoc_obj_output << assoc_ar_obj.to_s
253
+ end
254
+
255
+ html << assoc_obj_output
256
+ end
257
+
258
+ # output '...' if there are embeddeds that are not displayed and we did not render a link to embeddeds index
259
+ html << "<dt>...</dt><dd></dd>" if showing_less_than_all && ( section[:list_link].nil? || section[:list_link] == false )
260
+
261
+ end # def handle_associated_many
262
+
263
+ def find_link_entry( links, val )
264
+ links.each do |link|
265
+ #if link.is_a?( Hash )
266
+ # return link if link.has_key?( val.to_sym )
267
+ #else
268
+ return link if link == val.to_sym
269
+ #end
270
+ end
271
+ return nil
272
+ end
273
+
274
+ end
275
+ end
@@ -0,0 +1,12 @@
1
+ $:.unshift(File.dirname(__FILE__)) unless
2
+ $:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__)))
3
+
4
+ require 'g_sectioned_shower/view_helpers'
5
+
6
+ module GSectionedShower
7
+ VERSION = '1.0.6'
8
+ end
9
+
10
+ if defined?( ActionView::Base )
11
+ ActionView::Base.send( :include, GSectionedShower::ViewHelpers ) unless ActionView::Base.include?( GSectionedShower::ViewHelpers )
12
+ end
data/script/console ADDED
@@ -0,0 +1,10 @@
1
+ #!/usr/bin/env ruby
2
+ # File: script/console
3
+ irb = RUBY_PLATFORM =~ /(:?mswin|mingw)/ ? 'irb.bat' : 'irb'
4
+
5
+ libs = " -r irb/completion"
6
+ # Perhaps use a console_lib to store any extra methods I may want available in the cosole
7
+ # libs << " -r #{File.dirname(__FILE__) + '/../lib/console_lib/console_logger.rb'}"
8
+ libs << " -r #{File.dirname(__FILE__) + '/../lib/g_sectioned_shower.rb'}"
9
+ puts "Loading g_sectioned_shower gem"
10
+ exec "#{irb} #{libs} --simple-prompt"
data/script/destroy ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+ APP_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..'))
3
+
4
+ begin
5
+ require 'rubigen'
6
+ rescue LoadError
7
+ require 'rubygems'
8
+ require 'rubigen'
9
+ end
10
+ require 'rubigen/scripts/destroy'
11
+
12
+ ARGV.shift if ['--help', '-h'].include?(ARGV[0])
13
+ RubiGen::Base.use_component_sources! [:rubygems, :newgem, :newgem_theme, :test_unit]
14
+ RubiGen::Scripts::Destroy.new.run(ARGV)
data/script/generate ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+ APP_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..'))
3
+
4
+ begin
5
+ require 'rubigen'
6
+ rescue LoadError
7
+ require 'rubygems'
8
+ require 'rubigen'
9
+ end
10
+ require 'rubigen/scripts/generate'
11
+
12
+ ARGV.shift if ['--help', '-h'].include?(ARGV[0])
13
+ RubiGen::Base.use_component_sources! [:rubygems, :newgem, :newgem_theme, :test_unit]
14
+ RubiGen::Scripts::Generate.new.run(ARGV)
data/tasks/rspec.rake ADDED
@@ -0,0 +1,21 @@
1
+ begin
2
+ require 'spec'
3
+ rescue LoadError
4
+ require 'rubygems'
5
+ require 'spec'
6
+ end
7
+ begin
8
+ require 'spec/rake/spectask'
9
+ rescue LoadError
10
+ puts <<-EOS
11
+ To use rspec for testing you must install rspec gem:
12
+ gem install rspec
13
+ EOS
14
+ exit(0)
15
+ end
16
+
17
+ desc "Run the specs under spec/models"
18
+ Spec::Rake::SpecTask.new do |t|
19
+ t.spec_opts = ['--options', "spec/spec.opts"]
20
+ t.spec_files = FileList['spec/**/*_spec.rb']
21
+ end
@@ -0,0 +1,10 @@
1
+ require 'rubygems'
2
+ require 'test/unit'
3
+ require 'shoulda'
4
+
5
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
6
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
7
+ require 'g_sectioned_shower'
8
+
9
+ class Test::Unit::TestCase
10
+ end
metadata ADDED
@@ -0,0 +1,96 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: g_sectioned_shower
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.6
5
+ platform: ruby
6
+ authors:
7
+ - C. Jason Harrelson (midas)
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2009-10-29 00:00:00 -05:00
13
+ default_executable:
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: rails
17
+ type: :runtime
18
+ version_requirement:
19
+ version_requirements: !ruby/object:Gem::Requirement
20
+ requirements:
21
+ - - ">="
22
+ - !ruby/object:Gem::Version
23
+ version: 2.2.0
24
+ version:
25
+ - !ruby/object:Gem::Dependency
26
+ name: guilded
27
+ type: :runtime
28
+ version_requirement:
29
+ version_requirements: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: 1.0.0
34
+ version:
35
+ - !ruby/object:Gem::Dependency
36
+ name: shoulda
37
+ type: :development
38
+ version_requirement:
39
+ version_requirements: !ruby/object:Gem::Requirement
40
+ requirements:
41
+ - - ">="
42
+ - !ruby/object:Gem::Version
43
+ version: "0"
44
+ version:
45
+ description: A Guilded (http://github.com/midas/guilded/tree/master) component that creates adaptable show (detail) views of a single ActiveRecord object.
46
+ email: jason@lookforwardenterprises.com
47
+ executables: []
48
+
49
+ extensions: []
50
+
51
+ extra_rdoc_files:
52
+ - LICENSE
53
+ - README.rdoc
54
+ files:
55
+ - History.txt
56
+ - README.rdoc
57
+ - Rakefile
58
+ - VERSION
59
+ - g_sectioned_shower.gemspec
60
+ - lib/g_sectioned_shower.rb
61
+ - lib/g_sectioned_shower/view_helpers.rb
62
+ - script/console
63
+ - script/destroy
64
+ - script/generate
65
+ - tasks/rspec.rake
66
+ - LICENSE
67
+ has_rdoc: true
68
+ homepage: http://github.com/midas/tester
69
+ licenses: []
70
+
71
+ post_install_message:
72
+ rdoc_options:
73
+ - --charset=UTF-8
74
+ require_paths:
75
+ - lib
76
+ required_ruby_version: !ruby/object:Gem::Requirement
77
+ requirements:
78
+ - - ">="
79
+ - !ruby/object:Gem::Version
80
+ version: "0"
81
+ version:
82
+ required_rubygems_version: !ruby/object:Gem::Requirement
83
+ requirements:
84
+ - - ">="
85
+ - !ruby/object:Gem::Version
86
+ version: "0"
87
+ version:
88
+ requirements: []
89
+
90
+ rubyforge_project:
91
+ rubygems_version: 1.3.5
92
+ signing_key:
93
+ specification_version: 3
94
+ summary: A Guilded (http://github.com/midas/guilded/tree/master) component that creates adaptable show (detail) views of a single ActiveRecord object.
95
+ test_files:
96
+ - test/test_helper.rb