maybelline 1.1.0 → 1.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.travis.yml +6 -0
- data/LICENSE +19 -0
- data/README.md +59 -15
- data/Rakefile +5 -0
- data/lib/maybelline/version.rb +1 -1
- data/maybelline.gemspec +2 -1
- metadata +18 -5
data/.travis.yml
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
Copyright (c) 2012 Allen Madsen
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
4
|
+
of this software and associated documentation files (the "Software"), to deal
|
5
|
+
in the Software without restriction, including without limitation the rights
|
6
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
7
|
+
copies of the Software, and to permit persons to whom the Software is
|
8
|
+
furnished to do so, subject to the following conditions:
|
9
|
+
|
10
|
+
The above copyright notice and this permission notice shall be included in all
|
11
|
+
copies or substantial portions of the Software.
|
12
|
+
|
13
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
16
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
18
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
19
|
+
SOFTWARE.
|
data/README.md
CHANGED
@@ -1,21 +1,65 @@
|
|
1
1
|
# Maybelline
|
2
2
|
|
3
|
-
|
3
|
+
[![Build Status](http://travis-ci.org/blatyo/maybelline.png)](http://travis-ci.org/blatyo/maybelline)
|
4
|
+
|
5
|
+
An implementation of the [maybe monad](http://en.wikipedia.org/wiki/Monad_(functional_programming)#The_Maybe_monad).
|
6
|
+
|
7
|
+
## Setup
|
8
|
+
|
9
|
+
**Gemfile**
|
10
|
+
``` ruby
|
11
|
+
gem 'maybelline'
|
12
|
+
```
|
13
|
+
|
14
|
+
**Manual**
|
15
|
+
``` ruby
|
16
|
+
require 'maybelline'
|
17
|
+
```
|
4
18
|
|
5
19
|
## Usage
|
6
20
|
|
21
|
+
Say you have some objects like the ones below:
|
22
|
+
|
7
23
|
``` ruby
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
24
|
+
require 'ostruct'
|
25
|
+
|
26
|
+
data = {
|
27
|
+
"neat" => {
|
28
|
+
"super" => "cool",
|
29
|
+
"lame" => nil
|
30
|
+
}
|
31
|
+
}
|
32
|
+
|
33
|
+
object = OpenStruct.new(data)
|
34
|
+
object.neat = OpenStruct.new(object.neat)
|
35
|
+
```
|
36
|
+
|
37
|
+
If any method in the chain of calls returns nil, the block will return nil.
|
38
|
+
|
39
|
+
``` ruby
|
40
|
+
Maybe(data){|d| d["this_key_doesnt_exist"]["this_key_wont_get_called"]} #=> nil
|
41
|
+
data.maybe{|d| d["this_key_doesnt_exist"]["this_key_wont_get_called"]} #=> nil
|
42
|
+
object.maybe{|o| o.neat.lame.this_method_never_gets_called} #=> nil
|
43
|
+
```
|
44
|
+
|
45
|
+
If it is successful, it will return the value.
|
46
|
+
|
47
|
+
``` ruby
|
48
|
+
data.maybe{|d| d["neat"]["super"]} #=> "cool"
|
49
|
+
object.maybe{|o| o.neat.super} #=> "cool"
|
50
|
+
```
|
51
|
+
|
52
|
+
## Note on Reporting Issues
|
53
|
+
|
54
|
+
* Try to make a failing test case
|
55
|
+
* Tell me which version of ruby you're using
|
56
|
+
* Tell me which OS you are using
|
57
|
+
* Provide me with any extra files if necessary
|
58
|
+
|
59
|
+
## Note on Patches/Pull Requests
|
60
|
+
|
61
|
+
* Fork the project.
|
62
|
+
* Make your feature addition or bug fix.
|
63
|
+
* Add tests for it. This is important so I don't break it in a future version unintentionally.
|
64
|
+
* Commit, do not mess with rakefile, version, or history. (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
|
65
|
+
* Send me a pull request. Bonus points for topic branches.
|
data/Rakefile
CHANGED
data/lib/maybelline/version.rb
CHANGED
data/maybelline.gemspec
CHANGED
@@ -7,7 +7,7 @@ Gem::Specification.new do |s|
|
|
7
7
|
s.version = Maybelline::VERSION
|
8
8
|
s.authors = ["Allen Madsen"]
|
9
9
|
s.email = ["blatyo@gmail.com"]
|
10
|
-
s.homepage = ""
|
10
|
+
s.homepage = "https://blatyo.github.com/maybelline"
|
11
11
|
s.summary = %q{Maybe you should start using the maybe monad, stop checking for nil, and be confident}
|
12
12
|
s.description = %q{Maybe you should start using the maybe monad, stop checking for nil, and be confident}
|
13
13
|
|
@@ -20,5 +20,6 @@ Gem::Specification.new do |s|
|
|
20
20
|
|
21
21
|
# specify any dependencies here; for example:
|
22
22
|
s.add_development_dependency "rspec"
|
23
|
+
s.add_development_dependency "rake"
|
23
24
|
# s.add_runtime_dependency "rest-client"
|
24
25
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: maybelline
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-06-
|
12
|
+
date: 2012-06-30 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rspec
|
16
|
-
requirement: &
|
16
|
+
requirement: &70277833452260 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,7 +21,18 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :development
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70277833452260
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: rake
|
27
|
+
requirement: &70277833451820 !ruby/object:Gem::Requirement
|
28
|
+
none: false
|
29
|
+
requirements:
|
30
|
+
- - ! '>='
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '0'
|
33
|
+
type: :development
|
34
|
+
prerelease: false
|
35
|
+
version_requirements: *70277833451820
|
25
36
|
description: Maybe you should start using the maybe monad, stop checking for nil,
|
26
37
|
and be confident
|
27
38
|
email:
|
@@ -32,7 +43,9 @@ extra_rdoc_files: []
|
|
32
43
|
files:
|
33
44
|
- .gitignore
|
34
45
|
- .rspec
|
46
|
+
- .travis.yml
|
35
47
|
- Gemfile
|
48
|
+
- LICENSE
|
36
49
|
- README.md
|
37
50
|
- Rakefile
|
38
51
|
- lib/maybelline.rb
|
@@ -40,7 +53,7 @@ files:
|
|
40
53
|
- maybelline.gemspec
|
41
54
|
- spec/maybelline_spec.rb
|
42
55
|
- spec/spec_helper.rb
|
43
|
-
homepage:
|
56
|
+
homepage: https://blatyo.github.com/maybelline
|
44
57
|
licenses: []
|
45
58
|
post_install_message:
|
46
59
|
rdoc_options: []
|