helperful 0.5.2

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.
@@ -0,0 +1,71 @@
1
+ = Changelog
2
+
3
+
4
+ == Release 0.5.2
5
+
6
+ * CHANGED: GitHub Gem Building is Defunct. The gem is now hosted on Gemcutter (see http://github.com/blog/515-gem-building-is-defunct)
7
+
8
+
9
+ == Release 0.5.1
10
+
11
+ * ADDED: `canonical_link_tag` helper provides the ability to generate Canonical Link tags used by search engine crawlers to determine the preferred url for a page (closes #255).
12
+
13
+ * CHANGED: run test against Rails 2.3.x but ensure compatibility with Rails 2.2.x.
14
+
15
+
16
+ == Release 0.5.0
17
+
18
+ * REMOVED: `sidebar` helper. It was nothing special and just a wrapper for a simple Rails execution.
19
+
20
+
21
+ == Release 0.4.0
22
+
23
+ * ADDED: `javascript` and `stylesheet` helpers.
24
+
25
+ * FIXED: GitHub now requires the Manifest file to be included in the repos.
26
+
27
+
28
+ == Release 0.3.1
29
+
30
+ * FIXED: `javascript_content_for` doesn't properly concat output when called with block (closes #183).
31
+
32
+
33
+ == Release 0.3.0
34
+
35
+ * ADDED: Added `javascript_content_for helper`. `javascript_content_for` combines the features of `content_for` and `javascript_tag` (closes #149).
36
+
37
+ * FIXED: `has_content?` raises an error when has_content isn't initialized (closes #179).
38
+
39
+ * CHANGED: Changed status to alpha and removed development warning (closes #151).
40
+
41
+
42
+ == Release 0.2.2
43
+
44
+ * FIXED: The "Unhandled special" error message for real!
45
+
46
+
47
+ == Release 0.2.1
48
+
49
+ * FIXED: RubyGems fails to generate the documentation with the following error message "Unhandled special".
50
+
51
+
52
+ == Release 0.2.0
53
+
54
+ * ADDED: Added Helperful::ContentHelper module (subsequently renamed to Helperful::ContentHelper) with #sidebar helper for passing content_for :sidebar to the layout. Even if this is a really simple method, this method adds a bit of semantic meaning to common application usage of content_for for created sidebars.
55
+
56
+ * ADDED: Added HelperfulAffiliationsHelper module (subsequently renamed to Helperful::AffiliationsHelper).
57
+
58
+ * ADDED: Added HelperfulAffiliationsHelper#tradedoubler_verification_tag helper for generating Tradedoubler verifications tags (subsequently renamed to Helperful::AffiliationsHelper).
59
+
60
+ * ADDED: Added #helperful method as shortcut for including helper modules from the Helperful namespace.
61
+
62
+ * ADDED: Packaged library as a GEM.
63
+
64
+ * CHANGED: Renamed TitleHelper to HelperfulTitleHelper to prevent conflicts with other common helpers (subsequently renamed to Helperful::TitleHelper).
65
+
66
+ * CHANGED: Renamed all helper modules from HelperfulHelperName to Helperful::HelperName.
67
+
68
+
69
+ == Release 0.1.0
70
+
71
+ * ADDED: Imported TitleHelper from Gist.
@@ -0,0 +1,24 @@
1
+ = License
2
+
3
+ (The MIT License)
4
+
5
+ Copyright (c) 2008-2009 Simone Carletti <weppos@weppos.net>
6
+
7
+ Permission is hereby granted, free of charge, to any person obtaining
8
+ a copy of this software and associated documentation files (the
9
+ "Software"), to deal in the Software without restriction, including
10
+ without limitation the rights to use, copy, modify, merge, publish,
11
+ distribute, sublicense, and/or sell copies of the Software, and to
12
+ permit persons to whom the Software is furnished to do so, subject to
13
+ the following conditions:
14
+
15
+ The above copyright notice and this permission notice shall be
16
+ included in all copies or substantial portions of the Software.
17
+
18
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
19
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
21
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
22
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
23
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
24
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,29 @@
1
+ CHANGELOG.rdoc
2
+ helperful.gemspec
3
+ init.rb
4
+ install.rb
5
+ lib/helperful/affiliations_helper.rb
6
+ lib/helperful/asset_tag_helper.rb
7
+ lib/helperful/content_helper.rb
8
+ lib/helperful/deprecations.rb
9
+ lib/helperful/javascript_helper.rb
10
+ lib/helperful/title_helper.rb
11
+ lib/helperful/version.rb
12
+ lib/helperful.rb
13
+ LICENSE.rdoc
14
+ Manifest
15
+ rails/init.rb
16
+ Rakefile
17
+ README.rdoc
18
+ tasks/helperful_tasks.rake
19
+ test/affiliations_helper_test.rb
20
+ test/asset_tag_helper_test.rb
21
+ test/content_helper_test.rb
22
+ test/fixtures/content/has_content.html.erb
23
+ test/fixtures/content/has_content_is_called_alone.html.erb
24
+ test/fixtures/layouts/has_content.html.erb
25
+ test/helperful_test.rb
26
+ test/javascript_helper_test.rb
27
+ test/test_helper.rb
28
+ test/title_helper_test.rb
29
+ uninstall.rb
@@ -0,0 +1,211 @@
1
+ = Helperful
2
+
3
+ Helperful aims to be a collection of useful and reusable Rails helpers.
4
+
5
+
6
+ == Requirements
7
+
8
+ * Ruby >= 1.8.6
9
+ * Rails >= 2.2.x (tested up to Rails 2.3.3)
10
+
11
+
12
+ == Plugin Installation
13
+
14
+ === As a Gem
15
+
16
+ This is the preferred way to install Helperful and the best way if you want install a stable version.
17
+ The GEM is hosted on {Gemcutter}[http://gemcutter.org/gems/helperful].
18
+
19
+ $ gem install helperful --source http://gemcutter.org
20
+
21
+ With Rails >= 2.2, you can specify the GEM dependency in your environment.rb file so that Rails will automatically check the requirement on startup.
22
+
23
+ Rails::Initializer.run do |config|
24
+
25
+ # other configurations
26
+ # ...
27
+
28
+ config.gem "helperful", :source => "http://gemcutter.org"
29
+
30
+ end
31
+
32
+
33
+ === As a Plugin
34
+
35
+ This is the preferred way if you want to live on the edge and install a development version.
36
+
37
+ $ script/plugin install git://github.com/weppos/helperful.git
38
+
39
+
40
+ == Getting Started
41
+
42
+ Helper methods are grouped into different files according to their scope.
43
+
44
+ Before using an helper method you should include the helper file in your Rails application,
45
+ as you would expected to do for a standard Rails helper.
46
+ All helpers belongs to the Helperful namespace to prevent conflicts with default Rails helpers.
47
+ Don't forget to add the namespace when including an helper from your controller.
48
+
49
+ class MyController < ApplicationController
50
+
51
+ # include the title_helper
52
+ helper 'helperful/title'
53
+
54
+ # include the title_helper passing the qualified the module name
55
+ helper Helperful::TitleHelper
56
+
57
+ end
58
+
59
+
60
+ Moreover, the <tt>Helperful</tt> library provides a helpful method called <tt>helperful</tt>.
61
+ It aliases the standard Rails <tt>ActionController::Base#helper</tt> method with the exception that it automatically prepends the <tt>helperful</tt> namespace when necessary.
62
+
63
+ class MyController < ApplicationController
64
+
65
+ # include the title_helper
66
+ helperful :title
67
+
68
+ # include the title_helper passing the qualified the module name
69
+ helperful Helperful::TitleHelper
70
+
71
+ end
72
+
73
+
74
+ The following lines are equivalent:
75
+
76
+ helper 'helperful/title'
77
+ helper :'helperful/title'
78
+ helper Helperful::TitleHelper
79
+ helperful 'title'
80
+ helperful :title
81
+ helperful Helperful::TitleHelper
82
+
83
+
84
+ The <tt>helperful</tt> methods accepts any parameter accepted by the original <tt>helper</tt> method.
85
+
86
+ helper 'helperful/title', 'helperful/affiliations'
87
+ helperful :title, :affiliations
88
+
89
+
90
+ See the Rails documentation for <tt>ActionController::Base#helper</tt> method
91
+ for more details about how to include an helper into a Rails application.
92
+
93
+ Once included, all helper methods are available in the View.
94
+
95
+ <html>
96
+ <title><%= title 'This is a title' %></title>
97
+ <body>
98
+ <%= yield %>
99
+ </body>
100
+ </html>
101
+
102
+
103
+ == Helpers
104
+
105
+ This is a short description of all available helpers.
106
+ Please refer to the documentation available at the beginning of any helper file for further details.
107
+
108
+ === Asset Tag Helper
109
+
110
+ Provides a set of helpers for generating HTML that links views to assets such as images, javascripts, stylesheets, and feeds.
111
+
112
+ === Affiliations Helper
113
+
114
+ Provides a set of helpers for working with online affiliations.
115
+
116
+ The <tt>tradedoubler_verification_tag</tt> helper method returns the site verification tag required by {Tradedoubler}[http://www.tradedoubler.com/] to verify the publisher account ownership.
117
+
118
+ # In your template
119
+ <html>
120
+ <head>
121
+ <%= tradedoubler_verification_tag('00112233') %>
122
+ </head>
123
+ <body>
124
+ This is your page content.
125
+ </body>
126
+ </html>
127
+
128
+ # Will produce the following output.
129
+ <html>
130
+ <head>
131
+ <%= tradedoubler_verification_tag('00112233') %>
132
+ </head>
133
+ <body>
134
+ <!-- TradeDoubler site verification 00112233 -->
135
+ </body>
136
+ </html>
137
+
138
+ === Content Helper
139
+
140
+ Provides a set of helpers for capturing and working with your page content in a more effective way.
141
+
142
+ The <tt>has_content?</tt> helper is a natural fulfillment for the original <tt>content_for</tt> helper.
143
+
144
+ <% content_for :foo do %>
145
+ <div>This is a foo content.</div>
146
+ <% end %>
147
+
148
+ <% has_content? :foo # => true %>
149
+ <% has_content? "foo" # => true %>
150
+
151
+
152
+ === Javascript Helper
153
+
154
+ Provides a set of helpers for working with JavaScript in your views.
155
+
156
+ The <tt>javascript_content_for</tt> helper combines the features of <tt>content_for</tt> and <tt>javascript_tag</tt> into a single helper.
157
+
158
+ <% javascript_content_for :head do %>
159
+ $("#id").hide();
160
+ <% end %>
161
+
162
+ The code above looks like much more readable than the following one. Isn't it?
163
+
164
+ <% javascript_content_for :head do; javascript_tag do %>
165
+ $("#id").hide();
166
+ <% end; end %>
167
+
168
+
169
+ === Title Helper
170
+
171
+ Provides an helper for managing page title in Rails views and layouts.
172
+
173
+ # Include the helper in your controller.
174
+ # You might want to include it in ApplicationController to make it available
175
+ # always and everywhere in your templates.
176
+ class ApplicationController < ActionController::Base
177
+ helperful :title
178
+ end
179
+
180
+ # Now you can use set a title in your action
181
+ # Example. index.html.rb
182
+ <h1><%= title 'This is a title' %></h1>
183
+
184
+ # And print the title with a :site decorator in your layout.
185
+ <html>
186
+ <head>
187
+ <title><%= title :site => 'My Cool Site!' %></title>
188
+ </head>
189
+ <body>
190
+ <%= yield %>
191
+ </body>
192
+ </html>
193
+
194
+ Originally available at http://gist.github.com/3840.
195
+
196
+
197
+ == Credits
198
+
199
+ Author:: {Simone Carletti}[http://www.simonecarletti.com/] <weppos@weppos.net>
200
+
201
+
202
+ == Resources
203
+
204
+ * {Homepage}[http://code.simonecarletti.com/helperful]
205
+ * {GitHub}[http://github.com/weppos/helperful]
206
+
207
+
208
+ == License
209
+
210
+ Copyright (c) 2008-2009 Simone Carletti, Helperful is released under the MIT license.
211
+
@@ -0,0 +1,47 @@
1
+ $:.unshift(File.dirname(__FILE__) + "/lib")
2
+
3
+ require 'rubygems'
4
+ require 'rake'
5
+ require 'echoe'
6
+ require 'helperful'
7
+
8
+
9
+ PKG_NAME = ENV['PKG_NAME'] || Helperful::GEM
10
+ PKG_VERSION = ENV['PKG_VERSION'] || Helperful::VERSION
11
+ RUBYFORGE_PROJECT = nil
12
+
13
+ if ENV['SNAPSHOT'].to_i == 1
14
+ PKG_VERSION << "." << Time.now.utc.strftime("%Y%m%d%H%M%S")
15
+ end
16
+
17
+
18
+ Echoe.new(PKG_NAME, PKG_VERSION) do |p|
19
+ p.author = "Simone Carletti"
20
+ p.email = "weppos@weppos.net"
21
+ p.summary = "A collection of useful Rails helpers."
22
+ p.url = "http://code.simonecarletti.com/helperful"
23
+ p.project = RUBYFORGE_PROJECT
24
+ p.description = <<-EOD
25
+ Helperful aims to be a collection of useful and reusable Rails helpers.
26
+ EOD
27
+
28
+ p.need_zip = true
29
+
30
+ p.development_dependencies += ["rake ~>0.8",
31
+ "echoe ~>3.1",
32
+ "mocha ~>0.9.7"]
33
+
34
+ p.rcov_options = ["-Itest -x mocha,rcov,Rakefile"]
35
+ end
36
+
37
+
38
+ begin
39
+ require 'code_statistics'
40
+ desc "Show library's code statistics"
41
+ task :stats do
42
+ CodeStatistics.new(["Helperful", "lib"],
43
+ ["Tests", "test"]).to_s
44
+ end
45
+ rescue LoadError
46
+ puts "CodeStatistics (Rails) is not available"
47
+ end
@@ -0,0 +1,40 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ Gem::Specification.new do |s|
4
+ s.name = %q{helperful}
5
+ s.version = "0.5.2"
6
+
7
+ s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
8
+ s.authors = ["Simone Carletti"]
9
+ s.date = %q{2009-10-12}
10
+ s.description = %q{ Helperful aims to be a collection of useful and reusable Rails helpers.
11
+ }
12
+ s.email = %q{weppos@weppos.net}
13
+ s.extra_rdoc_files = ["CHANGELOG.rdoc", "lib/helperful/affiliations_helper.rb", "lib/helperful/asset_tag_helper.rb", "lib/helperful/content_helper.rb", "lib/helperful/deprecations.rb", "lib/helperful/javascript_helper.rb", "lib/helperful/title_helper.rb", "lib/helperful/version.rb", "lib/helperful.rb", "LICENSE.rdoc", "README.rdoc", "tasks/helperful_tasks.rake"]
14
+ s.files = ["CHANGELOG.rdoc", "helperful.gemspec", "init.rb", "install.rb", "lib/helperful/affiliations_helper.rb", "lib/helperful/asset_tag_helper.rb", "lib/helperful/content_helper.rb", "lib/helperful/deprecations.rb", "lib/helperful/javascript_helper.rb", "lib/helperful/title_helper.rb", "lib/helperful/version.rb", "lib/helperful.rb", "LICENSE.rdoc", "Manifest", "rails/init.rb", "Rakefile", "README.rdoc", "tasks/helperful_tasks.rake", "test/affiliations_helper_test.rb", "test/asset_tag_helper_test.rb", "test/content_helper_test.rb", "test/fixtures/content/has_content.html.erb", "test/fixtures/content/has_content_is_called_alone.html.erb", "test/fixtures/layouts/has_content.html.erb", "test/helperful_test.rb", "test/javascript_helper_test.rb", "test/test_helper.rb", "test/title_helper_test.rb", "uninstall.rb"]
15
+ s.homepage = %q{http://code.simonecarletti.com/helperful}
16
+ s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Helperful", "--main", "README.rdoc"]
17
+ s.require_paths = ["lib"]
18
+ s.rubygems_version = %q{1.3.5}
19
+ s.summary = %q{A collection of useful Rails helpers.}
20
+ s.test_files = ["test/affiliations_helper_test.rb", "test/asset_tag_helper_test.rb", "test/content_helper_test.rb", "test/helperful_test.rb", "test/javascript_helper_test.rb", "test/test_helper.rb", "test/title_helper_test.rb"]
21
+
22
+ if s.respond_to? :specification_version then
23
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
24
+ s.specification_version = 3
25
+
26
+ if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
27
+ s.add_development_dependency(%q<rake>, ["~> 0.8"])
28
+ s.add_development_dependency(%q<echoe>, ["~> 3.1"])
29
+ s.add_development_dependency(%q<mocha>, ["~> 0.9.7"])
30
+ else
31
+ s.add_dependency(%q<rake>, ["~> 0.8"])
32
+ s.add_dependency(%q<echoe>, ["~> 3.1"])
33
+ s.add_dependency(%q<mocha>, ["~> 0.9.7"])
34
+ end
35
+ else
36
+ s.add_dependency(%q<rake>, ["~> 0.8"])
37
+ s.add_dependency(%q<echoe>, ["~> 3.1"])
38
+ s.add_dependency(%q<mocha>, ["~> 0.9.7"])
39
+ end
40
+ end
data/init.rb ADDED
@@ -0,0 +1 @@
1
+ require File.join(File.dirname(__FILE__), 'rails', 'init')
@@ -0,0 +1 @@
1
+ # Install hook code here
@@ -0,0 +1,46 @@
1
+ #
2
+ # = Helperful
3
+ #
4
+ # A collection of useful Rails helpers.
5
+ #
6
+ #
7
+ # Category:: Rails
8
+ # Package:: Helperful
9
+ # Author:: Simone Carletti <weppos@weppos.net>
10
+ # Copyright:: 2008-2009 The Authors
11
+ # License:: MIT License
12
+ #
13
+ #--
14
+ #
15
+ #++
16
+
17
+
18
+ Dir.glob(File.dirname(__FILE__) + '/helperful/*_helper.rb').each { |helper| require helper }
19
+ require 'helperful/deprecations'
20
+ require 'helperful/version'
21
+
22
+
23
+ module Helperful
24
+
25
+ NAME = 'Helperful'
26
+ GEM = 'helperful'
27
+ AUTHORS = ['Simone Carletti <weppos@weppos.net>']
28
+
29
+
30
+ module ControllerMixin
31
+
32
+ def helperful(*args, &block)
33
+ args.flatten.each do |arg|
34
+ case arg
35
+ when String, Symbol
36
+ file_name = 'helperful/' + arg.to_s.underscore
37
+ helper(file_name)
38
+ else
39
+ helper(arg, &block)
40
+ end
41
+ end
42
+ end
43
+
44
+ end
45
+
46
+ end