amenable 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: a475b65e0b28577bf21459d1267f9a80b32636b2ea9ad614a07ca02e2969e4e8
4
+ data.tar.gz: ce7f241ba21d1e0380e0027665f1b33464864b61f1fdf76b50b3e99644f1a9ad
5
+ SHA512:
6
+ metadata.gz: 8011289c31bad632ebefe20fc42edf4454cffb9ffbde0cd96e576e6ab1bf91f83ac8c707b3e4769af505f5d1bef10a1d428e38a526641b75af1a3cd08ae04988
7
+ data.tar.gz: 91bbdf8c82fe716f4d727f8b4a2212d906ec34cf9f9034ddd710a72e382d2336ec8f818fb2c27af0e043b10c7ed69448ada7023d8d0081fbcca27a0e92325467
data/lib/amenable.rb ADDED
@@ -0,0 +1,60 @@
1
+ require 'amenable/version'
2
+
3
+ module Amenable
4
+ def tighten(fn)
5
+ name, redefiner = parse(fn)
6
+ rebuild(fn, :tighten)
7
+
8
+ # remount
9
+ end
10
+
11
+ private
12
+
13
+ def parse fn
14
+ case fn
15
+ when Symbol
16
+ name = fn
17
+ fn = method(fn)
18
+ redefiner = method(:define_method)
19
+ when Method
20
+ name = fn.name
21
+ redefiner = method(:define_method)
22
+ end
23
+
24
+ [ name, redefiner ]
25
+ end
26
+
27
+ def rebuild(fn, mode:)
28
+ rest = keyrest = false
29
+ params = []
30
+ keys = []
31
+
32
+ fn.parameters.each do |type, name|
33
+ case type
34
+ when :req, :opt
35
+ params << name
36
+ when :key, :keyreq
37
+ keys << name
38
+ when :rest
39
+ rest = true
40
+ when :keyrest
41
+ keyrest = true
42
+ else
43
+ raise RuntimeError, "unexpected parameter type: #{type}"
44
+ end
45
+ end
46
+
47
+ proc do |*args, **kwargs, &block|
48
+ if mode == :tighten
49
+ # remove unreferenced params
50
+ args.slice! params.count unless rest
51
+ kwargs = kwargs.slice(*keys) unless keyrest
52
+ else
53
+ # loosen
54
+ end
55
+
56
+ puts "call(#{args}, #{kwargs})"
57
+ fn.call(*args, **kwargs, &block)
58
+ end
59
+ end
60
+ end
@@ -0,0 +1,3 @@
1
+ class Amenable
2
+ VERSION = '0.0.1'
3
+ end
@@ -0,0 +1,3 @@
1
+ describe Amenable do
2
+
3
+ end
metadata ADDED
@@ -0,0 +1,116 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: amenable
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Daniel Pepper
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2021-04-08 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: byebug
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: codecov
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: simplecov
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ description: Flexibility when you need it.
84
+ email:
85
+ executables: []
86
+ extensions: []
87
+ extra_rdoc_files: []
88
+ files:
89
+ - lib/amenable.rb
90
+ - lib/amenable/version.rb
91
+ - spec/amenable_spec.rb
92
+ homepage: https://github.com/dpep/amenable_rb
93
+ licenses:
94
+ - MIT
95
+ metadata: {}
96
+ post_install_message:
97
+ rdoc_options: []
98
+ require_paths:
99
+ - lib
100
+ required_ruby_version: !ruby/object:Gem::Requirement
101
+ requirements:
102
+ - - ">="
103
+ - !ruby/object:Gem::Version
104
+ version: '0'
105
+ required_rubygems_version: !ruby/object:Gem::Requirement
106
+ requirements:
107
+ - - ">="
108
+ - !ruby/object:Gem::Version
109
+ version: '0'
110
+ requirements: []
111
+ rubygems_version: 3.0.8
112
+ signing_key:
113
+ specification_version: 4
114
+ summary: Amenable
115
+ test_files:
116
+ - spec/amenable_spec.rb