rahoulb-rujitsu 0.1.0

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.
Files changed (5) hide show
  1. data/README.rdoc +47 -0
  2. data/Rakefile +16 -0
  3. data/lib/rujitsu.rb +50 -0
  4. data/rujitsu.gemspec +31 -0
  5. metadata +63 -0
data/README.rdoc ADDED
@@ -0,0 +1,47 @@
1
+ = rujitsu
2
+
3
+ A Rails gem with various helper methods to smooth out your Ruby development.
4
+
5
+ == Install
6
+
7
+ gem install rahoulb-rujitsu --source http://gems.github.com
8
+
9
+ == Usage
10
+
11
+ === Generating random strings
12
+
13
+ The Fixnum class has a couple of extensions allowing you to generate random strings.
14
+
15
+ 5.random_letters
16
+ 5.random_numbers
17
+ 5.random_characters
18
+
19
+ === URL-friendly strings
20
+
21
+ The String class has an extension that strips out URL-unfriendly characters.
22
+
23
+ ""$%hello!@ 123 there'".to_url # => "hello-123-there"
24
+
25
+ == Released under the MIT Licence
26
+
27
+ Copyright (c) 2008 Brightbox Systems Ltd
28
+
29
+ Permission is hereby granted, free of charge, to any person obtaining a copy
30
+ of this software and associated documentation files (the "Software"), to deal
31
+ in the Software without restriction, including without limitation the rights
32
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
33
+ copies of the Software, and to permit persons to whom the Software is
34
+ furnished to do so, subject to the following conditions:
35
+
36
+ * The above copyright notice and this permission notice shall be included in
37
+ all copies or substantial portions of the Software.
38
+
39
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
40
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
41
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
42
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
43
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
44
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
45
+ THE SOFTWARE.
46
+
47
+ See http://www.brightbox.co.uk/ for contact details.
data/Rakefile ADDED
@@ -0,0 +1,16 @@
1
+ require 'rubygems'
2
+ require 'rake'
3
+ require 'echoe'
4
+
5
+ Echoe.new('rujitsu', '0.1.0') do | config |
6
+ config.description = 'Various helper methods to smooth over Ruby development'
7
+ config.url = 'http://github.com/rahoub/rujitsu'
8
+ config.author = 'Rahoul Baruah'
9
+ config.email = 'hello@3hv.co.uk'
10
+ config.ignore_pattern = ['tmp/*', 'script/*']
11
+ config.development_dependencies = []
12
+ end
13
+
14
+ Dir["#{File.dirname(__FILE__)}/tasks/*.rake"].sort.each do | rake_file |
15
+ load rake_file
16
+ end
data/lib/rujitsu.rb ADDED
@@ -0,0 +1,50 @@
1
+ class Numeric
2
+ # convert float values to "cents"
3
+ # my_value = 2.5
4
+ # my_value.to_cents # => 250
5
+ def to_cents
6
+ (self * 100.0).to_i
7
+ end
8
+ end
9
+
10
+ class Fixnum
11
+ #�produce a string of N random letters
12
+ # 5.random_letters
13
+ def random_letters
14
+ generate_random_string_using LETTERS
15
+ end
16
+ # produce a string of N random numbers
17
+ # 5.random_numbers
18
+ def random_numbers
19
+ generate_random_string_using NUMBERS
20
+ end
21
+ # produce a string of N random characters
22
+ # 5.random_characters
23
+ def random_characters
24
+ generate_random_string_using CHARACTERS
25
+ end
26
+
27
+ private
28
+
29
+ LETTERS = ('a'..'z').to_a
30
+ NUMBERS = ('0'..'9').to_a
31
+ CHARACTERS = LETTERS + NUMBERS
32
+
33
+ def generate_random_string_using legal_characters
34
+ result = ""
35
+ upper_limit = legal_characters.size - 1
36
+ self.times do | num |
37
+ result << legal_characters[rand(upper_limit)]
38
+ end
39
+ return result
40
+ end
41
+ end
42
+
43
+ class String
44
+ # Return a string that can be used as part of a url
45
+ def to_url
46
+ self.downcase.gsub(/[^\-0-9a-z ]/, '').split.join('-')
47
+ end
48
+ end
49
+
50
+
data/rujitsu.gemspec ADDED
@@ -0,0 +1,31 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ Gem::Specification.new do |s|
4
+ s.name = %q{rujitsu}
5
+ s.version = "0.1.0"
6
+
7
+ s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
8
+ s.authors = ["Rahoul Baruah"]
9
+ s.date = %q{2008-11-24}
10
+ s.description = %q{Various helper methods to smooth over Ruby development}
11
+ s.email = %q{hello@3hv.co.uk}
12
+ s.extra_rdoc_files = ["lib/rujitsu.rb", "README.rdoc"]
13
+ s.files = ["lib/rujitsu.rb", "Rakefile", "README.rdoc", "Manifest", "rujitsu.gemspec"]
14
+ s.has_rdoc = true
15
+ s.homepage = %q{http://github.com/rahoub/rujitsu}
16
+ s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Rujitsu", "--main", "README.rdoc"]
17
+ s.require_paths = ["lib"]
18
+ s.rubyforge_project = %q{rujitsu}
19
+ s.rubygems_version = %q{1.3.1}
20
+ s.summary = %q{Various helper methods to smooth over Ruby development}
21
+
22
+ if s.respond_to? :specification_version then
23
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
24
+ s.specification_version = 2
25
+
26
+ if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
27
+ else
28
+ end
29
+ else
30
+ end
31
+ end
metadata ADDED
@@ -0,0 +1,63 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rahoulb-rujitsu
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Rahoul Baruah
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2008-11-24 00:00:00 -08:00
13
+ default_executable:
14
+ dependencies: []
15
+
16
+ description: Various helper methods to smooth over Ruby development
17
+ email: hello@3hv.co.uk
18
+ executables: []
19
+
20
+ extensions: []
21
+
22
+ extra_rdoc_files:
23
+ - lib/rujitsu.rb
24
+ - README.rdoc
25
+ files:
26
+ - lib/rujitsu.rb
27
+ - Rakefile
28
+ - README.rdoc
29
+ - Manifest
30
+ - rujitsu.gemspec
31
+ has_rdoc: true
32
+ homepage: http://github.com/rahoub/rujitsu
33
+ post_install_message:
34
+ rdoc_options:
35
+ - --line-numbers
36
+ - --inline-source
37
+ - --title
38
+ - Rujitsu
39
+ - --main
40
+ - README.rdoc
41
+ require_paths:
42
+ - lib
43
+ required_ruby_version: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: "0"
48
+ version:
49
+ required_rubygems_version: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - ">="
52
+ - !ruby/object:Gem::Version
53
+ version: "1.2"
54
+ version:
55
+ requirements: []
56
+
57
+ rubyforge_project: rujitsu
58
+ rubygems_version: 1.2.0
59
+ signing_key:
60
+ specification_version: 2
61
+ summary: Various helper methods to smooth over Ruby development
62
+ test_files: []
63
+