functional-ruby 0.7.3 → 0.7.4
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/lib/functional.rb +1 -0
- data/lib/functional/platform.rb +120 -0
- data/lib/functional/version.rb +1 -1
- data/spec/functional/platform_spec.rb +501 -0
- data/spec/functional/utilities_spec.rb +31 -25
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1033510698e79e8472d8fee1bc631b9d03edce14
|
4
|
+
data.tar.gz: f3fbc19a3c18543984cba90b64ac8508b105bd63
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4d206b9ddcc7ab49f2225e8fe9a3fb638d9b35ab09a75ee6a33602d000003cf235dab1650fcc8e72accfaed3371b7254104bbae4227db16c64eaf4ea15cacb37
|
7
|
+
data.tar.gz: d90c081ad4efc3963d4e125d9c1867c138067d096e136c0fb0ad9d124f8438415d098a36847e877ccf9186df81906f495cecebcff55bdde7885dfb2af403a0e2
|
data/lib/functional.rb
CHANGED
@@ -0,0 +1,120 @@
|
|
1
|
+
require 'rbconfig'
|
2
|
+
|
3
|
+
module Functional
|
4
|
+
|
5
|
+
class Platform
|
6
|
+
|
7
|
+
attr_reader :ruby_version
|
8
|
+
attr_reader :host_os
|
9
|
+
attr_reader :ruby_name
|
10
|
+
|
11
|
+
def rubies
|
12
|
+
@rubies ||= [
|
13
|
+
:ruby, # C Ruby (MRI) or Rubinius, but NOT Windows
|
14
|
+
:ruby_18, # ruby AND version 1.8
|
15
|
+
:ruby_19, # ruby AND version 1.9
|
16
|
+
:mri, # Same as ruby, but not Rubinius
|
17
|
+
:mri_18, # mri AND version 1.8
|
18
|
+
:mri_19, # mri AND version 1.9
|
19
|
+
:mri_20, # mri AND version 20
|
20
|
+
:rbx, # Same as ruby, but only Rubinius (not MRI)
|
21
|
+
:jruby, # JRuby
|
22
|
+
:mswin, # Windows
|
23
|
+
:mingw, # Windows 'mingw32' platform (aka RubyInstaller)
|
24
|
+
:mingw_18, # mingw AND version 1.8
|
25
|
+
:mingw_19, # mingw AND version 1.9
|
26
|
+
:mingw_20, # mingw AND version 2.0
|
27
|
+
].freeze
|
28
|
+
end
|
29
|
+
|
30
|
+
def initialize(*args)
|
31
|
+
unless args.size == 0 || args.size == 3
|
32
|
+
raise ArgumentError.new("wrong number of arguments (#{args.size} for 0 or 3)")
|
33
|
+
end
|
34
|
+
|
35
|
+
@ruby_version = args[0] || RUBY_VERSION || RbConfig::CONFIG['ruby_version']
|
36
|
+
@host_os = args[1] || RbConfig::CONFIG['host_os']
|
37
|
+
@ruby_name = args[2] || RbConfig::CONFIG['ruby_install_name']
|
38
|
+
end
|
39
|
+
|
40
|
+
def windows?
|
41
|
+
truthy(@host_os =~ /win32/i) || truthy(@host_os =~ /mingw32/i)
|
42
|
+
end
|
43
|
+
|
44
|
+
def linux?
|
45
|
+
truthy(@host_os =~ /linux/i)
|
46
|
+
end
|
47
|
+
|
48
|
+
def osx?
|
49
|
+
truthy(@host_os =~ /darwin/i)
|
50
|
+
end
|
51
|
+
|
52
|
+
def ruby?
|
53
|
+
mri? || rbx?
|
54
|
+
end
|
55
|
+
|
56
|
+
def ruby_18?
|
57
|
+
ruby? && truthy(@ruby_version =~ /^1\.8/)
|
58
|
+
end
|
59
|
+
|
60
|
+
def ruby_19?
|
61
|
+
ruby? && truthy(@ruby_version =~ /^1\.9/)
|
62
|
+
end
|
63
|
+
|
64
|
+
def ruby_20?
|
65
|
+
ruby? && truthy(@ruby_version =~ /^2\.0/)
|
66
|
+
end
|
67
|
+
|
68
|
+
def mri?
|
69
|
+
truthy(@ruby_name =~ /^ruby$/i) && !windows?
|
70
|
+
end
|
71
|
+
|
72
|
+
def mri_18?
|
73
|
+
mri? && truthy(@ruby_version =~ /^1\.8/)
|
74
|
+
end
|
75
|
+
|
76
|
+
def mri_19?
|
77
|
+
mri? && truthy(@ruby_version =~ /^1\.9/)
|
78
|
+
end
|
79
|
+
|
80
|
+
def mri_20?
|
81
|
+
mri? && truthy(@ruby_version =~ /^2\.0/)
|
82
|
+
end
|
83
|
+
|
84
|
+
def rbx?
|
85
|
+
truthy(@ruby_name =~ /^rbx$/i)
|
86
|
+
end
|
87
|
+
|
88
|
+
def jruby?
|
89
|
+
truthy(@ruby_name =~ /^jruby$/i)
|
90
|
+
end
|
91
|
+
|
92
|
+
def mswin?
|
93
|
+
truthy(@host_os =~ /win32/i)
|
94
|
+
end
|
95
|
+
|
96
|
+
def mingw?
|
97
|
+
truthy(@host_os =~ /mingw32/i)
|
98
|
+
end
|
99
|
+
|
100
|
+
def mingw_18?
|
101
|
+
mingw? && truthy(@ruby_version =~ /^1\.8/)
|
102
|
+
end
|
103
|
+
|
104
|
+
def mingw_19?
|
105
|
+
mingw? && truthy(@ruby_version =~ /^1\.9/)
|
106
|
+
end
|
107
|
+
|
108
|
+
def mingw_20?
|
109
|
+
mingw? && truthy(@ruby_version =~ /^2\.0/)
|
110
|
+
end
|
111
|
+
|
112
|
+
private
|
113
|
+
|
114
|
+
def truthy(value)
|
115
|
+
return value == 0
|
116
|
+
end
|
117
|
+
end
|
118
|
+
|
119
|
+
PLATFORM = Functional::Platform.new
|
120
|
+
end
|
data/lib/functional/version.rb
CHANGED
@@ -0,0 +1,501 @@
|
|
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
|
@@ -159,42 +159,48 @@ describe 'utilities' do
|
|
159
159
|
|
160
160
|
context '#slurp' do
|
161
161
|
|
162
|
-
|
163
|
-
after(:all) { FakeFS.deactivate! }
|
162
|
+
unless Functional::PLATFORM.rbx?
|
164
163
|
|
165
|
-
|
166
|
-
|
164
|
+
before(:all) { FakeFS.activate! }
|
165
|
+
after(:all) { FakeFS.deactivate! }
|
167
166
|
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
167
|
+
let!(:path){ 'slurp.txt' }
|
168
|
+
let!(:text){ 'Hello, world!' }
|
169
|
+
|
170
|
+
it 'returns the contents of the file' do
|
171
|
+
File.open(path, 'w+') {|f| f.write(text) }
|
172
|
+
slurp(path).should eq text
|
173
|
+
end
|
172
174
|
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
175
|
+
it 'raises an exception when the file does not exist' do
|
176
|
+
lambda {
|
177
|
+
slurp('path/does/not/exist')
|
178
|
+
}.should raise_error(Errno::ENOENT)
|
179
|
+
end
|
177
180
|
end
|
178
181
|
end
|
179
182
|
|
180
183
|
context '#slurpee' do
|
181
184
|
|
182
|
-
|
183
|
-
after(:all) { FakeFS.deactivate! }
|
185
|
+
unless Functional::PLATFORM.rbx?
|
184
186
|
|
185
|
-
|
186
|
-
|
187
|
-
let!(:erb) { 'You are number <%= 2 * 3 %>.' }
|
187
|
+
before(:all) { FakeFS.activate! }
|
188
|
+
after(:all) { FakeFS.deactivate! }
|
188
189
|
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
190
|
+
let!(:path){ 'slurp.txt' }
|
191
|
+
let!(:text){ 'You are number 6.' }
|
192
|
+
let!(:erb) { 'You are number <%= 2 * 3 %>.' }
|
193
|
+
|
194
|
+
it 'returns the processed contents of the file' do
|
195
|
+
File.open(path, 'w+') {|f| f.write(erb) }
|
196
|
+
slurpee(path).should eq text
|
197
|
+
end
|
193
198
|
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
199
|
+
it 'raises an exception when the file does not exist' do
|
200
|
+
lambda {
|
201
|
+
slurpee('path/does/not/exist')
|
202
|
+
}.should raise_error(Errno::ENOENT)
|
203
|
+
end
|
198
204
|
end
|
199
205
|
end
|
200
206
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: functional-ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.7.
|
4
|
+
version: 0.7.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jerry D'Antonio
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-08-
|
11
|
+
date: 2013-08-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -38,6 +38,7 @@ files:
|
|
38
38
|
- lib/functional/behavior.rb
|
39
39
|
- lib/functional/behaviour.rb
|
40
40
|
- lib/functional/pattern_matching.rb
|
41
|
+
- lib/functional/platform.rb
|
41
42
|
- lib/functional/utilities.rb
|
42
43
|
- lib/functional/version.rb
|
43
44
|
- lib/functional.rb
|
@@ -48,6 +49,7 @@ files:
|
|
48
49
|
- spec/functional/behavior_spec.rb
|
49
50
|
- spec/functional/integration_spec.rb
|
50
51
|
- spec/functional/pattern_matching_spec.rb
|
52
|
+
- spec/functional/platform_spec.rb
|
51
53
|
- spec/functional/utilities_spec.rb
|
52
54
|
- spec/spec_helper.rb
|
53
55
|
homepage: https://github.com/jdantonio/functional-ruby/
|
@@ -87,5 +89,6 @@ test_files:
|
|
87
89
|
- spec/functional/behavior_spec.rb
|
88
90
|
- spec/functional/integration_spec.rb
|
89
91
|
- spec/functional/pattern_matching_spec.rb
|
92
|
+
- spec/functional/platform_spec.rb
|
90
93
|
- spec/functional/utilities_spec.rb
|
91
94
|
- spec/spec_helper.rb
|