weppos-helperful 0.5.0 → 0.5.1
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.
- data/CHANGELOG.rdoc +12 -5
- data/README.rdoc +11 -5
- data/Rakefile +7 -11
- data/helperful.gemspec +12 -12
- data/lib/helperful/asset_tag_helper.rb +27 -0
- data/lib/helperful/version.rb +1 -1
- data/test/asset_tag_helper_test.rb +42 -7
- data/test/content_helper_test.rb +5 -2
- data/test/test_helper.rb +9 -1
- metadata +9 -7
data/CHANGELOG.rdoc
CHANGED
@@ -1,28 +1,35 @@
|
|
1
1
|
= Changelog
|
2
2
|
|
3
3
|
|
4
|
+
== Release 0.5.1
|
5
|
+
|
6
|
+
* 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).
|
7
|
+
|
8
|
+
* CHANGED: run test against Rails 2.3.x but ensure compatibility with Rails 2.2.x.
|
9
|
+
|
10
|
+
|
4
11
|
== Release 0.5.0
|
5
12
|
|
6
|
-
* REMOVED:
|
13
|
+
* REMOVED: `sidebar` helper. It was nothing special and just a wrapper for a simple Rails execution.
|
7
14
|
|
8
15
|
|
9
16
|
== Release 0.4.0
|
10
17
|
|
11
|
-
* ADDED: javascript and stylesheet
|
18
|
+
* ADDED: `javascript` and `stylesheet` helpers.
|
12
19
|
|
13
20
|
* FIXED: GitHub now requires the Manifest file to be included in the repos.
|
14
21
|
|
15
22
|
|
16
23
|
== Release 0.3.1
|
17
24
|
|
18
|
-
* FIXED:
|
25
|
+
* FIXED: `javascript_content_for` doesn't properly concat output when called with block (closes #183).
|
19
26
|
|
20
27
|
|
21
28
|
== Release 0.3.0
|
22
29
|
|
23
|
-
* ADDED: Added
|
30
|
+
* ADDED: Added `javascript_content_for helper`. `javascript_content_for` combines the features of `content_for` and `javascript_tag` (closes #149).
|
24
31
|
|
25
|
-
* FIXED: has_content
|
32
|
+
* FIXED: `has_content?` raises an error when has_content isn't initialized (closes #179).
|
26
33
|
|
27
34
|
* CHANGED: Changed status to alpha and removed development warning (closes #151).
|
28
35
|
|
data/README.rdoc
CHANGED
@@ -3,6 +3,12 @@
|
|
3
3
|
Helperful aims to be a collection of useful and reusable Rails helpers.
|
4
4
|
|
5
5
|
|
6
|
+
== Requirements
|
7
|
+
|
8
|
+
* Ruby >= 1.8.6
|
9
|
+
* Rails >= 2.2.x (tested up to Rails 2.3.3)
|
10
|
+
|
11
|
+
|
6
12
|
== Plugin Installation
|
7
13
|
|
8
14
|
=== As a Gem
|
@@ -45,7 +51,7 @@ Don't forget to add the namespace when including an helper from your controller.
|
|
45
51
|
end
|
46
52
|
|
47
53
|
|
48
|
-
Moreover, the <tt>Helperful</tt> library provides a helpful method called <tt>helperful</tt>.
|
54
|
+
Moreover, the <tt>Helperful</tt> library provides a helpful method called <tt>helperful</tt>.
|
49
55
|
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.
|
50
56
|
|
51
57
|
class MyController < ApplicationController
|
@@ -70,7 +76,7 @@ The following lines are equivalent:
|
|
70
76
|
|
71
77
|
|
72
78
|
The <tt>helperful</tt> methods accepts any parameter accepted by the original <tt>helper</tt> method.
|
73
|
-
|
79
|
+
|
74
80
|
helper 'helperful/title', 'helperful/affiliations'
|
75
81
|
helperful :title, :affiliations
|
76
82
|
|
@@ -112,7 +118,7 @@ The <tt>tradedoubler_verification_tag</tt> helper method returns the site verifi
|
|
112
118
|
This is your page content.
|
113
119
|
</body>
|
114
120
|
</html>
|
115
|
-
|
121
|
+
|
116
122
|
# Will produce the following output.
|
117
123
|
<html>
|
118
124
|
<head>
|
@@ -132,7 +138,7 @@ The <tt>has_content?</tt> helper is a natural fulfillment for the original <tt>c
|
|
132
138
|
<% content_for :foo do %>
|
133
139
|
<div>This is a foo content.</div>
|
134
140
|
<% end %>
|
135
|
-
|
141
|
+
|
136
142
|
<% has_content? :foo # => true %>
|
137
143
|
<% has_content? "foo" # => true %>
|
138
144
|
|
@@ -195,5 +201,5 @@ Author:: {Simone Carletti}[http://www.simonecarletti.com/] <weppos@weppos.net>
|
|
195
201
|
|
196
202
|
== License
|
197
203
|
|
198
|
-
Copyright (c) 2008-2009 Simone Carletti, Helperful is released under the MIT license.
|
204
|
+
Copyright (c) 2008-2009 Simone Carletti, Helperful is released under the MIT license.
|
199
205
|
|
data/Rakefile
CHANGED
@@ -8,10 +8,6 @@ require 'helperful'
|
|
8
8
|
|
9
9
|
PKG_NAME = ENV['PKG_NAME'] || Helperful::GEM
|
10
10
|
PKG_VERSION = ENV['PKG_VERSION'] || Helperful::VERSION
|
11
|
-
PKG_FILES = FileList.new("{lib,rails,tasks,test}/**/*") do |files|
|
12
|
-
files.include %w(*.{rdoc,rb})
|
13
|
-
files.include %w(Rakefile)
|
14
|
-
end
|
15
11
|
RUBYFORGE_PROJECT = nil
|
16
12
|
|
17
13
|
if ENV['SNAPSHOT'].to_i == 1
|
@@ -23,19 +19,19 @@ Echoe.new(PKG_NAME, PKG_VERSION) do |p|
|
|
23
19
|
p.author = "Simone Carletti"
|
24
20
|
p.email = "weppos@weppos.net"
|
25
21
|
p.summary = "A collection of useful Rails helpers."
|
22
|
+
p.url = "http://code.simonecarletti.com/helperful"
|
23
|
+
p.project = RUBYFORGE_PROJECT
|
26
24
|
p.description = <<-EOD
|
27
25
|
Helperful aims to be a collection of useful and reusable Rails helpers.
|
28
26
|
EOD
|
29
|
-
p.url = "http://code.simonecarletti.com/helperful"
|
30
|
-
p.project = RUBYFORGE_PROJECT
|
31
27
|
|
32
28
|
p.need_zip = true
|
33
|
-
p.rcov_options = ["--main README.rdoc -x Rakefile -x mocha -x rcov"]
|
34
|
-
p.rdoc_pattern = /^(lib|CHANGELOG.rdoc|README.rdoc|LICENSE.rdoc)/
|
35
29
|
|
36
|
-
p.development_dependencies += ["rake
|
37
|
-
"echoe
|
38
|
-
"mocha
|
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"]
|
39
35
|
end
|
40
36
|
|
41
37
|
|
data/helperful.gemspec
CHANGED
@@ -2,15 +2,15 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = %q{helperful}
|
5
|
-
s.version = "0.5.
|
5
|
+
s.version = "0.5.1"
|
6
6
|
|
7
7
|
s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
|
8
8
|
s.authors = ["Simone Carletti"]
|
9
|
-
s.date = %q{2009-
|
9
|
+
s.date = %q{2009-08-20}
|
10
10
|
s.description = %q{ Helperful aims to be a collection of useful and reusable Rails helpers.
|
11
11
|
}
|
12
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"]
|
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
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
15
|
s.homepage = %q{http://code.simonecarletti.com/helperful}
|
16
16
|
s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Helperful", "--main", "README.rdoc"]
|
@@ -24,17 +24,17 @@ Gem::Specification.new do |s|
|
|
24
24
|
s.specification_version = 3
|
25
25
|
|
26
26
|
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
27
|
-
s.add_development_dependency(%q<rake>, ["
|
28
|
-
s.add_development_dependency(%q<echoe>, ["
|
29
|
-
s.add_development_dependency(%q<mocha>, ["
|
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
30
|
else
|
31
|
-
s.add_dependency(%q<rake>, ["
|
32
|
-
s.add_dependency(%q<echoe>, ["
|
33
|
-
s.add_dependency(%q<mocha>, ["
|
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
34
|
end
|
35
35
|
else
|
36
|
-
s.add_dependency(%q<rake>, ["
|
37
|
-
s.add_dependency(%q<echoe>, ["
|
38
|
-
s.add_dependency(%q<mocha>, ["
|
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
39
|
end
|
40
40
|
end
|
@@ -37,6 +37,33 @@ module Helperful
|
|
37
37
|
base.included_modules.include?(ActionView::Helpers::AssetTagHelper) || include(ActionView::Helpers::AssetTagHelper)
|
38
38
|
end
|
39
39
|
end
|
40
|
+
|
41
|
+
# Returns a link tag that search engine crawlers may use to determine
|
42
|
+
# the preferred version of a page with multiple URLs.
|
43
|
+
#
|
44
|
+
# More details about the canonical link tag are available
|
45
|
+
# at the following sources:
|
46
|
+
# * http://www.mattcutts.com/blog/canonical-link-tag/
|
47
|
+
# * http://googlewebmastercentral.blogspot.com/2009/02/specify-your-canonical.html
|
48
|
+
#
|
49
|
+
# Control the link options in url_for format using the +url_options+.
|
50
|
+
#
|
51
|
+
# ==== Examples
|
52
|
+
#
|
53
|
+
# canonical_link_tag
|
54
|
+
# # => <link rel="canonical" href=http://www.currenthost.com/controller/action" />
|
55
|
+
# canonical_link_tag(:action => "show")
|
56
|
+
# # => <link rel="canonical" href=http://www.currenthost.com/controller/show" />
|
57
|
+
# canonical_link_tag("http://www.example.com/product.php?item=swedish-fish")
|
58
|
+
# # => <link rel="canonical" href="http://www.example.com/product.php?item=swedish-fish" />
|
59
|
+
#
|
60
|
+
def canonical_link_tag(url_options = {})
|
61
|
+
tag(
|
62
|
+
"link",
|
63
|
+
"rel" => "canonical",
|
64
|
+
"href" => url_options.is_a?(Hash) ? url_for(url_options.merge(:only_path => false)) : url_options
|
65
|
+
)
|
66
|
+
end
|
40
67
|
|
41
68
|
# Converts given +files+ in javascript include statements
|
42
69
|
# and appends them in the head section of the page.
|
data/lib/helperful/version.rb
CHANGED
@@ -7,36 +7,71 @@ class AssetTagHelperTest < ActionView::TestCase
|
|
7
7
|
ActionController::Base.perform_caching = false
|
8
8
|
ActionController::Base.asset_host = nil
|
9
9
|
ENV.delete('RAILS_ASSET_ID')
|
10
|
+
|
11
|
+
@controller = Class.new do
|
12
|
+
attr_accessor :request
|
13
|
+
def url_for(*args)
|
14
|
+
case arg = args.first
|
15
|
+
when String
|
16
|
+
arg
|
17
|
+
when Hash
|
18
|
+
"http://www.example.com?#{arg.to_param}"
|
19
|
+
else
|
20
|
+
"http://www.example.com"
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end.new
|
24
|
+
|
25
|
+
@request = Class.new do
|
26
|
+
def protocol() 'http://' end
|
27
|
+
def ssl?() false end
|
28
|
+
def host_with_port() 'localhost' end
|
29
|
+
end.new
|
30
|
+
|
31
|
+
@controller.request = @request
|
10
32
|
end
|
11
|
-
|
12
|
-
|
33
|
+
|
34
|
+
|
35
|
+
CanonicalToTag = {
|
36
|
+
%(canonical_link_tag) => %(<link href="http://www.example.com?only_path=false" rel="canonical" />),
|
37
|
+
%(canonical_link_tag(:action => "show")) => %(<link href="http://www.example.com?action=show&only_path=false" rel="canonical" />),
|
38
|
+
%(canonical_link_tag("http://localhost/show")) => %(<link href="http://localhost/show" rel="canonical" />),
|
39
|
+
}
|
40
|
+
|
41
|
+
test "canonical_link_tag" do
|
42
|
+
CanonicalToTag.each do |method, tag|
|
43
|
+
assert_dom_equal(tag, eval(method))
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
|
13
48
|
JavascriptToTag = {
|
14
49
|
%(javascript) => %(javascript_include_tag),
|
15
50
|
%(javascript(["foo", "bar"])) => %(javascript_include_tag(["foo", "bar"])),
|
16
51
|
%(javascript("foo", "bar")) => %(javascript_include_tag("foo", "bar")),
|
17
52
|
%(javascript("foo", "bar", :cache => true)) => %(javascript_include_tag("foo", "bar", :cache => true)),
|
18
53
|
}
|
19
|
-
|
54
|
+
|
20
55
|
test "javascript" do
|
21
56
|
JavascriptToTag.each do |method, content|
|
22
57
|
expects(:content_for).with(:head, eval(content))
|
23
58
|
eval(method)
|
24
59
|
end
|
25
60
|
end
|
26
|
-
|
27
|
-
|
61
|
+
|
62
|
+
|
28
63
|
StylesheetToTag = {
|
29
64
|
%(stylesheet) => %(stylesheet_link_tag),
|
30
65
|
%(stylesheet(["foo", "bar"])) => %(stylesheet_link_tag(["foo", "bar"])),
|
31
66
|
%(stylesheet("foo", "bar")) => %(stylesheet_link_tag("foo", "bar")),
|
32
67
|
%(stylesheet("foo", "bar", :cache => true)) => %(stylesheet_link_tag("foo", "bar", :cache => true)),
|
33
68
|
}
|
34
|
-
|
69
|
+
|
35
70
|
test "stylesheet" do
|
36
71
|
StylesheetToTag.each do |method, content|
|
37
72
|
expects(:content_for).with(:head, eval(content))
|
38
73
|
eval(method)
|
39
74
|
end
|
40
75
|
end
|
41
|
-
|
76
|
+
|
42
77
|
end
|
data/test/content_helper_test.rb
CHANGED
@@ -20,8 +20,11 @@ end
|
|
20
20
|
ContentController.view_paths = [ File.dirname(__FILE__) + "/fixtures/" ]
|
21
21
|
|
22
22
|
|
23
|
-
class ContentTest <
|
24
|
-
|
23
|
+
class ContentTest < ActionController::TestCase
|
24
|
+
|
25
|
+
# Compatibility workaround for Rails ~> 2.2.0
|
26
|
+
tests ContentController
|
27
|
+
|
25
28
|
def setup
|
26
29
|
@controller = ContentController.new
|
27
30
|
@request = ActionController::TestRequest.new
|
data/test/test_helper.rb
CHANGED
@@ -16,7 +16,14 @@
|
|
16
16
|
|
17
17
|
|
18
18
|
require 'rubygems'
|
19
|
-
gem 'rails', '2.
|
19
|
+
gem 'rails', '2.3.3'
|
20
|
+
gem 'mocha', '0.9.7'
|
21
|
+
|
22
|
+
# Remember! Due to some Mocha internal changes,
|
23
|
+
# Rails 2.2.x requires Mocha 0.9.5 and
|
24
|
+
# Rails 2.3.x requires Mocha 0.9.7
|
25
|
+
# gem 'rails', '2.2.2'
|
26
|
+
# gem 'mocha', '0.9.5'
|
20
27
|
|
21
28
|
require 'mocha'
|
22
29
|
require 'test/unit'
|
@@ -35,5 +42,6 @@ RAILS_ENV = 'test' unless defined? RAILS_ENV
|
|
35
42
|
ActionController::Base.logger = nil
|
36
43
|
ActionController::Routing::Routes.reload rescue nil
|
37
44
|
|
45
|
+
|
38
46
|
# Unit tests for Helpers are based on unit tests created and developed by Rails core team.
|
39
47
|
# See action_pack/test/abstract_unit for more details.
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: weppos-helperful
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Simone Carletti
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-
|
12
|
+
date: 2009-08-20 00:00:00 -07:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -18,7 +18,7 @@ dependencies:
|
|
18
18
|
version_requirement:
|
19
19
|
version_requirements: !ruby/object:Gem::Requirement
|
20
20
|
requirements:
|
21
|
-
- -
|
21
|
+
- - ~>
|
22
22
|
- !ruby/object:Gem::Version
|
23
23
|
version: "0.8"
|
24
24
|
version:
|
@@ -28,7 +28,7 @@ dependencies:
|
|
28
28
|
version_requirement:
|
29
29
|
version_requirements: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- -
|
31
|
+
- - ~>
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: "3.1"
|
34
34
|
version:
|
@@ -38,9 +38,9 @@ dependencies:
|
|
38
38
|
version_requirement:
|
39
39
|
version_requirements: !ruby/object:Gem::Requirement
|
40
40
|
requirements:
|
41
|
-
- -
|
41
|
+
- - ~>
|
42
42
|
- !ruby/object:Gem::Version
|
43
|
-
version:
|
43
|
+
version: 0.9.7
|
44
44
|
version:
|
45
45
|
description: Helperful aims to be a collection of useful and reusable Rails helpers.
|
46
46
|
email: weppos@weppos.net
|
@@ -60,6 +60,7 @@ extra_rdoc_files:
|
|
60
60
|
- lib/helperful.rb
|
61
61
|
- LICENSE.rdoc
|
62
62
|
- README.rdoc
|
63
|
+
- tasks/helperful_tasks.rake
|
63
64
|
files:
|
64
65
|
- CHANGELOG.rdoc
|
65
66
|
- helperful.gemspec
|
@@ -92,6 +93,7 @@ files:
|
|
92
93
|
- uninstall.rb
|
93
94
|
has_rdoc: false
|
94
95
|
homepage: http://code.simonecarletti.com/helperful
|
96
|
+
licenses:
|
95
97
|
post_install_message:
|
96
98
|
rdoc_options:
|
97
99
|
- --line-numbers
|
@@ -117,7 +119,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
117
119
|
requirements: []
|
118
120
|
|
119
121
|
rubyforge_project:
|
120
|
-
rubygems_version: 1.
|
122
|
+
rubygems_version: 1.3.5
|
121
123
|
signing_key:
|
122
124
|
specification_version: 3
|
123
125
|
summary: A collection of useful Rails helpers.
|