scaruby 0.0.5 → 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,6 +1,6 @@
1
1
  # -*- encoding: utf-8 -*-
2
2
 
3
3
  module Scaruby
4
- VERSION = "0.0.5"
4
+ VERSION = "0.0.6"
5
5
  end
6
6
 
data/lib/scaruby.rb CHANGED
@@ -1,58 +1,59 @@
1
- # -*- encoding: utf-8 -*-
2
-
3
- require 'scaruby/appliable_proc'
4
- require 'scaruby/concurrent'
5
- require 'scaruby/converter'
6
- require 'scaruby/io'
7
- require 'scaruby/map'
8
- require 'scaruby/exception'
9
- require 'scaruby/option'
10
- require 'scaruby/seq'
11
- require 'scaruby/version'
12
-
13
- module Scaruby
14
-
15
- module Commons
16
-
17
- def assert_type(v, *types)
18
- is_matched = false
19
- unless v.nil? then
20
- found = types.inject(false) {|found,type|
21
- if found then true
22
- else v.is_a?(type)
23
- end
24
- }
25
- unless found then
26
- raise AssertionError,
27
- "The type of `#{v}` should be whichever of [#{types.join(', ')}] but actually #{v.class}."
28
- end
29
- end
30
- end
31
-
32
- end
33
-
34
- module Predef
35
-
36
- def assert(assertion)
37
- unless assertion then
38
- raise AssertionError, 'Assertion failed'
39
- end
40
- end
41
-
42
- def println(any)
43
- puts any.to_s
44
- end
45
-
46
- def read_line
47
- input = readline
48
- input.sub(/\r?\n/, '')
49
- end
50
-
51
- end
52
- end
53
-
54
- include Scaruby
55
- include Scaruby::Commons
56
- include Scaruby::Predef
57
-
58
-
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ require 'scaruby/appliable_proc'
4
+ require 'scaruby/concurrent'
5
+ require 'scaruby/converter'
6
+ require 'scaruby/io'
7
+ require 'scaruby/map'
8
+ require 'scaruby/exception'
9
+ require 'scaruby/option'
10
+ require 'scaruby/seq'
11
+ require 'scaruby/version'
12
+
13
+ module Scaruby
14
+
15
+ module Commons
16
+
17
+ def assert_type(v, *types)
18
+ unless v.nil?
19
+ found = types.inject(false) { |found, type|
20
+ if found
21
+ true
22
+ else
23
+ v.is_a?(type)
24
+ end
25
+ }
26
+ unless found
27
+ raise AssertionError,
28
+ "The type of `#{v}` should be whichever of [#{types.join(', ')}] but actually #{v.class}."
29
+ end
30
+ end
31
+ end
32
+
33
+ end
34
+
35
+ module Predef
36
+
37
+ def assert(assertion)
38
+ unless assertion
39
+ raise AssertionError, 'Assertion failed'
40
+ end
41
+ end
42
+
43
+ def println(any)
44
+ puts any.to_s
45
+ end
46
+
47
+ def read_line
48
+ input = readline
49
+ input.sub(/\r?\n/, '')
50
+ end
51
+
52
+ end
53
+ end
54
+
55
+ include Scaruby
56
+ include Scaruby::Commons
57
+ include Scaruby::Predef
58
+
59
+
data/scaruby.gemspec CHANGED
@@ -1,23 +1,23 @@
1
- # -*- encoding: utf-8 -*-
2
- $:.push File.expand_path("../lib", __FILE__)
3
- require "scaruby/version"
4
-
5
- Gem::Specification.new do |s|
6
- s.name = "scaruby"
7
- s.version = Scaruby::VERSION
8
- s.authors = ["Kazuhiro Sera"]
9
- s.email = ["seratch@gmail.com"]
10
- s.homepage = "https://github.com/seratch/scaruby"
11
- s.summary = %q{Scala API in Ruby}
12
- s.description = %q{Scala API in Ruby}
13
-
14
- s.rubyforge_project = "scaruby"
15
-
16
- s.files = `git ls-files`.split("\n")
17
- s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
18
- s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
19
- s.require_paths = ["lib"]
20
-
21
- s.required_ruby_version = '>= 1.9.2'
22
-
23
- end
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "scaruby/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "scaruby"
7
+ s.version = Scaruby::VERSION
8
+ s.authors = ["Kazuhiro Sera"]
9
+ s.email = ["seratch@gmail.com"]
10
+ s.homepage = "https://github.com/seratch/scaruby"
11
+ s.summary = %q{Scala API in Ruby}
12
+ s.description = %q{Scala API in Ruby}
13
+
14
+ s.rubyforge_project = "scaruby"
15
+
16
+ s.files = `git ls-files`.split("\n")
17
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
18
+ s.executables = `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) }
19
+ s.require_paths = ["lib"]
20
+
21
+ s.required_ruby_version = '>= 1.9.2'
22
+
23
+ end
@@ -1,27 +1,27 @@
1
- # -*- encoding: utf-8 -*-
2
-
3
- require 'scaruby/converter'
4
-
5
- describe Enumerable do
6
- it 'has #to_scaruby' do
7
- [1,2,3].to_scaruby.filter {|e| e > 1 }.to_a.should eq([2,3])
8
- end
9
- end
10
-
11
- describe Hash do
12
- it 'has #to_scaruby' do
13
- {123=>'abc',2=>'b',34=>'cd'}.to_scaruby.filter {|k,v|
14
- k.to_s.length == 1
15
- }.to_hash.should eq({2=>'b'})
16
- end
17
- end
18
-
19
- describe Object do
20
- it 'has #to_option' do
21
- 'abc'.to_option.is_defined.should eq(true)
22
- 'abc'.to_option.get_or_else('zzz').should eq('abc')
23
- nil.to_option.is_defined.should eq(false)
24
- nil.to_option.get_or_else('zzz').should eq('zzz')
25
- end
26
- end
27
-
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ require 'scaruby/converter'
4
+
5
+ describe Enumerable do
6
+ it 'has #to_scaruby' do
7
+ [1, 2, 3].to_scaruby.filter { |e| e > 1 }.to_a.should eq([2, 3])
8
+ end
9
+ end
10
+
11
+ describe Hash do
12
+ it 'has #to_scaruby' do
13
+ {123 => 'abc', 2 => 'b', 34 => 'cd'}.to_scaruby.filter { |k, v|
14
+ k.to_s.length == 1
15
+ }.to_hash.should eq({2 => 'b'})
16
+ end
17
+ end
18
+
19
+ describe Object do
20
+ it 'has #to_option' do
21
+ 'abc'.to_option.is_defined.should eq(true)
22
+ 'abc'.to_option.get_or_else('zzz').should eq('abc')
23
+ nil.to_option.is_defined.should eq(false)
24
+ nil.to_option.get_or_else('zzz').should eq('zzz')
25
+ end
26
+ end
27
+