spruz 0.2.8 → 0.2.9

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -1,5 +1,7 @@
1
+ # vim: set filetype=ruby et sw=2 ts=2:
2
+
1
3
  begin
2
- require 'rake/gempackagetask'
4
+ require 'rubygems/package_task'
3
5
  rescue LoadError
4
6
  end
5
7
  require 'rake/clean'
@@ -61,7 +63,7 @@ if defined? Gem
61
63
  end
62
64
  end
63
65
 
64
- Rake::GemPackageTask.new(spec) do |pkg|
66
+ Gem::PackageTask.new(spec) do |pkg|
65
67
  pkg.need_tar = true
66
68
  pkg.package_files += PKG_FILES
67
69
  end
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.8
1
+ 0.2.9
@@ -1,6 +1,6 @@
1
1
  module Spruz
2
2
  # Spruz version
3
- VERSION = '0.2.8'
3
+ VERSION = '0.2.9'
4
4
  VERSION_ARRAY = VERSION.split(/\./).map { |x| x.to_i } # :nodoc:
5
5
  VERSION_MAJOR = VERSION_ARRAY[0] # :nodoc:
6
6
  VERSION_MINOR = VERSION_ARRAY[1] # :nodoc:
@@ -18,4 +18,5 @@ module Spruz
18
18
  require 'spruz/xt/attempt'
19
19
  require 'spruz/xt/hash_symbolize_keys_recursive'
20
20
  require 'spruz/xt/range_plus'
21
+ require 'spruz/xt/named'
21
22
  end
@@ -0,0 +1,33 @@
1
+ class Object
2
+ if RUBY_VERSION >= '1.9'
3
+ def named(name, method, *args, &named_block)
4
+ extend Module.new {
5
+ define_method(name) do |*rest, &block|
6
+ block = named_block if named_block
7
+ __send__(method, *(args + rest), &block)
8
+ end
9
+ }
10
+ end
11
+ else
12
+ def named(name, method, *args, &block)
13
+ extend Module.new { define_method(name) { |*rest| __send__(method, *(args + rest), &block) } }
14
+ end
15
+ end
16
+ end
17
+
18
+ class Module
19
+ if RUBY_VERSION >= '1.9'
20
+ def named(name, method, *args, &named_block)
21
+ include Module.new {
22
+ define_method(name) do |*rest, &block|
23
+ block = named_block if named_block
24
+ __send__(method, *(args + rest), &block)
25
+ end
26
+ }
27
+ end
28
+ else
29
+ def named(name, method, *args, &block)
30
+ include Module.new { define_method(name) { |*rest| __send__(method, *(args + rest), &block) } }
31
+ end
32
+ end
33
+ end
@@ -2,22 +2,22 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{spruz}
5
- s.version = "0.2.7"
5
+ s.version = "0.2.9"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
- s.authors = ["Florian Frank"]
9
- s.date = %q{2011-05-20}
8
+ s.authors = [%q{Florian Frank}]
9
+ s.date = %q{2011-07-05}
10
10
  s.description = %q{All the stuff that isn't good/big enough for a real library.}
11
11
  s.email = %q{flori@ping.de}
12
- s.executables = ["enum"]
13
- s.extra_rdoc_files = ["README"]
14
- s.files = ["bin", "bin/enum", "install.rb", "lib", "lib/spruz", "lib/spruz/attempt.rb", "lib/spruz/bijection.rb", "lib/spruz/count_by.rb", "lib/spruz/deep_dup.rb", "lib/spruz/generator.rb", "lib/spruz/go.rb", "lib/spruz/hash_symbolize_keys_recursive.rb", "lib/spruz/hash_union.rb", "lib/spruz/limited.rb", "lib/spruz/memoize.rb", "lib/spruz/minimize.rb", "lib/spruz/module_group.rb", "lib/spruz/null.rb", "lib/spruz/once.rb", "lib/spruz/p.rb", "lib/spruz/partial_application.rb", "lib/spruz/round.rb", "lib/spruz/shuffle.rb", "lib/spruz/subhash.rb", "lib/spruz/time_dummy.rb", "lib/spruz/to_proc.rb", "lib/spruz/uniq_by.rb", "lib/spruz/version.rb", "lib/spruz/write.rb", "lib/spruz/xt", "lib/spruz/xt/attempt.rb", "lib/spruz/xt/blank.rb", "lib/spruz/xt/count_by.rb", "lib/spruz/xt/deep_dup.rb", "lib/spruz/xt/full.rb", "lib/spruz/xt/hash_symbolize_keys_recursive.rb", "lib/spruz/xt/hash_union.rb", "lib/spruz/xt/irb.rb", "lib/spruz/xt/null.rb", "lib/spruz/xt/p.rb", "lib/spruz/xt/partial_application.rb", "lib/spruz/xt/round.rb", "lib/spruz/xt/shuffle.rb", "lib/spruz/xt/subhash.rb", "lib/spruz/xt/symbol_to_proc.rb", "lib/spruz/xt/time_dummy.rb", "lib/spruz/xt/uniq_by.rb", "lib/spruz/xt/write.rb", "lib/spruz/xt.rb", "lib/spruz.rb", "LICENSE", "Rakefile", "README", "tests", "tests/test_spruz.rb", "tests/test_spruz_memoize.rb", "VERSION"]
12
+ s.executables = [%q{enum}]
13
+ s.extra_rdoc_files = [%q{README}]
14
+ s.files = [%q{tests}, %q{tests/test_spruz_memoize.rb}, %q{tests/test_spruz.rb}, %q{LICENSE}, %q{Rakefile}, %q{spruz.gemspec}, %q{lib}, %q{lib/spruz.rb}, %q{lib/spruz}, %q{lib/spruz/hash_symbolize_keys_recursive.rb}, %q{lib/spruz/hash_union.rb}, %q{lib/spruz/write.rb}, %q{lib/spruz/version.rb}, %q{lib/spruz/round.rb}, %q{lib/spruz/go.rb}, %q{lib/spruz/generator.rb}, %q{lib/spruz/shuffle.rb}, %q{lib/spruz/deep_dup.rb}, %q{lib/spruz/memoize.rb}, %q{lib/spruz/subhash.rb}, %q{lib/spruz/bijection.rb}, %q{lib/spruz/limited.rb}, %q{lib/spruz/attempt.rb}, %q{lib/spruz/to_proc.rb}, %q{lib/spruz/module_group.rb}, %q{lib/spruz/null.rb}, %q{lib/spruz/xt.rb}, %q{lib/spruz/once.rb}, %q{lib/spruz/xt}, %q{lib/spruz/xt/named.rb}, %q{lib/spruz/xt/hash_symbolize_keys_recursive.rb}, %q{lib/spruz/xt/hash_union.rb}, %q{lib/spruz/xt/write.rb}, %q{lib/spruz/xt/irb.rb}, %q{lib/spruz/xt/round.rb}, %q{lib/spruz/xt/shuffle.rb}, %q{lib/spruz/xt/deep_dup.rb}, %q{lib/spruz/xt/symbol_to_proc.rb}, %q{lib/spruz/xt/subhash.rb}, %q{lib/spruz/xt/attempt.rb}, %q{lib/spruz/xt/null.rb}, %q{lib/spruz/xt/p.rb}, %q{lib/spruz/xt/partial_application.rb}, %q{lib/spruz/xt/time_dummy.rb}, %q{lib/spruz/xt/full.rb}, %q{lib/spruz/xt/range_plus.rb}, %q{lib/spruz/xt/count_by.rb}, %q{lib/spruz/xt/blank.rb}, %q{lib/spruz/xt/uniq_by.rb}, %q{lib/spruz/p.rb}, %q{lib/spruz/minimize.rb}, %q{lib/spruz/partial_application.rb}, %q{lib/spruz/time_dummy.rb}, %q{lib/spruz/range_plus.rb}, %q{lib/spruz/count_by.rb}, %q{lib/spruz/uniq_by.rb}, %q{bin}, %q{bin/enum}, %q{README}, %q{VERSION}, %q{install.rb}]
15
15
  s.homepage = %q{http://flori.github.com/spruz}
16
- s.rdoc_options = ["--title", "Spruz", "--main", "README"]
17
- s.require_paths = ["lib"]
18
- s.rubygems_version = %q{1.7.2}
16
+ s.rdoc_options = [%q{--title}, %q{Spruz}, %q{--main}, %q{README}]
17
+ s.require_paths = [%q{lib}]
18
+ s.rubygems_version = %q{1.8.5}
19
19
  s.summary = %q{Useful stuff.}
20
- s.test_files = ["tests/test_spruz.rb", "tests/test_spruz_memoize.rb"]
20
+ s.test_files = [%q{tests/test_spruz_memoize.rb}, %q{tests/test_spruz.rb}]
21
21
 
22
22
  if s.respond_to? :specification_version then
23
23
  s.specification_version = 3
@@ -544,4 +544,33 @@ module Spruz
544
544
  assert_equal((1..5).to_a, (1...3) + (3..5))
545
545
  end
546
546
  end
547
+
548
+ class NamedTest < Test::Unit::TestCase
549
+ require 'spruz/xt/named'
550
+
551
+ def test_named_simple
552
+ a = [ 1, 2, 3 ]
553
+ a.named(:plus1, :map) { |x| x + 1 }
554
+ assert_equal [ 2, 3, 4 ], a.plus1
555
+ Array.named(:odd, :select) { |x| x % 2 == 1 }
556
+ assert_equal [ 3 ], a.plus1.odd
557
+ end
558
+
559
+ if RUBY_VERSION >= '1.9'
560
+ def foo(x, y, &block)
561
+ block.call x * y
562
+ end
563
+
564
+ def test_more_complex
565
+ Object.named(:foo_with_block, :foo) do |z|
566
+ z ** 2
567
+ end
568
+ assert_equal foo(2, 3) { |z| z ** 2 }, foo_with_block(2, 3)
569
+ Object.named(:foo_23, :foo, 2, 3)
570
+ assert_equal foo(2, 3) { |z| z ** 2 }, foo_23 { |z| z ** 2 }
571
+ Object.named(:foo_2, :foo, 2)
572
+ assert_equal foo(2, 3) { |z| z ** 2 }, foo_2(3) { |z| z ** 2 }
573
+ end
574
+ end
575
+ end
547
576
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: spruz
3
3
  version: !ruby/object:Gem::Version
4
- hash: 7
4
+ hash: 5
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 2
9
- - 8
10
- version: 0.2.8
9
+ - 9
10
+ version: 0.2.9
11
11
  platform: ruby
12
12
  authors:
13
13
  - Florian Frank
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-06-22 00:00:00 Z
18
+ date: 2011-07-05 00:00:00 Z
19
19
  dependencies: []
20
20
 
21
21
  description: All the stuff that isn't good/big enough for a real library.
@@ -52,6 +52,7 @@ files:
52
52
  - lib/spruz/null.rb
53
53
  - lib/spruz/xt.rb
54
54
  - lib/spruz/once.rb
55
+ - lib/spruz/xt/named.rb
55
56
  - lib/spruz/xt/hash_symbolize_keys_recursive.rb
56
57
  - lib/spruz/xt/hash_union.rb
57
58
  - lib/spruz/xt/write.rb
@@ -114,7 +115,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
114
115
  requirements: []
115
116
 
116
117
  rubyforge_project:
117
- rubygems_version: 1.8.4
118
+ rubygems_version: 1.8.5
118
119
  signing_key:
119
120
  specification_version: 3
120
121
  summary: Useful stuff.