sugar-high 0.7.0 → 0.7.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ language: ruby
2
+ rvm:
3
+ - 1.8.7
4
+ - 1.9.3
5
+ script: "rake"
6
+ gemfile:
7
+ - Gemfile
@@ -2,6 +2,8 @@ h1. Sugar high!
2
2
 
3
3
  Inspired by the 'zucker' project.
4
4
 
5
+ !https://secure.travis-ci.org/kristianmandrup/sugar-high.png(Build Status)!:http://travis-ci.org/kristianmandrup/sugar-high
6
+
5
7
  h2. Install
6
8
 
7
9
  <code>gem install sugar-high</code>
@@ -53,7 +55,7 @@ h3. Arguments
53
55
  h3. Array
54
56
 
55
57
  * pick_one! - pick one random item
56
- * pink (n) - pick n random item
58
+ * pick (n) - pick n random item
57
59
  * to_symbols
58
60
  * to_symbols_uniq
59
61
  * to_strings
data/Rakefile CHANGED
@@ -9,8 +9,12 @@ rescue Bundler::BundlerError => e
9
9
  $stderr.puts "Run `bundle install` to install missing gems"
10
10
  exit e.status_code
11
11
  end
12
+
12
13
  require 'rake'
13
14
 
15
+ $:.unshift File.expand_path('lib', File.dirname(__FILE__))
16
+ require 'sugar-high/version'
17
+
14
18
  require 'jeweler'
15
19
  Jeweler::Tasks.new do |gem|
16
20
  gem.name = "sugar-high"
@@ -20,18 +24,19 @@ Jeweler::Tasks.new do |gem|
20
24
  gem.homepage = "http://github.com/kristianmandrup/sugar-high"
21
25
  gem.email = "kmandrup@gmail.com"
22
26
  gem.authors = ["Kristian Mandrup"]
27
+ gem.version = SugarHigh::VERSION
23
28
  # dependencies defined in Gemfile
24
29
  end
25
30
  Jeweler::RubygemsDotOrgTasks.new
26
31
 
27
- require 'rake/testtask'
28
- Rake::TestTask.new(:test) do |test|
29
- test.libs << 'lib' << 'test'
30
- test.pattern = 'test/**/test_*.rb'
31
- test.verbose = true
32
+
33
+ require 'rspec/core'
34
+ require 'rspec/core/rake_task'
35
+ RSpec::Core::RakeTask.new(:spec) do |spec|
36
+ spec.pattern = FileList['spec/**/*_spec.rb']
32
37
  end
33
38
 
34
- task :default => :test
39
+ task :default => :spec
35
40
 
36
41
  require 'rdoc/task'
37
42
  Rake::RDocTask.new do |rdoc|
@@ -0,0 +1,12 @@
1
+ class Range
2
+ def intersect(other)
3
+ raise ArgumentError, 'value must be a Range' unless other.kind_of?(Range)
4
+
5
+ new_min = self.cover?(other.min) ? other.min : other.cover?(min) ? min : nil
6
+ new_max = self.cover?(other.max) ? other.max : other.cover?(max) ? max : nil
7
+
8
+ new_min && new_max ? new_min..new_max : nil
9
+ end
10
+ alias_method :intersection, :intersect
11
+ alias_method :&, :intersection
12
+ end
@@ -0,0 +1,3 @@
1
+ module SugarHigh
2
+ VERSION = '0.7.1'
3
+ end
@@ -0,0 +1,54 @@
1
+ require 'spec_helper'
2
+ require 'sugar-high/range'
3
+
4
+ describe Range do
5
+ describe '#intersection' do
6
+ context 'inclusive range' do
7
+
8
+ # Test an inclusive range
9
+ subject { 5..10 }
10
+
11
+ let(:tests) do
12
+ {
13
+ 1..4 => nil, # before
14
+ 11..15 => nil, # after
15
+ 1..6 => 5..6, # overlap_begin
16
+ 9..15 => 9..10, # overlap_end
17
+ 1..5 => 5..5, # overlap_begin_edge
18
+ 10..15 => 10..10, # overlap_end_edge
19
+ 5..10 => 5..10, # overlap_all
20
+ 6..9 => 6..9, # overlap_inner
21
+
22
+ 1...5 => nil, # before (exclusive range)
23
+ 1...7 => 5..6, # overlap_begin (exclusive range)
24
+ 1...6 => 5..5, # overlap_begin_edge (exclusive range)
25
+ 5...11 => 5..10, # overlap_all (exclusive range)
26
+ 6...10 => 6..9, # overlap_inner (exclusive range)
27
+ }
28
+ end
29
+
30
+ it 'should intersect correctly' do
31
+ tests.each do |other, expected|
32
+ subject.intersect(other).should == expected
33
+ end
34
+ end
35
+ end
36
+
37
+ context 'exclusive range' do
38
+ # Test an exclusive range
39
+ # This covers a bug found by Montgomery Kosma in the original code
40
+ subject { 1...10 }
41
+
42
+ let(:tests) do
43
+ #overlap_end
44
+ { 5..15 => 5..9}
45
+ end
46
+
47
+ it 'should intersect correctly' do
48
+ tests.each do |other, expected|
49
+ subject.intersect(other).should == expected
50
+ end
51
+ end
52
+ end
53
+ end
54
+ end
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "sugar-high"
8
- s.version = "0.7.0"
8
+ s.version = "0.7.1"
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"]
12
- s.date = "2012-06-28"
12
+ s.date = "2012-09-25"
13
13
  s.description = "More Ruby sugar - inspired by the 'zuker' project"
14
14
  s.email = "kmandrup@gmail.com"
15
15
  s.extra_rdoc_files = [
@@ -19,12 +19,12 @@ Gem::Specification.new do |s|
19
19
  s.files = [
20
20
  ".document",
21
21
  ".rspec",
22
+ ".travis.yml",
22
23
  "CHANGELOG.md",
23
24
  "Gemfile",
24
25
  "LICENSE",
25
26
  "README.textile",
26
27
  "Rakefile",
27
- "VERSION",
28
28
  "lib/sugar-high.rb",
29
29
  "lib/sugar-high/alias.rb",
30
30
  "lib/sugar-high/arguments.rb",
@@ -49,10 +49,12 @@ Gem::Specification.new do |s|
49
49
  "lib/sugar-high/path.rb",
50
50
  "lib/sugar-high/properties.rb",
51
51
  "lib/sugar-high/rails/concerns.rb",
52
+ "lib/sugar-high/range.rb",
52
53
  "lib/sugar-high/regexp.rb",
53
54
  "lib/sugar-high/rspec/configure.rb",
54
55
  "lib/sugar-high/rspec/matchers/have_aliases.rb",
55
56
  "lib/sugar-high/string.rb",
57
+ "lib/sugar-high/version.rb",
56
58
  "spec/fixtures/empty.txt",
57
59
  "spec/fixtures/non-empty.txt",
58
60
  "spec/fixtures/search_file.txt",
@@ -77,6 +79,7 @@ Gem::Specification.new do |s|
77
79
  "spec/sugar-high/rails/fixture_user/validations.rb",
78
80
  "spec/sugar-high/rails/shared/associations.rb",
79
81
  "spec/sugar-high/rails/shared/caching.rb",
82
+ "spec/sugar-high/range_spec.rb",
80
83
  "spec/sugar-high/regexp_spec.rb",
81
84
  "spec/sugar-high/string_spec.rb",
82
85
  "sugar-high.gemspec"
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.0
4
+ version: 0.7.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-06-28 00:00:00.000000000 Z
12
+ date: 2012-09-25 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rspec
@@ -101,12 +101,12 @@ extra_rdoc_files:
101
101
  files:
102
102
  - .document
103
103
  - .rspec
104
+ - .travis.yml
104
105
  - CHANGELOG.md
105
106
  - Gemfile
106
107
  - LICENSE
107
108
  - README.textile
108
109
  - Rakefile
109
- - VERSION
110
110
  - lib/sugar-high.rb
111
111
  - lib/sugar-high/alias.rb
112
112
  - lib/sugar-high/arguments.rb
@@ -131,10 +131,12 @@ files:
131
131
  - lib/sugar-high/path.rb
132
132
  - lib/sugar-high/properties.rb
133
133
  - lib/sugar-high/rails/concerns.rb
134
+ - lib/sugar-high/range.rb
134
135
  - lib/sugar-high/regexp.rb
135
136
  - lib/sugar-high/rspec/configure.rb
136
137
  - lib/sugar-high/rspec/matchers/have_aliases.rb
137
138
  - lib/sugar-high/string.rb
139
+ - lib/sugar-high/version.rb
138
140
  - spec/fixtures/empty.txt
139
141
  - spec/fixtures/non-empty.txt
140
142
  - spec/fixtures/search_file.txt
@@ -159,6 +161,7 @@ files:
159
161
  - spec/sugar-high/rails/fixture_user/validations.rb
160
162
  - spec/sugar-high/rails/shared/associations.rb
161
163
  - spec/sugar-high/rails/shared/caching.rb
164
+ - spec/sugar-high/range_spec.rb
162
165
  - spec/sugar-high/regexp_spec.rb
163
166
  - spec/sugar-high/string_spec.rb
164
167
  - sugar-high.gemspec
@@ -176,7 +179,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
176
179
  version: '0'
177
180
  segments:
178
181
  - 0
179
- hash: 2519562301567009285
182
+ hash: -379630514327345161
180
183
  required_rubygems_version: !ruby/object:Gem::Requirement
181
184
  none: false
182
185
  requirements:
data/VERSION DELETED
@@ -1 +0,0 @@
1
- 0.7.0