hobosupport 0.8.3 → 0.8.4
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/Manifest +15 -13
- data/Rakefile +1 -1
- data/hobosupport.gemspec +34 -30
- data/lib/hobo_support.rb +56 -0
- data/lib/{hobosupport → hobo_support}/array.rb +0 -0
- data/lib/{hobosupport → hobo_support}/blankslate.rb +0 -0
- data/lib/{hobosupport → hobo_support}/enumerable.rb +0 -0
- data/lib/hobo_support/fixes.rb +3 -0
- data/lib/hobo_support/fixes/chronic.rb +21 -0
- data/lib/{hobosupport → hobo_support}/fixes/module.rb +0 -0
- data/lib/{hobosupport → hobo_support}/fixes/pp.rb +0 -0
- data/lib/{hobosupport → hobo_support}/hash.rb +0 -0
- data/lib/{hobosupport → hobo_support}/implies.rb +0 -0
- data/lib/{hobosupport → hobo_support}/metaid.rb +0 -0
- data/lib/{hobosupport → hobo_support}/methodcall.rb +0 -0
- data/lib/{hobosupport → hobo_support}/methodphitamine.rb +0 -0
- data/lib/{hobosupport → hobo_support}/module.rb +4 -5
- data/lib/hobo_support/string.rb +19 -0
- data/lib/hobosupport.rb +12 -29
- metadata +33 -29
- data/lib/hobosupport/fixes.rb +0 -3
- data/lib/hobosupport/fixes/chronic.rb +0 -18
data/Manifest
CHANGED
@@ -1,17 +1,19 @@
|
|
1
1
|
CHANGES.txt
|
2
|
-
lib/
|
3
|
-
lib/
|
4
|
-
lib/
|
5
|
-
lib/
|
6
|
-
lib/
|
7
|
-
lib/
|
8
|
-
lib/
|
9
|
-
lib/
|
10
|
-
lib/
|
11
|
-
lib/
|
12
|
-
lib/
|
13
|
-
lib/
|
14
|
-
lib/
|
2
|
+
lib/hobo_support/array.rb
|
3
|
+
lib/hobo_support/blankslate.rb
|
4
|
+
lib/hobo_support/enumerable.rb
|
5
|
+
lib/hobo_support/fixes/chronic.rb
|
6
|
+
lib/hobo_support/fixes/module.rb
|
7
|
+
lib/hobo_support/fixes/pp.rb
|
8
|
+
lib/hobo_support/fixes.rb
|
9
|
+
lib/hobo_support/hash.rb
|
10
|
+
lib/hobo_support/implies.rb
|
11
|
+
lib/hobo_support/metaid.rb
|
12
|
+
lib/hobo_support/methodcall.rb
|
13
|
+
lib/hobo_support/methodphitamine.rb
|
14
|
+
lib/hobo_support/module.rb
|
15
|
+
lib/hobo_support/string.rb
|
16
|
+
lib/hobo_support.rb
|
15
17
|
lib/hobosupport.rb
|
16
18
|
Manifest
|
17
19
|
Manifest.txt
|
data/Rakefile
CHANGED
data/hobosupport.gemspec
CHANGED
@@ -1,18 +1,18 @@
|
|
1
1
|
|
2
|
-
# Gem::Specification for Hobosupport-0.8.
|
2
|
+
# Gem::Specification for Hobosupport-0.8.4
|
3
3
|
# Originally generated by Echoe
|
4
4
|
|
5
5
|
--- !ruby/object:Gem::Specification
|
6
6
|
name: hobosupport
|
7
7
|
version: !ruby/object:Gem::Version
|
8
|
-
version: 0.8.
|
8
|
+
version: 0.8.4
|
9
9
|
platform: ruby
|
10
10
|
authors:
|
11
11
|
- Tom Locke
|
12
12
|
autorequire:
|
13
13
|
bindir: bin
|
14
14
|
|
15
|
-
date: 2008-
|
15
|
+
date: 2008-12-06 00:00:00 +00:00
|
16
16
|
default_executable:
|
17
17
|
dependencies: []
|
18
18
|
|
@@ -23,36 +23,40 @@ executables: []
|
|
23
23
|
extensions: []
|
24
24
|
|
25
25
|
extra_rdoc_files:
|
26
|
-
- lib/
|
27
|
-
- lib/
|
28
|
-
- lib/
|
29
|
-
- lib/
|
30
|
-
- lib/
|
31
|
-
- lib/
|
32
|
-
- lib/
|
33
|
-
- lib/
|
34
|
-
- lib/
|
35
|
-
- lib/
|
36
|
-
- lib/
|
37
|
-
- lib/
|
38
|
-
- lib/
|
26
|
+
- lib/hobo_support/array.rb
|
27
|
+
- lib/hobo_support/blankslate.rb
|
28
|
+
- lib/hobo_support/enumerable.rb
|
29
|
+
- lib/hobo_support/fixes/chronic.rb
|
30
|
+
- lib/hobo_support/fixes/module.rb
|
31
|
+
- lib/hobo_support/fixes/pp.rb
|
32
|
+
- lib/hobo_support/fixes.rb
|
33
|
+
- lib/hobo_support/hash.rb
|
34
|
+
- lib/hobo_support/implies.rb
|
35
|
+
- lib/hobo_support/metaid.rb
|
36
|
+
- lib/hobo_support/methodcall.rb
|
37
|
+
- lib/hobo_support/methodphitamine.rb
|
38
|
+
- lib/hobo_support/module.rb
|
39
|
+
- lib/hobo_support/string.rb
|
40
|
+
- lib/hobo_support.rb
|
39
41
|
- lib/hobosupport.rb
|
40
42
|
- README.txt
|
41
43
|
files:
|
42
44
|
- CHANGES.txt
|
43
|
-
- lib/
|
44
|
-
- lib/
|
45
|
-
- lib/
|
46
|
-
- lib/
|
47
|
-
- lib/
|
48
|
-
- lib/
|
49
|
-
- lib/
|
50
|
-
- lib/
|
51
|
-
- lib/
|
52
|
-
- lib/
|
53
|
-
- lib/
|
54
|
-
- lib/
|
55
|
-
- lib/
|
45
|
+
- lib/hobo_support/array.rb
|
46
|
+
- lib/hobo_support/blankslate.rb
|
47
|
+
- lib/hobo_support/enumerable.rb
|
48
|
+
- lib/hobo_support/fixes/chronic.rb
|
49
|
+
- lib/hobo_support/fixes/module.rb
|
50
|
+
- lib/hobo_support/fixes/pp.rb
|
51
|
+
- lib/hobo_support/fixes.rb
|
52
|
+
- lib/hobo_support/hash.rb
|
53
|
+
- lib/hobo_support/implies.rb
|
54
|
+
- lib/hobo_support/metaid.rb
|
55
|
+
- lib/hobo_support/methodcall.rb
|
56
|
+
- lib/hobo_support/methodphitamine.rb
|
57
|
+
- lib/hobo_support/module.rb
|
58
|
+
- lib/hobo_support/string.rb
|
59
|
+
- lib/hobo_support.rb
|
56
60
|
- lib/hobosupport.rb
|
57
61
|
- Manifest
|
58
62
|
- Manifest.txt
|
@@ -93,7 +97,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
93
97
|
requirements: []
|
94
98
|
|
95
99
|
rubyforge_project: hobo
|
96
|
-
rubygems_version: 1.
|
100
|
+
rubygems_version: 1.3.1
|
97
101
|
specification_version: 2
|
98
102
|
summary: Core Ruby extensions from the Hobo project
|
99
103
|
test_files: []
|
data/lib/hobo_support.rb
ADDED
@@ -0,0 +1,56 @@
|
|
1
|
+
module HoboSupport
|
2
|
+
|
3
|
+
VERSION = "0.8.4"
|
4
|
+
|
5
|
+
end
|
6
|
+
|
7
|
+
|
8
|
+
# Some teeny fixes too diminutive to go elsewhere
|
9
|
+
|
10
|
+
class Object
|
11
|
+
|
12
|
+
# Often nice to ask e.g. some_object.is_a?(Symbol, String)
|
13
|
+
alias_method :is_a_without_multiple_args?, :is_a?
|
14
|
+
def is_a?(*args)
|
15
|
+
args.any? {|a| is_a_without_multiple_args?(a) }
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
19
|
+
|
20
|
+
|
21
|
+
class String
|
22
|
+
|
23
|
+
# Return the constant that this string refers to, or nil if ActiveSupport cannot load such a
|
24
|
+
# constant. This is much safer than `rescue NameError`, as that will mask genuine NameErrors
|
25
|
+
# that have been made in the code being loaded (#safe_constantize will not)
|
26
|
+
def safe_constantize
|
27
|
+
Object.class_eval self
|
28
|
+
rescue NameError => e
|
29
|
+
# Unforunately we have to rely on the error message to figure out which constant was missing.
|
30
|
+
# NameError has a #name method but it is always nil
|
31
|
+
if e.message !~ /\b#{self}$/
|
32
|
+
# oops - some other name error
|
33
|
+
raise
|
34
|
+
else
|
35
|
+
nil
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
40
|
+
|
41
|
+
module Kernel
|
42
|
+
|
43
|
+
def dbg(*args)
|
44
|
+
puts "---DEBUG---"
|
45
|
+
args.each do |a|
|
46
|
+
if a.is_a?(String) && a =~ /\n/
|
47
|
+
puts %("""\n) + a + %(\n"""\n)
|
48
|
+
else
|
49
|
+
p a
|
50
|
+
end
|
51
|
+
end
|
52
|
+
puts "-----------"
|
53
|
+
args.first
|
54
|
+
end
|
55
|
+
|
56
|
+
end
|
File without changes
|
File without changes
|
File without changes
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# --- Fix Chronic - can't parse '12th Jan' --- #
|
2
|
+
begin
|
3
|
+
require 'chronic'
|
4
|
+
|
5
|
+
module Chronic
|
6
|
+
|
7
|
+
class << self
|
8
|
+
def parse_with_hobo_fix(s)
|
9
|
+
if s =~ /^\s*\d+\s*(st|nd|rd|th)\s+[a-zA-Z]+(\s+\d+)?\s*$/
|
10
|
+
s = s.sub(/\s*\d+(st|nd|rd|th)/) {|s| s[0..-3]}
|
11
|
+
end
|
12
|
+
|
13
|
+
# Chronic can't parse '1/1/2008 1:00' or '1/1/2008 1:00 PM',
|
14
|
+
# so convert them to '1/1/2008 @ 1:00' and '1/1/2008 @ 1:00 PM'
|
15
|
+
s = s.sub(/^\s*(\d+\/\d+\/\d+)\s+(\d+:\d+.*)/, '\1 @ \2')
|
16
|
+
parse_without_hobo_fix(s)
|
17
|
+
end
|
18
|
+
alias_method_chain :parse, :hobo_fix
|
19
|
+
end
|
20
|
+
end
|
21
|
+
rescue LoadError; end
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
@@ -10,7 +10,7 @@ class Module
|
|
10
10
|
# like alias_method_chain on the class.
|
11
11
|
def included_in_class_callbacks(base)
|
12
12
|
if base.is_a?(Class)
|
13
|
-
included_modules.each { |m| m.included_in_class(base)
|
13
|
+
included_modules.each { |m| m.try.included_in_class(base) }
|
14
14
|
end
|
15
15
|
end
|
16
16
|
|
@@ -70,12 +70,11 @@ end
|
|
70
70
|
# still write it the same way
|
71
71
|
module Kernel
|
72
72
|
|
73
|
-
def classy_module(&b)
|
74
|
-
|
75
|
-
m.meta_def :included do |base|
|
73
|
+
def classy_module(mod=Module.new, &b)
|
74
|
+
mod.meta_def :included do |base|
|
76
75
|
base.class_eval &b
|
77
76
|
end
|
78
|
-
|
77
|
+
mod
|
79
78
|
end
|
80
79
|
|
81
80
|
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
class String
|
2
|
+
|
3
|
+
def remove(string_or_rx)
|
4
|
+
sub(string_or_rx, '')
|
5
|
+
end
|
6
|
+
|
7
|
+
def remove!(string_or_rx)
|
8
|
+
sub!(string_or_rx, '')
|
9
|
+
end
|
10
|
+
|
11
|
+
def remove_all(string_or_rx)
|
12
|
+
gsub(string_or_rx, '')
|
13
|
+
end
|
14
|
+
|
15
|
+
def remove_all!(string_or_rx)
|
16
|
+
gsub!(string_or_rx, '')
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
data/lib/hobosupport.rb
CHANGED
@@ -1,31 +1,14 @@
|
|
1
1
|
require 'activesupport'
|
2
2
|
|
3
|
-
require
|
4
|
-
require
|
5
|
-
require '
|
6
|
-
require '
|
7
|
-
require '
|
8
|
-
require '
|
9
|
-
require '
|
10
|
-
require '
|
11
|
-
require '
|
12
|
-
require '
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
VERSION = "0.8.3"
|
17
|
-
|
18
|
-
end
|
19
|
-
|
20
|
-
|
21
|
-
# Some teeny fixes too diminutive to go elsewhere
|
22
|
-
|
23
|
-
class Object
|
24
|
-
|
25
|
-
# Often nice to ask e.g. some_object.is_a?(Symbol, String)
|
26
|
-
alias_method :is_a_without_multiple_args?, :is_a?
|
27
|
-
def is_a?(*args)
|
28
|
-
args.any? {|a| is_a_without_multiple_args?(a) }
|
29
|
-
end
|
30
|
-
|
31
|
-
end
|
3
|
+
require 'hobo_support'
|
4
|
+
require "hobo_support/fixes"
|
5
|
+
require 'hobo_support/blankslate'
|
6
|
+
require 'hobo_support/methodcall'
|
7
|
+
require 'hobo_support/methodphitamine'
|
8
|
+
require 'hobo_support/metaid'
|
9
|
+
require 'hobo_support/implies'
|
10
|
+
require 'hobo_support/enumerable'
|
11
|
+
require 'hobo_support/array'
|
12
|
+
require 'hobo_support/hash'
|
13
|
+
require 'hobo_support/module'
|
14
|
+
require 'hobo_support/string'
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hobosupport
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.8.
|
4
|
+
version: 0.8.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tom Locke
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2008-
|
12
|
+
date: 2008-12-06 00:00:00 +00:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|
@@ -20,36 +20,40 @@ executables: []
|
|
20
20
|
extensions: []
|
21
21
|
|
22
22
|
extra_rdoc_files:
|
23
|
-
- lib/
|
24
|
-
- lib/
|
25
|
-
- lib/
|
26
|
-
- lib/
|
27
|
-
- lib/
|
28
|
-
- lib/
|
29
|
-
- lib/
|
30
|
-
- lib/
|
31
|
-
- lib/
|
32
|
-
- lib/
|
33
|
-
- lib/
|
34
|
-
- lib/
|
35
|
-
- lib/
|
23
|
+
- lib/hobo_support/array.rb
|
24
|
+
- lib/hobo_support/blankslate.rb
|
25
|
+
- lib/hobo_support/enumerable.rb
|
26
|
+
- lib/hobo_support/fixes/chronic.rb
|
27
|
+
- lib/hobo_support/fixes/module.rb
|
28
|
+
- lib/hobo_support/fixes/pp.rb
|
29
|
+
- lib/hobo_support/fixes.rb
|
30
|
+
- lib/hobo_support/hash.rb
|
31
|
+
- lib/hobo_support/implies.rb
|
32
|
+
- lib/hobo_support/metaid.rb
|
33
|
+
- lib/hobo_support/methodcall.rb
|
34
|
+
- lib/hobo_support/methodphitamine.rb
|
35
|
+
- lib/hobo_support/module.rb
|
36
|
+
- lib/hobo_support/string.rb
|
37
|
+
- lib/hobo_support.rb
|
36
38
|
- lib/hobosupport.rb
|
37
39
|
- README.txt
|
38
40
|
files:
|
39
41
|
- CHANGES.txt
|
40
|
-
- lib/
|
41
|
-
- lib/
|
42
|
-
- lib/
|
43
|
-
- lib/
|
44
|
-
- lib/
|
45
|
-
- lib/
|
46
|
-
- lib/
|
47
|
-
- lib/
|
48
|
-
- lib/
|
49
|
-
- lib/
|
50
|
-
- lib/
|
51
|
-
- lib/
|
52
|
-
- lib/
|
42
|
+
- lib/hobo_support/array.rb
|
43
|
+
- lib/hobo_support/blankslate.rb
|
44
|
+
- lib/hobo_support/enumerable.rb
|
45
|
+
- lib/hobo_support/fixes/chronic.rb
|
46
|
+
- lib/hobo_support/fixes/module.rb
|
47
|
+
- lib/hobo_support/fixes/pp.rb
|
48
|
+
- lib/hobo_support/fixes.rb
|
49
|
+
- lib/hobo_support/hash.rb
|
50
|
+
- lib/hobo_support/implies.rb
|
51
|
+
- lib/hobo_support/metaid.rb
|
52
|
+
- lib/hobo_support/methodcall.rb
|
53
|
+
- lib/hobo_support/methodphitamine.rb
|
54
|
+
- lib/hobo_support/module.rb
|
55
|
+
- lib/hobo_support/string.rb
|
56
|
+
- lib/hobo_support.rb
|
53
57
|
- lib/hobosupport.rb
|
54
58
|
- Manifest
|
55
59
|
- Manifest.txt
|
@@ -90,7 +94,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
90
94
|
requirements: []
|
91
95
|
|
92
96
|
rubyforge_project: hobo
|
93
|
-
rubygems_version: 1.
|
97
|
+
rubygems_version: 1.3.1
|
94
98
|
signing_key:
|
95
99
|
specification_version: 2
|
96
100
|
summary: Core Ruby extensions from the Hobo project
|
data/lib/hobosupport/fixes.rb
DELETED
@@ -1,18 +0,0 @@
|
|
1
|
-
# --- Fix Chronic - can't parse '12th Jan' --- #
|
2
|
-
begin
|
3
|
-
require 'chronic'
|
4
|
-
|
5
|
-
module Chronic
|
6
|
-
|
7
|
-
class << self
|
8
|
-
def parse_with_hobo_fix(s)
|
9
|
-
parse_without_hobo_fix(if s =~ /^\s*\d+\s*(st|nd|rd|th)\s+[a-zA-Z]+(\s+\d+)?\s*$/
|
10
|
-
s.sub(/\s*\d+(st|nd|rd|th)/) {|s| s[0..-3]}
|
11
|
-
else
|
12
|
-
s
|
13
|
-
end)
|
14
|
-
end
|
15
|
-
alias_method_chain :parse, :hobo_fix
|
16
|
-
end
|
17
|
-
end
|
18
|
-
rescue LoadError; end
|