resource-presentation-helpers 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +8 -0
- data/Gemfile.lock +93 -0
- data/README.md +28 -0
- data/Rakefile +53 -0
- data/VERSION +1 -0
- data/lib/resource-presentation-helpers.rb +73 -0
- data/resource-presentation-helpers.gemspec +51 -0
- metadata +104 -0
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,93 @@
|
|
1
|
+
GEM
|
2
|
+
remote: http://rubygems.org/
|
3
|
+
specs:
|
4
|
+
actionmailer (3.2.8)
|
5
|
+
actionpack (= 3.2.8)
|
6
|
+
mail (~> 2.4.4)
|
7
|
+
actionpack (3.2.8)
|
8
|
+
activemodel (= 3.2.8)
|
9
|
+
activesupport (= 3.2.8)
|
10
|
+
builder (~> 3.0.0)
|
11
|
+
erubis (~> 2.7.0)
|
12
|
+
journey (~> 1.0.4)
|
13
|
+
rack (~> 1.4.0)
|
14
|
+
rack-cache (~> 1.2)
|
15
|
+
rack-test (~> 0.6.1)
|
16
|
+
sprockets (~> 2.1.3)
|
17
|
+
activemodel (3.2.8)
|
18
|
+
activesupport (= 3.2.8)
|
19
|
+
builder (~> 3.0.0)
|
20
|
+
activerecord (3.2.8)
|
21
|
+
activemodel (= 3.2.8)
|
22
|
+
activesupport (= 3.2.8)
|
23
|
+
arel (~> 3.0.2)
|
24
|
+
tzinfo (~> 0.3.29)
|
25
|
+
activeresource (3.2.8)
|
26
|
+
activemodel (= 3.2.8)
|
27
|
+
activesupport (= 3.2.8)
|
28
|
+
activesupport (3.2.8)
|
29
|
+
i18n (~> 0.6)
|
30
|
+
multi_json (~> 1.0)
|
31
|
+
arel (3.0.2)
|
32
|
+
builder (3.0.0)
|
33
|
+
erubis (2.7.0)
|
34
|
+
git (1.2.5)
|
35
|
+
hike (1.2.1)
|
36
|
+
i18n (0.6.0)
|
37
|
+
jeweler (1.8.4)
|
38
|
+
bundler (~> 1.0)
|
39
|
+
git (>= 1.2.5)
|
40
|
+
rake
|
41
|
+
rdoc
|
42
|
+
journey (1.0.4)
|
43
|
+
json (1.7.4)
|
44
|
+
mail (2.4.4)
|
45
|
+
i18n (>= 0.4.0)
|
46
|
+
mime-types (~> 1.16)
|
47
|
+
treetop (~> 1.4.8)
|
48
|
+
mime-types (1.19)
|
49
|
+
multi_json (1.3.6)
|
50
|
+
polyglot (0.3.3)
|
51
|
+
rack (1.4.1)
|
52
|
+
rack-cache (1.2)
|
53
|
+
rack (>= 0.4)
|
54
|
+
rack-ssl (1.3.2)
|
55
|
+
rack
|
56
|
+
rack-test (0.6.1)
|
57
|
+
rack (>= 1.0)
|
58
|
+
rails (3.2.8)
|
59
|
+
actionmailer (= 3.2.8)
|
60
|
+
actionpack (= 3.2.8)
|
61
|
+
activerecord (= 3.2.8)
|
62
|
+
activeresource (= 3.2.8)
|
63
|
+
activesupport (= 3.2.8)
|
64
|
+
bundler (~> 1.0)
|
65
|
+
railties (= 3.2.8)
|
66
|
+
railties (3.2.8)
|
67
|
+
actionpack (= 3.2.8)
|
68
|
+
activesupport (= 3.2.8)
|
69
|
+
rack-ssl (~> 1.3.2)
|
70
|
+
rake (>= 0.8.7)
|
71
|
+
rdoc (~> 3.4)
|
72
|
+
thor (>= 0.14.6, < 2.0)
|
73
|
+
rake (0.9.2.2)
|
74
|
+
rdoc (3.12)
|
75
|
+
json (~> 1.4)
|
76
|
+
sprockets (2.1.3)
|
77
|
+
hike (~> 1.2)
|
78
|
+
rack (~> 1.0)
|
79
|
+
tilt (~> 1.1, != 1.3.0)
|
80
|
+
thor (0.15.4)
|
81
|
+
tilt (1.3.3)
|
82
|
+
treetop (1.4.10)
|
83
|
+
polyglot
|
84
|
+
polyglot (>= 0.3.1)
|
85
|
+
tzinfo (0.3.33)
|
86
|
+
|
87
|
+
PLATFORMS
|
88
|
+
ruby
|
89
|
+
|
90
|
+
DEPENDENCIES
|
91
|
+
bundler
|
92
|
+
jeweler (~> 1.8.4)
|
93
|
+
rails
|
data/README.md
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
# Resource-presentation-helpers
|
2
|
+
|
3
|
+
Rails helpers for presentation of resource objects
|
4
|
+
|
5
|
+
---
|
6
|
+
|
7
|
+
Copyright (c) 2012 mcasimir
|
8
|
+
|
9
|
+
MIT License
|
10
|
+
|
11
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
12
|
+
a copy of this software and associated documentation files (the
|
13
|
+
"Software"), to deal in the Software without restriction, including
|
14
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
15
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
16
|
+
permit persons to whom the Software is furnished to do so, subject to
|
17
|
+
the following conditions:
|
18
|
+
|
19
|
+
The above copyright notice and this permission notice shall be
|
20
|
+
included in all copies or substantial portions of the Software.
|
21
|
+
|
22
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
23
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
24
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
25
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
26
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
27
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
28
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/Rakefile
ADDED
@@ -0,0 +1,53 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'bundler'
|
5
|
+
begin
|
6
|
+
Bundler.setup(:default, :development)
|
7
|
+
rescue Bundler::BundlerError => e
|
8
|
+
$stderr.puts e.message
|
9
|
+
$stderr.puts "Run `bundle install` to install missing gems"
|
10
|
+
exit e.status_code
|
11
|
+
end
|
12
|
+
require 'rake'
|
13
|
+
|
14
|
+
require 'jeweler'
|
15
|
+
Jeweler::Tasks.new do |gem|
|
16
|
+
# gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
|
17
|
+
gem.name = "resource-presentation-helpers"
|
18
|
+
gem.homepage = "http://github.com/mcasimir/kaminari-bootstrap"
|
19
|
+
gem.license = "MIT"
|
20
|
+
gem.summary = %Q{Rails helpers for presentation of resource objects}
|
21
|
+
gem.description = %Q{Rails helpers for presentation of resource objects}
|
22
|
+
gem.email = "maurizio.cas@gmail.com"
|
23
|
+
gem.authors = ["mcasimir"]
|
24
|
+
# dependencies defined in Gemfile
|
25
|
+
end
|
26
|
+
Jeweler::RubygemsDotOrgTasks.new
|
27
|
+
|
28
|
+
|
29
|
+
task :push do
|
30
|
+
message = ENV["message"] || "commit #{Time.now}"
|
31
|
+
`git add . && git commit -a -m '#{message}' && git push`
|
32
|
+
end
|
33
|
+
|
34
|
+
task "release:patch" do
|
35
|
+
Rake::Task["gemspec"].invoke
|
36
|
+
Rake::Task["version:bump:patch"]
|
37
|
+
Rake::Task["push"].invoke
|
38
|
+
Rake::Task["release"].invoke
|
39
|
+
end
|
40
|
+
|
41
|
+
task "release:minor" do
|
42
|
+
Rake::Task["gemspec"].invoke
|
43
|
+
Rake::Task["version:bump:minor"]
|
44
|
+
Rake::Task["push"].invoke
|
45
|
+
Rake::Task["release"].invoke
|
46
|
+
end
|
47
|
+
|
48
|
+
task "release:major" do
|
49
|
+
Rake::Task["gemspec"].invoke
|
50
|
+
Rake::Task["version:bump:major"]
|
51
|
+
Rake::Task["push"].invoke
|
52
|
+
Rake::Task["release"].invoke
|
53
|
+
end
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.1.1
|
@@ -0,0 +1,73 @@
|
|
1
|
+
# Author:: Maurizio Casimirri (mailto:maurizio.cas@gmail.com)
|
2
|
+
# Copyright:: Copyright (c) 2012 Maurizio Casimirri
|
3
|
+
#
|
4
|
+
# Permission is hereby granted, free of charge, to any person obtaining
|
5
|
+
# a copy of this software and associated documentation files (the
|
6
|
+
# "Software"), to deal in the Software without restriction, including
|
7
|
+
# without limitation the rights to use, copy, modify, merge, publish,
|
8
|
+
# distribute, sublicense, and/or sell copies of the Software, and to
|
9
|
+
# permit persons to whom the Software is furnished to do so, subject to
|
10
|
+
# the following conditions:
|
11
|
+
#
|
12
|
+
# The above copyright notice and this permission notice shall be
|
13
|
+
# included in all copies or substantial portions of the Software.
|
14
|
+
#
|
15
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
16
|
+
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
17
|
+
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
18
|
+
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
19
|
+
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
20
|
+
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
21
|
+
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
22
|
+
|
23
|
+
require 'rails'
|
24
|
+
|
25
|
+
module ResourcePresentationHelpers
|
26
|
+
|
27
|
+
def image_method_for(resource, opts = {})
|
28
|
+
klass = resource.is_a?(Class) ? resource : resource.class
|
29
|
+
any_names = ((klass.respond_to?(:column_names) ? klass.column_names : []) + klass.public_instance_methods).map {|name| "#{name}"}.uniq.delete_if {|meth| meth =~ /^_/}
|
30
|
+
%w(photo image thumbnail logo).find {|meth| any_names.include?(meth)}
|
31
|
+
end
|
32
|
+
|
33
|
+
def image_for(resource, opts = {})
|
34
|
+
attachment_or_url = resource && (meth = image_method_for(resource, opts)) && resource.send(meth)
|
35
|
+
return nil if attachment_or_url.nil?
|
36
|
+
|
37
|
+
if attachment_or_url.is_a?(Paperclip::Attachment)
|
38
|
+
style = opts[:style] && attachment_or_url.styles.keys.include?("#{opts[:style]}") ? opts[:style] : :original
|
39
|
+
attachment_or_url.send(:url, style)
|
40
|
+
else
|
41
|
+
attachment_or_url
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
def name_method_for(resource, opts = {})
|
46
|
+
klass = resource.is_a?(Class) ? resource : resource.class
|
47
|
+
any_names = ((klass.respond_to?(:column_names) ? klass.column_names : []) + klass.public_instance_methods).map {|name| "#{name}"}.uniq.delete_if {|meth| meth =~ /^_/}
|
48
|
+
%w(to_label title name label browser_title seo_title seo_name key claim email to_s).find {|meth| any_names.include?(meth)}
|
49
|
+
end
|
50
|
+
alias :title_method_for :name_method_for
|
51
|
+
alias :label_method_for :name_method_for
|
52
|
+
|
53
|
+
def name_for(resource, opts = {})
|
54
|
+
resource && (meth = label_method_for(resource, opts)) && resource.send(meth)
|
55
|
+
end
|
56
|
+
alias :title_for :name_for
|
57
|
+
alias :label_for :name_for
|
58
|
+
|
59
|
+
def description_method_for(resource, opts = {})
|
60
|
+
klass = resource.is_a?(Class) ? resource : resource.class
|
61
|
+
any_names = ((klass.respond_to?(:column_names) ? klass.column_names : []) + klass.public_instance_methods).map {|name| "#{name}"}.uniq.delete_if {|meth| meth =~ /^_/}
|
62
|
+
%w(description excerpt meta_descripiton to_description).find {|meth| any_names.include?(meth)}
|
63
|
+
end
|
64
|
+
|
65
|
+
def description_for(resource, opts = {})
|
66
|
+
resource && ( meth = description_method_for(resource, opts) ) && resource.send(meth)
|
67
|
+
end
|
68
|
+
|
69
|
+
end
|
70
|
+
|
71
|
+
ActionView::Base.send :include, ResourcePresentationHelpers
|
72
|
+
|
73
|
+
|
@@ -0,0 +1,51 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
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 = "resource-presentation-helpers"
|
8
|
+
s.version = "0.1.1"
|
9
|
+
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = ["mcasimir"]
|
12
|
+
s.date = "2012-08-13"
|
13
|
+
s.description = "Rails helpers for presentation of resource objects"
|
14
|
+
s.email = "maurizio.cas@gmail.com"
|
15
|
+
s.extra_rdoc_files = [
|
16
|
+
"README.md"
|
17
|
+
]
|
18
|
+
s.files = [
|
19
|
+
"Gemfile",
|
20
|
+
"Gemfile.lock",
|
21
|
+
"README.md",
|
22
|
+
"Rakefile",
|
23
|
+
"VERSION",
|
24
|
+
"lib/resource-presentation-helpers.rb",
|
25
|
+
"resource-presentation-helpers.gemspec"
|
26
|
+
]
|
27
|
+
s.homepage = "http://github.com/mcasimir/kaminari-bootstrap"
|
28
|
+
s.licenses = ["MIT"]
|
29
|
+
s.require_paths = ["lib"]
|
30
|
+
s.rubygems_version = "1.8.24"
|
31
|
+
s.summary = "Rails helpers for presentation of resource objects"
|
32
|
+
|
33
|
+
if s.respond_to? :specification_version then
|
34
|
+
s.specification_version = 3
|
35
|
+
|
36
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
37
|
+
s.add_runtime_dependency(%q<rails>, [">= 0"])
|
38
|
+
s.add_development_dependency(%q<bundler>, [">= 0"])
|
39
|
+
s.add_development_dependency(%q<jeweler>, ["~> 1.8.4"])
|
40
|
+
else
|
41
|
+
s.add_dependency(%q<rails>, [">= 0"])
|
42
|
+
s.add_dependency(%q<bundler>, [">= 0"])
|
43
|
+
s.add_dependency(%q<jeweler>, ["~> 1.8.4"])
|
44
|
+
end
|
45
|
+
else
|
46
|
+
s.add_dependency(%q<rails>, [">= 0"])
|
47
|
+
s.add_dependency(%q<bundler>, [">= 0"])
|
48
|
+
s.add_dependency(%q<jeweler>, ["~> 1.8.4"])
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
metadata
ADDED
@@ -0,0 +1,104 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: resource-presentation-helpers
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- mcasimir
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-08-13 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: rails
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: bundler
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
type: :development
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: jeweler
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ~>
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: 1.8.4
|
54
|
+
type: :development
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ~>
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 1.8.4
|
62
|
+
description: Rails helpers for presentation of resource objects
|
63
|
+
email: maurizio.cas@gmail.com
|
64
|
+
executables: []
|
65
|
+
extensions: []
|
66
|
+
extra_rdoc_files:
|
67
|
+
- README.md
|
68
|
+
files:
|
69
|
+
- Gemfile
|
70
|
+
- Gemfile.lock
|
71
|
+
- README.md
|
72
|
+
- Rakefile
|
73
|
+
- VERSION
|
74
|
+
- lib/resource-presentation-helpers.rb
|
75
|
+
- resource-presentation-helpers.gemspec
|
76
|
+
homepage: http://github.com/mcasimir/kaminari-bootstrap
|
77
|
+
licenses:
|
78
|
+
- MIT
|
79
|
+
post_install_message:
|
80
|
+
rdoc_options: []
|
81
|
+
require_paths:
|
82
|
+
- lib
|
83
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
84
|
+
none: false
|
85
|
+
requirements:
|
86
|
+
- - ! '>='
|
87
|
+
- !ruby/object:Gem::Version
|
88
|
+
version: '0'
|
89
|
+
segments:
|
90
|
+
- 0
|
91
|
+
hash: 1151529953820233306
|
92
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
93
|
+
none: false
|
94
|
+
requirements:
|
95
|
+
- - ! '>='
|
96
|
+
- !ruby/object:Gem::Version
|
97
|
+
version: '0'
|
98
|
+
requirements: []
|
99
|
+
rubyforge_project:
|
100
|
+
rubygems_version: 1.8.24
|
101
|
+
signing_key:
|
102
|
+
specification_version: 3
|
103
|
+
summary: Rails helpers for presentation of resource objects
|
104
|
+
test_files: []
|