mh_extensions 0.1.5.5 → 0.1.5.6

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.
data/CHANGELOG.rdoc CHANGED
@@ -1,3 +1,5 @@
1
+ = Version 0.1.5.6
2
+ * Camelize from ActiveSupport::Inflector (to use outside of Rails)
1
3
  = Version 0.1.5.5
2
4
  * String to class converter: "Fixnum".to_class #=> Fixnum
3
5
  = Version 0.1.5.3
data/Rakefile CHANGED
@@ -3,7 +3,7 @@ require 'rubygems'
3
3
  require 'rake'
4
4
  require 'echoe'
5
5
 
6
- Echoe.new('mh_extensions', '0.1.5.5') do |p|
6
+ Echoe.new('mh_extensions', '0.1.5.6') do |p|
7
7
  p.description = "Package of usefull ruby basic classes (and not only) extensions"
8
8
  p.url = "https://github.com/mensfeld/MH-Extensions"
9
9
  p.author = "Maciej Mensfeld"
data/lib/string.rb CHANGED
@@ -95,8 +95,7 @@ class String
95
95
  # Examples:
96
96
  # "Fixnum".to_class #=> Fixnum
97
97
  # "Something".to_class #=> nil
98
- class String
99
- def to_class
98
+ def to_class
100
99
  chain = self.split "::"
101
100
  klass = Kernel
102
101
  chain.each do |klass_string|
@@ -106,6 +105,18 @@ class String
106
105
  rescue NameError
107
106
  nil
108
107
  end
108
+
109
+ def camelize(first_letter_in_uppercase = true)
110
+ if first_letter_in_uppercase
111
+ self.to_s.gsub(/\/(.?)/) { "::#{$1.upcase}" }.gsub(/(?:^|_)(.)/) { $1.upcase }
112
+ else
113
+ self.to_s[0].chr.downcase + camelize(self)[1..-1]
114
+ end
115
+ end
116
+
117
+ def camelize!(first_letter_in_uppercase = true)
118
+ self.replace self.camelize(first_letter_in_uppercase)
119
+ self
109
120
  end
110
121
 
111
122
  end
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{mh_extensions}
5
- s.version = "0.1.5.5"
5
+ s.version = "0.1.5.6"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = [%q{Maciej Mensfeld}]
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mh_extensions
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.5.5
4
+ version: 0.1.5.6
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: