fp_rb 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +3 -0
- data/fp_rb.gemspec +0 -1
- data/lib/fp_rb/version.rb +1 -1
- data/lib/fp_rb.rb +29 -4
- metadata +3 -16
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1be61e229ee71c120b653342672b6caf5b7efac3
|
4
|
+
data.tar.gz: 4410e0e74838669916f26085919896b8cf2ac5bb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c43c2abb14e1a55ad11fbbb47430282c0b9b5c06f7df7c8220fcf76dc9c61c5d147e1745e6519824f7b93e21b667fcc20d8f557b705903ebddd9757ac49bb710
|
7
|
+
data.tar.gz: 053fc2cdc5eccf3639573bfded0f267da5355d3e211abdf1712e4c290860889197cf9ca84f1892d09cbb45a6501a040277b258fc8dcb5e2c55bb513426dd1d9c
|
data/.rubocop.yml
ADDED
data/fp_rb.gemspec
CHANGED
@@ -22,7 +22,6 @@ Gem::Specification.new do |spec|
|
|
22
22
|
spec.require_paths = ["lib"]
|
23
23
|
|
24
24
|
spec.add_runtime_dependency "superators19", "~>0.9.3"
|
25
|
-
spec.add_runtime_dependency "activesupport"
|
26
25
|
spec.add_development_dependency "bundler", "~> 1.14"
|
27
26
|
spec.add_development_dependency "rake", "~> 10.0"
|
28
27
|
spec.add_development_dependency "minitest", "~> 5.0"
|
data/lib/fp_rb/version.rb
CHANGED
data/lib/fp_rb.rb
CHANGED
@@ -3,11 +3,36 @@ require "fp_rb/version"
|
|
3
3
|
require 'fp_rb/operator'
|
4
4
|
require 'fp_rb/maybe'
|
5
5
|
require 'fp_rb/result'
|
6
|
-
|
6
|
+
|
7
|
+
class Module
|
8
|
+
# stolen from Rails mattr_accessor
|
9
|
+
def def_fn(*syms, instance_reader: true, instance_accessor: true, default: nil)
|
10
|
+
syms.each do |sym|
|
11
|
+
raise NameError.new("invalid attribute name: #{sym}") unless (sym =~ /\A[_A-Za-z]\w*\z/)
|
12
|
+
class_eval(<<-EOS, __FILE__, __LINE__ + 1)
|
13
|
+
@@#{sym} = nil unless defined? @@#{sym}
|
14
|
+
def self.#{sym}
|
15
|
+
@@#{sym}
|
16
|
+
end
|
17
|
+
EOS
|
18
|
+
|
19
|
+
if instance_reader && instance_accessor
|
20
|
+
class_eval(<<-EOS, __FILE__, __LINE__ + 1)
|
21
|
+
def #{sym}
|
22
|
+
@@#{sym}
|
23
|
+
end
|
24
|
+
EOS
|
25
|
+
end
|
26
|
+
|
27
|
+
sym_default_value = (block_given? && default.nil?) ? yield : default
|
28
|
+
class_variable_set("@@#{sym}", sym_default_value) unless sym_default_value.nil?
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
7
32
|
|
8
33
|
module FpRb
|
9
|
-
|
34
|
+
def_fn :and_then
|
10
35
|
|
11
|
-
@@and_then = ->
|
12
|
-
@@map = ->
|
36
|
+
@@and_then = ->f, a { a.and_then(f) }.curry
|
37
|
+
@@map = ->f, a { a.map(f) }.curry
|
13
38
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fp_rb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Martin Chabot
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-08-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: superators19
|
@@ -24,20 +24,6 @@ dependencies:
|
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: 0.9.3
|
27
|
-
- !ruby/object:Gem::Dependency
|
28
|
-
name: activesupport
|
29
|
-
requirement: !ruby/object:Gem::Requirement
|
30
|
-
requirements:
|
31
|
-
- - ">="
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version: '0'
|
34
|
-
type: :runtime
|
35
|
-
prerelease: false
|
36
|
-
version_requirements: !ruby/object:Gem::Requirement
|
37
|
-
requirements:
|
38
|
-
- - ">="
|
39
|
-
- !ruby/object:Gem::Version
|
40
|
-
version: '0'
|
41
27
|
- !ruby/object:Gem::Dependency
|
42
28
|
name: bundler
|
43
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -88,6 +74,7 @@ extensions: []
|
|
88
74
|
extra_rdoc_files: []
|
89
75
|
files:
|
90
76
|
- ".gitignore"
|
77
|
+
- ".rubocop.yml"
|
91
78
|
- ".travis.yml"
|
92
79
|
- CODE_OF_CONDUCT.md
|
93
80
|
- Gemfile
|