hashslice 1.0.7 → 1.0.8

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGES CHANGED
@@ -1,3 +1,8 @@
1
+ == 1.0.8 - 31-Aug-2011
2
+ * Removed an old install task, updated the clean task and set a
3
+ default task in the Rakefile.
4
+ * Minor updates to the gemspec.
5
+
1
6
  == 1.0.7 - 27-Sep-2009
2
7
  * Fixed a packaging bug.
3
8
  * Minor updates to the gemspec.
data/README CHANGED
@@ -2,8 +2,7 @@
2
2
  Slicing for Ruby hashes.
3
3
 
4
4
  = Installation
5
- rake test (optional)
6
- rake install
5
+ gem install hashslice
7
6
 
8
7
  = Synopsis
9
8
  require 'hashslice'
@@ -36,7 +35,7 @@
36
35
  If there are more values than keys, the extra values are dropped.
37
36
 
38
37
  = Copyright
39
- Copyright (c) 2001-2009, The FaerieMUD Consortium and Daniel J. Berger.
38
+ Copyright (c) 2001-2011, The FaerieMUD Consortium and Daniel J. Berger.
40
39
  All rights reserved.
41
40
 
42
41
  = License
data/Rakefile CHANGED
@@ -1,23 +1,27 @@
1
- require 'rake'
2
- require 'rake/clean'
3
- require 'rake/testtask'
4
-
5
- desc "Install the hashslice library (non-gem)"
6
- task :install do
7
- cp 'lib/hashslice.rb', Config::CONFIG['sitelibdir'], :verbose => true
8
- end
9
-
10
- desc 'Build the hashslice gem'
11
- task :gem do
12
- spec = eval(IO.read('hashslice.gemspec'))
13
- Gem::Builder.new(spec).build
14
-
15
- desc "Install the hashslice library as a gem"
16
- task :install_gem => [:gem] do
17
- file = Dir["*.gem"].first
18
- sh "gem install #{file}"
19
-
20
- Rake::TestTask.new do |t|
21
- t.warning = true
22
- t.verbose = true
23
- end
1
+ require 'rake'
2
+ require 'rake/clean'
3
+ require 'rake/testtask'
4
+
5
+ CLEAN.include("**/*.gem", "**/*.rbc")
6
+
7
+ namespace :gem do
8
+
9
+ desc 'Build the hashslice gem'
10
+ task :create => [:clean] do
11
+ spec = eval(IO.read('hashslice.gemspec'))
12
+ Gem::Builder.new(spec).build
13
+ end
14
+
15
+ desc "Install the hashslice library as a gem"
16
+ task :install => [:create] do
17
+ file = Dir["*.gem"].first
18
+ sh "gem install #{file}"
19
+ end
20
+ end
21
+
22
+ Rake::TestTask.new do |t|
23
+ t.warning = true
24
+ t.verbose = true
25
+ end
26
+
27
+ task :default => :test
@@ -1,25 +1,24 @@
1
1
  require 'rubygems'
2
2
 
3
3
  Gem::Specification.new do |gem|
4
- gem.name = 'hashslice'
5
- gem.version = '1.0.7'
6
- gem.authors = ['Daniel J. Berger', 'Michael Granger']
7
- gem.license = 'Artistic 2.0'
8
- gem.email = 'djberg96@gmail.com'
9
- gem.homepage = 'http://www.rubyforge.org/projects/shards'
10
- gem.summary = "Adds hash slicing to Ruby's Hash class"
11
- gem.test_file = 'test/test_hashslice.rb'
12
- gem.has_rdoc = true
13
- gem.files = Dir['**/*'].reject{ |f| f.include?('CVS') }
4
+ gem.name = 'hashslice'
5
+ gem.version = '1.0.8'
6
+ gem.authors = ['Daniel J. Berger', 'Michael Granger']
7
+ gem.license = 'Artistic 2.0'
8
+ gem.email = 'djberg96@gmail.com'
9
+ gem.homepage = 'http://www.rubyforge.org/projects/shards'
10
+ gem.summary = "Adds hash slicing to Ruby's Hash class"
11
+ gem.test_file = 'test/test_hashslice.rb'
12
+ gem.files = Dir['**/*'].reject{ |f| f.include?('git') }
14
13
 
15
- gem.rubyforge_project = 'shards'
16
- gem.extra_rdoc_files = ['README', 'CHANGES', 'MANIFEST']
14
+ gem.rubyforge_project = 'shards'
15
+ gem.extra_rdoc_files = ['README', 'CHANGES', 'MANIFEST']
17
16
 
18
- gem.add_development_dependency('test-unit', '>= 2.0.3')
17
+ gem.add_development_dependency('test-unit', '>= 2.1.0')
19
18
 
20
- gem.description = <<-EOF
21
- The hashslice library adds builtin hash slicing to Ruby's Hash class.
22
- This lets you reference, or assign to, multiple hash keys simultaneously
23
- via the Hash#[] and Hash#[]= methods, respectively.
24
- EOF
19
+ gem.description = <<-EOF
20
+ The hashslice library adds builtin hash slicing to Ruby's Hash class.
21
+ This lets you reference, or assign to, multiple hash keys simultaneously
22
+ via the Hash#[] and Hash#[]= methods, respectively.
23
+ EOF
25
24
  end
@@ -1,65 +1,65 @@
1
1
  class Hash
2
- alias href []
3
- alias hset []=
4
-
5
- # The version of the hashslice library
6
- VERSION_HASHSLICE = '1.0.7'
2
+ alias href []
3
+ alias hset []=
7
4
 
8
- # Retrieve a hash slice. If a single key is provided, returns a single
9
- # value. If multiple keys are provided, an array of values is returned.
10
- #
11
- # Examples:
12
- #
13
- # hash = {'a' => 1, 'b' => 2, 'c' => 3}
14
- # hash['a'] -> 1
15
- # hash['a', 'c'] -> [1, 3]
16
- #
17
- def [](*args)
18
- if args.length == 1
19
- href(args[0])
20
- else
21
- args.map{ |k| href(k) }
22
- end
23
- end
5
+ # The version of the hashslice library
6
+ VERSION_HASHSLICE = '1.0.8'
24
7
 
25
- alias slice []
8
+ # Retrieve a hash slice. If a single key is provided, returns a single
9
+ # value. If multiple keys are provided, an array of values is returned.
10
+ #
11
+ # Examples:
12
+ #
13
+ # hash = {'a' => 1, 'b' => 2, 'c' => 3}
14
+ # hash['a'] -> 1
15
+ # hash['a', 'c'] -> [1, 3]
16
+ #
17
+ def [](*args)
18
+ if args.length == 1
19
+ href(args[0])
20
+ else
21
+ args.map{ |k| href(k) }
22
+ end
23
+ end
26
24
 
27
- # Hash slice assignment. You can assign a list of values to a list of keys
28
- # in a single operation on a one for one basis.
29
- #
30
- # If the number of keys exceeds the number of values, the remaining keys
31
- # are assigned a value of nil.
32
- #
33
- # If the number of values exceeds the number of keys, the extra values are
34
- # dropped.
35
- #
36
- # Examples:
37
- #
38
- # hash['a'] = 1, 2 -> {a => [1, 2]}
39
- # hash['a', 'b'] = 3, 4 -> {a => 3, b => 4}
40
- # hash['a', 'b'] = 5 -> {a => 5, b => nil}
41
- # hash['a', 'b'] = 3, 4, 5 -> {a => 3, b => 4}
42
- #
43
- def []=(*args)
44
- if args.length <= 2
45
- hset(*args)
46
- else
47
- values = args.pop # Last arg is the value. The rest are keys.
48
- values = [values] unless values.is_a?(Array)
49
- args.each_index{ |i| hset(args[i], values[i]) }
50
- end
51
- end
52
-
53
- # Returns a sub-hash of the current hash.
54
- #
55
- # Example:
56
- #
57
- # hash = {'a' => 1, 'b' => 2, 'c' => 3}
58
- # hash.hash_of('a', 'b') -> {'a' => 1, 'b' => 2}
59
- #
60
- def hash_of(*args)
61
- temp = {}
62
- args.map{ |k| temp[k] = href(k) }
63
- temp
25
+ alias slice []
26
+
27
+ # Hash slice assignment. You can assign a list of values to a list of keys
28
+ # in a single operation on a one for one basis.
29
+ #
30
+ # If the number of keys exceeds the number of values, the remaining keys
31
+ # are assigned a value of nil.
32
+ #
33
+ # If the number of values exceeds the number of keys, the extra values are
34
+ # dropped.
35
+ #
36
+ # Examples:
37
+ #
38
+ # hash['a'] = 1, 2 -> {a => [1, 2]}
39
+ # hash['a', 'b'] = 3, 4 -> {a => 3, b => 4}
40
+ # hash['a', 'b'] = 5 -> {a => 5, b => nil}
41
+ # hash['a', 'b'] = 3, 4, 5 -> {a => 3, b => 4}
42
+ #
43
+ def []=(*args)
44
+ if args.length <= 2
45
+ hset(*args)
46
+ else
47
+ values = args.pop # Last arg is the value. The rest are keys.
48
+ values = [values] unless values.is_a?(Array)
49
+ args.each_index{ |i| hset(args[i], values[i]) }
50
+ end
64
51
  end
52
+
53
+ # Returns a sub-hash of the current hash.
54
+ #
55
+ # Example:
56
+ #
57
+ # hash = {'a' => 1, 'b' => 2, 'c' => 3}
58
+ # hash.hash_of('a', 'b') -> {'a' => 1, 'b' => 2}
59
+ #
60
+ def hash_of(*args)
61
+ temp = {}
62
+ args.map{ |k| temp[k] = href(k) }
63
+ temp
64
+ end
65
65
  end
@@ -16,7 +16,7 @@ class TC_Hashslice < Test::Unit::TestCase
16
16
  end
17
17
 
18
18
  def test_version
19
- assert_equal('1.0.7', Hash::VERSION_HASHSLICE)
19
+ assert_equal('1.0.8', Hash::VERSION_HASHSLICE)
20
20
  end
21
21
 
22
22
  def test_get_slice_instance_method_basic
metadata CHANGED
@@ -1,7 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hashslice
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.7
4
+ hash: 7
5
+ prerelease:
6
+ segments:
7
+ - 1
8
+ - 0
9
+ - 8
10
+ version: 1.0.8
5
11
  platform: ruby
6
12
  authors:
7
13
  - Daniel J. Berger
@@ -10,20 +16,25 @@ autorequire:
10
16
  bindir: bin
11
17
  cert_chain: []
12
18
 
13
- date: 2009-09-27 00:00:00 -06:00
14
- default_executable:
19
+ date: 2011-08-31 00:00:00 Z
15
20
  dependencies:
16
21
  - !ruby/object:Gem::Dependency
17
22
  name: test-unit
18
- type: :development
19
- version_requirement:
20
- version_requirements: !ruby/object:Gem::Requirement
23
+ prerelease: false
24
+ requirement: &id001 !ruby/object:Gem::Requirement
25
+ none: false
21
26
  requirements:
22
27
  - - ">="
23
28
  - !ruby/object:Gem::Version
24
- version: 2.0.3
25
- version:
26
- description: " The hashslice library adds builtin hash slicing to Ruby's Hash class.\n This lets you reference, or assign to, multiple hash keys simultaneously\n via the Hash#[] and Hash#[]= methods, respectively.\n"
29
+ hash: 11
30
+ segments:
31
+ - 2
32
+ - 1
33
+ - 0
34
+ version: 2.1.0
35
+ type: :development
36
+ version_requirements: *id001
37
+ description: " The hashslice library adds builtin hash slicing to Ruby's Hash class.\n This lets you reference, or assign to, multiple hash keys simultaneously\n via the Hash#[] and Hash#[]= methods, respectively.\n"
27
38
  email: djberg96@gmail.com
28
39
  executables: []
29
40
 
@@ -41,7 +52,6 @@ files:
41
52
  - Rakefile
42
53
  - README
43
54
  - test/test_hashslice.rb
44
- has_rdoc: true
45
55
  homepage: http://www.rubyforge.org/projects/shards
46
56
  licenses:
47
57
  - Artistic 2.0
@@ -51,21 +61,27 @@ rdoc_options: []
51
61
  require_paths:
52
62
  - lib
53
63
  required_ruby_version: !ruby/object:Gem::Requirement
64
+ none: false
54
65
  requirements:
55
66
  - - ">="
56
67
  - !ruby/object:Gem::Version
68
+ hash: 3
69
+ segments:
70
+ - 0
57
71
  version: "0"
58
- version:
59
72
  required_rubygems_version: !ruby/object:Gem::Requirement
73
+ none: false
60
74
  requirements:
61
75
  - - ">="
62
76
  - !ruby/object:Gem::Version
77
+ hash: 3
78
+ segments:
79
+ - 0
63
80
  version: "0"
64
- version:
65
81
  requirements: []
66
82
 
67
83
  rubyforge_project: shards
68
- rubygems_version: 1.3.5
84
+ rubygems_version: 1.8.10
69
85
  signing_key:
70
86
  specification_version: 3
71
87
  summary: Adds hash slicing to Ruby's Hash class