every 1.0 → 1.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,10 @@
1
+ LICENSE
2
+ Manifest
3
+ README
4
+ Rakefile
5
+ TODO
6
+ benchmarks.rb
7
+ every.gemspec
8
+ examples.rb
9
+ lib/every.rb
10
+ test/test_every.rb
data/Rakefile CHANGED
@@ -1,57 +1,51 @@
1
1
  # --------------------------------------------------
2
- # tasks mostly copied from thin's Rakefile
3
- # http://github.com/macournoyer/thin/tree/master
2
+ # Tests
4
3
  # --------------------------------------------------
4
+ task(:default => "test")
5
5
 
6
- require 'rake/gempackagetask'
7
- require 'pathname'
8
- require 'yaml'
9
-
10
- RUBY_1_9 = RUBY_VERSION =~ /^1\.9/
11
- WIN = (RUBY_PLATFORM =~ /mswin|cygwin/)
12
- SUDO = (WIN ? "" : "sudo")
13
-
14
- def gem
15
- RUBY_1_9 ? 'gem19' : 'gem'
16
- end
17
-
18
- def all_except(paths)
19
- Dir['**/*'] - paths.map {|path| path.strip.gsub(/^\//,'').gsub(/\/$/,'') }
20
- end
21
-
22
- spec = Gem::Specification.new do |s|
23
- s.name = 'every'
24
- s.version = '1.0'
25
- s.summary = "Symbol#to_proc's hot cousin. Simple and elegant alternative to using &:method with enumerables."
26
- s.description = "Symbol#to_proc's hot cousin. Simple and elegant alternative to using &:method with enumerables."
27
- s.author = "Martin Aumont"
28
- s.email = 'mynyml@gmail.com'
29
- s.homepage = ''
30
- s.has_rdoc = true
31
- s.require_path = "lib"
32
- s.files = Dir['**/*']
33
- end
34
-
35
- Rake::GemPackageTask.new(spec) do |p|
36
- p.gem_spec = spec
6
+ desc "Run tests"
7
+ task(:test) do
8
+ system "ruby -rubygems -I.:lib test/test_every.rb"
37
9
  end
38
10
 
39
-
40
- desc "Remove package products"
41
- task :clean => :clobber_package
42
-
43
- desc "Update the gemspec for GitHub's gem server"
44
- task :gemspec do
45
- Pathname("#{spec.name}.gemspec").open('w') {|f| f << YAML.dump(spec) }
11
+ namespace(:test) do
12
+ desc "Run all tests on multiple ruby versions (requires rvm)"
13
+ task(:portability) do
14
+ versions = %w( 1.8.6 1.8.7 1.9 1.9.2 jruby )
15
+ versions.each do |version|
16
+ system <<-BASH
17
+ bash -c 'source ~/.rvm/scripts/rvm;
18
+ rvm use #{version};
19
+ echo "--------- #{version} ----------";
20
+ rake -s test'
21
+ BASH
22
+ end
23
+ end
46
24
  end
47
25
 
48
- desc "Install gem"
49
- task :install => [:clobber, :package] do
50
- sh "#{SUDO} #{gem} install pkg/#{spec.full_name}.gem"
26
+ # --------------------------------------------------
27
+ # Docs
28
+ # --------------------------------------------------
29
+ desc "Generate YARD Documentation"
30
+ task :yardoc do
31
+ require 'yard'
32
+ files = %w( lib/**/*.rb )
33
+ options = %w( -o doc/yard --readme README.rdoc --files LICENSE )
34
+ YARD::CLI::Yardoc.run *(options + files)
51
35
  end
52
36
 
53
- desc "Uninstall gem"
54
- task :uninstall => :clean do
55
- sh "#{SUDO} #{gem} uninstall -v #{spec.version} -x #{spec.name}"
37
+ # --------------------------------------------------
38
+ # Stats
39
+ # --------------------------------------------------
40
+ desc "LOC count"
41
+ task(:loc) do
42
+ loc = 0
43
+ Dir['lib/**/*'].each do |file|
44
+ next if File.directory?(file)
45
+ File.read(file).each_line do |line|
46
+ loc += 1 unless line.strip.empty? || line.strip =~ /^#/
47
+ end
48
+ end
49
+ puts "lib files contain #{loc} SLOCs"
56
50
  end
57
51
 
@@ -1,66 +1,15 @@
1
- --- !ruby/object:Gem::Specification
2
- name: every
3
- version: !ruby/object:Gem::Version
4
- version: "1.0"
5
- platform: ruby
6
- authors:
7
- - Martin Aumont
8
- autorequire:
9
- bindir: bin
10
- cert_chain: []
11
-
12
- date: 2009-05-19 00:00:00 -04:00
13
- default_executable:
14
- dependencies: []
15
-
16
- description: Symbol#to_proc's hot cousin. Simple and elegant alternative to using &:method with enumerables.
17
- email: mynyml@gmail.com
18
- executables: []
19
-
20
- extensions: []
21
-
22
- extra_rdoc_files: []
23
-
24
- files:
25
- - Rakefile
26
- - test
27
- - test/test_every.rb
28
- - test/test_helper.rb
29
- - every.gemspec
30
- - benchmarks.rb
31
- - TODO
32
- - lib
33
- - lib/every.rb
34
- - LICENSE
35
- - examples.rb
36
- - README
37
- has_rdoc: true
38
- homepage: ""
39
- licenses: []
40
-
41
- post_install_message:
42
- rdoc_options: []
43
-
44
- require_paths:
45
- - lib
46
- required_ruby_version: !ruby/object:Gem::Requirement
47
- requirements:
48
- - - ">="
49
- - !ruby/object:Gem::Version
50
- version: "0"
51
- version:
52
- required_rubygems_version: !ruby/object:Gem::Requirement
53
- requirements:
54
- - - ">="
55
- - !ruby/object:Gem::Version
56
- version: "0"
57
- version:
58
- requirements: []
59
-
60
- rubyforge_project:
61
- rubygems_version: 1.3.3
62
- signing_key:
63
- specification_version: 3
64
- summary: Symbol#to_proc's hot cousin. Simple and elegant alternative to using &:method with enumerables.
65
- test_files: []
66
-
1
+ Gem::Specification.new do |s|
2
+ s.name = "every"
3
+ s.version = "1.1"
4
+ s.summary = "Symbol#to_proc's hot cousin. Simple and elegant alternative to using &:method with enumerables"
5
+ s.description = "Symbol#to_proc's hot cousin. Simple and elegant alternative to using &:method with enumerables."
6
+ s.author = "Martin Aumont"
7
+ s.email = "mynyml@gmail.com"
8
+ s.homepage = "http://github.com/mynyml/every"
9
+ s.rubyforge_project = "every"
10
+ s.has_rdoc = true
11
+ s.require_path = "lib"
12
+ s.files = File.read("Manifest").strip.split("\n")
13
+
14
+ s.add_development_dependency 'minitest'
15
+ end
@@ -1,14 +1,15 @@
1
1
  module Enumerable
2
2
  class Proxy
3
- instance_methods.each { |m| undef_method(m) unless m.match(/^__/) }
3
+ instance_methods.each {|m| undef_method(m) unless m.match(/^__|object_id/) }
4
+
4
5
  def initialize(enum, method=:map)
5
6
  @enum, @method = enum, method
6
7
  end
8
+
7
9
  def method_missing(method, *args, &block)
8
10
  @enum.__send__(@method) {|o| o.__send__(method, *args, &block) }
9
11
  end
10
12
  end
11
- end
12
- module Enumerable
13
+
13
14
  def every() Proxy.new(self) end
14
15
  end
@@ -1,23 +1,26 @@
1
- require 'pathname'
2
1
  require 'set'
3
- root = Pathname(__FILE__).dirname.parent
4
- require root.join('test/test_helper')
5
- require root.join('lib/every')
2
+ require 'minitest/autorun'
3
+ require 'minitest/spec'
4
+ require 'lib/every'
6
5
 
7
- class EveryTest < Test::Unit::TestCase
8
- context "Every" do
9
- test "is a basic object" do
10
- whitelist = %w( __id__ __send__ method_missing )
11
- Enumerable::Proxy.instance_methods.to_set.should be(whitelist.to_set)
12
- end
13
- test "passes message onto enumerable's items" do
14
- [1.4, 2.4, 3.4].every.floor.should be([1,2,3])
15
- end
16
- test "allows arguments" do
17
- %w( axb dxf ).every.gsub(/x/,'y').should be(%w( ayb dyf ))
18
- end
19
- test "allows blocks" do
20
- %w( axb dxf ).every.gsub(/x/) { 'y' }.should be(%w( ayb dyf ))
21
- end
6
+ describe "Every" do
7
+
8
+ it "should pass message onto enumerable's items" do
9
+ [1.4, 2.4, 3.4].every.floor.must_equal([1,2,3])
10
+ end
11
+
12
+ it "should allow arguments" do
13
+ %w( axb dxf ).every.gsub(/x/,'y').must_equal(%w( ayb dyf ))
14
+ end
15
+
16
+ it "should allow blocks" do
17
+ %w( axb dxf ).every.gsub(/x/) { 'y' }.must_equal(%w( ayb dyf ))
18
+ end
19
+
20
+ it "should be a basic object" do
21
+ whitelist = %w( __id__ __send__ method_missing object_id )
22
+ whitelist << '__jtrap' if RUBY_PLATFORM == 'java'
23
+
24
+ Enumerable::Proxy.instance_methods.every.to_s.to_set.must_equal(whitelist.to_set)
22
25
  end
23
26
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: every
3
3
  version: !ruby/object:Gem::Version
4
- version: "1.0"
4
+ version: "1.1"
5
5
  platform: ruby
6
6
  authors:
7
7
  - Martin Aumont
@@ -9,10 +9,19 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-08-25 00:00:00 -04:00
12
+ date: 2009-12-29 00:00:00 -05:00
13
13
  default_executable:
14
- dependencies: []
15
-
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: minitest
17
+ type: :development
18
+ version_requirement:
19
+ version_requirements: !ruby/object:Gem::Requirement
20
+ requirements:
21
+ - - ">="
22
+ - !ruby/object:Gem::Version
23
+ version: "0"
24
+ version:
16
25
  description: Symbol#to_proc's hot cousin. Simple and elegant alternative to using &:method with enumerables.
17
26
  email: mynyml@gmail.com
18
27
  executables: []
@@ -22,18 +31,18 @@ extensions: []
22
31
  extra_rdoc_files: []
23
32
 
24
33
  files:
34
+ - LICENSE
35
+ - Manifest
36
+ - README
25
37
  - Rakefile
26
- - test/test_every.rb
27
- - test/test_helper.rb
28
- - every.gemspec
29
- - benchmarks.rb
30
38
  - TODO
31
- - lib/every.rb
32
- - LICENSE
39
+ - benchmarks.rb
40
+ - every.gemspec
33
41
  - examples.rb
34
- - README
42
+ - lib/every.rb
43
+ - test/test_every.rb
35
44
  has_rdoc: true
36
- homepage: ""
45
+ homepage: http://github.com/mynyml/every
37
46
  licenses: []
38
47
 
39
48
  post_install_message:
@@ -55,10 +64,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
55
64
  version:
56
65
  requirements: []
57
66
 
58
- rubyforge_project:
67
+ rubyforge_project: every
59
68
  rubygems_version: 1.3.5
60
69
  signing_key:
61
70
  specification_version: 3
62
- summary: Symbol#to_proc's hot cousin. Simple and elegant alternative to using &:method with enumerables.
71
+ summary: Symbol#to_proc's hot cousin. Simple and elegant alternative to using &:method with enumerables
63
72
  test_files: []
64
73
 
@@ -1,9 +0,0 @@
1
- require 'test/unit'
2
- require 'rubygems'
3
- require 'context'
4
- require 'matchy'
5
- begin
6
- require 'ruby-debug'
7
- require 'quietbacktrace'
8
- rescue LoadError, RuntimeError
9
- end