wordnik_ruby_helpers 0.1.8 → 0.1.9

Sign up to get free protection for your applications and to get access to all the features.
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --colour
@@ -1,97 +1,108 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- wordnik_ruby_helpers (0.1.7)
4
+ wordnik_ruby_helpers (0.1.8)
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.7)
12
- ZenTest (4.5.0)
13
- abstract (1.0.0)
14
- actionmailer (3.0.9)
15
- actionpack (= 3.0.9)
16
- mail (~> 2.2.19)
17
- actionpack (3.0.9)
18
- activemodel (= 3.0.9)
19
- activesupport (= 3.0.9)
20
- builder (~> 2.1.2)
21
- erubis (~> 2.6.6)
22
- i18n (~> 0.5.0)
23
- rack (~> 1.2.1)
24
- rack-mount (~> 0.6.14)
25
- rack-test (~> 0.5.7)
26
- tzinfo (~> 0.3.23)
27
- activemodel (3.0.9)
28
- activesupport (= 3.0.9)
29
- builder (~> 2.1.2)
30
- i18n (~> 0.5.0)
31
- activerecord (3.0.9)
32
- activemodel (= 3.0.9)
33
- activesupport (= 3.0.9)
34
- arel (~> 2.0.10)
35
- tzinfo (~> 0.3.23)
36
- activeresource (3.0.9)
37
- activemodel (= 3.0.9)
38
- activesupport (= 3.0.9)
39
- activesupport (3.0.9)
40
- arel (2.0.10)
41
- autotest (4.4.6)
42
- ZenTest (>= 4.4.1)
43
- autotest-rails-pure (4.1.2)
44
- builder (2.1.2)
45
- diff-lcs (1.1.2)
46
- erubis (2.6.6)
47
- abstract (>= 1.0.0)
48
- i18n (0.5.0)
49
- mail (2.2.19)
50
- activesupport (>= 2.3.6)
11
+ RedCloth (4.2.9)
12
+ actionmailer (3.2.1)
13
+ actionpack (= 3.2.1)
14
+ mail (~> 2.4.0)
15
+ actionpack (3.2.1)
16
+ activemodel (= 3.2.1)
17
+ activesupport (= 3.2.1)
18
+ builder (~> 3.0.0)
19
+ erubis (~> 2.7.0)
20
+ journey (~> 1.0.1)
21
+ rack (~> 1.4.0)
22
+ rack-cache (~> 1.1)
23
+ rack-test (~> 0.6.1)
24
+ sprockets (~> 2.1.2)
25
+ activemodel (3.2.1)
26
+ activesupport (= 3.2.1)
27
+ builder (~> 3.0.0)
28
+ activerecord (3.2.1)
29
+ activemodel (= 3.2.1)
30
+ activesupport (= 3.2.1)
31
+ arel (~> 3.0.0)
32
+ tzinfo (~> 0.3.29)
33
+ activeresource (3.2.1)
34
+ activemodel (= 3.2.1)
35
+ activesupport (= 3.2.1)
36
+ activesupport (3.2.1)
37
+ i18n (~> 0.6)
38
+ multi_json (~> 1.0)
39
+ arel (3.0.2)
40
+ builder (3.0.0)
41
+ diff-lcs (1.1.3)
42
+ erubis (2.7.0)
43
+ hike (1.2.1)
44
+ i18n (0.6.0)
45
+ journey (1.0.3)
46
+ json (1.6.5)
47
+ mail (2.4.1)
51
48
  i18n (>= 0.4.0)
52
49
  mime-types (~> 1.16)
53
50
  treetop (~> 1.4.8)
54
- mime-types (1.16)
55
- polyglot (0.3.1)
56
- rack (1.2.3)
57
- rack-mount (0.6.14)
58
- rack (>= 1.0.0)
59
- rack-test (0.5.7)
51
+ mime-types (1.17.2)
52
+ multi_json (1.1.0)
53
+ nokogiri (1.5.0)
54
+ polyglot (0.3.3)
55
+ rack (1.4.1)
56
+ rack-cache (1.1)
57
+ rack (>= 0.4)
58
+ rack-ssl (1.3.2)
59
+ rack
60
+ rack-test (0.6.1)
60
61
  rack (>= 1.0)
61
- rails (3.0.9)
62
- actionmailer (= 3.0.9)
63
- actionpack (= 3.0.9)
64
- activerecord (= 3.0.9)
65
- activeresource (= 3.0.9)
66
- activesupport (= 3.0.9)
62
+ rails (3.2.1)
63
+ actionmailer (= 3.2.1)
64
+ actionpack (= 3.2.1)
65
+ activerecord (= 3.2.1)
66
+ activeresource (= 3.2.1)
67
+ activesupport (= 3.2.1)
67
68
  bundler (~> 1.0)
68
- railties (= 3.0.9)
69
- railties (3.0.9)
70
- actionpack (= 3.0.9)
71
- activesupport (= 3.0.9)
69
+ railties (= 3.2.1)
70
+ railties (3.2.1)
71
+ actionpack (= 3.2.1)
72
+ activesupport (= 3.2.1)
73
+ rack-ssl (~> 1.3.2)
72
74
  rake (>= 0.8.7)
73
75
  rdoc (~> 3.4)
74
- thor (~> 0.14.4)
75
- rake (0.9.2)
76
- rdoc (3.8)
77
- rspec (2.6.0)
78
- rspec-core (~> 2.6.0)
79
- rspec-expectations (~> 2.6.0)
80
- rspec-mocks (~> 2.6.0)
81
- rspec-core (2.6.4)
82
- rspec-expectations (2.6.0)
76
+ thor (~> 0.14.6)
77
+ rake (0.9.2.2)
78
+ rdoc (3.12)
79
+ json (~> 1.4)
80
+ rspec (2.8.0)
81
+ rspec-core (~> 2.8.0)
82
+ rspec-expectations (~> 2.8.0)
83
+ rspec-mocks (~> 2.8.0)
84
+ rspec-core (2.8.0)
85
+ rspec-expectations (2.8.0)
83
86
  diff-lcs (~> 1.1.2)
84
- rspec-mocks (2.6.0)
87
+ rspec-mocks (2.8.0)
88
+ rspec2-rails-views-matchers (0.2.2)
89
+ nokogiri (>= 1.4.4)
90
+ rspec (>= 2.0.0)
91
+ sprockets (2.1.2)
92
+ hike (~> 1.2)
93
+ rack (~> 1.0)
94
+ tilt (~> 1.1, != 1.3.0)
85
95
  thor (0.14.6)
86
- treetop (1.4.9)
96
+ tilt (1.3.3)
97
+ treetop (1.4.10)
98
+ polyglot
87
99
  polyglot (>= 0.3.1)
88
- tzinfo (0.3.29)
100
+ tzinfo (0.3.31)
89
101
 
90
102
  PLATFORMS
91
103
  ruby
92
104
 
93
105
  DEPENDENCIES
94
- autotest
95
- autotest-rails-pure
96
106
  rspec
107
+ rspec2-rails-views-matchers
97
108
  wordnik_ruby_helpers!
@@ -1,8 +1,36 @@
1
+ # -*- encoding : utf-8 -*-
2
+
1
3
  require 'uri'
2
4
 
3
5
  module WordnikRubyHelpers
4
6
  module ViewHelpers
5
7
 
8
+ def embolden_substring(text, substring, options={})
9
+ options.reverse_merge!(:case_sensitive => true)
10
+ if options[:case_sensitive]
11
+ text.gsub(/(#{substring})/, "<strong>\\1</strong>").html_safe
12
+ else
13
+ text.gsub(/(#{substring})/i, "<strong>\\1</strong>").html_safe
14
+ end
15
+ end
16
+
17
+ # Wrap strings in quotes (single by default)
18
+ #
19
+ def in_quotes(str, quote_type = :single)
20
+ s = str.to_s
21
+ t = (quote_type == :single) ? 's' : 'd'
22
+ # Remove surrounding quotes, if present
23
+ s.gsub!(/^\"|\"$/, '')
24
+ s.gsub!(/^\'|\'$/, '')
25
+ "&l#{t}quo;#{s}&r#{t}quo;".html_safe
26
+ end
27
+
28
+ # A shorter version of Rails' content_tag...
29
+ #
30
+ # Usage:
31
+ # html_tag :div, "this is a div"
32
+ # html_tag 'span.big', 'this is big (hidden) span', :style => "display:none"
33
+ # html_tag 'span#bob.old.big', 'this is big old bob'
6
34
  def html_tag(element, content, properties={})
7
35
 
8
36
  # Extract class and id
@@ -1,3 +1,3 @@
1
1
  module WordnikRubyHelpers
2
- VERSION = "0.1.8"
2
+ VERSION = "0.1.9"
3
3
  end
@@ -2,10 +2,56 @@ require 'spec_helper'
2
2
 
3
3
  describe WordnikRubyHelpers do
4
4
 
5
+ describe "emboldening substrings in text" do
6
+
7
+ it "does simple emboldening" do
8
+ embolden_substring('this or that', 'or').should == "this <strong>or</strong> that"
9
+ end
10
+
11
+ it "stringifies :sybmols" do
12
+ embolden_substring('up the wazoo', :wazoo).should == "up the <strong>wazoo</strong>"
13
+ end
14
+
15
+ it "is case sensitive by default" do
16
+ embolden_substring('up the wazoo', 'WAZOO').should == "up the wazoo"
17
+ end
18
+
19
+ it "can be case insensitive" do
20
+ embolden_substring('up the wazoo', 'WAZOO', :case_sensitive => false).should == "up the <strong>wazoo</strong>"
21
+ end
22
+
23
+ it "emboldens all substrings" do
24
+ embolden_substring('like fatta like sahn', 'like').should == "<strong>like</strong> fatta <strong>like</strong> sahn"
25
+ end
26
+
27
+ end
28
+
29
+ describe "in_quotes" do
30
+
31
+ it "single-quotes a string by default" do
32
+ in_quotes('dog').should == "&lsquo;dog&rsquo;".html_safe
33
+ end
34
+
35
+ it "optionally double-quotes a string" do
36
+ in_quotes('hobble', :double).should == "&ldquo;hobble&rdquo;".html_safe
37
+ end
38
+
39
+ it "stringifies non-strings" do
40
+ in_quotes(5, :double).should == "&ldquo;5&rdquo;".html_safe
41
+ end
42
+
43
+ it "removes existing double quotes" do
44
+ in_quotes("\"bingo\"", :double).should == "&ldquo;bingo&rdquo;".html_safe
45
+ end
46
+
47
+ it "removes existing single quotes" do
48
+ in_quotes("'jingo'", :double).should == "&ldquo;jingo&rdquo;".html_safe
49
+ end
50
+
51
+ end
5
52
 
6
53
  context "favicon_url_for_domain" do
7
54
 
8
-
9
55
  it "should return a URL for a google favicon, given the string's domain" do
10
56
  url = "http://nytimes.com/we-love-wordnik"
11
57
  url.favicon_url_for_domain.should == 'http://www.google.com/s2/favicons?domain=nytimes.com'
@@ -141,10 +187,12 @@ describe WordnikRubyHelpers do
141
187
  a.symbolize_and_underscore_keys!
142
188
  a.keys.should == [:first_name, :last_name]
143
189
  end
144
-
145
190
 
146
191
  end
192
+
193
+ describe "String" do
147
194
 
148
-
195
+
196
+ end
149
197
 
150
198
  end
@@ -18,10 +18,11 @@ Gem::Specification.new do |s|
18
18
  s.add_dependency 'RedCloth', '>= 4.2.3'
19
19
 
20
20
  s.add_development_dependency 'rspec'
21
+ s.add_development_dependency 'rspec2-rails-views-matchers'
21
22
 
22
23
  # Optional..
23
- s.add_development_dependency 'autotest'
24
- s.add_development_dependency 'autotest-rails-pure'
24
+ # s.add_development_dependency 'autotest'
25
+ # s.add_development_dependency 'autotest-rails-pure'
25
26
  # s.add_development_dependency 'autotest-growl'
26
27
  # s.add_development_dependency 'autotest-fsevent'
27
28
 
metadata CHANGED
@@ -1,86 +1,72 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: wordnik_ruby_helpers
3
- version: !ruby/object:Gem::Version
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.9
4
5
  prerelease:
5
- version: 0.1.8
6
6
  platform: ruby
7
- authors:
7
+ authors:
8
8
  - Zeke Sikelianos
9
9
  - John McGrath
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
-
14
- date: 2011-08-12 00:00:00 -07:00
15
- default_executable:
16
- dependencies:
17
- - !ruby/object:Gem::Dependency
13
+ date: 2012-02-25 00:00:00.000000000 Z
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
18
16
  name: rails
19
- prerelease: false
20
- requirement: &id001 !ruby/object:Gem::Requirement
17
+ requirement: &70177226114220 !ruby/object:Gem::Requirement
21
18
  none: false
22
- requirements:
23
- - - ">="
24
- - !ruby/object:Gem::Version
25
- version: "0"
19
+ requirements:
20
+ - - ! '>='
21
+ - !ruby/object:Gem::Version
22
+ version: '0'
26
23
  type: :runtime
27
- version_requirements: *id001
28
- - !ruby/object:Gem::Dependency
29
- name: RedCloth
30
24
  prerelease: false
31
- requirement: &id002 !ruby/object:Gem::Requirement
25
+ version_requirements: *70177226114220
26
+ - !ruby/object:Gem::Dependency
27
+ name: RedCloth
28
+ requirement: &70177226113720 !ruby/object:Gem::Requirement
32
29
  none: false
33
- requirements:
34
- - - ">="
35
- - !ruby/object:Gem::Version
30
+ requirements:
31
+ - - ! '>='
32
+ - !ruby/object:Gem::Version
36
33
  version: 4.2.3
37
34
  type: :runtime
38
- version_requirements: *id002
39
- - !ruby/object:Gem::Dependency
40
- name: rspec
41
35
  prerelease: false
42
- requirement: &id003 !ruby/object:Gem::Requirement
36
+ version_requirements: *70177226113720
37
+ - !ruby/object:Gem::Dependency
38
+ name: rspec
39
+ requirement: &70177226113300 !ruby/object:Gem::Requirement
43
40
  none: false
44
- requirements:
45
- - - ">="
46
- - !ruby/object:Gem::Version
47
- version: "0"
41
+ requirements:
42
+ - - ! '>='
43
+ - !ruby/object:Gem::Version
44
+ version: '0'
48
45
  type: :development
49
- version_requirements: *id003
50
- - !ruby/object:Gem::Dependency
51
- name: autotest
52
46
  prerelease: false
53
- requirement: &id004 !ruby/object:Gem::Requirement
47
+ version_requirements: *70177226113300
48
+ - !ruby/object:Gem::Dependency
49
+ name: rspec2-rails-views-matchers
50
+ requirement: &70177226112840 !ruby/object:Gem::Requirement
54
51
  none: false
55
- requirements:
56
- - - ">="
57
- - !ruby/object:Gem::Version
58
- version: "0"
52
+ requirements:
53
+ - - ! '>='
54
+ - !ruby/object:Gem::Version
55
+ version: '0'
59
56
  type: :development
60
- version_requirements: *id004
61
- - !ruby/object:Gem::Dependency
62
- name: autotest-rails-pure
63
57
  prerelease: false
64
- requirement: &id005 !ruby/object:Gem::Requirement
65
- none: false
66
- requirements:
67
- - - ">="
68
- - !ruby/object:Gem::Version
69
- version: "0"
70
- type: :development
71
- version_requirements: *id005
72
- description: A handful of monkey patches and view helpers that we use in our rails projects
73
- email:
58
+ version_requirements: *70177226112840
59
+ description: A handful of monkey patches and view helpers that we use in our rails
60
+ projects
61
+ email:
74
62
  - zeke@wordnik.com
75
63
  - john@wordnik.com
76
64
  executables: []
77
-
78
65
  extensions: []
79
-
80
66
  extra_rdoc_files: []
81
-
82
- files:
67
+ files:
83
68
  - .gitignore
69
+ - .rspec
84
70
  - Gemfile
85
71
  - Gemfile.lock
86
72
  - README.md
@@ -91,35 +77,31 @@ files:
91
77
  - spec/spec_helper.rb
92
78
  - spec/wordnik_ruby_helpers_spec.rb
93
79
  - wordnik_ruby_helpers.gemspec
94
- has_rdoc: true
95
80
  homepage: http://wordnik.com
96
81
  licenses: []
97
-
98
82
  post_install_message:
99
83
  rdoc_options: []
100
-
101
- require_paths:
84
+ require_paths:
102
85
  - lib
103
- required_ruby_version: !ruby/object:Gem::Requirement
86
+ required_ruby_version: !ruby/object:Gem::Requirement
104
87
  none: false
105
- requirements:
106
- - - ">="
107
- - !ruby/object:Gem::Version
108
- version: "0"
109
- required_rubygems_version: !ruby/object:Gem::Requirement
88
+ requirements:
89
+ - - ! '>='
90
+ - !ruby/object:Gem::Version
91
+ version: '0'
92
+ required_rubygems_version: !ruby/object:Gem::Requirement
110
93
  none: false
111
- requirements:
112
- - - ">="
113
- - !ruby/object:Gem::Version
114
- version: "0"
94
+ requirements:
95
+ - - ! '>='
96
+ - !ruby/object:Gem::Version
97
+ version: '0'
115
98
  requirements: []
116
-
117
99
  rubyforge_project: wordnik_ruby_helpers
118
- rubygems_version: 1.5.1
100
+ rubygems_version: 1.8.10
119
101
  signing_key:
120
102
  specification_version: 3
121
103
  summary: A handful of monkey patches and view helpers that we use in our rails projects
122
- test_files:
104
+ test_files:
123
105
  - spec/spec.opts
124
106
  - spec/spec_helper.rb
125
107
  - spec/wordnik_ruby_helpers_spec.rb