truncate_with_hover 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,4 @@
1
+ *.gem
2
+ .bundle
3
+ Gemfile.lock
4
+ pkg/*
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in truncate_with_hover.gemspec
4
+ gemspec
@@ -0,0 +1,10 @@
1
+ # Overview
2
+
3
+ truncate_with_hover is a simple gem that adds the method
4
+ `truncate_with_hover` to `ActionView::Helpers::TextHelper`.
5
+ This method behaves like `truncate`, except that it wraps everything in
6
+ a `<span>` tag with the non-truncated text as the `title` attribute.
7
+
8
+ ## TODO
9
+
10
+ Write some specs :)
@@ -0,0 +1 @@
1
+ require 'bundler/gem_tasks'
@@ -0,0 +1,19 @@
1
+ require "truncate_with_hover/version"
2
+
3
+ module TruncateWithHover
4
+ include ActionView::Helpers::TagHelper
5
+
6
+ def truncate_with_hover(text, options = {})
7
+ return if text.blank?
8
+
9
+ options.reverse_merge!(:length => 25)
10
+
11
+ if text.length > options[:length]
12
+ content_tag :span, truncate(text, options), :title => text
13
+ else
14
+ text
15
+ end
16
+ end
17
+ end
18
+
19
+ ActionView::Helpers::TextHelper.send :include, TruncateWithHover
@@ -0,0 +1,3 @@
1
+ module TruncateWithHover
2
+ VERSION = "0.1.0"
3
+ end
@@ -0,0 +1,20 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "truncate_with_hover/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "truncate_with_hover"
7
+ s.version = TruncateWithHover::VERSION
8
+ s.authors = ["hoverlover"]
9
+ s.email = ["hoverlover@gmail.com"]
10
+ s.homepage = "https://github.com/hoverlover/truncate_with_hover"
11
+ s.summary = %q{Like Rails' TextHelper#truncate, except with hover text.}
12
+ s.description = s.summary
13
+
14
+ s.rubyforge_project = "truncate_with_hover"
15
+
16
+ s.files = `git ls-files`.split("\n")
17
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
18
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
19
+ s.require_paths = ["lib"]
20
+ end
metadata ADDED
@@ -0,0 +1,61 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: truncate_with_hover
3
+ version: !ruby/object:Gem::Version
4
+ prerelease:
5
+ version: 0.1.0
6
+ platform: ruby
7
+ authors:
8
+ - hoverlover
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+
13
+ date: 2011-08-09 00:00:00 Z
14
+ dependencies: []
15
+
16
+ description: Like Rails' TextHelper#truncate, except with hover text.
17
+ email:
18
+ - hoverlover@gmail.com
19
+ executables: []
20
+
21
+ extensions: []
22
+
23
+ extra_rdoc_files: []
24
+
25
+ files:
26
+ - .gitignore
27
+ - Gemfile
28
+ - README.md
29
+ - Rakefile
30
+ - lib/truncate_with_hover.rb
31
+ - lib/truncate_with_hover/version.rb
32
+ - truncate_with_hover.gemspec
33
+ homepage: https://github.com/hoverlover/truncate_with_hover
34
+ licenses: []
35
+
36
+ post_install_message:
37
+ rdoc_options: []
38
+
39
+ require_paths:
40
+ - lib
41
+ required_ruby_version: !ruby/object:Gem::Requirement
42
+ none: false
43
+ requirements:
44
+ - - ">="
45
+ - !ruby/object:Gem::Version
46
+ version: "0"
47
+ required_rubygems_version: !ruby/object:Gem::Requirement
48
+ none: false
49
+ requirements:
50
+ - - ">="
51
+ - !ruby/object:Gem::Version
52
+ version: "0"
53
+ requirements: []
54
+
55
+ rubyforge_project: truncate_with_hover
56
+ rubygems_version: 1.8.5
57
+ signing_key:
58
+ specification_version: 3
59
+ summary: Like Rails' TextHelper#truncate, except with hover text.
60
+ test_files: []
61
+