kelredd-useful 0.3.3 → 0.3.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -20,7 +20,7 @@ module Useful::RubyExtensions::Array
20
20
 
21
21
  # returns a new array, containing the contents of an_a with the contents of this array, removing duplicates
22
22
  def merge(an_a)
23
- self.class.merge(self.clone, an_a)
23
+ self.class.merge(self.dup, an_a)
24
24
  end
25
25
  # adds the contents of an_a to this array, removing duplicates (inline version of #merge)
26
26
  def merge!(an_a)
@@ -1,10 +1,12 @@
1
+ require 'date'
2
+
1
3
  module Useful; end
2
4
  module Useful::RubyExtensions; end
3
5
 
4
6
  module Useful::RubyExtensions::Date
5
-
7
+
6
8
  WEEK_DAYS = (1..5)
7
-
9
+
8
10
  def week_days_between(end_date)
9
11
  raise ::ArgumentError, "End date cannot be nil." if end_date.nil?
10
12
  raise ::ArgumentError, "End date cannot come before questioned date." if end_date < self
@@ -41,14 +41,14 @@ module Useful::RubyExtensions::Hash
41
41
  module InstanceMethods
42
42
 
43
43
  def only(*keys)
44
- self.class.only(self.clone, keys)
44
+ self.class.only(self.dup, keys)
45
45
  end
46
46
  def only!(*keys)
47
47
  self.class.only(self, keys)
48
48
  end
49
49
 
50
50
  def except(*keys)
51
- self.class.except(self.clone, keys)
51
+ self.class.except(self.dup, keys)
52
52
  end
53
53
 
54
54
  def except!(*keys)
@@ -56,7 +56,7 @@ module Useful::RubyExtensions::Hash
56
56
  end
57
57
 
58
58
  def nillify
59
- self.class.nillify(self.clone)
59
+ self.class.nillify(self.dup)
60
60
  end
61
61
  def nillify!
62
62
  self.class.nillify(self)
@@ -143,7 +143,7 @@ module Useful::RubyExtensions::Hash
143
143
 
144
144
  # Return a new hash with all keys converted to strings.
145
145
  def stringify_keys
146
- self.class.stringify_keys(self.clone)
146
+ self.class.stringify_keys(self.dup)
147
147
  end unless {}.respond_to?('stringify_keys')
148
148
  # Destructively convert all keys to strings.
149
149
  def stringify_keys!
@@ -152,7 +152,7 @@ module Useful::RubyExtensions::Hash
152
152
 
153
153
  # Return a new hash with all keys converted to strings.
154
154
  def symbolize_keys
155
- self.class.symbolize_keys(self.clone)
155
+ self.class.symbolize_keys(self.dup)
156
156
  end unless {}.respond_to?('symbolize_keys')
157
157
  # Destructively convert all keys to strings.
158
158
  def symbolize_keys!
@@ -1,20 +1,21 @@
1
+ require 'stringio'
1
2
  require 'useful/ruby_extensions/nil_class'
2
3
 
3
4
  module Useful; end
4
5
  module Useful::RubyExtensions; end
5
6
 
6
7
  module Useful::RubyExtensions::Object
7
-
8
+
8
9
  def false?
9
10
  self == false
10
11
  end
11
12
  alias_method :is_false?, :false?
12
-
13
+
13
14
  def true?
14
15
  self == true
15
16
  end
16
17
  alias_method :is_true?, :true?
17
-
18
+
18
19
  def capture_std_output
19
20
  out = ::StringIO.new
20
21
  err = ::StringIO.new
@@ -26,7 +27,7 @@ module Useful::RubyExtensions::Object
26
27
  $stdout = STDOUT
27
28
  $stderr = STDERR
28
29
  end
29
-
30
+
30
31
  module FromActivesupport
31
32
 
32
33
  def blank?
@@ -59,7 +60,7 @@ module Useful::RubyExtensions::Object
59
60
  # end
60
61
  #
61
62
  # foo # => ['bar', 'baz']
62
- #
63
+ #
63
64
  # # returning with a block argument
64
65
  # def foo
65
66
  # returning [] do |values|
@@ -67,7 +68,7 @@ module Useful::RubyExtensions::Object
67
68
  # values << 'baz'
68
69
  # end
69
70
  # end
70
- #
71
+ #
71
72
  # foo # => ['bar', 'baz']
72
73
  def returning(value)
73
74
  yield(value)
@@ -88,11 +89,11 @@ module Useful::RubyExtensions::Object
88
89
  yield self
89
90
  self
90
91
  end unless ::Object.new.respond_to?('tap')
91
-
92
- # Invokes the method identified by the symbol +method+, passing it any arguments
92
+
93
+ # Invokes the method identified by the symbol +method+, passing it any arguments
93
94
  # and/or the block specified, just like the regular Ruby <tt>Object#send</tt> does.
94
95
  #
95
- # *Unlike* that method however, a +NoMethodError+ exception will *not* be raised
96
+ # *Unlike* that method however, a +NoMethodError+ exception will *not* be raised
96
97
  # and +nil+ will be returned instead, if the receiving object is a +nil+ object or NilClass.
97
98
  #
98
99
  # ==== Examples
@@ -109,7 +110,7 @@ module Useful::RubyExtensions::Object
109
110
  # Person.try(:find, 1)
110
111
  # @people.try(:collect) {|p| p.name}
111
112
  #--
112
- # This method definition below is for rdoc purposes only. The alias_method call
113
+ # This method definition below is for rdoc purposes only. The alias_method call
113
114
  # below overrides it as an optimization since +try+ behaves like +Object#send+,
114
115
  # unless called on +NilClass+.
115
116
  # => see try method definition on the NilClass extensions for details.
@@ -122,11 +123,11 @@ module Useful::RubyExtensions::Object
122
123
  end
123
124
 
124
125
  end
125
-
126
+
126
127
  def self.included(receiver)
127
128
  receiver.send :include, FromActivesupport
128
129
  end
129
-
130
+
130
131
  end
131
132
 
132
133
  class Object
@@ -46,7 +46,7 @@ module Useful::RubyExtensions::String
46
46
 
47
47
  # returns a new string, with hash values sub'd in where hash keys exist in original string
48
48
  def hsub(hash)
49
- self.class.hsub(self.clone, hash)
49
+ self.class.hsub(self.dup, hash)
50
50
  end
51
51
  # substitutes the keys in hash that exist in the string, with values of hash
52
52
  def hsub!(hash)
@@ -1,13 +1,13 @@
1
1
  module Useful
2
2
  module Version
3
-
3
+
4
4
  MAJOR = 0
5
5
  MINOR = 3
6
- TINY = 3
7
-
6
+ TINY = 4
7
+
8
8
  def self.to_s # :nodoc:
9
9
  [MAJOR, MINOR, TINY].join('.')
10
10
  end
11
-
11
+
12
12
  end
13
13
  end
metadata CHANGED
@@ -1,12 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kelredd-useful
3
3
  version: !ruby/object:Gem::Version
4
+ hash: 27
4
5
  prerelease: false
5
6
  segments:
6
7
  - 0
7
8
  - 3
8
- - 3
9
- version: 0.3.3
9
+ - 4
10
+ version: 0.3.4
10
11
  platform: ruby
11
12
  authors:
12
13
  - Kelly Redding
@@ -14,16 +15,18 @@ autorequire:
14
15
  bindir: bin
15
16
  cert_chain: []
16
17
 
17
- date: 2010-04-16 00:00:00 -05:00
18
+ date: 2010-08-27 00:00:00 -05:00
18
19
  default_executable:
19
20
  dependencies:
20
21
  - !ruby/object:Gem::Dependency
21
22
  name: json
22
23
  prerelease: false
23
24
  requirement: &id001 !ruby/object:Gem::Requirement
25
+ none: false
24
26
  requirements:
25
27
  - - ">="
26
28
  - !ruby/object:Gem::Version
29
+ hash: 3
27
30
  segments:
28
31
  - 0
29
32
  version: "0"
@@ -89,23 +92,27 @@ rdoc_options:
89
92
  require_paths:
90
93
  - lib
91
94
  required_ruby_version: !ruby/object:Gem::Requirement
95
+ none: false
92
96
  requirements:
93
97
  - - ">="
94
98
  - !ruby/object:Gem::Version
99
+ hash: 3
95
100
  segments:
96
101
  - 0
97
102
  version: "0"
98
103
  required_rubygems_version: !ruby/object:Gem::Requirement
104
+ none: false
99
105
  requirements:
100
106
  - - ">="
101
107
  - !ruby/object:Gem::Version
108
+ hash: 3
102
109
  segments:
103
110
  - 0
104
111
  version: "0"
105
112
  requirements: []
106
113
 
107
114
  rubyforge_project:
108
- rubygems_version: 1.3.6
115
+ rubygems_version: 1.3.7
109
116
  signing_key:
110
117
  specification_version: 3
111
118
  summary: A collection of useful helpers for various ruby things.