ruby_extensions 1.0.5 → 1.0.8

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/lib/m_hash.rb ADDED
@@ -0,0 +1,11 @@
1
+ class Hash
2
+
3
+ def join(pair_string, join_string)
4
+ a = []
5
+ self.each_pair do |k, v|
6
+ a << sprintf(pair_string, k, v)
7
+ end
8
+ a.join(join_string)
9
+ end
10
+
11
+ end
data/lib/m_kernel.rb CHANGED
@@ -9,4 +9,22 @@ module Kernel
9
9
  return pp_out.string
10
10
  end
11
11
 
12
+ def retryable(options = {}, &block)
13
+ opts = { :tries => 1, :on => Exception }.merge(options)
14
+
15
+ retries = opts[:tries]
16
+ retry_exceptions = [opts[:on]].flatten
17
+
18
+ x = %{
19
+ begin
20
+ return yield
21
+ rescue #{retry_exceptions.join(", ")} => e
22
+ retries -= 1
23
+ retry if retries > 0
24
+ end
25
+ }
26
+
27
+ eval(x, &block)
28
+ end
29
+
12
30
  end
data/lib/m_string.rb CHANGED
@@ -1,7 +1,31 @@
1
- require 'active_support'
2
1
  class String
3
2
 
4
- include ActiveSupport::CoreExtensions::String::Inflections
3
+ def linkify(enabled = true, options = {}, &block)
4
+ text = self.dup
5
+ m = text.match(/(\".*?\":\S*)/)
6
+ until m.nil?
7
+ y = m.to_s.strip
8
+ t = y.match(/\"(.*)\"/).captures
9
+ url = y.match(/\":(.*)/).captures
10
+ break if t.to_s == "" or url.to_s == ""
11
+ if block_given?
12
+ if enabled
13
+ ret = yield t, url, options
14
+ text.gsub!(y, ret)
15
+ else
16
+ text.gsub!(y, t.to_s)
17
+ end
18
+ else
19
+ if enabled
20
+ text.gsub!(y, "<a href=\"#{url}\" #{options.join("%s=\"%s\"", " ")}>#{t}</a>")
21
+ else
22
+ text.gsub!(y, t.to_s)
23
+ end
24
+ end
25
+ m = text.match(/\s(\".*?\":\S*)/)
26
+ end
27
+ return text
28
+ end
5
29
 
6
30
  def methodize
7
31
  x = self
@@ -76,6 +100,15 @@ class String
76
100
  x
77
101
  end
78
102
 
103
+ def underscore
104
+ camel_cased_word = self.dup
105
+ camel_cased_word.to_s.gsub(/::/, '/').
106
+ gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2').
107
+ gsub(/([a-z\d])([A-Z])/,'\1_\2').
108
+ tr("-", "_").
109
+ downcase
110
+ end
111
+
79
112
  def starts_with?(x)
80
113
  self.match(/^#{x}/) ? true : false
81
114
  end
@@ -2,4 +2,4 @@
2
2
  gem_name: ruby_extensions
3
3
  package: ruby_extensions
4
4
  project: magrathea
5
- version: 1.0.5
5
+ version: 1.0.8
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby_extensions
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.5
4
+ version: 1.0.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - markbates
@@ -14,6 +14,7 @@ autorequire:
14
14
  - m_math
15
15
  - m_logger
16
16
  - m_kernel
17
+ - m_hash
17
18
  - m_float
18
19
  - m_dir
19
20
  - m_class
@@ -26,6 +27,7 @@ autorequire:
26
27
  - m_math
27
28
  - m_logger
28
29
  - m_kernel
30
+ - m_hash
29
31
  - m_float
30
32
  - m_dir
31
33
  - m_class
@@ -33,7 +35,7 @@ autorequire:
33
35
  bindir: bin
34
36
  cert_chain: []
35
37
 
36
- date: 2008-01-25 00:00:00 -05:00
38
+ date: 2008-01-29 00:00:00 -05:00
37
39
  default_executable:
38
40
  dependencies: []
39
41
 
@@ -51,6 +53,7 @@ files:
51
53
  - lib/m_class.rb
52
54
  - lib/m_dir.rb
53
55
  - lib/m_float.rb
56
+ - lib/m_hash.rb
54
57
  - lib/m_kernel.rb
55
58
  - lib/m_logger.rb
56
59
  - lib/m_math.rb