kelredd-useful 0.2.9 → 0.2.10
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/lib/useful/erb_helpers/links.rb +16 -6
- data/lib/useful/ruby_extensions/string.rb +1 -1
- data/lib/useful/version.rb +1 -1
- metadata +18 -9
@@ -8,6 +8,8 @@ module Useful::ErbHelpers; end
|
|
8
8
|
|
9
9
|
module Useful::ErbHelpers::Links
|
10
10
|
|
11
|
+
ABSOLUTE_LINK_PATH = /\Ahttp[s]*:\/\//
|
12
|
+
|
11
13
|
include Useful::ErbHelpers::Common
|
12
14
|
|
13
15
|
# helper to emulate action view's 'link_to'
|
@@ -65,7 +67,11 @@ module Useful::ErbHelpers::Links
|
|
65
67
|
# EX : image_tag '/better/logo.jpg'
|
66
68
|
# => <img src="/better/logo.jpg" />
|
67
69
|
def image_tag(source,options={})
|
68
|
-
options[:src] =
|
70
|
+
options[:src] = if source =~ ABSOLUTE_LINK_PATH
|
71
|
+
source
|
72
|
+
else
|
73
|
+
['/'].include?(source[0..0]) ? source : "/images/#{source}"
|
74
|
+
end
|
69
75
|
tag(:img, options)
|
70
76
|
end
|
71
77
|
|
@@ -146,12 +152,16 @@ module Useful::ErbHelpers::Links
|
|
146
152
|
end
|
147
153
|
|
148
154
|
def build_src_href(src, options)
|
149
|
-
href = ""
|
150
155
|
src = src.to_s
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
156
|
+
if src =~ ABSOLUTE_LINK_PATH
|
157
|
+
src
|
158
|
+
else
|
159
|
+
href = ""
|
160
|
+
href += ['/'].include?(src[0..0]) ? src : "/#{options[:default_path]}/#{src}"
|
161
|
+
href += options[:extension] unless src.include?(options[:extension])
|
162
|
+
href += "?#{Time.now.to_i}" if options[:environment].to_s == 'development'
|
163
|
+
href
|
164
|
+
end
|
155
165
|
end
|
156
166
|
|
157
167
|
end
|
@@ -105,7 +105,7 @@ module Useful::RubyExtensions::String
|
|
105
105
|
# "active_record".camelize # => "ActiveRecord"
|
106
106
|
# "active_record".camelize(:lower) # => "activeRecord"
|
107
107
|
# "active_record/errors".camelize # => "ActiveRecord::Errors"
|
108
|
-
# "active_record/
|
108
|
+
# "active_record/error".camelize(:lower) # => "activeRecord::Error"
|
109
109
|
def camelize(lower_case_and_underscored_word, first_letter_in_uppercase = true)
|
110
110
|
if first_letter_in_uppercase
|
111
111
|
lower_case_and_underscored_word.to_s.gsub(/\/(.?)/) { "::#{$1.upcase}" }.gsub(/(?:^|_)(.)/) { $1.upcase }
|
data/lib/useful/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,12 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kelredd-useful
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 0
|
7
|
+
- 2
|
8
|
+
- 10
|
9
|
+
version: 0.2.10
|
5
10
|
platform: ruby
|
6
11
|
authors:
|
7
12
|
- Kelly Redding
|
@@ -9,19 +14,21 @@ autorequire:
|
|
9
14
|
bindir: bin
|
10
15
|
cert_chain: []
|
11
16
|
|
12
|
-
date: 2010-
|
17
|
+
date: 2010-02-25 00:00:00 -06:00
|
13
18
|
default_executable:
|
14
19
|
dependencies:
|
15
20
|
- !ruby/object:Gem::Dependency
|
16
21
|
name: json
|
17
|
-
|
18
|
-
|
19
|
-
version_requirements: !ruby/object:Gem::Requirement
|
22
|
+
prerelease: false
|
23
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
20
24
|
requirements:
|
21
25
|
- - ">="
|
22
26
|
- !ruby/object:Gem::Version
|
27
|
+
segments:
|
28
|
+
- 0
|
23
29
|
version: "0"
|
24
|
-
|
30
|
+
type: :runtime
|
31
|
+
version_requirements: *id001
|
25
32
|
description:
|
26
33
|
email: kelly@kelredd.com
|
27
34
|
executables: []
|
@@ -84,18 +91,20 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
84
91
|
requirements:
|
85
92
|
- - ">="
|
86
93
|
- !ruby/object:Gem::Version
|
94
|
+
segments:
|
95
|
+
- 0
|
87
96
|
version: "0"
|
88
|
-
version:
|
89
97
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
90
98
|
requirements:
|
91
99
|
- - ">="
|
92
100
|
- !ruby/object:Gem::Version
|
101
|
+
segments:
|
102
|
+
- 0
|
93
103
|
version: "0"
|
94
|
-
version:
|
95
104
|
requirements: []
|
96
105
|
|
97
106
|
rubyforge_project:
|
98
|
-
rubygems_version: 1.3.
|
107
|
+
rubygems_version: 1.3.6
|
99
108
|
signing_key:
|
100
109
|
specification_version: 3
|
101
110
|
summary: A collection of useful helpers for various ruby things.
|