hobosupport 0.8.3 → 0.8.4

Sign up to get free protection for your applications and to get access to all the features.
data/Manifest CHANGED
@@ -1,17 +1,19 @@
1
1
  CHANGES.txt
2
- lib/hobosupport/array.rb
3
- lib/hobosupport/blankslate.rb
4
- lib/hobosupport/enumerable.rb
5
- lib/hobosupport/fixes/chronic.rb
6
- lib/hobosupport/fixes/module.rb
7
- lib/hobosupport/fixes/pp.rb
8
- lib/hobosupport/fixes.rb
9
- lib/hobosupport/hash.rb
10
- lib/hobosupport/implies.rb
11
- lib/hobosupport/metaid.rb
12
- lib/hobosupport/methodcall.rb
13
- lib/hobosupport/methodphitamine.rb
14
- lib/hobosupport/module.rb
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
@@ -8,7 +8,7 @@ Echoe.new('hobosupport') do |p|
8
8
  p.project = "hobo"
9
9
 
10
10
  p.changelog = "CHANGES.txt"
11
- p.version = "0.8.3"
11
+ p.version = "0.8.4"
12
12
 
13
13
  p.development_dependencies = []
14
14
  end
data/hobosupport.gemspec CHANGED
@@ -1,18 +1,18 @@
1
1
 
2
- # Gem::Specification for Hobosupport-0.8.3
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.3
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-10-15 00:00:00 +01:00
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/hobosupport/array.rb
27
- - lib/hobosupport/blankslate.rb
28
- - lib/hobosupport/enumerable.rb
29
- - lib/hobosupport/fixes/chronic.rb
30
- - lib/hobosupport/fixes/module.rb
31
- - lib/hobosupport/fixes/pp.rb
32
- - lib/hobosupport/fixes.rb
33
- - lib/hobosupport/hash.rb
34
- - lib/hobosupport/implies.rb
35
- - lib/hobosupport/metaid.rb
36
- - lib/hobosupport/methodcall.rb
37
- - lib/hobosupport/methodphitamine.rb
38
- - lib/hobosupport/module.rb
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/hobosupport/array.rb
44
- - lib/hobosupport/blankslate.rb
45
- - lib/hobosupport/enumerable.rb
46
- - lib/hobosupport/fixes/chronic.rb
47
- - lib/hobosupport/fixes/module.rb
48
- - lib/hobosupport/fixes/pp.rb
49
- - lib/hobosupport/fixes.rb
50
- - lib/hobosupport/hash.rb
51
- - lib/hobosupport/implies.rb
52
- - lib/hobosupport/metaid.rb
53
- - lib/hobosupport/methodcall.rb
54
- - lib/hobosupport/methodphitamine.rb
55
- - lib/hobosupport/module.rb
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.2.0
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: []
@@ -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,3 @@
1
+ require "hobo_support/fixes/chronic"
2
+ require "hobo_support/fixes/pp"
3
+ require "hobo_support/fixes/module"
@@ -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
@@ -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) if m.respond_to?(:included_in_class) }
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
- m = Module.new
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
- m
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 "hobosupport/fixes"
4
- require 'hobosupport/blankslate'
5
- require 'hobosupport/methodcall'
6
- require 'hobosupport/methodphitamine'
7
- require 'hobosupport/metaid'
8
- require 'hobosupport/implies'
9
- require 'hobosupport/enumerable'
10
- require 'hobosupport/array'
11
- require 'hobosupport/hash'
12
- require 'hobosupport/module'
13
-
14
- module HoboSupport
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.3
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-10-15 00:00:00 +01:00
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/hobosupport/array.rb
24
- - lib/hobosupport/blankslate.rb
25
- - lib/hobosupport/enumerable.rb
26
- - lib/hobosupport/fixes/chronic.rb
27
- - lib/hobosupport/fixes/module.rb
28
- - lib/hobosupport/fixes/pp.rb
29
- - lib/hobosupport/fixes.rb
30
- - lib/hobosupport/hash.rb
31
- - lib/hobosupport/implies.rb
32
- - lib/hobosupport/metaid.rb
33
- - lib/hobosupport/methodcall.rb
34
- - lib/hobosupport/methodphitamine.rb
35
- - lib/hobosupport/module.rb
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/hobosupport/array.rb
41
- - lib/hobosupport/blankslate.rb
42
- - lib/hobosupport/enumerable.rb
43
- - lib/hobosupport/fixes/chronic.rb
44
- - lib/hobosupport/fixes/module.rb
45
- - lib/hobosupport/fixes/pp.rb
46
- - lib/hobosupport/fixes.rb
47
- - lib/hobosupport/hash.rb
48
- - lib/hobosupport/implies.rb
49
- - lib/hobosupport/metaid.rb
50
- - lib/hobosupport/methodcall.rb
51
- - lib/hobosupport/methodphitamine.rb
52
- - lib/hobosupport/module.rb
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.2.0
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
@@ -1,3 +0,0 @@
1
- require "hobosupport/fixes/chronic"
2
- require "hobosupport/fixes/pp"
3
- require "hobosupport/fixes/module"
@@ -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