magician 0.2.1 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.travis.yml +6 -8
- data/CHANGELOG.md +33 -5
- data/Gemfile +7 -7
- data/LICENSE.txt +1 -1
- data/README.md +15 -9
- data/VERSION +1 -1
- data/lib/magician/array.rb +133 -92
- data/lib/magician/integer.rb +44 -50
- data/lib/magician/math.rb +167 -116
- data/lib/magician/numeric.rb +38 -26
- data/lib/magician/random.rb +31 -0
- data/lib/magician/shortcuts.rb +5 -2
- data/lib/magician/string.rb +7 -7
- data/magician.gemspec +20 -18
- data/spec/array_spec.rb +87 -70
- data/spec/integer_spec.rb +44 -30
- data/spec/math_spec.rb +90 -72
- data/spec/numeric_spec.rb +36 -18
- data/spec/random_spec.rb +21 -0
- data/spec/shortcuts_spec.rb +7 -5
- data/spec/spec_helper.rb +2 -0
- data/spec/string_spec.rb +10 -9
- metadata +20 -18
data/spec/random_spec.rb
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
require "#{File.dirname __FILE__}/spec_helper"
|
2
|
+
|
3
|
+
describe Random do
|
4
|
+
|
5
|
+
before :each do
|
6
|
+
@r = Random.new
|
7
|
+
end
|
8
|
+
|
9
|
+
it 'should get a random boolean' do
|
10
|
+
5.times { [true, false].should include @r.boolean }
|
11
|
+
end
|
12
|
+
|
13
|
+
it 'should get a random coin toss' do
|
14
|
+
5.times { ['heads', 'tails'].should include @r.coin }
|
15
|
+
end
|
16
|
+
|
17
|
+
it 'should get a random die roll' do
|
18
|
+
5.times { (1..6).should include @r.die }
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
data/spec/shortcuts_spec.rb
CHANGED
@@ -1,10 +1,12 @@
|
|
1
|
-
require File.
|
1
|
+
require "#{File.dirname __FILE__}/spec_helper"
|
2
2
|
|
3
3
|
describe 'Shortcuts' do
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
5
|
+
it 'should properly alias certain values from Math' do
|
6
|
+
PI.should == Math::PI
|
7
|
+
E.should == Math::E
|
8
|
+
I.should == Complex::I
|
9
|
+
GOLDEN_RATIO.should == (1 + Math.sqrt(5))/2
|
10
|
+
end
|
9
11
|
|
10
12
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -2,6 +2,7 @@
|
|
2
2
|
require 'simplecov'
|
3
3
|
SimpleCov.start { add_filter '/spec/' }
|
4
4
|
|
5
|
+
# Set up the load path and RSpec
|
5
6
|
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
6
7
|
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
7
8
|
require 'rspec'
|
@@ -11,6 +12,7 @@ require 'magician'
|
|
11
12
|
# in ./support/ and its subdirectories.
|
12
13
|
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
|
13
14
|
|
15
|
+
# RSpec configuration
|
14
16
|
RSpec.configure do |config|
|
15
17
|
|
16
18
|
end
|
data/spec/string_spec.rb
CHANGED
@@ -1,14 +1,15 @@
|
|
1
|
-
require File.
|
1
|
+
require "#{File.dirname __FILE__}/spec_helper"
|
2
2
|
|
3
3
|
describe String do
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
5
|
+
it 'should determine if it is a palindrome' do
|
6
|
+
''.palindrome?.should be_true
|
7
|
+
'a'.palindrome?.should be_true
|
8
|
+
'deed'.palindrome?.should be_true
|
9
|
+
'racecar'.palindrome?.should be_true
|
10
|
+
|
11
|
+
'cats'.palindrome?.should be_false
|
12
|
+
'no'.palindrome?.should be_false
|
13
|
+
end
|
13
14
|
|
14
15
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: magician
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
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:
|
12
|
+
date: 2013-03-18 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rspec
|
@@ -18,7 +18,7 @@ dependencies:
|
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
20
20
|
- !ruby/object:Gem::Version
|
21
|
-
version: 2.
|
21
|
+
version: '2.13'
|
22
22
|
type: :development
|
23
23
|
prerelease: false
|
24
24
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -26,7 +26,7 @@ dependencies:
|
|
26
26
|
requirements:
|
27
27
|
- - ~>
|
28
28
|
- !ruby/object:Gem::Version
|
29
|
-
version: 2.
|
29
|
+
version: '2.13'
|
30
30
|
- !ruby/object:Gem::Dependency
|
31
31
|
name: yard
|
32
32
|
requirement: !ruby/object:Gem::Requirement
|
@@ -50,7 +50,7 @@ dependencies:
|
|
50
50
|
requirements:
|
51
51
|
- - ~>
|
52
52
|
- !ruby/object:Gem::Version
|
53
|
-
version: '
|
53
|
+
version: '4.0'
|
54
54
|
type: :development
|
55
55
|
prerelease: false
|
56
56
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -58,23 +58,23 @@ dependencies:
|
|
58
58
|
requirements:
|
59
59
|
- - ~>
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: '
|
61
|
+
version: '4.0'
|
62
62
|
- !ruby/object:Gem::Dependency
|
63
63
|
name: bundler
|
64
64
|
requirement: !ruby/object:Gem::Requirement
|
65
65
|
none: false
|
66
66
|
requirements:
|
67
|
-
- -
|
67
|
+
- - ~>
|
68
68
|
- !ruby/object:Gem::Version
|
69
|
-
version: '
|
69
|
+
version: '1.2'
|
70
70
|
type: :development
|
71
71
|
prerelease: false
|
72
72
|
version_requirements: !ruby/object:Gem::Requirement
|
73
73
|
none: false
|
74
74
|
requirements:
|
75
|
-
- -
|
75
|
+
- - ~>
|
76
76
|
- !ruby/object:Gem::Version
|
77
|
-
version: '
|
77
|
+
version: '1.2'
|
78
78
|
- !ruby/object:Gem::Dependency
|
79
79
|
name: jeweler
|
80
80
|
requirement: !ruby/object:Gem::Requirement
|
@@ -82,7 +82,7 @@ dependencies:
|
|
82
82
|
requirements:
|
83
83
|
- - ~>
|
84
84
|
- !ruby/object:Gem::Version
|
85
|
-
version: 1.8
|
85
|
+
version: '1.8'
|
86
86
|
type: :development
|
87
87
|
prerelease: false
|
88
88
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -90,23 +90,23 @@ dependencies:
|
|
90
90
|
requirements:
|
91
91
|
- - ~>
|
92
92
|
- !ruby/object:Gem::Version
|
93
|
-
version: 1.8
|
93
|
+
version: '1.8'
|
94
94
|
- !ruby/object:Gem::Dependency
|
95
95
|
name: simplecov
|
96
96
|
requirement: !ruby/object:Gem::Requirement
|
97
97
|
none: false
|
98
98
|
requirements:
|
99
|
-
- -
|
99
|
+
- - ~>
|
100
100
|
- !ruby/object:Gem::Version
|
101
|
-
version: '0'
|
101
|
+
version: '0.7'
|
102
102
|
type: :development
|
103
103
|
prerelease: false
|
104
104
|
version_requirements: !ruby/object:Gem::Requirement
|
105
105
|
none: false
|
106
106
|
requirements:
|
107
|
-
- -
|
107
|
+
- - ~>
|
108
108
|
- !ruby/object:Gem::Version
|
109
|
-
version: '0'
|
109
|
+
version: '0.7'
|
110
110
|
description: A suite of handy methods for doing calculations in irb.
|
111
111
|
email: thenickperson@gmail.com
|
112
112
|
executables: []
|
@@ -129,6 +129,7 @@ files:
|
|
129
129
|
- lib/magician/integer.rb
|
130
130
|
- lib/magician/math.rb
|
131
131
|
- lib/magician/numeric.rb
|
132
|
+
- lib/magician/random.rb
|
132
133
|
- lib/magician/shortcuts.rb
|
133
134
|
- lib/magician/string.rb
|
134
135
|
- magician.gemspec
|
@@ -136,6 +137,7 @@ files:
|
|
136
137
|
- spec/integer_spec.rb
|
137
138
|
- spec/math_spec.rb
|
138
139
|
- spec/numeric_spec.rb
|
140
|
+
- spec/random_spec.rb
|
139
141
|
- spec/shortcuts_spec.rb
|
140
142
|
- spec/spec_helper.rb
|
141
143
|
- spec/string_spec.rb
|
@@ -154,7 +156,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
154
156
|
version: '0'
|
155
157
|
segments:
|
156
158
|
- 0
|
157
|
-
hash: -
|
159
|
+
hash: -48719407583839754
|
158
160
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
159
161
|
none: false
|
160
162
|
requirements:
|
@@ -163,7 +165,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
163
165
|
version: '0'
|
164
166
|
requirements: []
|
165
167
|
rubyforge_project:
|
166
|
-
rubygems_version: 1.8.
|
168
|
+
rubygems_version: 1.8.23
|
167
169
|
signing_key:
|
168
170
|
specification_version: 3
|
169
171
|
summary: A suite of handy methods for doing calculations in irb.
|