mh_extensions 0.1.5.4 → 0.1.5.5

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG.rdoc CHANGED
@@ -1,3 +1,5 @@
1
+ = Version 0.1.5.5
2
+ * String to class converter: "Fixnum".to_class #=> Fixnum
1
3
  = Version 0.1.5.3
2
4
  * Workaround for Rails dev env
3
5
  = Version 0.1.5
data/Manifest CHANGED
@@ -15,5 +15,4 @@ lib/mh_extensions.rb
15
15
  lib/rand.rb
16
16
  lib/range.rb
17
17
  lib/string.rb
18
- lib/string_ext.rb
19
18
  lib/txt_file_handler.rb
data/Rakefile CHANGED
@@ -1,8 +1,9 @@
1
+ require 'psych'
1
2
  require 'rubygems'
2
3
  require 'rake'
3
4
  require 'echoe'
4
5
 
5
- Echoe.new('mh_extensions', '0.1.5.4') do |p|
6
+ Echoe.new('mh_extensions', '0.1.5.5') do |p|
6
7
  p.description = "Package of usefull ruby basic classes (and not only) extensions"
7
8
  p.url = "https://github.com/mensfeld/MH-Extensions"
8
9
  p.author = "Maciej Mensfeld"
data/lib/mh_extensions.rb CHANGED
@@ -4,7 +4,6 @@ require "hash"
4
4
  require "rand"
5
5
  require "range"
6
6
  require "string"
7
- require "string_ext"
8
7
  require "browser_detector"
9
8
  require "txt_file_handler"
10
9
  require "acts_as_tree_ext"
data/lib/string.rb CHANGED
@@ -87,4 +87,25 @@ class String
87
87
  self
88
88
  end
89
89
 
90
+ def is_number?
91
+ self.match(/\A[+-]?\d+?(\.\d+)?\Z/) == nil ? false : true
92
+ end
93
+
94
+ # Allows you turning a string into a class if class with provided name exists
95
+ # Examples:
96
+ # "Fixnum".to_class #=> Fixnum
97
+ # "Something".to_class #=> nil
98
+ class String
99
+ def to_class
100
+ chain = self.split "::"
101
+ klass = Kernel
102
+ chain.each do |klass_string|
103
+ klass = klass.const_get klass_string
104
+ end
105
+ klass.is_a?(Class) ? klass : nil
106
+ rescue NameError
107
+ nil
108
+ end
109
+ end
110
+
90
111
  end
@@ -2,22 +2,20 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{mh_extensions}
5
- s.version = "0.1.5.4"
5
+ s.version = "0.1.5.5"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
8
- s.authors = ["Maciej Mensfeld"]
9
- s.cert_chain = ["/home/mencio/.cert_keys/gem-public_cert.pem"]
10
- s.date = %q{2011-05-03}
8
+ s.authors = [%q{Maciej Mensfeld}]
9
+ s.date = %q{2011-07-07}
11
10
  s.description = %q{Package of usefull ruby basic classes (and not only) extensions}
12
11
  s.email = %q{maciej@mensfeld.pl}
13
- s.extra_rdoc_files = ["CHANGELOG.rdoc", "README.md", "lib/activerecord_ext.rb", "lib/acts_as_tree_ext.rb", "lib/array.rb", "lib/browser_detector.rb", "lib/date_ext.rb", "lib/hash.rb", "lib/mh_extensions.rb", "lib/rand.rb", "lib/range.rb", "lib/string.rb", "lib/string_ext.rb", "lib/txt_file_handler.rb"]
14
- s.files = ["CHANGELOG.rdoc", "Gemfile", "MIT-LICENSE", "Manifest", "README.md", "Rakefile", "init.rb", "lib/activerecord_ext.rb", "lib/acts_as_tree_ext.rb", "lib/array.rb", "lib/browser_detector.rb", "lib/date_ext.rb", "lib/hash.rb", "lib/mh_extensions.rb", "lib/rand.rb", "lib/range.rb", "lib/string.rb", "lib/string_ext.rb", "lib/txt_file_handler.rb", "mh_extensions.gemspec"]
12
+ s.extra_rdoc_files = [%q{CHANGELOG.rdoc}, %q{README.md}, %q{lib/activerecord_ext.rb}, %q{lib/acts_as_tree_ext.rb}, %q{lib/array.rb}, %q{lib/browser_detector.rb}, %q{lib/date_ext.rb}, %q{lib/hash.rb}, %q{lib/mh_extensions.rb}, %q{lib/rand.rb}, %q{lib/range.rb}, %q{lib/string.rb}, %q{lib/txt_file_handler.rb}]
13
+ s.files = [%q{CHANGELOG.rdoc}, %q{Gemfile}, %q{MIT-LICENSE}, %q{Manifest}, %q{README.md}, %q{Rakefile}, %q{init.rb}, %q{lib/activerecord_ext.rb}, %q{lib/acts_as_tree_ext.rb}, %q{lib/array.rb}, %q{lib/browser_detector.rb}, %q{lib/date_ext.rb}, %q{lib/hash.rb}, %q{lib/mh_extensions.rb}, %q{lib/rand.rb}, %q{lib/range.rb}, %q{lib/string.rb}, %q{lib/txt_file_handler.rb}, %q{mh_extensions.gemspec}]
15
14
  s.homepage = %q{https://github.com/mensfeld/MH-Extensions}
16
- s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Mh_extensions", "--main", "README.md"]
17
- s.require_paths = ["lib"]
15
+ s.rdoc_options = [%q{--line-numbers}, %q{--inline-source}, %q{--title}, %q{Mh_extensions}, %q{--main}, %q{README.md}]
16
+ s.require_paths = [%q{lib}]
18
17
  s.rubyforge_project = %q{mh_extensions}
19
- s.rubygems_version = %q{1.5.2}
20
- s.signing_key = %q{/home/mencio/.cert_keys/gem-private_key.pem}
18
+ s.rubygems_version = %q{1.8.5}
21
19
  s.summary = %q{Package of usefull ruby basic classes (and not only) extensions}
22
20
 
23
21
  if s.respond_to? :specification_version then
metadata CHANGED
@@ -1,47 +1,21 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: mh_extensions
3
- version: !ruby/object:Gem::Version
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.5.5
4
5
  prerelease:
5
- version: 0.1.5.4
6
6
  platform: ruby
7
- authors:
7
+ authors:
8
8
  - Maciej Mensfeld
9
9
  autorequire:
10
10
  bindir: bin
11
- cert_chain:
12
- - |
13
- -----BEGIN CERTIFICATE-----
14
- MIIDMjCCAhqgAwIBAgIBADANBgkqhkiG9w0BAQUFADA/MQ8wDQYDVQQDDAZtYWNp
15
- ZWoxGDAWBgoJkiaJk/IsZAEZFghtZW5zZmVsZDESMBAGCgmSJomT8ixkARkWAnBs
16
- MB4XDTExMDQwOTA5NDcyMloXDTEyMDQwODA5NDcyMlowPzEPMA0GA1UEAwwGbWFj
17
- aWVqMRgwFgYKCZImiZPyLGQBGRYIbWVuc2ZlbGQxEjAQBgoJkiaJk/IsZAEZFgJw
18
- bDCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAL0+nG3V4/exIeiJ0IN+
19
- wVfq8Utcu4Qpo+58EIVMIu3FiK+8w6MBvatZnUrRu12pqWLw9xrUkCiYeRErD+jF
20
- AmdggIM/tu9CcjvURXH7VeTzOVA+pnV+eJWMD61o8HljFVcb/nyEYYVKErtr9/O4
21
- QrIGv5lnszq1PMj2sBMy2gOP1YnzawncMLmkpp/T5SU4JZ5gAktGMRVz8RxmZzF5
22
- 6NVqFLbuqSRSU5U//WJvZVJt8dycCGgQzBM4Vi3nkOWyjIF0BANf1TqnlU2u6s8d
23
- UK1AoDZfg5feef5e8eqoomHebX1opNGM/SOQhu3LRgax4rJfnl6VS3I2wighohsf
24
- AgcCAwEAAaM5MDcwCQYDVR0TBAIwADAdBgNVHQ4EFgQUGlrWBqxVieAPk7NEzBDp
25
- kM+iAMMwCwYDVR0PBAQDAgSwMA0GCSqGSIb3DQEBBQUAA4IBAQAJMoyBaJs8boiz
26
- lFpbw6MWjk+7ZhqoHpFrWEV4nzb5GzyHZ7GU/pa1fSEQR0SCs+LnTLQbAYNQyUTT
27
- O+UsTuA7xzI//v6cSodv3Q9NbfoDlou74xv1NXorWoosQFMpVWrXv+c/1RqU3cq4
28
- WUr+rRiveEXG4tXOwkrpX8KH8xVp2vQZcGw3AXPqhzfqDGzpHd6ws3lk+8HoSrSo
29
- 2L68tDoxraF2Z2toAg9vfFw1+mOeDk1xVIPVcBy3tJxstHfHGHlQuMiRiDQX2b2D
30
- YYU8UWVt2841IwB5Dgl4O+atXhe9ZTBO0W32pl4Bq5CP9lhQRT1KL7sxfznJlF7Y
31
- BH3YFsdk
32
- -----END CERTIFICATE-----
33
-
34
- date: 2011-05-03 00:00:00 +02:00
35
- default_executable:
11
+ cert_chain: []
12
+ date: 2011-07-07 00:00:00.000000000Z
36
13
  dependencies: []
37
-
38
14
  description: Package of usefull ruby basic classes (and not only) extensions
39
15
  email: maciej@mensfeld.pl
40
16
  executables: []
41
-
42
17
  extensions: []
43
-
44
- extra_rdoc_files:
18
+ extra_rdoc_files:
45
19
  - CHANGELOG.rdoc
46
20
  - README.md
47
21
  - lib/activerecord_ext.rb
@@ -54,9 +28,8 @@ extra_rdoc_files:
54
28
  - lib/rand.rb
55
29
  - lib/range.rb
56
30
  - lib/string.rb
57
- - lib/string_ext.rb
58
31
  - lib/txt_file_handler.rb
59
- files:
32
+ files:
60
33
  - CHANGELOG.rdoc
61
34
  - Gemfile
62
35
  - MIT-LICENSE
@@ -74,41 +47,36 @@ files:
74
47
  - lib/rand.rb
75
48
  - lib/range.rb
76
49
  - lib/string.rb
77
- - lib/string_ext.rb
78
50
  - lib/txt_file_handler.rb
79
51
  - mh_extensions.gemspec
80
- has_rdoc: true
81
52
  homepage: https://github.com/mensfeld/MH-Extensions
82
53
  licenses: []
83
-
84
54
  post_install_message:
85
- rdoc_options:
55
+ rdoc_options:
86
56
  - --line-numbers
87
57
  - --inline-source
88
58
  - --title
89
59
  - Mh_extensions
90
60
  - --main
91
61
  - README.md
92
- require_paths:
62
+ require_paths:
93
63
  - lib
94
- required_ruby_version: !ruby/object:Gem::Requirement
64
+ required_ruby_version: !ruby/object:Gem::Requirement
95
65
  none: false
96
- requirements:
97
- - - ">="
98
- - !ruby/object:Gem::Version
99
- version: "0"
100
- required_rubygems_version: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - ! '>='
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
70
+ required_rubygems_version: !ruby/object:Gem::Requirement
101
71
  none: false
102
- requirements:
103
- - - ">="
104
- - !ruby/object:Gem::Version
105
- version: "1.2"
72
+ requirements:
73
+ - - ! '>='
74
+ - !ruby/object:Gem::Version
75
+ version: '1.2'
106
76
  requirements: []
107
-
108
77
  rubyforge_project: mh_extensions
109
- rubygems_version: 1.5.2
78
+ rubygems_version: 1.8.5
110
79
  signing_key:
111
80
  specification_version: 3
112
81
  summary: Package of usefull ruby basic classes (and not only) extensions
113
82
  test_files: []
114
-
data/lib/string_ext.rb DELETED
@@ -1,57 +0,0 @@
1
- # coding: utf-8
2
-
3
- # Required string extensions
4
-
5
- class String
6
- # Removes any "not url friendly" stuff and returns "pure" url
7
- def to_url
8
- temp = self.downcase
9
- temp
10
- temp.gsub!(/[âäàãáäå�?ăąǎǟǡǻ�?ȃȧẵặ]/,'a')
11
- temp.gsub!(/[ëêéèẽēĕėẻȅȇẹȩęḙḛ�?ếễểḕḗệ�?]/,'e')
12
- temp.gsub!(/[�?iìíîĩīĭïỉ�?ịįȉȋḭɨḯ]/,'i')
13
- temp.gsub!(/[òóôõ�?�?ȯö�?őǒ�?�?ơǫ�?ɵøồốỗổȱȫȭ�?�?ṑṓ�?ớỡởợǭộǿ]/,'o')
14
- temp.gsub!(/[ùúûũūŭüủůűǔȕȗưụṳųṷṵṹṻǖǜǘǖǚừứữửự]/,'u')
15
- temp.gsub!(/[ỳýŷỹȳ�?ÿỷẙƴỵ]/,'y')
16
- temp.gsub!(/[ñǹń]/,'n')
17
- temp.gsub!(/[çć]/,'c')
18
- temp.gsub!(/[ß]/,'ss')
19
- temp.gsub!(/[œ]/,'oe')
20
- temp.gsub!(/[ij]/,'ij')
21
- temp.gsub!(/[�?ł]/,'l')
22
- temp.gsub!(/[ś]/,'s')
23
- temp.gsub!(/[źż]/,'z')
24
- temp.gsub!(/[^a-zA-Z 0-9]/, "")
25
- temp.gsub!(/\s/,'-')
26
- temp.gsub!(/\-+$/,'')
27
- temp.gsub!(/^\-+/,'')
28
- temp
29
- end
30
-
31
- def to_url!
32
- self.replace self.to_url
33
- end
34
-
35
- # Change new line to html <br/>
36
- def nl2br
37
- self.gsub("\n\r","<br>").gsub("\r", "").gsub("\n", "<br />")
38
- end
39
-
40
- def nl2br!
41
- self.replace self.nl2br
42
- end
43
-
44
- # Trim string to required length
45
- def trim(length = 20, end_str = '...')
46
- if self.length > length
47
- return "#{self[0, length-end_str.length]}#{end_str}"
48
- end
49
- self
50
- end
51
-
52
- def trim!(length = 20, end_str = '...')
53
- self.replace self.trim(length, end_str)
54
- self
55
- end
56
-
57
- end
data.tar.gz.sig DELETED
Binary file
metadata.gz.sig DELETED
@@ -1,4 +0,0 @@
1
- 9*��ر��*& ��i�b��K�[PGxE��M�o�u��ڗ��Z�z4�F���� ̏����2�n*�2�8�fc
2
- ��Y�{��y:Û0U�olXMs�QU���u�:��6`Y¶�mo�"�^;���('� �C ��ߊ�5Jc��g�MTmj��ԩ�LQ�ێ�t�
3
- EԪ��B2���jje`
4
- �@����e��^#Y��c�(���]��)��w�9}(�g��Qΐ��:Vn/