include_any 0.0.1 → 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/.gitignore CHANGED
@@ -1,6 +1,6 @@
1
1
  *.gem
2
2
  *.rbc
3
- .bundle
3
+ *.bundle
4
4
  .config
5
5
  .yardoc
6
6
  Gemfile.lock
@@ -0,0 +1,4 @@
1
+ before_install: gem install bundler -v 1.2.1
2
+ language: ruby
3
+ rvm:
4
+ - 1.9.3
@@ -0,0 +1,9 @@
1
+ # IncludeAny Change Log
2
+
3
+ ## v0.0.2
4
+ - Core extensions now make `include_any` in `Class` & `Module` private.
5
+ - Improve documentation.
6
+ - Add tests.
7
+
8
+ ## v0.0.1
9
+ - First release.
data/README.md CHANGED
@@ -1,5 +1,7 @@
1
1
  # IncludeAny
2
2
 
3
+ [![Build Status](https://secure.travis-ci.org/amarshall/include_any.png)](http://travis-ci.org/amarshall/include_any)
4
+
3
5
  Allows including any object, not just modules. Of course, this is just in
4
6
  theory—see “Bugs & Caveats” below.
5
7
 
@@ -13,7 +15,7 @@ or include it in your Gemfile as usual.
13
15
 
14
16
  ## Usage
15
17
 
16
- The method of interest here is `IncludeAny.include_any`. By default this is not
18
+ The method of interest here is `IncludeAny#include_any`. By default this is not
17
19
  mixed-in anywhere, but doing
18
20
 
19
21
  require 'include_any/core_ext'
@@ -32,21 +34,25 @@ Then we can get going:
32
34
  include_any C
33
35
  end
34
36
 
35
- D.ancestors
36
- #=> [C, Object, Kernel, BasicObject]
37
+ D.ancestors.include? C
38
+ #=> true
37
39
 
38
- D.new.f
40
+ D.new.foo
39
41
  #=> "bar!"
40
42
 
41
43
  Well would you look at that! We’ve included a `Class`. Magical!
42
44
 
43
45
  ## Bugs & Caveats
44
46
 
45
- Use at your own risk, kids.
47
+ Use at your own risk, kids. I would strongly recommend against using this in
48
+ production code; it modifies the very core of Ruby's core, and if something
49
+ goes wrong it will do so spectacuarly.
46
50
 
47
51
  - Currently seg faults if passed anything but a `Class` or `Module`. It should
48
52
  accept (most) any object.
49
- - Will probably fail to install or seg fault under anything but MRI 1.9.3
53
+ - Will probably fail to install or seg fault under anything but MRI 1.9.3.
54
+
55
+ See the issues for more.
50
56
 
51
57
  ## Contributing
52
58
 
data/Rakefile CHANGED
@@ -1 +1,14 @@
1
- require "bundler/gem_tasks"
1
+ require 'bundler'
2
+ Bundler.setup
3
+
4
+ require 'bundler/gem_tasks'
5
+ require 'rake/extensiontask'
6
+ require 'rspec/core/rake_task'
7
+
8
+ Rake::ExtensionTask.new('include_any') do |config|
9
+ config.lib_dir = 'lib/include_any'
10
+ end
11
+ RSpec::Core::RakeTask.new(:spec)
12
+
13
+ task :default => :spec
14
+ task :spec => :compile
@@ -11,10 +11,18 @@ Gem::Specification.new do |gem|
11
11
  gem.description = %q{Allows including any object}
12
12
  gem.summary = %q{Allows including any object}
13
13
  gem.homepage = "http://johnandrewmarshall.com/projects/include_any"
14
+ gem.license = 'MIT'
14
15
 
15
16
  gem.files = `git ls-files`.split($/)
16
17
  gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
17
18
  gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
18
19
  gem.require_paths = ["lib"]
19
20
  gem.extensions = ['ext/include_any/extconf.rb']
21
+
22
+ gem.required_ruby_version = '1.9.3'
23
+
24
+ gem.add_development_dependency 'bundler', '>= 1.2'
25
+ gem.add_development_dependency 'rake'
26
+ gem.add_development_dependency 'rake-compiler'
27
+ gem.add_development_dependency 'rspec', '>= 2.0.0'
20
28
  end
@@ -2,8 +2,10 @@ require 'include_any'
2
2
 
3
3
  class Class
4
4
  include IncludeAny
5
+ private :include_any
5
6
  end
6
7
 
7
8
  class Module
8
9
  include IncludeAny
10
+ private :include_any
9
11
  end
@@ -1,3 +1,3 @@
1
1
  module IncludeAny
2
- VERSION = '0.0.1'
2
+ VERSION = '0.0.2'
3
3
  end
@@ -0,0 +1,69 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'IncludeAny#include_any' do
4
+ it "should work when including a class" do
5
+ d = Class.new
6
+ c = Class.new do
7
+ extend IncludeAny
8
+ include_any d
9
+ end
10
+
11
+ c.ancestors.should include d
12
+ end
13
+
14
+ it "should work when including a module" do
15
+ m = Module.new
16
+ c = Class.new do
17
+ extend IncludeAny
18
+ include_any m
19
+ end
20
+
21
+ c.ancestors.should include m
22
+ end
23
+
24
+ it "should work when including the object being defined" do
25
+ pending 'it seg faults'
26
+
27
+ c = Class.new do
28
+ extend IncludeAny
29
+ include_any c
30
+ end
31
+
32
+ c.ancestors.should include c
33
+ end
34
+
35
+ it "should work when including a non-Class/Module object" do
36
+ pending 'it seg faults'
37
+
38
+ o = Object.new
39
+ Class.new do
40
+ extend IncludeAny
41
+ include_any o
42
+ end
43
+
44
+ c.ancestors.should include o
45
+ end
46
+
47
+ it "should work with super" do
48
+ d = Class.new do
49
+ def f; 42; end
50
+ end
51
+ c = Class.new do
52
+ extend IncludeAny
53
+ include_any d
54
+ def f; super + 1; end
55
+ end
56
+
57
+ expect { c.new.f }.to_not raise_exception
58
+ c.new.f.should == 43
59
+ end
60
+
61
+ it "should not pollute the ancestors with duplicates" do
62
+ c = Class.new do
63
+ extend IncludeAny
64
+ include_any Class.new
65
+ end
66
+
67
+ c.ancestors.should == c.ancestors.uniq
68
+ end
69
+ end
@@ -0,0 +1,5 @@
1
+ require 'include_any'
2
+
3
+ RSpec.configure do |config|
4
+ config.color_enabled = true
5
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: include_any
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,8 +9,52 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-10-19 00:00:00.000000000 Z
13
- dependencies: []
12
+ date: 2012-10-20 00:00:00.000000000Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: bundler
16
+ requirement: &70292057108360 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '1.2'
22
+ type: :development
23
+ prerelease: false
24
+ version_requirements: *70292057108360
25
+ - !ruby/object:Gem::Dependency
26
+ name: rake
27
+ requirement: &70292057107580 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ! '>='
31
+ - !ruby/object:Gem::Version
32
+ version: '0'
33
+ type: :development
34
+ prerelease: false
35
+ version_requirements: *70292057107580
36
+ - !ruby/object:Gem::Dependency
37
+ name: rake-compiler
38
+ requirement: &70292057106700 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ! '>='
42
+ - !ruby/object:Gem::Version
43
+ version: '0'
44
+ type: :development
45
+ prerelease: false
46
+ version_requirements: *70292057106700
47
+ - !ruby/object:Gem::Dependency
48
+ name: rspec
49
+ requirement: &70292057105740 !ruby/object:Gem::Requirement
50
+ none: false
51
+ requirements:
52
+ - - ! '>='
53
+ - !ruby/object:Gem::Version
54
+ version: 2.0.0
55
+ type: :development
56
+ prerelease: false
57
+ version_requirements: *70292057105740
14
58
  description: Allows including any object
15
59
  email:
16
60
  - andrew@johnandrewmarshall.com
@@ -20,6 +64,8 @@ extensions:
20
64
  extra_rdoc_files: []
21
65
  files:
22
66
  - .gitignore
67
+ - .travis.yml
68
+ - CHANGELOG
23
69
  - Gemfile
24
70
  - LICENSE.txt
25
71
  - README.md
@@ -31,8 +77,11 @@ files:
31
77
  - lib/include_any.rb
32
78
  - lib/include_any/core_ext.rb
33
79
  - lib/include_any/version.rb
80
+ - spec/lib/include_any_spec.rb
81
+ - spec/spec_helper.rb
34
82
  homepage: http://johnandrewmarshall.com/projects/include_any
35
- licenses: []
83
+ licenses:
84
+ - MIT
36
85
  post_install_message:
37
86
  rdoc_options: []
38
87
  require_paths:
@@ -40,20 +89,24 @@ require_paths:
40
89
  required_ruby_version: !ruby/object:Gem::Requirement
41
90
  none: false
42
91
  requirements:
43
- - - ! '>='
92
+ - - =
44
93
  - !ruby/object:Gem::Version
45
- version: '0'
94
+ version: 1.9.3
46
95
  required_rubygems_version: !ruby/object:Gem::Requirement
47
96
  none: false
48
97
  requirements:
49
98
  - - ! '>='
50
99
  - !ruby/object:Gem::Version
51
100
  version: '0'
101
+ segments:
102
+ - 0
103
+ hash: 3596787878946325054
52
104
  requirements: []
53
105
  rubyforge_project:
54
- rubygems_version: 1.8.24
106
+ rubygems_version: 1.8.10
55
107
  signing_key:
56
108
  specification_version: 3
57
109
  summary: Allows including any object
58
- test_files: []
59
- has_rdoc:
110
+ test_files:
111
+ - spec/lib/include_any_spec.rb
112
+ - spec/spec_helper.rb