functional-ruby 0.7.7 → 1.0.0
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.
- checksums.yaml +4 -4
- data/README.md +92 -152
- data/doc/memo.txt +192 -0
- data/doc/pattern_matching.txt +485 -0
- data/doc/protocol.txt +221 -0
- data/doc/record.txt +144 -0
- data/doc/thread_safety.txt +8 -0
- data/lib/functional.rb +48 -18
- data/lib/functional/abstract_struct.rb +161 -0
- data/lib/functional/delay.rb +117 -0
- data/lib/functional/either.rb +222 -0
- data/lib/functional/memo.rb +93 -0
- data/lib/functional/method_signature.rb +72 -0
- data/lib/functional/option.rb +209 -0
- data/lib/functional/pattern_matching.rb +117 -100
- data/lib/functional/protocol.rb +157 -0
- data/lib/functional/protocol_info.rb +193 -0
- data/lib/functional/record.rb +155 -0
- data/lib/functional/type_check.rb +112 -0
- data/lib/functional/union.rb +152 -0
- data/lib/functional/version.rb +3 -1
- data/spec/functional/abstract_struct_shared.rb +154 -0
- data/spec/functional/complex_pattern_matching_spec.rb +205 -0
- data/spec/functional/configuration_spec.rb +17 -0
- data/spec/functional/delay_spec.rb +147 -0
- data/spec/functional/either_spec.rb +237 -0
- data/spec/functional/memo_spec.rb +207 -0
- data/spec/functional/option_spec.rb +292 -0
- data/spec/functional/pattern_matching_spec.rb +279 -276
- data/spec/functional/protocol_info_spec.rb +444 -0
- data/spec/functional/protocol_spec.rb +274 -0
- data/spec/functional/record_spec.rb +175 -0
- data/spec/functional/type_check_spec.rb +103 -0
- data/spec/functional/union_spec.rb +110 -0
- data/spec/spec_helper.rb +6 -4
- metadata +55 -45
- data/lib/functional/behavior.rb +0 -138
- data/lib/functional/behaviour.rb +0 -2
- data/lib/functional/catalog.rb +0 -487
- data/lib/functional/collection.rb +0 -403
- data/lib/functional/inflect.rb +0 -127
- data/lib/functional/platform.rb +0 -120
- data/lib/functional/search.rb +0 -132
- data/lib/functional/sort.rb +0 -41
- data/lib/functional/utilities.rb +0 -189
- data/md/behavior.md +0 -188
- data/md/catalog.md +0 -32
- data/md/collection.md +0 -32
- data/md/inflect.md +0 -32
- data/md/pattern_matching.md +0 -512
- data/md/platform.md +0 -32
- data/md/search.md +0 -32
- data/md/sort.md +0 -32
- data/md/utilities.md +0 -55
- data/spec/functional/behavior_spec.rb +0 -528
- data/spec/functional/catalog_spec.rb +0 -1206
- data/spec/functional/collection_spec.rb +0 -752
- data/spec/functional/inflect_spec.rb +0 -85
- data/spec/functional/integration_spec.rb +0 -205
- data/spec/functional/platform_spec.rb +0 -501
- data/spec/functional/search_spec.rb +0 -187
- data/spec/functional/sort_spec.rb +0 -61
- data/spec/functional/utilities_spec.rb +0 -277
@@ -1,85 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
module Functional
|
4
|
-
|
5
|
-
describe Inflect do
|
6
|
-
|
7
|
-
context '#camelize' do
|
8
|
-
|
9
|
-
specify { Inflect.camelize('active_model').should eq 'ActiveModel' }
|
10
|
-
specify { Inflect.camelize('active_model', :lower).should eq 'activeModel' }
|
11
|
-
specify { Inflect.camelize(:active_model).should eq 'ActiveModel' }
|
12
|
-
specify { Inflect.camelize(:active_model, :lower).should eq 'activeModel' }
|
13
|
-
|
14
|
-
specify { Inflect.camelize('active_model/errors').should eq 'ActiveModel::Errors' }
|
15
|
-
specify { Inflect.camelize('active_model/errors', :lower).should eq 'activeModel::Errors' }
|
16
|
-
specify { Inflect.camelize(:'active_model/errors').should eq 'ActiveModel::Errors' }
|
17
|
-
specify { Inflect.camelize(:'active_model/errors', :lower).should eq 'activeModel::Errors' }
|
18
|
-
end
|
19
|
-
|
20
|
-
context '#underscore' do
|
21
|
-
|
22
|
-
specify { Inflect.underscore('ActiveModel').should eq 'active_model' }
|
23
|
-
specify { Inflect.underscore(:'ActiveModel').should eq 'active_model' }
|
24
|
-
|
25
|
-
specify { Inflect.underscore('ActiveModel::Errors').should eq 'active_model/errors' }
|
26
|
-
specify { Inflect.underscore(:'ActiveModel::Errors').should eq 'active_model/errors' }
|
27
|
-
end
|
28
|
-
|
29
|
-
context '#humanize' do
|
30
|
-
|
31
|
-
specify { Inflect.humanize('employee_salary').should eq 'Employee salary' }
|
32
|
-
specify { Inflect.humanize('author_id').should eq 'Author' }
|
33
|
-
|
34
|
-
specify { Inflect.humanize(:employee_salary).should eq 'Employee salary' }
|
35
|
-
specify { Inflect.humanize(:author_id).should eq 'Author' }
|
36
|
-
end
|
37
|
-
|
38
|
-
context '#titleize' do
|
39
|
-
|
40
|
-
specify { Inflect.titleize('man from the boondocks').should eq 'Man From The Boondocks' }
|
41
|
-
specify { Inflect.titleize('x-men: the last stand').should eq 'X Men: The Last Stand' }
|
42
|
-
specify { Inflect.titleize('TheManWithoutAPast').should eq 'The Man Without A Past' }
|
43
|
-
specify { Inflect.titleize('raiders_of_the_lost_ark').should eq 'Raiders Of The Lost Ark' }
|
44
|
-
|
45
|
-
specify { Inflect.titleize(:'man from the boondocks').should eq 'Man From The Boondocks' }
|
46
|
-
specify { Inflect.titleize(:'x-men: the last stand').should eq 'X Men: The Last Stand' }
|
47
|
-
specify { Inflect.titleize(:'TheManWithoutAPast').should eq 'The Man Without A Past' }
|
48
|
-
specify { Inflect.titleize(:'raiders_of_the_lost_ark').should eq 'Raiders Of The Lost Ark' }
|
49
|
-
end
|
50
|
-
|
51
|
-
context '#dasherize' do
|
52
|
-
|
53
|
-
specify { Inflect.dasherize('puni_puni').should eq 'puni-puni' }
|
54
|
-
specify { Inflect.dasherize(:'puni_puni').should eq 'puni-puni' }
|
55
|
-
end
|
56
|
-
|
57
|
-
context '#extensionize' do
|
58
|
-
|
59
|
-
specify { Inflect.extensionize('my_file.png', :png).should eq 'my_file.png' }
|
60
|
-
specify { Inflect.extensionize('my_file.png', 'png').should eq 'my_file.png' }
|
61
|
-
specify { Inflect.extensionize('my_file.png', '.png').should eq 'my_file.png' }
|
62
|
-
specify { Inflect.extensionize('MY_FILE.PNG', '.png').should eq 'MY_FILE.PNG' }
|
63
|
-
|
64
|
-
specify { Inflect.extensionize('my_file.png', :jpg).should eq 'my_file.png.jpg' }
|
65
|
-
specify { Inflect.extensionize('my_file.png', 'jpg').should eq 'my_file.png.jpg' }
|
66
|
-
specify { Inflect.extensionize('my_file.png', '.jpg').should eq 'my_file.png.jpg' }
|
67
|
-
|
68
|
-
specify { Inflect.extensionize('my_file.png', :jpg, :chomp => true).should eq 'my_file.jpg' }
|
69
|
-
specify { Inflect.extensionize('my_file.png', 'jpg', :chomp => true).should eq 'my_file.jpg' }
|
70
|
-
specify { Inflect.extensionize('my_file.png', '.jpg', :chomp => true).should eq 'my_file.jpg' }
|
71
|
-
|
72
|
-
specify { Inflect.extensionize('my_file', :png).should eq 'my_file.png' }
|
73
|
-
specify { Inflect.extensionize('my_file', 'png').should eq 'my_file.png' }
|
74
|
-
specify { Inflect.extensionize('my_file', '.png').should eq 'my_file.png' }
|
75
|
-
|
76
|
-
specify { Inflect.extensionize('My File', :png).should eq 'My File.png' }
|
77
|
-
specify { Inflect.extensionize('My File', 'png').should eq 'My File.png' }
|
78
|
-
specify { Inflect.extensionize('My File', '.png').should eq 'My File.png' }
|
79
|
-
|
80
|
-
specify { Inflect.extensionize('My File ', :png).should eq 'My File.png' }
|
81
|
-
specify { Inflect.extensionize('My File ', 'png').should eq 'My File.png' }
|
82
|
-
specify { Inflect.extensionize('My File ', '.png').should eq 'My File.png' }
|
83
|
-
end
|
84
|
-
end
|
85
|
-
end
|
@@ -1,205 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'ostruct'
|
3
|
-
|
4
|
-
class Bar
|
5
|
-
def greet
|
6
|
-
return 'Hello, World!'
|
7
|
-
end
|
8
|
-
end
|
9
|
-
|
10
|
-
class Foo < Bar
|
11
|
-
include PatternMatching
|
12
|
-
|
13
|
-
attr_accessor :name
|
14
|
-
|
15
|
-
defn(:initialize) { @name = 'baz' }
|
16
|
-
defn(:initialize, _) {|name| @name = name.to_s }
|
17
|
-
|
18
|
-
defn(:greet, _) do |name|
|
19
|
-
"Hello, #{name}!"
|
20
|
-
end
|
21
|
-
|
22
|
-
defn(:greet, :male, _) { |name|
|
23
|
-
"Hello, Mr. #{name}!"
|
24
|
-
}
|
25
|
-
defn(:greet, :female, _) { |name|
|
26
|
-
"Hello, Ms. #{name}!"
|
27
|
-
}
|
28
|
-
defn(:greet, nil, _) { |name|
|
29
|
-
"Goodbye, #{name}!"
|
30
|
-
}
|
31
|
-
defn(:greet, _, _) { |_, name|
|
32
|
-
"Hello, #{name}!"
|
33
|
-
}
|
34
|
-
|
35
|
-
defn(:hashable, _, {foo: :bar}, _) { |_, opts, _|
|
36
|
-
:foo_bar
|
37
|
-
}
|
38
|
-
defn(:hashable, _, {foo: _, bar: _}, _) { |_, f, b, _|
|
39
|
-
[f, b]
|
40
|
-
}
|
41
|
-
defn(:hashable, _, {foo: _}, _) { |_, f, _|
|
42
|
-
f
|
43
|
-
}
|
44
|
-
defn(:hashable, _, {}, _) {
|
45
|
-
:empty
|
46
|
-
}
|
47
|
-
defn(:hashable, _, _, _) { |_, _, _|
|
48
|
-
:unbound
|
49
|
-
}
|
50
|
-
|
51
|
-
defn(:options, _) { |opts|
|
52
|
-
opts
|
53
|
-
}
|
54
|
-
|
55
|
-
defn(:recurse) {
|
56
|
-
'w00t!'
|
57
|
-
}
|
58
|
-
defn(:recurse, :match) {
|
59
|
-
recurse()
|
60
|
-
}
|
61
|
-
defn(:recurse, :super) {
|
62
|
-
greet()
|
63
|
-
}
|
64
|
-
defn(:recurse, :instance) {
|
65
|
-
@name
|
66
|
-
}
|
67
|
-
defn(:recurse, _) { |arg|
|
68
|
-
arg
|
69
|
-
}
|
70
|
-
|
71
|
-
defn(:concat, Integer, Integer) { |first, second|
|
72
|
-
first + second
|
73
|
-
}
|
74
|
-
defn(:concat, Integer, String) { |first, second|
|
75
|
-
"#{first} #{second}"
|
76
|
-
}
|
77
|
-
defn(:concat, String, String) { |first, second|
|
78
|
-
first + second
|
79
|
-
}
|
80
|
-
defn(:concat, Integer, UNBOUND) { |first, second|
|
81
|
-
first + second.to_i
|
82
|
-
}
|
83
|
-
|
84
|
-
defn(:all, :one, ALL) { |args|
|
85
|
-
args
|
86
|
-
}
|
87
|
-
defn(:all, :one, Integer, ALL) { |int, args|
|
88
|
-
[int, args]
|
89
|
-
}
|
90
|
-
defn(:all, 1, _, ALL) { |var, args|
|
91
|
-
[var, args]
|
92
|
-
}
|
93
|
-
defn(:all, ALL) { | args|
|
94
|
-
args
|
95
|
-
}
|
96
|
-
|
97
|
-
defn(:old_enough, _){ true }.when{|x| x >= 16 }
|
98
|
-
defn(:old_enough, _){ false }
|
99
|
-
|
100
|
-
defn(:right_age, _) {
|
101
|
-
true
|
102
|
-
}.when{|x| x >= 16 && x <= 104 }
|
103
|
-
|
104
|
-
defn(:right_age, _) {
|
105
|
-
false
|
106
|
-
}
|
107
|
-
|
108
|
-
defn(:wrong_age, _) {
|
109
|
-
true
|
110
|
-
}.when{|x| x < 16 || x > 104 }
|
111
|
-
|
112
|
-
defn(:wrong_age, _) {
|
113
|
-
false
|
114
|
-
}
|
115
|
-
end
|
116
|
-
|
117
|
-
class Baz < Foo
|
118
|
-
def boom_boom_room
|
119
|
-
'zoom zoom zoom'
|
120
|
-
end
|
121
|
-
def who(first, last)
|
122
|
-
[first, last].join(' ')
|
123
|
-
end
|
124
|
-
end
|
125
|
-
|
126
|
-
class Fizzbuzz < Baz
|
127
|
-
include PatternMatching
|
128
|
-
defn(:who, Integer) { |count|
|
129
|
-
(1..count).each.reduce(:+)
|
130
|
-
}
|
131
|
-
defn(:who) { 0 }
|
132
|
-
end
|
133
|
-
|
134
|
-
describe 'integration' do
|
135
|
-
|
136
|
-
let(:name) { 'Pattern Matcher' }
|
137
|
-
subject { Foo.new(name) }
|
138
|
-
|
139
|
-
specify { subject.greet.should eq 'Hello, World!' }
|
140
|
-
|
141
|
-
specify { subject.greet('Jerry').should eq 'Hello, Jerry!' }
|
142
|
-
|
143
|
-
specify { subject.greet(:male, 'Jerry').should eq 'Hello, Mr. Jerry!' }
|
144
|
-
specify { subject.greet(:female, 'Jeri').should eq 'Hello, Ms. Jeri!' }
|
145
|
-
specify { subject.greet(:unknown, 'Jerry').should eq 'Hello, Jerry!' }
|
146
|
-
specify { subject.greet(nil, 'Jerry').should eq 'Goodbye, Jerry!' }
|
147
|
-
specify {
|
148
|
-
lambda { Foo.new.greet(1,2,3,4,5,6,7) }.should raise_error(NoMethodError)
|
149
|
-
}
|
150
|
-
|
151
|
-
specify { subject.options(bar: :baz, one: 1, many: 2).should == {bar: :baz, one: 1, many: 2} }
|
152
|
-
|
153
|
-
specify { subject.hashable(:male, {foo: :bar}, :female).should eq :foo_bar }
|
154
|
-
specify { subject.hashable(:male, {foo: :baz}, :female).should eq :baz }
|
155
|
-
specify { subject.hashable(:male, {foo: 1, bar: 2}, :female).should eq [1, 2] }
|
156
|
-
specify { subject.hashable(:male, {foo: 1, baz: 2}, :female).should eq 1 }
|
157
|
-
specify { subject.hashable(:male, {bar: :baz}, :female).should eq :unbound }
|
158
|
-
specify { subject.hashable(:male, {}, :female).should eq :empty }
|
159
|
-
|
160
|
-
specify { subject.recurse.should eq 'w00t!' }
|
161
|
-
specify { subject.recurse(:match).should eq 'w00t!' }
|
162
|
-
specify { subject.recurse(:super).should eq 'Hello, World!' }
|
163
|
-
specify { subject.recurse(:instance).should eq name }
|
164
|
-
specify { subject.recurse(:foo).should eq :foo }
|
165
|
-
|
166
|
-
specify { subject.concat(1, 1).should eq 2 }
|
167
|
-
specify { subject.concat(1, 'shoe').should eq '1 shoe' }
|
168
|
-
specify { subject.concat('shoe', 'fly').should eq 'shoefly' }
|
169
|
-
specify { subject.concat(1, 2.9).should eq 3 }
|
170
|
-
|
171
|
-
specify { subject.all(:one, 'a', 'bee', :see).should == ['a', 'bee', :see] }
|
172
|
-
specify { subject.all(:one, 1, 'bee', :see).should == [1, 'bee', :see] }
|
173
|
-
specify { subject.all(1, 'a', 'bee', :see).should == ['a', ['bee', :see]] }
|
174
|
-
specify { subject.all('a', 'bee', :see).should == ['a', 'bee', :see] }
|
175
|
-
specify { lambda { subject.all }.should raise_error(NoMethodError) }
|
176
|
-
|
177
|
-
specify { subject.old_enough(20).should be_true }
|
178
|
-
specify { subject.old_enough(10).should be_false }
|
179
|
-
|
180
|
-
specify { subject.right_age(20).should be_true }
|
181
|
-
specify { subject.right_age(10).should be_false }
|
182
|
-
specify { subject.right_age(110).should be_false }
|
183
|
-
|
184
|
-
specify { subject.wrong_age(20).should be_false }
|
185
|
-
specify { subject.wrong_age(10).should be_true }
|
186
|
-
specify { subject.wrong_age(110).should be_true }
|
187
|
-
|
188
|
-
context 'inheritance' do
|
189
|
-
|
190
|
-
specify { Fizzbuzz.new.greet(:male, 'Jerry').should eq 'Hello, Mr. Jerry!' }
|
191
|
-
specify { Fizzbuzz.new.greet(:female, 'Jeri').should eq 'Hello, Ms. Jeri!' }
|
192
|
-
specify { Fizzbuzz.new.greet(:unknown, 'Jerry').should eq 'Hello, Jerry!' }
|
193
|
-
specify { Fizzbuzz.new.greet(nil, 'Jerry').should eq 'Goodbye, Jerry!' }
|
194
|
-
|
195
|
-
specify { Fizzbuzz.new.who(5).should eq 15 }
|
196
|
-
specify { Fizzbuzz.new.who().should eq 0 }
|
197
|
-
specify {
|
198
|
-
lambda {
|
199
|
-
Fizzbuzz.new.who('Jerry', 'secret middle name', "D'Antonio")
|
200
|
-
}.should raise_error(NoMethodError)
|
201
|
-
}
|
202
|
-
|
203
|
-
specify { Fizzbuzz.new.boom_boom_room.should eq 'zoom zoom zoom' }
|
204
|
-
end
|
205
|
-
end
|
@@ -1,501 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
module Functional
|
4
|
-
|
5
|
-
describe Platform do
|
6
|
-
|
7
|
-
# ruby-2.0.0
|
8
|
-
let(:mri_200) do
|
9
|
-
{
|
10
|
-
:MAJOR => '2',
|
11
|
-
:MINOR => '0',
|
12
|
-
:TEENY => '0',
|
13
|
-
:PATCHLEVEL => '195',
|
14
|
-
:ruby_install_name => 'ruby',
|
15
|
-
:ruby_version => '2.0.0',
|
16
|
-
:host_os => 'linux-gnu'
|
17
|
-
}
|
18
|
-
end
|
19
|
-
|
20
|
-
# ruby-1.9.3 windows
|
21
|
-
let(:mri_193_win) do
|
22
|
-
{
|
23
|
-
:MAJOR => '1',
|
24
|
-
:MINOR => '9',
|
25
|
-
:TEENY => '1',
|
26
|
-
:PATCHLEVEL => '448',
|
27
|
-
:ruby_install_name => 'ruby',
|
28
|
-
:ruby_version => '1.9.1',
|
29
|
-
:host_os => 'mingw32'
|
30
|
-
}
|
31
|
-
end
|
32
|
-
|
33
|
-
# ruby-1.9.3 linux
|
34
|
-
let(:mri_193) do
|
35
|
-
{
|
36
|
-
:MAJOR => '1',
|
37
|
-
:MINOR => '9',
|
38
|
-
:TEENY => '1',
|
39
|
-
:PATCHLEVEL => '327',
|
40
|
-
:ruby_install_name => 'ruby',
|
41
|
-
:ruby_version => '1.9.1',
|
42
|
-
:host_os => 'linux-gnu'
|
43
|
-
}
|
44
|
-
end
|
45
|
-
|
46
|
-
# ruby-1.9.2
|
47
|
-
let(:mri_192) do
|
48
|
-
{
|
49
|
-
:MAJOR => '1',
|
50
|
-
:MINOR => '9',
|
51
|
-
:TEENY => '1',
|
52
|
-
:PATCHLEVEL => '320',
|
53
|
-
:ruby_install_name => 'ruby',
|
54
|
-
:ruby_version => '1.9.1',
|
55
|
-
:host_os => 'linux-gnu'
|
56
|
-
}
|
57
|
-
end
|
58
|
-
|
59
|
-
# ruby-1.8.7
|
60
|
-
let(:mri_187) do
|
61
|
-
{
|
62
|
-
:MAJOR => '1',
|
63
|
-
:ruby_version => '1.8',
|
64
|
-
:PATCHLEVEL => '371',
|
65
|
-
:MINOR => '8',
|
66
|
-
:host_os => 'linux-gnu',
|
67
|
-
:TEENY => '7',
|
68
|
-
:ruby_install_name => 'ruby'
|
69
|
-
}
|
70
|
-
end
|
71
|
-
|
72
|
-
# ruby-1.8.6
|
73
|
-
let(:mri_186) do
|
74
|
-
{
|
75
|
-
:MAJOR => '1',
|
76
|
-
:ruby_version => '1.8',
|
77
|
-
:MINOR => '8',
|
78
|
-
:host_os => 'linux-gnu',
|
79
|
-
:ruby_install_name => 'ruby',
|
80
|
-
:TEENY => '6'
|
81
|
-
}
|
82
|
-
end
|
83
|
-
|
84
|
-
# ree-1.8.7-2012.02
|
85
|
-
let(:ree_187) do
|
86
|
-
{
|
87
|
-
:MINOR => '8',
|
88
|
-
:MAJOR => '1',
|
89
|
-
:host_os => 'linux-gnu',
|
90
|
-
:PATCHLEVEL => '358',
|
91
|
-
:ruby_install_name => 'ruby',
|
92
|
-
:TEENY => '7',
|
93
|
-
:ruby_version => '1.8'
|
94
|
-
}
|
95
|
-
end
|
96
|
-
|
97
|
-
# ree-1.8.7 on os x
|
98
|
-
let(:ree_187_osx) do
|
99
|
-
{
|
100
|
-
:host_os => 'darwin11.4.2',
|
101
|
-
:ruby_install_name => 'ruby',
|
102
|
-
:MINOR => '8',
|
103
|
-
:MAJOR => '1',
|
104
|
-
:ruby_version => '1.8',
|
105
|
-
:TEENY => '7',
|
106
|
-
:PATCHLEVEL => '358'
|
107
|
-
}
|
108
|
-
end
|
109
|
-
|
110
|
-
# rubinius-2.0.0.rc1 (rbx) 1.9 mode
|
111
|
-
let(:rubinius_19) do
|
112
|
-
{
|
113
|
-
:ruby_install_name => 'rbx',
|
114
|
-
:MAJOR => '1',
|
115
|
-
:MINOR => '9',
|
116
|
-
:TEENY => '3',
|
117
|
-
:ruby_version => '1.9',
|
118
|
-
:host_os => 'darwin11.4.2'
|
119
|
-
}
|
120
|
-
end
|
121
|
-
|
122
|
-
# rubinius-2.0.0.rc1 (rbx) 1.8 mode
|
123
|
-
let(:rubinius_18) do
|
124
|
-
{
|
125
|
-
:ruby_install_name => 'rbx',
|
126
|
-
:host_os => 'darwin11.4.2',
|
127
|
-
:ruby_version => '1.8',
|
128
|
-
:TEENY => '7',
|
129
|
-
:MAJOR => '1',
|
130
|
-
:MINOR => '8'
|
131
|
-
}
|
132
|
-
end
|
133
|
-
|
134
|
-
# jruby-1.7.0
|
135
|
-
let(:jruby_170) do
|
136
|
-
{
|
137
|
-
:MAJOR => '1',
|
138
|
-
:MINOR => '9',
|
139
|
-
:TEENY => '3',
|
140
|
-
:ruby_version => '1.9',
|
141
|
-
:ruby_install_name => 'jruby',
|
142
|
-
:host_os => 'linux'
|
143
|
-
}
|
144
|
-
end
|
145
|
-
|
146
|
-
# jruby-1.7.0 on os x
|
147
|
-
let(:jruby_170_osx) do
|
148
|
-
{
|
149
|
-
:MAJOR => '1',
|
150
|
-
:MINOR => '9',
|
151
|
-
:TEENY => '3',
|
152
|
-
:ruby_version => '1.9',
|
153
|
-
:ruby_install_name => 'jruby',
|
154
|
-
:host_os => 'darwin'
|
155
|
-
}
|
156
|
-
end
|
157
|
-
|
158
|
-
# jruby-1.6.8
|
159
|
-
let(:jruby_168) do
|
160
|
-
{
|
161
|
-
:MAJOR => '1',
|
162
|
-
:MINOR => '8',
|
163
|
-
:TEENY => '7',
|
164
|
-
:ruby_version => '1.8',
|
165
|
-
:ruby_install_name => 'jruby',
|
166
|
-
:host_os => 'linux'
|
167
|
-
}
|
168
|
-
end
|
169
|
-
|
170
|
-
# jruby-1.6.7.2
|
171
|
-
let(:jruby_1672) do
|
172
|
-
{
|
173
|
-
:MAJOR => '1',
|
174
|
-
:MINOR => '8',
|
175
|
-
:TEENY => '7',
|
176
|
-
:ruby_version => '1.8',
|
177
|
-
:ruby_install_name => 'jruby',
|
178
|
-
:host_os => 'linux'
|
179
|
-
}
|
180
|
-
end
|
181
|
-
|
182
|
-
# jruby-1.6.7
|
183
|
-
let(:jruby_167) do
|
184
|
-
{
|
185
|
-
:MAJOR => '1',
|
186
|
-
:MINOR => '8',
|
187
|
-
:TEENY => '7',
|
188
|
-
:ruby_version => '1.8',
|
189
|
-
:ruby_install_name => 'jruby',
|
190
|
-
:host_os => 'linux'
|
191
|
-
}
|
192
|
-
end
|
193
|
-
|
194
|
-
def platform_for(config)
|
195
|
-
return Platform.new(config[:ruby_version], config[:host_os],
|
196
|
-
config[:ruby_install_name])
|
197
|
-
end
|
198
|
-
|
199
|
-
context 'operating system' do
|
200
|
-
|
201
|
-
it 'properly detects Linux' do
|
202
|
-
platform = platform_for(mri_193)
|
203
|
-
platform.should be_linux
|
204
|
-
platform.should_not be_windows
|
205
|
-
platform.should_not be_osx
|
206
|
-
end
|
207
|
-
|
208
|
-
it 'properly detects Windows' do
|
209
|
-
platform = platform_for(mri_193_win)
|
210
|
-
platform.should_not be_linux
|
211
|
-
platform.should be_windows
|
212
|
-
platform.should_not be_osx
|
213
|
-
end
|
214
|
-
|
215
|
-
it 'properly detects OS X' do
|
216
|
-
platform = platform_for(jruby_170_osx)
|
217
|
-
platform.should_not be_linux
|
218
|
-
platform.should_not be_windows
|
219
|
-
platform.should be_osx
|
220
|
-
end
|
221
|
-
end
|
222
|
-
|
223
|
-
context 'Ruby version' do
|
224
|
-
|
225
|
-
it 'properly detects Rubinius (rbx) 1.8 mode (Linux)' do
|
226
|
-
platform = platform_for(rubinius_18)
|
227
|
-
|
228
|
-
platform.should be_ruby
|
229
|
-
platform.should be_ruby_18
|
230
|
-
platform.should_not be_ruby_19
|
231
|
-
platform.should_not be_ruby_20
|
232
|
-
platform.should_not be_mri
|
233
|
-
platform.should_not be_mri_18
|
234
|
-
platform.should_not be_mri_19
|
235
|
-
platform.should_not be_mri_20
|
236
|
-
platform.should be_rbx
|
237
|
-
platform.should_not be_jruby
|
238
|
-
platform.should_not be_mswin
|
239
|
-
platform.should_not be_mingw
|
240
|
-
platform.should_not be_mingw_18
|
241
|
-
platform.should_not be_mingw_19
|
242
|
-
platform.should_not be_mingw_20
|
243
|
-
end
|
244
|
-
|
245
|
-
it 'properly detects Rubinius (rbx) 1.9 mode (Linux)' do
|
246
|
-
platform = platform_for(rubinius_19)
|
247
|
-
|
248
|
-
platform.should be_ruby
|
249
|
-
platform.should_not be_ruby_18
|
250
|
-
platform.should be_ruby_19
|
251
|
-
platform.should_not be_mri
|
252
|
-
platform.should_not be_mri_18
|
253
|
-
platform.should_not be_mri_19
|
254
|
-
platform.should_not be_mri_20
|
255
|
-
platform.should be_rbx
|
256
|
-
platform.should_not be_jruby
|
257
|
-
platform.should_not be_mswin
|
258
|
-
platform.should_not be_mingw
|
259
|
-
platform.should_not be_mingw_18
|
260
|
-
platform.should_not be_mingw_19
|
261
|
-
platform.should_not be_mingw_20
|
262
|
-
end
|
263
|
-
|
264
|
-
it 'properly detects JRuby 1.6.7 (Linux)' do
|
265
|
-
platform = platform_for(jruby_167)
|
266
|
-
|
267
|
-
platform.should_not be_ruby
|
268
|
-
platform.should_not be_ruby_18
|
269
|
-
platform.should_not be_ruby_19
|
270
|
-
platform.should_not be_ruby_20
|
271
|
-
platform.should_not be_mri
|
272
|
-
platform.should_not be_mri_18
|
273
|
-
platform.should_not be_mri_19
|
274
|
-
platform.should_not be_mri_20
|
275
|
-
platform.should_not be_rbx
|
276
|
-
platform.should be_jruby
|
277
|
-
platform.should_not be_mswin
|
278
|
-
platform.should_not be_mingw
|
279
|
-
platform.should_not be_mingw_18
|
280
|
-
platform.should_not be_mingw_19
|
281
|
-
platform.should_not be_mingw_20
|
282
|
-
end
|
283
|
-
|
284
|
-
it 'properly detects JRuby 1.6.7.2 (Linux)' do
|
285
|
-
platform = platform_for(jruby_1672)
|
286
|
-
|
287
|
-
platform.should_not be_ruby
|
288
|
-
platform.should_not be_ruby_18
|
289
|
-
platform.should_not be_ruby_19
|
290
|
-
platform.should_not be_ruby_20
|
291
|
-
platform.should_not be_mri
|
292
|
-
platform.should_not be_mri_18
|
293
|
-
platform.should_not be_mri_19
|
294
|
-
platform.should_not be_mri_20
|
295
|
-
platform.should_not be_rbx
|
296
|
-
platform.should be_jruby
|
297
|
-
platform.should_not be_mswin
|
298
|
-
platform.should_not be_mingw
|
299
|
-
platform.should_not be_mingw_18
|
300
|
-
platform.should_not be_mingw_19
|
301
|
-
platform.should_not be_mingw_20
|
302
|
-
end
|
303
|
-
|
304
|
-
it 'properly detects JRuby 1.6.8 (Linux)' do
|
305
|
-
platform = platform_for(jruby_168)
|
306
|
-
|
307
|
-
platform.should_not be_ruby
|
308
|
-
platform.should_not be_ruby_18
|
309
|
-
platform.should_not be_ruby_19
|
310
|
-
platform.should_not be_ruby_20
|
311
|
-
platform.should_not be_mri
|
312
|
-
platform.should_not be_mri_18
|
313
|
-
platform.should_not be_mri_19
|
314
|
-
platform.should_not be_mri_20
|
315
|
-
platform.should_not be_rbx
|
316
|
-
platform.should be_jruby
|
317
|
-
platform.should_not be_mswin
|
318
|
-
platform.should_not be_mingw
|
319
|
-
platform.should_not be_mingw_18
|
320
|
-
platform.should_not be_mingw_19
|
321
|
-
platform.should_not be_mingw_20
|
322
|
-
end
|
323
|
-
|
324
|
-
it 'properly detects JRuby 1.7.0 (Linux)' do
|
325
|
-
platform = platform_for(jruby_170)
|
326
|
-
|
327
|
-
platform.should_not be_ruby
|
328
|
-
platform.should_not be_ruby_18
|
329
|
-
platform.should_not be_ruby_19
|
330
|
-
platform.should_not be_ruby_20
|
331
|
-
platform.should_not be_mri
|
332
|
-
platform.should_not be_mri_18
|
333
|
-
platform.should_not be_mri_19
|
334
|
-
platform.should_not be_mri_20
|
335
|
-
platform.should_not be_rbx
|
336
|
-
platform.should be_jruby
|
337
|
-
platform.should_not be_mswin
|
338
|
-
platform.should_not be_mingw
|
339
|
-
platform.should_not be_mingw_18
|
340
|
-
platform.should_not be_mingw_19
|
341
|
-
platform.should_not be_mingw_20
|
342
|
-
end
|
343
|
-
|
344
|
-
it 'properly detects JRuby 1.7.0 (OS X)' do
|
345
|
-
platform = platform_for(jruby_170_osx)
|
346
|
-
|
347
|
-
platform.should_not be_ruby
|
348
|
-
platform.should_not be_ruby_18
|
349
|
-
platform.should_not be_ruby_19
|
350
|
-
platform.should_not be_ruby_20
|
351
|
-
platform.should_not be_mri
|
352
|
-
platform.should_not be_mri_18
|
353
|
-
platform.should_not be_mri_19
|
354
|
-
platform.should_not be_mri_20
|
355
|
-
platform.should_not be_rbx
|
356
|
-
platform.should be_jruby
|
357
|
-
platform.should_not be_mswin
|
358
|
-
platform.should_not be_mingw
|
359
|
-
platform.should_not be_mingw_18
|
360
|
-
platform.should_not be_mingw_19
|
361
|
-
platform.should_not be_mingw_20
|
362
|
-
end
|
363
|
-
|
364
|
-
it 'properly detects REE 1.8.7 (Linux)' do
|
365
|
-
platform = platform_for(ree_187)
|
366
|
-
|
367
|
-
platform.should be_ruby
|
368
|
-
platform.should be_ruby_18
|
369
|
-
platform.should_not be_ruby_19
|
370
|
-
platform.should_not be_ruby_20
|
371
|
-
platform.should be_mri
|
372
|
-
platform.should be_mri_18
|
373
|
-
platform.should_not be_mri_19
|
374
|
-
platform.should_not be_mri_20
|
375
|
-
platform.should_not be_rbx
|
376
|
-
platform.should_not be_jruby
|
377
|
-
platform.should_not be_mswin
|
378
|
-
platform.should_not be_mingw
|
379
|
-
platform.should_not be_mingw_18
|
380
|
-
platform.should_not be_mingw_19
|
381
|
-
platform.should_not be_mingw_20
|
382
|
-
end
|
383
|
-
|
384
|
-
it 'properly detects REE 1.8.7 (OS X)' do
|
385
|
-
platform = platform_for(ree_187_osx)
|
386
|
-
|
387
|
-
platform.should be_ruby
|
388
|
-
platform.should be_ruby_18
|
389
|
-
platform.should_not be_ruby_19
|
390
|
-
platform.should_not be_ruby_20
|
391
|
-
platform.should be_mri
|
392
|
-
platform.should be_mri_18
|
393
|
-
platform.should_not be_mri_19
|
394
|
-
platform.should_not be_mri_20
|
395
|
-
platform.should_not be_rbx
|
396
|
-
platform.should_not be_jruby
|
397
|
-
platform.should_not be_mswin
|
398
|
-
platform.should_not be_mingw
|
399
|
-
platform.should_not be_mingw_18
|
400
|
-
platform.should_not be_mingw_19
|
401
|
-
platform.should_not be_mingw_20
|
402
|
-
end
|
403
|
-
|
404
|
-
it 'properly detects MRI 1.8.6 (Linux)' do
|
405
|
-
platform = platform_for(mri_186)
|
406
|
-
|
407
|
-
platform.should be_ruby
|
408
|
-
platform.should be_ruby_18
|
409
|
-
platform.should_not be_ruby_19
|
410
|
-
platform.should_not be_ruby_20
|
411
|
-
platform.should be_mri
|
412
|
-
platform.should be_mri_18
|
413
|
-
platform.should_not be_mri_19
|
414
|
-
platform.should_not be_mri_20
|
415
|
-
platform.should_not be_rbx
|
416
|
-
platform.should_not be_jruby
|
417
|
-
platform.should_not be_mswin
|
418
|
-
platform.should_not be_mingw
|
419
|
-
platform.should_not be_mingw_18
|
420
|
-
platform.should_not be_mingw_19
|
421
|
-
platform.should_not be_mingw_20
|
422
|
-
end
|
423
|
-
|
424
|
-
it 'properly detects MRI 1.8.7 (Linux)' do
|
425
|
-
platform = platform_for(mri_187)
|
426
|
-
|
427
|
-
platform.should be_ruby
|
428
|
-
platform.should be_ruby_18
|
429
|
-
platform.should_not be_ruby_19
|
430
|
-
platform.should_not be_ruby_20
|
431
|
-
platform.should be_mri
|
432
|
-
platform.should be_mri_18
|
433
|
-
platform.should_not be_mri_19
|
434
|
-
platform.should_not be_mri_20
|
435
|
-
platform.should_not be_rbx
|
436
|
-
platform.should_not be_jruby
|
437
|
-
platform.should_not be_mswin
|
438
|
-
platform.should_not be_mingw
|
439
|
-
platform.should_not be_mingw_18
|
440
|
-
platform.should_not be_mingw_19
|
441
|
-
platform.should_not be_mingw_20
|
442
|
-
end
|
443
|
-
|
444
|
-
it 'properly detects MRI 1.9.2 (Linux)' do
|
445
|
-
platform = platform_for(mri_192)
|
446
|
-
|
447
|
-
platform.should be_ruby
|
448
|
-
platform.should_not be_ruby_18
|
449
|
-
platform.should be_ruby_19
|
450
|
-
platform.should be_mri
|
451
|
-
platform.should_not be_mri_18
|
452
|
-
platform.should be_mri_19
|
453
|
-
platform.should_not be_rbx
|
454
|
-
platform.should_not be_jruby
|
455
|
-
platform.should_not be_mswin
|
456
|
-
platform.should_not be_mingw
|
457
|
-
platform.should_not be_mingw_18
|
458
|
-
platform.should_not be_mingw_19
|
459
|
-
platform.should_not be_mingw_20
|
460
|
-
end
|
461
|
-
|
462
|
-
it 'properly detects MRI 1.9.3 (Linux)' do
|
463
|
-
platform = platform_for(mri_193)
|
464
|
-
|
465
|
-
platform.should be_ruby
|
466
|
-
platform.should_not be_ruby_18
|
467
|
-
platform.should be_ruby_19
|
468
|
-
platform.should be_mri
|
469
|
-
platform.should_not be_mri_18
|
470
|
-
platform.should be_mri_19
|
471
|
-
platform.should_not be_rbx
|
472
|
-
platform.should_not be_jruby
|
473
|
-
platform.should_not be_mswin
|
474
|
-
platform.should_not be_mingw
|
475
|
-
platform.should_not be_mingw_18
|
476
|
-
platform.should_not be_mingw_19
|
477
|
-
platform.should_not be_mingw_20
|
478
|
-
end
|
479
|
-
|
480
|
-
it 'properly detects MRI 2.0.0 (Linux)' do
|
481
|
-
platform = platform_for(mri_200)
|
482
|
-
|
483
|
-
platform.should be_ruby
|
484
|
-
platform.should_not be_ruby_18
|
485
|
-
platform.should_not be_ruby_19
|
486
|
-
platform.should be_ruby_20
|
487
|
-
platform.should be_mri
|
488
|
-
platform.should_not be_mri_18
|
489
|
-
platform.should_not be_mri_19
|
490
|
-
platform.should be_mri_20
|
491
|
-
platform.should_not be_rbx
|
492
|
-
platform.should_not be_jruby
|
493
|
-
platform.should_not be_mswin
|
494
|
-
platform.should_not be_mingw
|
495
|
-
platform.should_not be_mingw_18
|
496
|
-
platform.should_not be_mingw_19
|
497
|
-
platform.should_not be_mingw_20
|
498
|
-
end
|
499
|
-
end
|
500
|
-
end
|
501
|
-
end
|