acts_as_linkable 0.0.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/README +13 -0
- data/Rakefile +58 -0
- data/acts_as_linkable.gemspec +46 -0
- data/install.rb +1 -0
- data/lib/acts_as_linkable.rb +6 -0
- data/lib/acts_as_linkable_core.rb +31 -0
- data/rails/init.rb +2 -0
- data/test/acts_as_linkable_test.rb +8 -0
- data/test/test_helper.rb +3 -0
- data/uninstall.rb +1 -0
- metadata +76 -0
data/README
ADDED
data/Rakefile
ADDED
@@ -0,0 +1,58 @@
|
|
1
|
+
require 'rake'
|
2
|
+
require 'rake/testtask'
|
3
|
+
require 'rake/rdoctask'
|
4
|
+
|
5
|
+
VERSION = "0.0.1"
|
6
|
+
|
7
|
+
desc 'Default: run unit tests.'
|
8
|
+
task :default => :test
|
9
|
+
|
10
|
+
desc 'Test the anaf_habtm plugin.'
|
11
|
+
Rake::TestTask.new(:test) do |t|
|
12
|
+
t.libs << 'lib'
|
13
|
+
t.libs << 'test'
|
14
|
+
t.pattern = 'test/**/*_test.rb'
|
15
|
+
t.verbose = true
|
16
|
+
end
|
17
|
+
|
18
|
+
desc 'Generate documentation for the anaf_habtm plugin.'
|
19
|
+
Rake::RDocTask.new(:rdoc) do |rdoc|
|
20
|
+
rdoc.rdoc_dir = 'rdoc'
|
21
|
+
rdoc.title = 'AnafHabtm'
|
22
|
+
rdoc.options << '--line-numbers' << '--inline-source'
|
23
|
+
rdoc.rdoc_files.include('README')
|
24
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
25
|
+
end
|
26
|
+
PKG_FILES = FileList[
|
27
|
+
'acts_as_linkable.gemspec',
|
28
|
+
'Gemfile',
|
29
|
+
'install.rb',
|
30
|
+
'Rakefile', 'README', 'uninstall.rb',
|
31
|
+
'lib/**/*',
|
32
|
+
'rails/**/*',
|
33
|
+
'test/**/*'
|
34
|
+
]
|
35
|
+
|
36
|
+
begin
|
37
|
+
require 'jeweler'
|
38
|
+
Jeweler::Tasks.new do |s|
|
39
|
+
s.name = "acts_as_linkable"
|
40
|
+
s.version = VERSION
|
41
|
+
s.author = "Tyler Gannon"
|
42
|
+
s.email = "t--g__a--nnon@gmail.com"
|
43
|
+
s.homepage = "http://github.com/tylergannon/acts_as_linkable"
|
44
|
+
s.platform = Gem::Platform::RUBY
|
45
|
+
s.description = "Helper methods for defining link characteristics on objects."
|
46
|
+
s.summary = "Acts As Linkable helper methods."
|
47
|
+
s.files = PKG_FILES.to_a
|
48
|
+
s.require_path = "lib"
|
49
|
+
s.has_rdoc = false
|
50
|
+
s.extra_rdoc_files = ["README"]
|
51
|
+
|
52
|
+
end
|
53
|
+
rescue LoadError
|
54
|
+
puts "Jeweler not available. Install it with: gem install jeweler"
|
55
|
+
end
|
56
|
+
|
57
|
+
|
58
|
+
|
@@ -0,0 +1,46 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = %q{acts_as_linkable}
|
8
|
+
s.version = "0.0.1"
|
9
|
+
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = ["Tyler Gannon"]
|
12
|
+
s.date = %q{2010-07-11}
|
13
|
+
s.description = %q{Helper methods for defining link characteristics on objects.}
|
14
|
+
s.email = %q{t--g__a--nnon@gmail.com}
|
15
|
+
s.extra_rdoc_files = [
|
16
|
+
"README"
|
17
|
+
]
|
18
|
+
s.files = [
|
19
|
+
"README",
|
20
|
+
"Rakefile",
|
21
|
+
"acts_as_linkable.gemspec",
|
22
|
+
"install.rb",
|
23
|
+
"lib/acts_as_linkable.rb",
|
24
|
+
"lib/acts_as_linkable_core.rb",
|
25
|
+
"rails/init.rb",
|
26
|
+
"test/acts_as_linkable_test.rb",
|
27
|
+
"test/test_helper.rb",
|
28
|
+
"uninstall.rb"
|
29
|
+
]
|
30
|
+
s.homepage = %q{http://github.com/tylergannon/acts_as_linkable}
|
31
|
+
s.rdoc_options = ["--charset=UTF-8"]
|
32
|
+
s.require_paths = ["lib"]
|
33
|
+
s.rubygems_version = %q{1.3.7}
|
34
|
+
s.summary = %q{Acts As Linkable helper methods.}
|
35
|
+
|
36
|
+
if s.respond_to? :specification_version then
|
37
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
38
|
+
s.specification_version = 3
|
39
|
+
|
40
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
41
|
+
else
|
42
|
+
end
|
43
|
+
else
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
data/install.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
# Install hook code here
|
@@ -0,0 +1,31 @@
|
|
1
|
+
module ActsAsLinkable
|
2
|
+
module ActiveRecordExtensions
|
3
|
+
def acts_as_linkable(opts={}, &block)
|
4
|
+
class_eval "def link_attr; #{opts.inspect}; end;"
|
5
|
+
end
|
6
|
+
end
|
7
|
+
|
8
|
+
module ActionViewExtensions
|
9
|
+
def link(obj)
|
10
|
+
return unless obj
|
11
|
+
if (obj.class == Array) || (obj.class == ActiveRecord::Relation)
|
12
|
+
obj.map{|v| link(v)}.join(", ")
|
13
|
+
else
|
14
|
+
p = obj.link_attr
|
15
|
+
p[:partial] = "#{obj.class.name.tableize}/link" if p.empty?
|
16
|
+
unless p[:partial].nil?
|
17
|
+
obj_name = (p[:object_name] ||= obj.class.name.underscore).to_s.to_sym
|
18
|
+
render :partial => p[:partial], :locals => {obj_name => obj}
|
19
|
+
else
|
20
|
+
opts = {}
|
21
|
+
link_attr = obj.link_attr
|
22
|
+
link_attr.each do |key, val|
|
23
|
+
link_attr[key] = obj.send(val) if val.class == Symbol
|
24
|
+
end
|
25
|
+
opts[:title] = link_attr[:title] if link_attr.has_key?(:title)
|
26
|
+
link_to link_attr[:name], obj, opts
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
data/rails/init.rb
ADDED
data/test/test_helper.rb
ADDED
data/uninstall.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
# Uninstall hook code here
|
metadata
ADDED
@@ -0,0 +1,76 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: acts_as_linkable
|
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
|
+
- Tyler Gannon
|
14
|
+
autorequire:
|
15
|
+
bindir: bin
|
16
|
+
cert_chain: []
|
17
|
+
|
18
|
+
date: 2010-07-11 00:00:00 -07:00
|
19
|
+
default_executable:
|
20
|
+
dependencies: []
|
21
|
+
|
22
|
+
description: Helper methods for defining link characteristics on objects.
|
23
|
+
email: t--g__a--nnon@gmail.com
|
24
|
+
executables: []
|
25
|
+
|
26
|
+
extensions: []
|
27
|
+
|
28
|
+
extra_rdoc_files:
|
29
|
+
- README
|
30
|
+
files:
|
31
|
+
- README
|
32
|
+
- Rakefile
|
33
|
+
- acts_as_linkable.gemspec
|
34
|
+
- install.rb
|
35
|
+
- lib/acts_as_linkable.rb
|
36
|
+
- lib/acts_as_linkable_core.rb
|
37
|
+
- rails/init.rb
|
38
|
+
- test/acts_as_linkable_test.rb
|
39
|
+
- test/test_helper.rb
|
40
|
+
- uninstall.rb
|
41
|
+
has_rdoc: true
|
42
|
+
homepage: http://github.com/tylergannon/acts_as_linkable
|
43
|
+
licenses: []
|
44
|
+
|
45
|
+
post_install_message:
|
46
|
+
rdoc_options:
|
47
|
+
- --charset=UTF-8
|
48
|
+
require_paths:
|
49
|
+
- lib
|
50
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
51
|
+
none: false
|
52
|
+
requirements:
|
53
|
+
- - ">="
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
hash: 3
|
56
|
+
segments:
|
57
|
+
- 0
|
58
|
+
version: "0"
|
59
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
60
|
+
none: false
|
61
|
+
requirements:
|
62
|
+
- - ">="
|
63
|
+
- !ruby/object:Gem::Version
|
64
|
+
hash: 3
|
65
|
+
segments:
|
66
|
+
- 0
|
67
|
+
version: "0"
|
68
|
+
requirements: []
|
69
|
+
|
70
|
+
rubyforge_project:
|
71
|
+
rubygems_version: 1.3.7
|
72
|
+
signing_key:
|
73
|
+
specification_version: 3
|
74
|
+
summary: Acts As Linkable helper methods.
|
75
|
+
test_files: []
|
76
|
+
|