refine 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,33 @@
1
+ Allows you to use `refine` in older Ruby versions. It will simply fall back to
2
+ `prepend` if available, to `include` otherwise (read: you will still pollute
3
+ global scope).
4
+
5
+ ## Installation
6
+
7
+ gem install refine
8
+
9
+ ## Example
10
+
11
+ require 'refine' if RUBY_VERSION < '2.0'
12
+
13
+ module PassiveSupport
14
+ refine String do
15
+ def underscore
16
+ # ...
17
+ end
18
+
19
+ def camel_case
20
+ # ...
21
+ end
22
+ end
23
+
24
+ refine Module do
25
+ def parent
26
+ # ...
27
+ end
28
+ end
29
+ end
30
+
31
+ class MyFancyApp
32
+ using PassiveSupport
33
+ end
@@ -0,0 +1,3 @@
1
+ task(:test) { ruby "-Ilib test/*_test.rb" }
2
+ task(:default => :test)
3
+ task(:spec => :test)
@@ -0,0 +1,33 @@
1
+ unless respond_to? :refine
2
+ require 'set'
3
+
4
+ module Refinement
5
+ class << self
6
+ attr_accessor :show_warnings
7
+ end
8
+
9
+ self.show_warnings = true
10
+
11
+ module Refine
12
+ append_features Module
13
+
14
+ def refine(mod, &block)
15
+ complain = Refinement.show_warnings
16
+ Refinement.show_warnings = complain == :always
17
+ warn "no #refine, polluting global namespace instead" if complain
18
+ ext = Module.new(&block)
19
+ if mod.respond_to? :prepend, true
20
+ mod.send :prepend, ext
21
+ else
22
+ warn "no #prepend, changing inheritance order" if complain
23
+ mod.send :include, ext
24
+ end
25
+ end
26
+ end
27
+
28
+ module Using
29
+ append_features Object
30
+ def using(*) end
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,17 @@
1
+ Gem::Specification.new do |s|
2
+ s.name = "refine"
3
+ s.version = "0.0.1"
4
+ s.platform = Gem::Platform::RUBY
5
+ s.authors = ["Konstantin Haase"]
6
+ s.email = ["k.haase@finn.de"]
7
+ s.homepage = "http://github.com/rkh/refine"
8
+ s.summary = %q{Start using refine, today. Be ready for Ruby 2.0!}
9
+ s.description = s.summary
10
+
11
+ s.rubyforge_project = "refine"
12
+
13
+ s.files = `git ls-files`.split("\n")
14
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
15
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
16
+ s.require_paths = ["lib"]
17
+ end
@@ -0,0 +1,15 @@
1
+ require 'minitest/autorun'
2
+ require 'refine'
3
+
4
+ class ExtenderTest < MiniTest::Unit::TestCase
5
+ module Refining
6
+ refine String do
7
+ def foo(x) x * 42 end
8
+ end
9
+ end
10
+
11
+ def test_foo
12
+ using Refining
13
+ assert_equal 42, "foo".foo(1)
14
+ end
15
+ end
metadata ADDED
@@ -0,0 +1,72 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: refine
3
+ version: !ruby/object:Gem::Version
4
+ hash: 29
5
+ prerelease: false
6
+ segments:
7
+ - 0
8
+ - 0
9
+ - 1
10
+ version: 0.0.1
11
+ platform: ruby
12
+ authors:
13
+ - Konstantin Haase
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2010-11-17 00:00:00 -08:00
19
+ default_executable:
20
+ dependencies: []
21
+
22
+ description: Start using refine, today. Be ready for Ruby 2.0!
23
+ email:
24
+ - k.haase@finn.de
25
+ executables: []
26
+
27
+ extensions: []
28
+
29
+ extra_rdoc_files: []
30
+
31
+ files:
32
+ - README.md
33
+ - Rakefile
34
+ - lib/refine.rb
35
+ - refine.gemspec
36
+ - test/refine_test.rb
37
+ has_rdoc: true
38
+ homepage: http://github.com/rkh/refine
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
+ none: false
48
+ requirements:
49
+ - - ">="
50
+ - !ruby/object:Gem::Version
51
+ hash: 3
52
+ segments:
53
+ - 0
54
+ version: "0"
55
+ required_rubygems_version: !ruby/object:Gem::Requirement
56
+ none: false
57
+ requirements:
58
+ - - ">="
59
+ - !ruby/object:Gem::Version
60
+ hash: 3
61
+ segments:
62
+ - 0
63
+ version: "0"
64
+ requirements: []
65
+
66
+ rubyforge_project: refine
67
+ rubygems_version: 1.3.7
68
+ signing_key:
69
+ specification_version: 3
70
+ summary: Start using refine, today. Be ready for Ruby 2.0!
71
+ test_files:
72
+ - test/refine_test.rb