wordnik_ruby_helpers 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile.lock CHANGED
@@ -1,91 +1,89 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- wordnik_ruby_helpers (0.0.8)
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.3)
11
+ RedCloth (4.2.7)
12
12
  abstract (1.0.0)
13
- actionmailer (3.0.3)
14
- actionpack (= 3.0.3)
15
- mail (~> 2.2.9)
16
- actionpack (3.0.3)
17
- activemodel (= 3.0.3)
18
- activesupport (= 3.0.3)
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.4)
21
+ i18n (~> 0.5.0)
22
22
  rack (~> 1.2.1)
23
- rack-mount (~> 0.6.13)
24
- rack-test (~> 0.5.6)
23
+ rack-mount (~> 0.6.14)
24
+ rack-test (~> 0.5.7)
25
25
  tzinfo (~> 0.3.23)
26
- activemodel (3.0.3)
27
- activesupport (= 3.0.3)
26
+ activemodel (3.0.7)
27
+ activesupport (= 3.0.7)
28
28
  builder (~> 2.1.2)
29
- i18n (~> 0.4)
30
- activerecord (3.0.3)
31
- activemodel (= 3.0.3)
32
- activesupport (= 3.0.3)
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.3)
36
- activemodel (= 3.0.3)
37
- activesupport (= 3.0.3)
38
- activesupport (3.0.3)
39
- arel (2.0.6)
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.14)
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.1)
53
- rack-mount (0.6.13)
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.3)
58
- actionmailer (= 3.0.3)
59
- actionpack (= 3.0.3)
60
- activerecord (= 3.0.3)
61
- activeresource (= 3.0.3)
62
- activesupport (= 3.0.3)
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.3)
65
- railties (3.0.3)
66
- actionpack (= 3.0.3)
67
- activesupport (= 3.0.3)
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.4.0)
72
- rspec-core (~> 2.4.0)
73
- rspec-expectations (~> 2.4.0)
74
- rspec-mocks (~> 2.4.0)
75
- rspec-core (2.4.0)
76
- rspec-expectations (2.4.0)
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.4.0)
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.23)
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!
@@ -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,3 +1,3 @@
1
1
  module WordnikRubyHelpers
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
@@ -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.0
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-04-19 00:00:00 -07:00
14
+ date: 2011-05-09 00:00:00 -07:00
15
15
  default_executable:
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency