hobo_support 2.0.0 → 2.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 2.0.0
1
+ 2.0.1
@@ -44,7 +44,7 @@ We have the "." operator to call methods on objects. These extensions introduce
44
44
  >> nil._?.length
45
45
  => nil
46
46
 
47
- When the receiver is nil, any method with any arguments will return nil. You can use Ruby's || idiom to provide a different value when nil.
47
+ When the receiver is nil, any method with any arguments will return nil. You can use Ruby's `||` idiom to provide a different value when nil.
48
48
 
49
49
  >> expires = nil
50
50
  >> expires._?.to_s( :default ) || "never"
@@ -52,7 +52,7 @@ When the receiver is nil, any method with any arguments will return nil. You ca
52
52
 
53
53
  Note that `_?` should *always* be followed by a method call. It is not intended to store the intermediate result. Don't do this!
54
54
 
55
- intermediate = nil._?
55
+ >> intermediate = nil._?
56
56
 
57
57
  ### `Object#try`
58
58
 
@@ -81,7 +81,7 @@ may use `try` to call a Rails 2.3 function that doesn't exist on Rails
81
81
 
82
82
  >> nil.try(:foo)
83
83
  => nil
84
- >> nil.try {|p| "(not available"}
84
+ >> nil.try {|p| "(not available)"}
85
85
  >> "(not available)"
86
86
  >> "foo".try(:reverse)
87
- >> "oof"
87
+ >> "oof"
@@ -14,6 +14,12 @@ E.g. The length of the first word that starts with a capital letter
14
14
  >> %w(my name is Fred).map_and_find { |s| s.length if s =~ /^[A-Z]/ }
15
15
  => 4
16
16
 
17
+ Usage with the `not_found` argument
18
+
19
+ >> %w(my name is not available).map_and_find('Foo') { |s| s.length if s =~ /^[A-Z]/ }
20
+ => "Foo"
21
+
22
+
17
23
  ## `Enumerable#map_with_index`
18
24
 
19
25
  * `enum.map_with_index { |element, index| block }`
@@ -74,6 +80,7 @@ Shorthand for `reject` when you need to reject on a single method call.
74
80
  ## `Enumerable#drop_while`
75
81
 
76
82
  * `enum.drop_while { |element| block }`
83
+ * `enum.drop_while! { |element| block }`
77
84
 
78
85
  Passes each element in turn to the block until the block returns false. Returns the remaining elements in a new array.
79
86
 
@@ -92,7 +99,7 @@ There is also a destructive version for arrays
92
99
 
93
100
  * `enum.take_while { |element| block }`
94
101
 
95
- Passes each element in turn to the block until the block returns false. Returns a new with the elements for which the block returned true
102
+ Passes each element in turn to the block until the block returns false. Returns a new array with the elements for which the block returned true.
96
103
 
97
104
  >> %w(this is a nice example).take_while { |s| s.length > 1 }
98
105
  => ["this", "is"]
@@ -13,7 +13,7 @@ This is the Hash version of `Enumerable#select`. i.e. a way to create a new hash
13
13
  >> {1=>2, 3=>4, 6=>5}.select_hash { |key, value| key < value }
14
14
  => {1=>2, 3=>4}
15
15
 
16
- You can also give a block that takes one argument, in which case the block is given the value only
16
+ You can also give a block that takes one argument, in which case the block is given the value only.
17
17
 
18
18
  >> {1=>2, 3=>4, 6=>5}.select_hash { |value| value != 2 }
19
19
  => {3=>4, 6=>5}
@@ -24,12 +24,12 @@ You can also give a block that takes one argument, in which case the block is gi
24
24
  * `hash.map_hash { |key, value| block } => hash`
25
25
  * `hash.map_hash { |value| block } => hash`
26
26
 
27
- Applies a function to each *value* in a Hash, resulting in a new hash with the same keys but new values. The block is passed each key, value pair and should return the new value
27
+ Applies a function to each *value* in a Hash, resulting in a new hash with the same keys but new values. The block is passed each key, value pair and should return the new value.
28
28
 
29
29
  >> {1=>2, 3=>4, 6=>5}.map_hash { |key, value| key < value }
30
30
  => {1=>true, 3=>true, 6=>false}
31
31
 
32
- You can also give a block which takes one argument, in which case only the value is passed in
32
+ You can also give a block which takes one argument, in which case only the value is passed in.
33
33
 
34
34
  >> {1=>2, 3=>4, 6=>5}.map_hash { |value| value * 100 }
35
35
  => {1=>200, 3=>400, 6=>500 }
@@ -40,12 +40,12 @@ You can also give a block which takes one argument, in which case only the value
40
40
  * `hash.partition_hash(keys) => [hash1, hash2]`
41
41
  * `hash.partition_hash { |key, value| block } => hash`
42
42
 
43
- Returns an array of two hashes, the first with all the key/value pairs where the key was in passed Enumerable, the second with the remaining key/value pairs
43
+ Returns an array of two hashes, the first with all the key/value pairs where the key was in passed Enumerable, the second with the remaining key/value pairs.
44
44
 
45
45
  >> {1=>2, 3=>4, 6=>5}.partition_hash([1, 3])
46
46
  => [{1=>2, 3=>4}, {6=>5}]
47
47
 
48
- When passed a block, each pair is passed to the block in turn. The result is two hashes, the first containing those pairs for which the block returned true, the second with the remaining pairs
48
+ When passed a block, each pair is passed to the block in turn. The result is two hashes, the first containing those pairs for which the block returned true, the second with the remaining pairs.
49
49
 
50
50
  >> {1=>2, 3=>4, 6=>5}.partition_hash { |key, value| key < value }
51
51
  => [{1=>2, 3=>4}, {6=>5}]
@@ -54,7 +54,7 @@ When passed a block, each pair is passed to the block in turn. The result is two
54
54
 
55
55
  * `hash.recursive_update(hash2)`
56
56
 
57
- Like `#update` but where a sub-hash would overwrite another sub-hash, they are instead also merged, recursively
57
+ Like `#update` but where a sub-hash would overwrite another sub-hash, they are instead also merged, recursively.
58
58
 
59
59
  >> h = { :a => 1, :b => { :x => 10 } }
60
60
  >> h.recursive_update({ :c => 3, :b => { :y => 20 } })
@@ -75,7 +75,7 @@ Returns a new hash, the left-hand-side hash with all pairs removed where the key
75
75
 
76
76
  * `hash & array => array`
77
77
 
78
- Returns a new array, the left hand side hash restricted to pairs where the key is present in the right-hand-side array
78
+ Returns a new array, the left hand side hash restricted to pairs where the key is present in the right-hand-side array.
79
79
 
80
80
  >> {1=>2, 3=>4, 6=>5} & [1, 3]
81
81
  => {1=>2, 3=>4}
@@ -84,7 +84,7 @@ Returns a new array, the left hand side hash restricted to pairs where the key i
84
84
 
85
85
  * `hash | hash => hash`
86
86
 
87
- An alias for merge
87
+ An alias for merge.
88
88
 
89
89
  >> {1 => 2} | {1 => 3, 2 => 4}
90
90
  => {1 => 3, 2 => 4}
@@ -103,16 +103,16 @@ Returns an array of values for the given keys. Useful for extracting a few optio
103
103
 
104
104
  * `hash.compact => hash`
105
105
 
106
- Returns a hash with the same items as the receiver except those where the value is nil
106
+ Returns a hash with the same items as the receiver except those where the value is nil.
107
107
 
108
108
  >> {1=>'a', 2=>nil, 3=>'b'}.compact
109
109
  => {1=>'a', 3=>'b'}
110
110
 
111
- ## `Hash#compact`
111
+ ## `Hash#compact!`
112
112
 
113
113
  * `hash.compact!`
114
114
 
115
- Removes every pair from the hash where the value is nil
115
+ Removes every pair from the hash where the value is nil.
116
116
 
117
117
  >> h = {1=>'a', 2=>nil, 3=>'b'}
118
118
  >> h.compact!
@@ -7,10 +7,10 @@ Why the Luck Stiff's essential meta-programming additions to Object. These are p
7
7
 
8
8
  ## `Object#metaclass`
9
9
 
10
- Returns the "metaclass", "eigenclass" or "singleton class" of a given ruby Object
10
+ Returns the "metaclass", "eigenclass" or "singleton class" of a given ruby Object.
11
11
 
12
12
  >> o = Object.new
13
- >> def o.foo; ;123; end
13
+ >> def o.foo; 123; end
14
14
  >> o.foo
15
15
  => 123
16
16
  >> o.metaclass.method_defined?(:foo)
@@ -41,7 +41,7 @@ When a module is included in a class, it gets a callback on the `included` metho
41
41
  => "MY NAME IS C"
42
42
 
43
43
 
44
- ## `Module#interiting_cattr_reader`
44
+ ## `Module#inheriting_cattr_reader`
45
45
 
46
46
  Declares a reader for an instance variable on the class. The attribute is looked up on the superclass if not defined on the receiving class. In other words, the superclass defines a default that subclasses can override. The declaration can also give a default, as shown here.
47
47
 
@@ -52,7 +52,7 @@ Declares a reader for an instance variable on the class. The attribute is looked
52
52
 
53
53
  class B < A; end
54
54
 
55
- `B` has the same nickname as its superclass `A`
55
+ `B` has the same nickname as its superclass `A`.
56
56
 
57
57
  >> A.nickname
58
58
  => "Andy"
@@ -4,7 +4,7 @@
4
4
  >> $:.unshift File.join(File.expand_path(File.dirname(__FILE__)), '../../../hobo_support/lib')
5
5
  >> require 'hobo_support'
6
6
 
7
- ## safe_join
7
+ ## `safe_join`
8
8
 
9
9
  Version of Array#join that preserves html\_safe:
10
10
 
@@ -27,7 +27,6 @@ Version of Array#join that preserves html\_safe:
27
27
  >> ["<a>".html_safe, "<b>".html_safe].safe_join.html_safe?
28
28
  => true
29
29
 
30
-
31
30
  >> ["<a>", "<b>"].safe_join("<br>")
32
31
  => "&lt;a&gt;&lt;br&gt;&lt;b&gt;"
33
32
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hobo_support
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0
4
+ version: 2.0.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-02-27 00:00:00.000000000 Z
12
+ date: 2013-06-23 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
@@ -32,7 +32,7 @@ dependencies:
32
32
  requirement: !ruby/object:Gem::Requirement
33
33
  none: false
34
34
  requirements:
35
- - - ! '>='
35
+ - - '>='
36
36
  - !ruby/object:Gem::Version
37
37
  version: '0'
38
38
  type: :development
@@ -40,7 +40,7 @@ dependencies:
40
40
  version_requirements: !ruby/object:Gem::Requirement
41
41
  none: false
42
42
  requirements:
43
- - - ! '>='
43
+ - - '>='
44
44
  - !ruby/object:Gem::Version
45
45
  version: '0'
46
46
  description: Core Ruby extensions from the Hobo project
@@ -100,18 +100,18 @@ require_paths:
100
100
  required_ruby_version: !ruby/object:Gem::Requirement
101
101
  none: false
102
102
  requirements:
103
- - - ! '>='
103
+ - - '>='
104
104
  - !ruby/object:Gem::Version
105
105
  version: '0'
106
106
  required_rubygems_version: !ruby/object:Gem::Requirement
107
107
  none: false
108
108
  requirements:
109
- - - ! '>='
109
+ - - '>='
110
110
  - !ruby/object:Gem::Version
111
111
  version: 1.3.6
112
112
  requirements: []
113
113
  rubyforge_project: hobo
114
- rubygems_version: 1.8.24
114
+ rubygems_version: 1.8.25
115
115
  signing_key:
116
116
  specification_version: 3
117
117
  summary: Core Ruby extensions from the Hobo project