sugar-high 0.7.1 → 0.7.2

Sign up to get free protection for your applications and to get access to all the features.
data/.rvmrc ADDED
@@ -0,0 +1 @@
1
+ rvm use 1.9.2@sugar-high --create
@@ -1,6 +1,6 @@
1
1
  language: ruby
2
2
  rvm:
3
- - 1.8.7
3
+ - 1.9.2
4
4
  - 1.9.3
5
5
  script: "rake"
6
6
  gemfile:
@@ -16,6 +16,8 @@ h2. Update Aug 21, 2011
16
16
 
17
17
  Extracted *file_mutate* and *sweetloader* gems.
18
18
 
19
+ Only tested for Ruby 1.9.2 and 1.9.3. Using *Travis CI*.
20
+
19
21
  h2. Sugar packs
20
22
 
21
23
  * alias
@@ -38,3 +38,17 @@ class Module
38
38
  end
39
39
  end
40
40
  end
41
+
42
+ # http://blog.jayfields.com/2008/02/ruby-replace-methodmissing-with-dynamic.html
43
+ class DelegateDecorator
44
+ def initialize(subject)
45
+ subject.public_methods(false).each do |meth|
46
+ (class << self; self; end).class_eval do
47
+ define_method meth do |*args|
48
+ subject.send meth, *args
49
+ end
50
+ end
51
+ end
52
+ end
53
+ end
54
+
@@ -1,4 +1,16 @@
1
1
  class Range
2
+ def intersection(other)
3
+ raise ArgumentError, 'value must be a Range' unless other.kind_of?(Range)
4
+
5
+ min, max = first, exclude_end? ? max : last
6
+ other_min, other_max = other.first, other.exclude_end? ? other.max : other.last
7
+
8
+ new_min = self === other_min ? other_min : other === min ? min : nil
9
+ new_max = self === other_max ? other_max : other === max ? max : nil
10
+
11
+ new_min && new_max ? new_min..new_max : nil
12
+ end
13
+
2
14
  def intersect(other)
3
15
  raise ArgumentError, 'value must be a Range' unless other.kind_of?(Range)
4
16
 
@@ -6,7 +18,9 @@ class Range
6
18
  new_max = self.cover?(other.max) ? other.max : other.cover?(max) ? max : nil
7
19
 
8
20
  new_min && new_max ? new_min..new_max : nil
21
+
22
+ rescue # if above doesn't work for ruby version
23
+ intersection(other)
9
24
  end
10
- alias_method :intersection, :intersect
11
- alias_method :&, :intersection
25
+ alias_method :&, :intersect
12
26
  end
@@ -1,3 +1,3 @@
1
1
  module SugarHigh
2
- VERSION = '0.7.1'
2
+ VERSION = '0.7.2'
3
3
  end
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "sugar-high"
8
- s.version = "0.7.1"
8
+ s.version = "0.7.2"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Kristian Mandrup"]
@@ -19,6 +19,7 @@ Gem::Specification.new do |s|
19
19
  s.files = [
20
20
  ".document",
21
21
  ".rspec",
22
+ ".rvmrc",
22
23
  ".travis.yml",
23
24
  "CHANGELOG.md",
24
25
  "Gemfile",
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sugar-high
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.1
4
+ version: 0.7.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -101,6 +101,7 @@ extra_rdoc_files:
101
101
  files:
102
102
  - .document
103
103
  - .rspec
104
+ - .rvmrc
104
105
  - .travis.yml
105
106
  - CHANGELOG.md
106
107
  - Gemfile
@@ -179,7 +180,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
179
180
  version: '0'
180
181
  segments:
181
182
  - 0
182
- hash: -379630514327345161
183
+ hash: -2985088833944067172
183
184
  required_rubygems_version: !ruby/object:Gem::Requirement
184
185
  none: false
185
186
  requirements: