quality_extensions 1.1.1 → 1.1.2
Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,19 @@
|
|
1
|
+
# http://pastie.org/10707
|
2
|
+
# author unknown, please make yourself known
|
3
|
+
# if you would like credit.
|
4
|
+
|
5
|
+
class Hash
|
6
|
+
# Usage { :a => 1, :b => 2, :c => 3}.except(:a) -> { :b => 2, :c => 3}
|
7
|
+
def except(*keys)
|
8
|
+
self.reject { |k,v|
|
9
|
+
keys.include? k.to_sym
|
10
|
+
}
|
11
|
+
end
|
12
|
+
|
13
|
+
# Usage { :a => 1, :b => 2, :c => 3}.only(:a) -> {:a => 1}
|
14
|
+
def only(*keys)
|
15
|
+
self.dup.reject { |k,v|
|
16
|
+
!keys.include? k.to_sym
|
17
|
+
}
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
#--
|
2
|
+
# Source:: extensions gem
|
3
|
+
#++
|
4
|
+
|
5
|
+
require 'pp'
|
6
|
+
require 'stringio'
|
7
|
+
class Object
|
8
|
+
#
|
9
|
+
# Returns a pretty-printed string of the object. Requires libraries +pp+ and
|
10
|
+
# +stringio+ from the Ruby standard library.
|
11
|
+
#
|
12
|
+
# The following code pretty-prints an object (much like +p+ plain-prints an
|
13
|
+
# object):
|
14
|
+
#
|
15
|
+
# pp object
|
16
|
+
#
|
17
|
+
# The following code captures the pretty-printing in +str+ instead of
|
18
|
+
# sending it to +STDOUT+.
|
19
|
+
#
|
20
|
+
# str = object.pp_s
|
21
|
+
#
|
22
|
+
def pp_s
|
23
|
+
pps = StringIO.new
|
24
|
+
PP.pp(self, pps)
|
25
|
+
pps.string
|
26
|
+
end
|
27
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: quality_extensions
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tyler Rick and others
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2008-
|
12
|
+
date: 2008-12-30 00:00:00 -08:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|
@@ -46,6 +46,7 @@ files:
|
|
46
46
|
- lib/quality_extensions/dir/each_child.rb
|
47
47
|
- lib/quality_extensions/mutex/if_available.rb
|
48
48
|
- lib/quality_extensions/global_variable_set.rb
|
49
|
+
- lib/quality_extensions/hash/only.rb
|
49
50
|
- lib/quality_extensions/hash/to_date.rb
|
50
51
|
- lib/quality_extensions/hash/all.rb
|
51
52
|
- lib/quality_extensions/hash/delete_unless.rb
|
@@ -94,6 +95,7 @@ files:
|
|
94
95
|
- lib/quality_extensions/object/methods.rb
|
95
96
|
- lib/quality_extensions/object/default.rb
|
96
97
|
- lib/quality_extensions/object/singleton_send.rb
|
98
|
+
- lib/quality_extensions/object/pp_s.rb
|
97
99
|
- lib/quality_extensions/object/ignore_access.rb
|
98
100
|
- lib/quality_extensions/object/if_else.rb
|
99
101
|
- lib/quality_extensions/object/mcall.rb
|