duct_tape 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (55) hide show
  1. data/Gemfile +10 -0
  2. data/Gemfile.lock +35 -0
  3. data/LICENSE +25 -0
  4. data/README.md +223 -0
  5. data/Rakefile +38 -0
  6. data/VERSION +1 -0
  7. data/duct_tape.gemspec +106 -0
  8. data/ext/mkrf_conf.rb +36 -0
  9. data/git_hooks/env_vars.sh +287 -0
  10. data/git_hooks/post-commit +43 -0
  11. data/git_hooks/post-merge +8 -0
  12. data/git_hooks/pre-commit +273 -0
  13. data/install_git_hooks +17 -0
  14. data/lib/algorithms/containers/heap.rb +15 -0
  15. data/lib/algorithms/containers/priority_queue.rb +11 -0
  16. data/lib/algorithms/containers.rb +1 -0
  17. data/lib/duct_tape/autoassociative_array.rb +110 -0
  18. data/lib/duct_tape.rb +10 -0
  19. data/lib/ext/array.rb +327 -0
  20. data/lib/ext/boolean.rb +3 -0
  21. data/lib/ext/datetime.rb +7 -0
  22. data/lib/ext/dir.rb +59 -0
  23. data/lib/ext/file.rb +40 -0
  24. data/lib/ext/hash.rb +83 -0
  25. data/lib/ext/kernel.rb +593 -0
  26. data/lib/ext/numeric.rb +74 -0
  27. data/lib/ext/object.rb +17 -0
  28. data/lib/ext/pathname.rb +114 -0
  29. data/lib/ext/range.rb +7 -0
  30. data/lib/ext/regexp.rb +12 -0
  31. data/lib/ext/string.rb +54 -0
  32. data/lib/ext/symbol.rb +8 -0
  33. data/lib/ext/time.rb +32 -0
  34. data/lib/ext/uri.rb +16 -0
  35. data/spec/algorithms/containers/heap_spec.rb +19 -0
  36. data/spec/algorithms/containers/priority_queue_spec.rb +19 -0
  37. data/spec/duct_tape/autoassociative_array_spec.rb +139 -0
  38. data/spec/ext/array_spec.rb +407 -0
  39. data/spec/ext/boolean_spec.rb +19 -0
  40. data/spec/ext/datetime_spec.rb +10 -0
  41. data/spec/ext/dir_spec.rb +46 -0
  42. data/spec/ext/file_spec.rb +10 -0
  43. data/spec/ext/hash_spec.rb +73 -0
  44. data/spec/ext/kernel_spec.rb +64 -0
  45. data/spec/ext/numeric_spec.rb +61 -0
  46. data/spec/ext/object_spec.rb +19 -0
  47. data/spec/ext/pathname_spec.rb +13 -0
  48. data/spec/ext/range_spec.rb +10 -0
  49. data/spec/ext/regexp_spec.rb +10 -0
  50. data/spec/ext/string_spec.rb +73 -0
  51. data/spec/ext/symbol_spec.rb +10 -0
  52. data/spec/ext/time_spec.rb +19 -0
  53. data/spec/ext/uri_spec.rb +28 -0
  54. data/spec/spec_helper.rb +7 -0
  55. metadata +183 -0
data/Gemfile ADDED
@@ -0,0 +1,10 @@
1
+ source "http://rubygems.org"
2
+
3
+ group :development do
4
+ gem "rake"
5
+ gem "yard"
6
+ gem "jeweler"
7
+ gem "rspec"
8
+ end
9
+
10
+ gem "facets"
data/Gemfile.lock ADDED
@@ -0,0 +1,35 @@
1
+ GEM
2
+ remote: http://rubygems.org/
3
+ specs:
4
+ diff-lcs (1.1.3)
5
+ facets (2.9.3)
6
+ git (1.2.5)
7
+ jeweler (1.8.4)
8
+ bundler (~> 1.0)
9
+ git (>= 1.2.5)
10
+ rake
11
+ rdoc
12
+ json (1.7.3)
13
+ rake (0.9.2.2)
14
+ rdoc (3.12)
15
+ json (~> 1.4)
16
+ rspec (2.11.0)
17
+ rspec-core (~> 2.11.0)
18
+ rspec-expectations (~> 2.11.0)
19
+ rspec-mocks (~> 2.11.0)
20
+ rspec-core (2.11.0)
21
+ rspec-expectations (2.11.1)
22
+ diff-lcs (~> 1.1.3)
23
+ rspec-mocks (2.11.1)
24
+ yard (0.8.2.1)
25
+
26
+ PLATFORMS
27
+ ruby
28
+ x86-mingw32
29
+
30
+ DEPENDENCIES
31
+ facets
32
+ jeweler
33
+ rake
34
+ rspec
35
+ yard
data/LICENSE ADDED
@@ -0,0 +1,25 @@
1
+ # 2-Clause BSD License
2
+ #
3
+ # Copyright (c) 2011-2012, Tim Rodriguez [twrodriguez](https://github.com/twrodriguez)
4
+ # All rights reserved.
5
+ #
6
+ # Redistribution and use in source and binary forms, with or without
7
+ # modification, are permitted provided that the following conditions are met:
8
+ #
9
+ # 1) Redistributions of source code must retain the above copyright notice,
10
+ # this list of conditions and the following disclaimer.
11
+ # 2) Redistributions in binary form must reproduce the above copyright notice,
12
+ # this list of conditions and the following disclaimer in the documentation
13
+ # and/or other materials provided with the distribution.
14
+ #
15
+ # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
16
+ # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17
+ # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18
+ # ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
19
+ # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
20
+ # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
21
+ # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22
+ # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23
+ # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
24
+ # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
25
+ # POSSIBILITY OF SUCH DAMAGE.
data/README.md ADDED
@@ -0,0 +1,223 @@
1
+ duct_tape
2
+ =========
3
+
4
+ Utility Patchwork Library for Ruby 1.8.7+
5
+
6
+ Getting Started
7
+ ---------------
8
+
9
+ Install the gem.
10
+
11
+ $ sudo gem install duct_tape
12
+
13
+ Require with rubygems.
14
+
15
+ require 'rubygems'
16
+ require 'duct_tape'
17
+
18
+ Because duct_tape requires the excellent [facets](https://github.com/rubyworks/facets)
19
+ and [algorithms](https://github.com/kanwei/algorithms) gems, the core classes have become
20
+ much more malleable. Any overridden methods have maintained their original functionality.
21
+
22
+ Supported Platforms
23
+ -------------------
24
+
25
+ - Mac OSX, Linux, FreeBSD, Solaris, Windows XP or Later (mingw)
26
+ - Ruby Versions 1.8.7+
27
+ - MRI, YARV, RubyEE, Rubinius, JRuby
28
+
29
+ Requirements
30
+ ------------
31
+
32
+ - Ruby 1.8.7 (MRI / RubyEE / Rubinius):
33
+ - [facets](https://github.com/rubyworks/facets) gem
34
+ - [algorithms](https://github.com/kanwei/algorithms) gem
35
+ - Ruby 1.9+:
36
+ - [facets](https://github.com/rubyworks/facets) gem
37
+ - [algorithms](https://github.com/kanwei/algorithms) gem
38
+ - JRuby:
39
+ - [facets](https://github.com/rubyworks/facets) gem
40
+
41
+ Core Extensions
42
+ ---------------
43
+
44
+ Array, TrueClass, FalseClass, DateTime, Dir, File, Hash, Kernel, Numeric, Object,
45
+ Pathname, Range, Regexp, String, Symbol, Time, and URI have patches in duct_tape.
46
+ Here are a few examples:
47
+
48
+ # Array
49
+ ["a","b","c"].to_h #=> {0=>"a", 1=>"b", 2=>"c"}
50
+ [[1,2], [3,4]].to_h #=> {1=>2, 3=>4}
51
+ [{1 => 2}, {3 => 4}].to_h #=> {1=>2, 3=>4}
52
+ [{"name" => 1, "value" => 2},
53
+ {"name" => 3, "value" => 4}].to_h #=> {1=>2, 3=>4}
54
+ [{:x => 1, :y => 2},
55
+ {:x => 3, :y => 4}].to_h(:x, :y) #=> {1=>2, 3=>4}
56
+ [{1 => 2, 3 => 4}, {1 => 4}].to_h #=> {1=>[2, 4], 3=>4}
57
+ [1,2,3,4,5,6,7].chunk(3) #=> [[1, 2, 3], [4, 5, 6], [7]]
58
+ [1,2] * [3,4] #=> [[1, 3], [1, 4], [2, 3], [2, 4]]
59
+ [0,1] ** 0 #=> []
60
+ [0,1] ** 1 #=> [[0], [1]]
61
+ [0,1] ** 2 #=> [[0, 0], [0, 1], [1, 0], [1, 1]]
62
+ [1,1,1].unanimous? #=> true
63
+ [1,1,2].unanimous? #=> false
64
+ [1,1,1].unanimous?(1) #=> true
65
+ [1,1,1].unanimous?(2) #=> false
66
+ [1,1,1].unanimous? { |i| i != 2 } #=> true
67
+ [1,1,1].unanimous?(4) { |i| i + 3 } #=> true
68
+
69
+ # Range
70
+ (1..7).chunk(3) #=> [[1, 2, 3], [4, 5, 6], [7]]
71
+
72
+ # Hash
73
+ {1=>{2=>3}}.deep_merge({1=>{3=>4}}) #=> {1=>{2=>3, 3=>4}}
74
+ {1=>[2, 3]}}.deep_merge({1=>[3, 4]}}) #=> {1=>[2, 3, 4]}
75
+ {1=>2, 2=>3, 3=>4, 4=>5}.chunk(2) #=> [{1=>2, 2=>3}, {3=>4, 4=>5}]
76
+ {1=>{2=>3}, 2=>{3=>4}} & {2=>4} #=> {2=>{3=>4}}
77
+ {1=>{2=>3}, 2=>{3=>4}} & [2] #=> {2=>{3=>4}}
78
+ {1=>{2=>3}, 2=>{3=>4}} - {2=>4} #=> {1=>{2=>3}}
79
+ {1=>{2=>3}, 2=>{3=>4}} - [2] #=> {1=>{2=>3}}
80
+
81
+ # Regexp
82
+ /ll/.invert #=> /\A(?:(?!ll).)+\z/
83
+ "hello" =~ /ll/ #=> 2
84
+ "hello" =~ /ll/.invert #=> nil
85
+ "hello" =~ /ll/.invert.invert #=> 2
86
+
87
+ # Pathname
88
+ Pathname.which("which") #=> #<Pathname:/bin/which>
89
+
90
+ # String
91
+ "lorem ipsum".word_wrap(3) #=> "lor\nem\nips\num\n"
92
+ "1234567890".chunk(3) #=> ["123", "456", "789", "0"]
93
+ "%{x} %{y}" % {:x => 3, :y => 4} #=> "3 4"
94
+
95
+ # Time
96
+ Time.duration(61621) #=> "17 hours, 7 minutes, and 1 second"
97
+
98
+ Platform Detection
99
+ ------------------
100
+
101
+ # Kernel (on Fedora)
102
+ detect_platform #=> {:arch=>"i386",
103
+ # :hostname=>"Teruhide",
104
+ # :install_cmd=>"yum install -y",
105
+ # :install_method=>"install",
106
+ # :interpreter=>"jruby",
107
+ # :interpreter_language=>"java",
108
+ # :ipv4=>"192.168.1.24",
109
+ # :local_install_cmd=>"yum localinstall -y",
110
+ # :mac_addr=>"00:1c:25:74:c9:6c",
111
+ # :n_cpus=>4,
112
+ # :os_distro=>"Fedora",
113
+ # :os_nickname=>"Verne",
114
+ # :os_version=>"16",
115
+ # :pkg_arch=>"i386",
116
+ # :pkg_format=>"rpm",
117
+ # :platform=>"linux",
118
+ # :ram=>2106052608,
119
+ # :ruby_version=>"1.8.7"}
120
+
121
+ # Kernel (on Windows)
122
+ detect_platform #=> {:arch=>"i386",
123
+ # :hostname=>"TIM-84DDD2CE6C6",
124
+ # :install_cmd=>"install",
125
+ # :install_method=>"install",
126
+ # :interpreter=>"mri",
127
+ # :interpreter_language=>"c",
128
+ # :ipv4=>"10.0.2.15",
129
+ # :mac_addr=>"00:1c:25:74:c9:6c",
130
+ # :n_cpus=>8,
131
+ # :os_distro=>"XP Professional",
132
+ # :os_nickname=>"Microsoft Windows XP Professional",
133
+ # :os_version=>"5.1.2600",
134
+ # :platform=>"windows",
135
+ # :ram=>2146435072,
136
+ # :ruby_version=>"1.9.3"}
137
+
138
+ # Kernel (on OpenSolaris)
139
+ detect_platform #=> {:arch=>"i386",
140
+ # :hostname=>"opensolaris",
141
+ # :install_cmd=>"pkg install",
142
+ # :install_method=>"install",
143
+ # :interpreter=>"mri",
144
+ # :interpreter_language=>"c",
145
+ # :ipv4=>"192.168.1.70",
146
+ # :mac_addr=>"00:1c:25:74:c9:6c",
147
+ # :n_cpus=>8,
148
+ # :os_distro=>"OpenSolaris",
149
+ # :os_nickname=>"OpenSolaris 2009.06",
150
+ # :os_version=>"5.11",
151
+ # :platform=>"solaris",
152
+ # :ram=>2147483648,
153
+ # :ruby_version=>"1.8.7"}
154
+
155
+
156
+ AutoassociativeArray
157
+ --------------------
158
+
159
+ In addition to core extensions, duct_tape includes a new container class called an
160
+ AutoassociativeArray. Think of it as a cross between a relational database and a
161
+ bidirectional hash. It also adds partial matching capabilities, though the runtime
162
+ of partial matches can explode if abused in the worst case.
163
+
164
+ aa = Containers::AutoassociativeArray.new
165
+ aa << [1,2,3] << [2,3,4] << [3,4,5] #=> [[1, 2, 3], [2, 3, 4], [3, 4, 5]]
166
+ aa[1] #=> [1, 2, 3]
167
+ aa[2] #=> [[1, 2, 3], [2, 3, 4]]
168
+ aa[3] #=> [[1, 2, 3], [2, 3, 4], [3, 4, 5]]
169
+ aa[4] #=> [[2, 3, 4], [3, 4, 5]]
170
+ aa[5] #=> [3, 4, 5]
171
+ aa[2,3] #=> [[1, 2, 3], [2, 3, 4]]
172
+ aa[2,3,4] #=> [2, 3, 4]
173
+ aa[2,5] #=> []
174
+ aa.partial_match(1,4) #=> [[2, 3, 4], [3, 4, 5]]
175
+ aa.partial_match(1,5) #=> [[1, 2, 3], [3, 4, 5]]
176
+ aa.partial_match(1,3,5) #=> [[1, 2, 3], [3, 4, 5]]
177
+ aa.partial_match(1,4,5) #=> [3, 4, 5]
178
+ aa.partial_match(2,4) #=> [2, 3, 4]
179
+ aa.partial_match(2,5) #=> [[1, 2, 3], [2, 3, 4]]
180
+
181
+ Partial matches return the set of arrays with the most matched elements from the
182
+ query.
183
+
184
+ Contributing to duct_tape
185
+ -------------------------
186
+
187
+ - Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
188
+ - Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
189
+ - Fork the project.
190
+ - Start a feature/bugfix branch.
191
+ - Commit and push until you are happy with your contribution.
192
+ - Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
193
+ - Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
194
+
195
+ License
196
+ -------
197
+
198
+ 2-Clause BSD License
199
+
200
+ Copyright (c) 2011-2012, Tim Rodriguez ([twrodriguez](https://github.com/twrodriguez))
201
+ All rights reserved.
202
+
203
+ Redistribution and use in source and binary forms, with or without
204
+ modification, are permitted provided that the following conditions are met:
205
+
206
+ 1. Redistributions of source code must retain the above copyright notice,
207
+ this list of conditions and the following disclaimer.
208
+
209
+ 2. Redistributions in binary form must reproduce the above copyright notice,
210
+ this list of conditions and the following disclaimer in the documentation
211
+ and/or other materials provided with the distribution.
212
+
213
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
214
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
215
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
216
+ ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
217
+ LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
218
+ CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
219
+ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
220
+ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
221
+ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
222
+ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
223
+ POSSIBILITY OF SUCH DAMAGE.
data/Rakefile ADDED
@@ -0,0 +1,38 @@
1
+ require 'rubygems'
2
+ require 'rake'
3
+ require 'jeweler'
4
+
5
+ version = File.read(File.expand_path("../VERSION",__FILE__)).strip
6
+ Jeweler::Tasks.new do |gem|
7
+ gem.name = "duct_tape"
8
+ gem.summary = "A bunch of useful patches for core Ruby classes"
9
+ gem.description = "A general-purpose utility library for Ruby"
10
+ gem.email = ["tw.rodriguez@gmail.com"]
11
+ gem.homepage = "http://github.com/twrodriguez/duct_tape"
12
+ gem.authors = ["Tim Rodriguez"]
13
+ gem.extensions = 'ext/mkrf_conf.rb'
14
+ gem.required_ruby_version = '>= 1.8.7'
15
+ gem.license = 'Simplified BSD'
16
+ gem.version = version
17
+ # dependencies defined in Gemfile
18
+ end
19
+ Jeweler::RubygemsDotOrgTasks.new
20
+
21
+ require 'rspec/core'
22
+ require 'rspec/core/rake_task'
23
+ RSpec::Core::RakeTask.new(:spec) do |spec|
24
+ spec.pattern = FileList['spec/**/*_spec.rb']
25
+ end
26
+
27
+ RSpec::Core::RakeTask.new(:rcov) do |spec|
28
+ spec.pattern = 'spec/**/*_spec.rb'
29
+ spec.rcov = true
30
+ end
31
+
32
+ task :default => :spec
33
+
34
+ begin
35
+ require 'yard'
36
+ YARD::Rake::YardocTask.new
37
+ rescue LoadError
38
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.0.4
data/duct_tape.gemspec ADDED
@@ -0,0 +1,106 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = "duct_tape"
8
+ s.version = "0.0.4"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Tim Rodriguez"]
12
+ s.date = "2012-11-02"
13
+ s.description = "A general-purpose utility library for Ruby"
14
+ s.email = ["tw.rodriguez@gmail.com"]
15
+ s.extensions = ["ext/mkrf_conf.rb"]
16
+ s.extra_rdoc_files = [
17
+ "LICENSE",
18
+ "README.md"
19
+ ]
20
+ s.files = [
21
+ "Gemfile",
22
+ "Gemfile.lock",
23
+ "LICENSE",
24
+ "README.md",
25
+ "Rakefile",
26
+ "VERSION",
27
+ "duct_tape.gemspec",
28
+ "ext/mkrf_conf.rb",
29
+ "git_hooks/env_vars.sh",
30
+ "git_hooks/post-commit",
31
+ "git_hooks/post-merge",
32
+ "git_hooks/pre-commit",
33
+ "install_git_hooks",
34
+ "lib/algorithms/containers.rb",
35
+ "lib/algorithms/containers/heap.rb",
36
+ "lib/algorithms/containers/priority_queue.rb",
37
+ "lib/duct_tape.rb",
38
+ "lib/duct_tape/autoassociative_array.rb",
39
+ "lib/ext/array.rb",
40
+ "lib/ext/boolean.rb",
41
+ "lib/ext/datetime.rb",
42
+ "lib/ext/dir.rb",
43
+ "lib/ext/file.rb",
44
+ "lib/ext/hash.rb",
45
+ "lib/ext/kernel.rb",
46
+ "lib/ext/numeric.rb",
47
+ "lib/ext/object.rb",
48
+ "lib/ext/pathname.rb",
49
+ "lib/ext/range.rb",
50
+ "lib/ext/regexp.rb",
51
+ "lib/ext/string.rb",
52
+ "lib/ext/symbol.rb",
53
+ "lib/ext/time.rb",
54
+ "lib/ext/uri.rb",
55
+ "spec/algorithms/containers/heap_spec.rb",
56
+ "spec/algorithms/containers/priority_queue_spec.rb",
57
+ "spec/duct_tape/autoassociative_array_spec.rb",
58
+ "spec/ext/array_spec.rb",
59
+ "spec/ext/boolean_spec.rb",
60
+ "spec/ext/datetime_spec.rb",
61
+ "spec/ext/dir_spec.rb",
62
+ "spec/ext/file_spec.rb",
63
+ "spec/ext/hash_spec.rb",
64
+ "spec/ext/kernel_spec.rb",
65
+ "spec/ext/numeric_spec.rb",
66
+ "spec/ext/object_spec.rb",
67
+ "spec/ext/pathname_spec.rb",
68
+ "spec/ext/range_spec.rb",
69
+ "spec/ext/regexp_spec.rb",
70
+ "spec/ext/string_spec.rb",
71
+ "spec/ext/symbol_spec.rb",
72
+ "spec/ext/time_spec.rb",
73
+ "spec/ext/uri_spec.rb",
74
+ "spec/spec_helper.rb"
75
+ ]
76
+ s.homepage = "http://github.com/twrodriguez/duct_tape"
77
+ s.licenses = ["Simplified BSD"]
78
+ s.require_paths = ["lib"]
79
+ s.required_ruby_version = Gem::Requirement.new(">= 1.8.7")
80
+ s.rubygems_version = "1.8.24"
81
+ s.summary = "A bunch of useful patches for core Ruby classes"
82
+
83
+ if s.respond_to? :specification_version then
84
+ s.specification_version = 3
85
+
86
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
87
+ s.add_runtime_dependency(%q<facets>, [">= 0"])
88
+ s.add_development_dependency(%q<rake>, [">= 0"])
89
+ s.add_development_dependency(%q<yard>, [">= 0"])
90
+ s.add_development_dependency(%q<jeweler>, [">= 0"])
91
+ s.add_development_dependency(%q<rspec>, [">= 0"])
92
+ else
93
+ s.add_dependency(%q<facets>, [">= 0"])
94
+ s.add_dependency(%q<rake>, [">= 0"])
95
+ s.add_dependency(%q<yard>, [">= 0"])
96
+ s.add_dependency(%q<jeweler>, [">= 0"])
97
+ s.add_dependency(%q<rspec>, [">= 0"])
98
+ end
99
+ else
100
+ s.add_dependency(%q<facets>, [">= 0"])
101
+ s.add_dependency(%q<rake>, [">= 0"])
102
+ s.add_dependency(%q<yard>, [">= 0"])
103
+ s.add_dependency(%q<jeweler>, [">= 0"])
104
+ s.add_dependency(%q<rspec>, [">= 0"])
105
+ end
106
+ end
data/ext/mkrf_conf.rb ADDED
@@ -0,0 +1,36 @@
1
+ require 'rubygems'
2
+ require 'rubygems/command.rb'
3
+ require 'rubygems/dependency_installer.rb'
4
+ require 'rbconfig'
5
+
6
+ begin
7
+ Gem::Command.build_args = ARGV
8
+ rescue NoMethodError
9
+ end
10
+
11
+ inst = Gem::DependencyInstaller.new
12
+ engine = ::RbConfig::CONFIG['RUBY_INSTALL_NAME']
13
+ if defined?(RUBY_ENGINE)
14
+ engine << " " << RUBY_ENGINE
15
+ end
16
+ # JRuby can have issues compiling algorithms' extensions
17
+ # Maglev, IronRuby, and MacRuby are untested
18
+ if engine !~ /jruby|maglev|ir|macruby/i
19
+ begin
20
+ require 'algorithms'
21
+ rescue LoadError
22
+ puts "No JRuby, Maglev, IronRuby, or MacRuby detected, installing 'algorithms'..."
23
+ inst.install "algorithms"
24
+ end
25
+ end
26
+
27
+ if RUBY_VERSION >= "1.9"
28
+ #inst.install "simplecov"
29
+ else
30
+ #inst.install "rcov"
31
+ end
32
+
33
+ # create dummy rakefile to indicate success
34
+ f = File.open(File.join(File.dirname(__FILE__), "Rakefile"), "w")
35
+ f.write("task :default\n")
36
+ f.close