neerajdotname-tidbits 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. data/README.markdown +35 -0
  2. data/lib/tidbits.rb +29 -0
  3. metadata +57 -0
@@ -0,0 +1,35 @@
1
+ == Introduction
2
+
3
+ This is a collection of useful tools I have picked up over the time. Please go through the comments
4
+ posted in source code to get a feel of what it contains.
5
+
6
+ == How to install
7
+
8
+ <pre>
9
+ <code>
10
+ gem sources -a http://gems.github.com
11
+ sudo gem install neerajdotname-tidbits
12
+ </code>
13
+ </pre>
14
+
15
+ <pre>
16
+ <code>
17
+ config.gem "neerajdotname-tidbits",
18
+ :lib => tidbits',
19
+ :source => 'http://gems.github.com'
20
+ </code>
21
+ </pre>
22
+
23
+ == Feedback
24
+
25
+ Email me: neerajdotname [at] gmail (dot) com
26
+
27
+ == Author Blog
28
+
29
+ www.neeraj.name
30
+
31
+ == License
32
+
33
+ MIT
34
+
35
+ Copyright (c) 2009 neerajdotname
@@ -0,0 +1,29 @@
1
+ class String
2
+
3
+ # squeezes non-alphanumeric character sequences down to one underscore
4
+ # also makes sure it doesn't start or end with an underscore:
5
+ # \W neither letter or digit
6
+ # \W Any non-word character [^a-zA-Z0-9_]
7
+ # more at http://www.roblocher.com/technotes/regexp.aspx
8
+ #
9
+ def sluggify(length = 40)
10
+ downcase.gsub(/\W/, ' ').strip.gsub(' ', '-').squeeze('-')
11
+ end
12
+
13
+ # this lets you do things like
14
+ # f = 'foo'
15
+ # f.foo? #=> true
16
+ # f.woo? #=> false
17
+ #
18
+ # inspired by StringInquirer in ActiveSupport
19
+ def method_missing(method_name, *arguments)
20
+ if method_name.to_s[-1,1] == "?"
21
+ self == method_name.to_s[0..-2]
22
+ else
23
+ super
24
+ end
25
+ end
26
+
27
+
28
+ end
29
+
metadata ADDED
@@ -0,0 +1,57 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: neerajdotname-tidbits
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Neeraj Singh
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2009-08-10 00:00:00 -07:00
13
+ default_executable:
14
+ dependencies: []
15
+
16
+ description: collection of useful utilities.
17
+ email:
18
+ - neerajdotname@gmail.com
19
+ executables: []
20
+
21
+ extensions: []
22
+
23
+ extra_rdoc_files:
24
+ - README.markdown
25
+ files:
26
+ - README.markdown
27
+ - lib/tidbits.rb
28
+ has_rdoc: false
29
+ homepage: http://github.com/neerajdotname/tidbits
30
+ licenses:
31
+ post_install_message:
32
+ rdoc_options:
33
+ - --main
34
+ - README.markdown
35
+ require_paths:
36
+ - lib
37
+ required_ruby_version: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - ">="
40
+ - !ruby/object:Gem::Version
41
+ version: "0"
42
+ version:
43
+ required_rubygems_version: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: "0"
48
+ version:
49
+ requirements: []
50
+
51
+ rubyforge_project: neerajdotname
52
+ rubygems_version: 1.3.5
53
+ signing_key:
54
+ specification_version: 2
55
+ summary: collection of useful tools
56
+ test_files: []
57
+