hash-utils 2.1.2 → 2.2.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,4 +1,8 @@
1
1
 
2
+ 2.2.0 (2013-12-05)
3
+ * Array: #values
4
+ * Hash: #deep_merge! and #deep_merge removed
5
+
2
6
  2.1.2 (2013-06-07)
3
7
  * Hash: #first_key, #first_value
4
8
 
data/README.md CHANGED
@@ -49,7 +49,7 @@ Contributing
49
49
  Copyright
50
50
  ---------
51
51
 
52
- Copyright © 2011 – 2012 [Martin Kozák][10]. See `LICENSE.txt` for
52
+ Copyright © 2011 – 2013 [Martin Kozák][10]. See `LICENSE.txt` for
53
53
  further details.
54
54
 
55
55
  [1]: http://rubyworks.github.com/facets/
data/Rakefile CHANGED
@@ -21,7 +21,7 @@ Jeweler::Tasks.new do |gem|
21
21
  gem.homepage = "http://github.com/martinkozak/hash-utils"
22
22
  gem.license = "MIT"
23
23
  gem.summary = 'Adds more than 155 useful and frequently rather fundamental methods which are missing in Ruby programming language, to Array, File, Hash, Module, Object, String and Symbol classes. It tries to be similar project to Ruby Facets on principle, but less complex, more practical, non-atomic and organized by better way. Thanks to defensive and careful patching it should be compatible with all other libraries.'
24
- #gem.post_install_message = "\nHASH UTILS: The 2.0 version avoids the method overwriting conflicts by not performing overwriting of already implemented methods. By this way, it can damage your existing applications based on older versions although it's very improbable. \n\n"
24
+ gem.post_install_message = "\nHASH UTILS: The 2.2 version removes the #deep_merge and #deep_merge! methods to avoid conflicts with Active Support or other libraries. Use them or the 'deep_merge' gem if need them. \n\n"
25
25
  gem.email = "martinkozak@martinkozak.net"
26
26
  gem.authors = ["Martin Kozák"]
27
27
  # Include your dependencies below. Runtime dependencies are required when using your gem,
data/VERSION CHANGED
@@ -1 +1 @@
1
- 2.1.2
1
+ 2.2.0
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "hash-utils"
8
- s.version = "2.1.2"
8
+ s.version = "2.2.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Martin Koz\u{e1}k"]
12
- s.date = "2013-06-07"
12
+ s.date = "2013-12-05"
13
13
  s.email = "martinkozak@martinkozak.net"
14
14
  s.extra_rdoc_files = [
15
15
  "LICENSE.txt",
@@ -59,6 +59,7 @@ Gem::Specification.new do |s|
59
59
  ]
60
60
  s.homepage = "http://github.com/martinkozak/hash-utils"
61
61
  s.licenses = ["MIT"]
62
+ s.post_install_message = "\nHASH UTILS: The 2.2 version removes the #deep_merge and #deep_merge! methods to avoid conflicts with Active Support or other libraries. Use them or the 'deep_merge' gem if need them. \n\n"
62
63
  s.require_paths = ["lib"]
63
64
  s.rubygems_version = "1.8.25"
64
65
  s.summary = "Adds more than 155 useful and frequently rather fundamental methods which are missing in Ruby programming language, to Array, File, Hash, Module, Object, String and Symbol classes. It tries to be similar project to Ruby Facets on principle, but less complex, more practical, non-atomic and organized by better way. Thanks to defensive and careful patching it should be compatible with all other libraries."
@@ -1,5 +1,5 @@
1
1
  # encoding: utf-8
2
- # (c) 2011-2012 Martin Kozák (martinkozak@martinkozak.net)
2
+ # (c) 2011-2013 Martin Poljak (martin@poljak.cz)
3
3
 
4
4
  require "hash-utils/object"
5
5
  require "ruby-version"
@@ -581,5 +581,22 @@ class Array
581
581
  end
582
582
  end
583
583
 
584
+ ##
585
+ # Returns values of the array.
586
+ #
587
+ # @example
588
+ # x = [1, 2, 3, 4, 5]
589
+ # x.values # will return array itself
590
+ #
591
+ # @return [Array] self
592
+ # @since 2.1.3
593
+ #
594
+
595
+ if not self.__hash_utils_instance_respond_to? :values
596
+ def values
597
+ self
598
+ end
599
+ end
600
+
584
601
  end
585
602
 
@@ -611,65 +611,6 @@ class Hash
611
611
  return result
612
612
  end
613
613
  end
614
-
615
- ##
616
- # Merges two hashes recursively in place. Receives unlimited
617
- # count of hashes for merging them in left to right order.
618
- #
619
- # @param [*Hash] hashs for merge from
620
- # @return [Hash] hash for merge to
621
- # @since 0.12.0
622
- #
623
-
624
- if not self.__hash_utils_instance_respond_to? :deep_merge!
625
- def deep_merge!(*args)
626
- fm = args.map { |hash| [self, hash] }
627
-
628
- while not fm.empty?
629
- _in, _out = fm.shift
630
- _out.each_pair do |k, v|
631
- if v.kind_of? Hash
632
- fm << [_in[k], _out[k]]
633
- else
634
- _in[k] = v
635
- end
636
- end
637
- end
638
-
639
- return self
640
- end
641
- end
642
-
643
- ##
644
- # Merges two hashes recursively and returns new +Hash+. Receives
645
- # unlimited count of hashes for merging them in left to right order.
646
- # Included hashes will be copied too.
647
- #
648
- # @param [*Hash] hashes for merge from
649
- # @return [Hash] hash for merge to
650
- # @since 0.12.0
651
- #
652
-
653
- if not self.__hash_utils_instance_respond_to? :deep_merge
654
- def deep_merge(*args)
655
- result = self.dup
656
- fm = args.map { |hash| [result, hash] }
657
-
658
- while not fm.empty?
659
- _in, _out = fm.shift
660
- _out.each_pair do |k, v|
661
- if _in[k].kind_of? Hash
662
- _in[k] = _in[k].dup
663
- fm << [_in[k], _out[k]]
664
- else
665
- _in[k] = v
666
- end
667
- end
668
- end
669
-
670
- return result
671
- end
672
- end
673
614
 
674
615
  ##
675
616
  # Iterates through items with given key only. None-existing values
@@ -161,6 +161,10 @@ describe "Array" do
161
161
  specify("#to_set") do
162
162
  [1, 2, 3].to_set.should eq(Set::new([1, 2, 3]))
163
163
  end
164
+ specify("#values") do
165
+ a = [1, 2, 3]
166
+ a.values.should eq(a)
167
+ end
164
168
  specify("#zip!") do
165
169
  t = [1, 2, 3]
166
170
  t.zip!
@@ -121,18 +121,6 @@ describe "Hash" do
121
121
  t.map_values! { |i| i + 1 }
122
122
  t.should eq({ :a => 2, :b => 3 })
123
123
  end
124
- specify("#deep_merge") do
125
- h1 = {:a => {:b => :c, :d => :e}}
126
- h2 = {:a => {:d => :f, :h => :i}}
127
- h = h1.deep_merge(h2)
128
- h.should eq({:a => {:b => :c, :d => :f, :h => :i}})
129
- h1.should eq({:a => {:b => :c, :d => :e}})
130
- end
131
- specify("#deep_merge!") do
132
- h = {:a => {:b => :c, :d => :e}}
133
- h.deep_merge!({:a => {:d => :f, :h => :i}})
134
- h.should eq({:a => {:b => :c, :d => :f, :h => :i}})
135
- end
136
124
  specify("#keys_to_sym") do
137
125
  h = {"a" => "b", 2 => "c", "d" => "e"}
138
126
  h.keys_to_sym.should eq({:a => "b", 2 => "c", :d => "e"})
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hash-utils
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.2
4
+ version: 2.2.0
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-06-07 00:00:00.000000000 Z
12
+ date: 2013-12-05 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: ruby-version
@@ -158,7 +158,9 @@ files:
158
158
  homepage: http://github.com/martinkozak/hash-utils
159
159
  licenses:
160
160
  - MIT
161
- post_install_message:
161
+ post_install_message: "\nHASH UTILS: The 2.2 version removes the #deep_merge and #deep_merge!
162
+ methods to avoid conflicts with Active Support or other libraries. Use them or the
163
+ 'deep_merge' gem if need them. \n\n"
162
164
  rdoc_options: []
163
165
  require_paths:
164
166
  - lib
@@ -170,7 +172,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
170
172
  version: '0'
171
173
  segments:
172
174
  - 0
173
- hash: 814178071789703873
175
+ hash: -3166404120164833176
174
176
  required_rubygems_version: !ruby/object:Gem::Requirement
175
177
  none: false
176
178
  requirements: