maybe_monad 0.0.1 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.rspec +2 -0
- data/.rspec_status +9 -0
- data/Rakefile +3 -6
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/lib/maybe_monad/version.rb +1 -1
- data/lib/maybe_monad.rb +2 -6
- data/maybe_monad.gemspec +2 -2
- data/spec/maybe_monad_spec.rb +48 -0
- data/spec/spec_helper.rb +12 -0
- metadata +26 -24
- data/spec/spec_maybe_monad.rb +0 -49
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: f764aebbaae44b81e26bd18cfe2e697f048aee4d
|
4
|
+
data.tar.gz: 4015da28b157817efabeb2140517a1eec0b1a7ad
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 8fb900691fce3ee764dadbd8e4da8b60df0414dedae99ae97f9f0b4a41080fed94e3b4d190372f4e86bdfb27956b895736accda2b96c83ab6cd79eb406e30b33
|
7
|
+
data.tar.gz: 5b3d3b75119dbaf5b3464c151624fad7b706de43423e5dd46b84857f77a8b34e7916cca4764fea3f34aa5f216c9e8b865d4b51e4144a936aca4e0fdcb870b2e2
|
data/.rspec
ADDED
data/.rspec_status
ADDED
@@ -0,0 +1,9 @@
|
|
1
|
+
example_id | status | run_time |
|
2
|
+
--------------------------------- | ------ | --------------- |
|
3
|
+
./spec/maybe_monad_spec.rb[1:1:1] | passed | 0.00036 seconds |
|
4
|
+
./spec/maybe_monad_spec.rb[1:2:1] | passed | 0.00008 seconds |
|
5
|
+
./spec/maybe_monad_spec.rb[1:3:1] | passed | 0.00007 seconds |
|
6
|
+
./spec/maybe_monad_spec.rb[1:4:1] | passed | 0.00007 seconds |
|
7
|
+
./spec/maybe_monad_spec.rb[1:5:1] | passed | 0.00007 seconds |
|
8
|
+
./spec/maybe_monad_spec.rb[1:5:2] | passed | 0.00006 seconds |
|
9
|
+
./spec/maybe_monad_spec.rb[1:6:1] | passed | 0.00007 seconds |
|
data/Rakefile
CHANGED
@@ -1,9 +1,6 @@
|
|
1
1
|
require "bundler/gem_tasks"
|
2
|
+
require "rspec/core/rake_task"
|
2
3
|
|
3
|
-
|
4
|
+
RSpec::Core::RakeTask.new(:spec)
|
4
5
|
|
5
|
-
|
6
|
-
t.libs.push "lib"
|
7
|
-
t.test_files = FileList['spec/spec_*.rb']
|
8
|
-
t.verbose = true
|
9
|
-
end
|
6
|
+
task :default => :spec
|
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "xxx"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
data/lib/maybe_monad/version.rb
CHANGED
data/lib/maybe_monad.rb
CHANGED
@@ -22,12 +22,8 @@ module MaybeMonad
|
|
22
22
|
@just
|
23
23
|
end
|
24
24
|
|
25
|
-
def method_missing(name, *args)
|
26
|
-
|
27
|
-
@just.nil? ? Monad.new(nil) : Monad.new(@just.__send__(name, *args))
|
28
|
-
|
29
|
-
## extra, nil respond to methods that can respond
|
30
|
-
#@just.respond_to?(name) ? Monad.new(@just.__send__(name, *args)) : Monad.new(nil)
|
25
|
+
def method_missing(name, *args, &block)
|
26
|
+
@just.respond_to?(name) ? Monad.new(@just.__send__(name, *args, &block)) : Monad.new(nil)
|
31
27
|
end
|
32
28
|
|
33
29
|
end
|
data/maybe_monad.gemspec
CHANGED
@@ -18,6 +18,6 @@ Gem::Specification.new do |spec|
|
|
18
18
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
19
|
spec.require_paths = ["lib"]
|
20
20
|
|
21
|
-
spec.add_development_dependency "bundler"
|
22
|
-
spec.add_development_dependency "
|
21
|
+
spec.add_development_dependency "bundler"
|
22
|
+
spec.add_development_dependency "rspec"
|
23
23
|
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe MaybeMonad::Monad do
|
4
|
+
|
5
|
+
before do
|
6
|
+
end
|
7
|
+
|
8
|
+
describe "test soup is nil" do
|
9
|
+
it 'must return ""' do
|
10
|
+
expect(nil.maybe.to_s.just).to eq ""
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
describe "test actual soup call undef method" do
|
15
|
+
it "must return nil" do
|
16
|
+
expect("a".maybe.aaa.just).to eq nil
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
describe "test actual soup" do
|
21
|
+
it "must return 2" do
|
22
|
+
expect(2.maybe.to_s.just).to eq "2"
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
describe "test method with parameters" do
|
27
|
+
it "must return false" do
|
28
|
+
expect("a".maybe.respond_to?("aaa").to_s.just).to eq "false"
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
describe "test method #[]" do
|
33
|
+
it "must return 2" do
|
34
|
+
expect([1, 2, 3].maybe[1].to_s.just).to eq "2"
|
35
|
+
end
|
36
|
+
|
37
|
+
it "must return nil" do
|
38
|
+
expect([1, 2, 3].maybe[4].to_s.just).to eq ""
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
describe "test block" do
|
43
|
+
it "must return 2" do
|
44
|
+
expect(([1].maybe.map { |x| x + 1 })[0].just).to eq 2
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
require 'bundler/setup'
|
2
|
+
|
3
|
+
require 'maybe_monad'
|
4
|
+
|
5
|
+
RSpec.configure do |config|
|
6
|
+
# Enable flags like --only-failures and --next-failure
|
7
|
+
config.example_status_persistence_file_path = ".rspec_status"
|
8
|
+
|
9
|
+
config.expect_with :rspec do |c|
|
10
|
+
c.syntax = :expect
|
11
|
+
end
|
12
|
+
end
|
metadata
CHANGED
@@ -1,89 +1,91 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: maybe_monad
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
5
|
-
prerelease:
|
4
|
+
version: 0.1.1
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- liangjingyang
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date:
|
11
|
+
date: 2017-07-05 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: bundler
|
16
15
|
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
16
|
requirements:
|
19
|
-
- -
|
17
|
+
- - ">="
|
20
18
|
- !ruby/object:Gem::Version
|
21
|
-
version: '
|
19
|
+
version: '0'
|
22
20
|
type: :development
|
23
21
|
prerelease: false
|
24
22
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
23
|
requirements:
|
27
|
-
- -
|
24
|
+
- - ">="
|
28
25
|
- !ruby/object:Gem::Version
|
29
|
-
version: '
|
26
|
+
version: '0'
|
30
27
|
- !ruby/object:Gem::Dependency
|
31
|
-
name:
|
28
|
+
name: rspec
|
32
29
|
requirement: !ruby/object:Gem::Requirement
|
33
|
-
none: false
|
34
30
|
requirements:
|
35
|
-
- -
|
31
|
+
- - ">="
|
36
32
|
- !ruby/object:Gem::Version
|
37
33
|
version: '0'
|
38
34
|
type: :development
|
39
35
|
prerelease: false
|
40
36
|
version_requirements: !ruby/object:Gem::Requirement
|
41
|
-
none: false
|
42
37
|
requirements:
|
43
|
-
- -
|
38
|
+
- - ">="
|
44
39
|
- !ruby/object:Gem::Version
|
45
40
|
version: '0'
|
46
41
|
description: another maybe monad library
|
47
42
|
email:
|
48
43
|
- simple.continue@gmail.com
|
49
|
-
executables:
|
44
|
+
executables:
|
45
|
+
- console
|
46
|
+
- setup
|
50
47
|
extensions: []
|
51
48
|
extra_rdoc_files: []
|
52
49
|
files:
|
53
|
-
- .gitignore
|
50
|
+
- ".gitignore"
|
51
|
+
- ".rspec"
|
52
|
+
- ".rspec_status"
|
54
53
|
- Gemfile
|
55
54
|
- LICENSE.txt
|
56
55
|
- README.md
|
57
56
|
- Rakefile
|
57
|
+
- bin/console
|
58
|
+
- bin/setup
|
58
59
|
- lib/maybe_monad.rb
|
59
60
|
- lib/maybe_monad/version.rb
|
60
61
|
- maybe_monad.gemspec
|
61
62
|
- maybe_monad.png
|
62
|
-
- spec/
|
63
|
+
- spec/maybe_monad_spec.rb
|
64
|
+
- spec/spec_helper.rb
|
63
65
|
homepage: ''
|
64
66
|
licenses:
|
65
67
|
- MIT
|
68
|
+
metadata: {}
|
66
69
|
post_install_message:
|
67
70
|
rdoc_options: []
|
68
71
|
require_paths:
|
69
72
|
- lib
|
70
73
|
required_ruby_version: !ruby/object:Gem::Requirement
|
71
|
-
none: false
|
72
74
|
requirements:
|
73
|
-
- -
|
75
|
+
- - ">="
|
74
76
|
- !ruby/object:Gem::Version
|
75
77
|
version: '0'
|
76
78
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
77
|
-
none: false
|
78
79
|
requirements:
|
79
|
-
- -
|
80
|
+
- - ">="
|
80
81
|
- !ruby/object:Gem::Version
|
81
82
|
version: '0'
|
82
83
|
requirements: []
|
83
84
|
rubyforge_project:
|
84
|
-
rubygems_version:
|
85
|
+
rubygems_version: 2.5.2
|
85
86
|
signing_key:
|
86
|
-
specification_version:
|
87
|
+
specification_version: 4
|
87
88
|
summary: another maybe monad library
|
88
89
|
test_files:
|
89
|
-
- spec/
|
90
|
+
- spec/maybe_monad_spec.rb
|
91
|
+
- spec/spec_helper.rb
|
data/spec/spec_maybe_monad.rb
DELETED
@@ -1,49 +0,0 @@
|
|
1
|
-
require 'minitest/autorun'
|
2
|
-
require 'maybe_monad'
|
3
|
-
|
4
|
-
describe MaybeMonad::Monad do
|
5
|
-
|
6
|
-
before do
|
7
|
-
end
|
8
|
-
|
9
|
-
# default, nil don't respond to any method
|
10
|
-
describe "test soup is nil" do
|
11
|
-
it "must return nil" do
|
12
|
-
nil.maybe.to_s.just.must_equal nil
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
## extra, nil respond to methods that can respond
|
17
|
-
#describe "test soup is nil" do
|
18
|
-
#it 'must return ""' do
|
19
|
-
#nil.maybe.to_s.just.must_equal ""
|
20
|
-
#end
|
21
|
-
#end
|
22
|
-
|
23
|
-
## extra, just return nil if actual soup call undef method
|
24
|
-
#describe "test actual soup call undef method" do
|
25
|
-
#it "must return nil" do
|
26
|
-
#"a".maybe.aaa.just.must_equal nil
|
27
|
-
#end
|
28
|
-
#end
|
29
|
-
|
30
|
-
describe "test actual soup" do
|
31
|
-
it "must return 2" do
|
32
|
-
2.maybe.to_s.just.must_equal "2"
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
describe "test method with parameters" do
|
37
|
-
it "must return false" do
|
38
|
-
"a".maybe.respond_to?("aaa").to_s.just.must_equal "false"
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
describe "test method #[]" do
|
43
|
-
it "must return 2" do
|
44
|
-
[1, 2, 3].maybe[1].to_s.just.must_equal "2"
|
45
|
-
end
|
46
|
-
end
|
47
|
-
|
48
|
-
end
|
49
|
-
|