wordnik_ruby_helpers 0.1.0 → 0.1.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/Gemfile.lock +43 -45
- data/lib/wordnik_ruby_helpers.rb +14 -0
- data/lib/wordnik_ruby_helpers/version.rb +1 -1
- data/spec/wordnik_ruby_helpers_spec.rb +24 -0
- metadata +2 -2
data/Gemfile.lock
CHANGED
@@ -1,91 +1,89 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
wordnik_ruby_helpers (0.0
|
4
|
+
wordnik_ruby_helpers (0.1.0)
|
5
5
|
RedCloth (>= 4.2.3)
|
6
6
|
rails
|
7
7
|
|
8
8
|
GEM
|
9
9
|
remote: http://rubygems.org/
|
10
10
|
specs:
|
11
|
-
RedCloth (4.2.
|
11
|
+
RedCloth (4.2.7)
|
12
12
|
abstract (1.0.0)
|
13
|
-
actionmailer (3.0.
|
14
|
-
actionpack (= 3.0.
|
15
|
-
mail (~> 2.2.
|
16
|
-
actionpack (3.0.
|
17
|
-
activemodel (= 3.0.
|
18
|
-
activesupport (= 3.0.
|
13
|
+
actionmailer (3.0.7)
|
14
|
+
actionpack (= 3.0.7)
|
15
|
+
mail (~> 2.2.15)
|
16
|
+
actionpack (3.0.7)
|
17
|
+
activemodel (= 3.0.7)
|
18
|
+
activesupport (= 3.0.7)
|
19
19
|
builder (~> 2.1.2)
|
20
20
|
erubis (~> 2.6.6)
|
21
|
-
i18n (~> 0.
|
21
|
+
i18n (~> 0.5.0)
|
22
22
|
rack (~> 1.2.1)
|
23
|
-
rack-mount (~> 0.6.
|
24
|
-
rack-test (~> 0.5.
|
23
|
+
rack-mount (~> 0.6.14)
|
24
|
+
rack-test (~> 0.5.7)
|
25
25
|
tzinfo (~> 0.3.23)
|
26
|
-
activemodel (3.0.
|
27
|
-
activesupport (= 3.0.
|
26
|
+
activemodel (3.0.7)
|
27
|
+
activesupport (= 3.0.7)
|
28
28
|
builder (~> 2.1.2)
|
29
|
-
i18n (~> 0.
|
30
|
-
activerecord (3.0.
|
31
|
-
activemodel (= 3.0.
|
32
|
-
activesupport (= 3.0.
|
29
|
+
i18n (~> 0.5.0)
|
30
|
+
activerecord (3.0.7)
|
31
|
+
activemodel (= 3.0.7)
|
32
|
+
activesupport (= 3.0.7)
|
33
33
|
arel (~> 2.0.2)
|
34
34
|
tzinfo (~> 0.3.23)
|
35
|
-
activeresource (3.0.
|
36
|
-
activemodel (= 3.0.
|
37
|
-
activesupport (= 3.0.
|
38
|
-
activesupport (3.0.
|
39
|
-
arel (2.0.
|
35
|
+
activeresource (3.0.7)
|
36
|
+
activemodel (= 3.0.7)
|
37
|
+
activesupport (= 3.0.7)
|
38
|
+
activesupport (3.0.7)
|
39
|
+
arel (2.0.9)
|
40
40
|
builder (2.1.2)
|
41
41
|
diff-lcs (1.1.2)
|
42
42
|
erubis (2.6.6)
|
43
43
|
abstract (>= 1.0.0)
|
44
44
|
i18n (0.5.0)
|
45
|
-
mail (2.2.
|
45
|
+
mail (2.2.19)
|
46
46
|
activesupport (>= 2.3.6)
|
47
47
|
i18n (>= 0.4.0)
|
48
48
|
mime-types (~> 1.16)
|
49
49
|
treetop (~> 1.4.8)
|
50
50
|
mime-types (1.16)
|
51
51
|
polyglot (0.3.1)
|
52
|
-
rack (1.2.
|
53
|
-
rack-mount (0.6.
|
52
|
+
rack (1.2.2)
|
53
|
+
rack-mount (0.6.14)
|
54
54
|
rack (>= 1.0.0)
|
55
55
|
rack-test (0.5.7)
|
56
56
|
rack (>= 1.0)
|
57
|
-
rails (3.0.
|
58
|
-
actionmailer (= 3.0.
|
59
|
-
actionpack (= 3.0.
|
60
|
-
activerecord (= 3.0.
|
61
|
-
activeresource (= 3.0.
|
62
|
-
activesupport (= 3.0.
|
57
|
+
rails (3.0.7)
|
58
|
+
actionmailer (= 3.0.7)
|
59
|
+
actionpack (= 3.0.7)
|
60
|
+
activerecord (= 3.0.7)
|
61
|
+
activeresource (= 3.0.7)
|
62
|
+
activesupport (= 3.0.7)
|
63
63
|
bundler (~> 1.0)
|
64
|
-
railties (= 3.0.
|
65
|
-
railties (3.0.
|
66
|
-
actionpack (= 3.0.
|
67
|
-
activesupport (= 3.0.
|
64
|
+
railties (= 3.0.7)
|
65
|
+
railties (3.0.7)
|
66
|
+
actionpack (= 3.0.7)
|
67
|
+
activesupport (= 3.0.7)
|
68
68
|
rake (>= 0.8.7)
|
69
69
|
thor (~> 0.14.4)
|
70
70
|
rake (0.8.7)
|
71
|
-
rspec (2.
|
72
|
-
rspec-core (~> 2.
|
73
|
-
rspec-expectations (~> 2.
|
74
|
-
rspec-mocks (~> 2.
|
75
|
-
rspec-core (2.
|
76
|
-
rspec-expectations (2.
|
71
|
+
rspec (2.5.0)
|
72
|
+
rspec-core (~> 2.5.0)
|
73
|
+
rspec-expectations (~> 2.5.0)
|
74
|
+
rspec-mocks (~> 2.5.0)
|
75
|
+
rspec-core (2.5.2)
|
76
|
+
rspec-expectations (2.5.0)
|
77
77
|
diff-lcs (~> 1.1.2)
|
78
|
-
rspec-mocks (2.
|
78
|
+
rspec-mocks (2.5.0)
|
79
79
|
thor (0.14.6)
|
80
80
|
treetop (1.4.9)
|
81
81
|
polyglot (>= 0.3.1)
|
82
|
-
tzinfo (0.3.
|
82
|
+
tzinfo (0.3.27)
|
83
83
|
|
84
84
|
PLATFORMS
|
85
85
|
ruby
|
86
86
|
|
87
87
|
DEPENDENCIES
|
88
|
-
RedCloth (>= 4.2.3)
|
89
|
-
rails
|
90
88
|
rspec
|
91
89
|
wordnik_ruby_helpers!
|
data/lib/wordnik_ruby_helpers.rb
CHANGED
@@ -2,6 +2,20 @@ require 'uri'
|
|
2
2
|
|
3
3
|
module WordnikRubyHelpers
|
4
4
|
module ViewHelpers
|
5
|
+
|
6
|
+
def tag(element, content, properties={})
|
7
|
+
|
8
|
+
# Extract class and id
|
9
|
+
css = element.to_s.scan(/\.(\w+)/).flatten.sort.join(" ")
|
10
|
+
id = element.to_s.scan(/\#(\w+)/).flatten.first
|
11
|
+
|
12
|
+
# Clean up the element
|
13
|
+
element = element.to_s.split('#').first.split('.').first
|
14
|
+
|
15
|
+
properties[:class] = css unless css.blank?
|
16
|
+
properties[:id] = id unless id.blank?
|
17
|
+
content_tag(element, content, properties)
|
18
|
+
end
|
5
19
|
|
6
20
|
# Use words if within the last week, otherwise use date (show year if not this year)
|
7
21
|
def time_ago_in_words_or_date(date,options={})
|
@@ -1,6 +1,30 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe WordnikRubyHelpers do
|
4
|
+
|
5
|
+
context "tag" do
|
6
|
+
|
7
|
+
it "works!" do
|
8
|
+
tag('span', 'wing').should == "<span>wing</span>"
|
9
|
+
end
|
10
|
+
|
11
|
+
it "accounts for symbols as element names" do
|
12
|
+
tag(:span, 'wing').should == "<span>wing</span>"
|
13
|
+
end
|
14
|
+
|
15
|
+
it "accounts for shorthand css classes and id" do
|
16
|
+
tag('span.big', 'wing').should == "<span class=\"big\">wing</span>"
|
17
|
+
tag('span#bob', 'wing').should == "<span id=\"bob\">wing</span>"
|
18
|
+
tag('span#bob.old.big', 'wing').should == "<span class=\"big old\" id=\"bob\">wing</span>"
|
19
|
+
tag('span.old.big#bob', 'wing').should == "<span class=\"big old\" id=\"bob\">wing</span>"
|
20
|
+
end
|
21
|
+
|
22
|
+
it "accounts for extra properties" do
|
23
|
+
tag('span#bob.old.big', 'wing', :rel => 'bird').should == "<span class=\"big old\" id=\"bob\" rel=\"bird\">wing</span>"
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
27
|
+
|
4
28
|
context "time_ago_in_words_or_date" do
|
5
29
|
it "should get relative times right" do
|
6
30
|
time_ago_in_words_or_date(Time.now - 10.minutes).should == "10 minutes ago"
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: wordnik_ruby_helpers
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.1.
|
5
|
+
version: 0.1.1
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Zeke Sikelianos
|
@@ -11,7 +11,7 @@ autorequire:
|
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
13
|
|
14
|
-
date: 2011-
|
14
|
+
date: 2011-05-09 00:00:00 -07:00
|
15
15
|
default_executable:
|
16
16
|
dependencies:
|
17
17
|
- !ruby/object:Gem::Dependency
|