sugar-high 0.7.1 → 0.7.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/.rvmrc +1 -0
- data/.travis.yml +1 -1
- data/README.textile +2 -0
- data/lib/sugar-high/delegate.rb +14 -0
- data/lib/sugar-high/range.rb +16 -2
- data/lib/sugar-high/version.rb +1 -1
- data/sugar-high.gemspec +2 -1
- metadata +3 -2
data/.rvmrc
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
rvm use 1.9.2@sugar-high --create
|
data/.travis.yml
CHANGED
data/README.textile
CHANGED
data/lib/sugar-high/delegate.rb
CHANGED
|
@@ -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
|
+
|
data/lib/sugar-high/range.rb
CHANGED
|
@@ -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
|
|
11
|
-
alias_method :&, :intersection
|
|
25
|
+
alias_method :&, :intersect
|
|
12
26
|
end
|
data/lib/sugar-high/version.rb
CHANGED
data/sugar-high.gemspec
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
|
|
6
6
|
Gem::Specification.new do |s|
|
|
7
7
|
s.name = "sugar-high"
|
|
8
|
-
s.version = "0.7.
|
|
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.
|
|
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: -
|
|
183
|
+
hash: -2985088833944067172
|
|
183
184
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
184
185
|
none: false
|
|
185
186
|
requirements:
|