rlet 0.7.0 → 0.8.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +29 -4
- data/lib/rlet.rb +6 -0
- data/lib/rlet/expose.rb +1 -0
- data/lib/rlet/let.rb +8 -1
- data/lib/rlet/version.rb +3 -0
- metadata +19 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0d88f8fb70037560e1a016207871a9e89024bd93
|
4
|
+
data.tar.gz: d7b35547adbd29ad6cb670f50b1e420501813992
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 03d715937769b7356083fe1dfccada13155701dce32eb68a759f060e4669eeb0a23b27dd7d3b0ced3e1b6ead5ef8b6d3ce00832e755a23807e29204e0867dbbd
|
7
|
+
data.tar.gz: f0911a88f8299d5ee62e02735408c624cd6a3d27990b05473a90f3525f40f0398602915d9618c4ead587ad85cc1539daf50cbcdddf3d4037299d7e4e237008ef
|
data/README.md
CHANGED
@@ -28,8 +28,6 @@ Or from bundler
|
|
28
28
|
|
29
29
|
The gems contain two modules, Let and Concern. You can use them like so:
|
30
30
|
|
31
|
-
require 'rlet'
|
32
|
-
|
33
31
|
class ContactsController
|
34
32
|
include Let
|
35
33
|
include RestfulResource
|
@@ -50,6 +48,32 @@ The gems contain two modules, Let and Concern. You can use them like so:
|
|
50
48
|
end
|
51
49
|
end
|
52
50
|
|
51
|
+
Normally, you want to expose the methods as public methods. Sometimes,
|
52
|
+
you want to use protected methods. You can do so with `letp`:
|
53
|
+
|
54
|
+
class ContactsController
|
55
|
+
include Let
|
56
|
+
include RestfulResource
|
57
|
+
|
58
|
+
letp(:model) { Contact }
|
59
|
+
|
60
|
+
def show
|
61
|
+
respond_with resource
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
module RestfulResource
|
66
|
+
extend Concern
|
67
|
+
|
68
|
+
included do
|
69
|
+
letp(:resource) { model.find(id) }
|
70
|
+
letp(:id) { params[:id] }
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
This is useful for Rails installation that still have dynamically inferred
|
75
|
+
routes.
|
76
|
+
|
53
77
|
Concern is embedded from ActiveSupport. If ActiveSupport::Concern is loaded, it will use that. This
|
54
78
|
allows one to use concerns without having ActiveSupport as a dependency.
|
55
79
|
|
@@ -81,6 +105,8 @@ Additionally, to expose `let()` with instance variables for use in templates, yo
|
|
81
105
|
end
|
82
106
|
end
|
83
107
|
|
108
|
+
***DEPRECATION NOTICE*** Expose is not needed in Rails. Use `helper_method` instead
|
109
|
+
|
84
110
|
### LazyOptions
|
85
111
|
|
86
112
|
One pattern that comes up is creating a class which takes an option as an initializer, and then
|
@@ -171,11 +197,10 @@ We can refactor into:
|
|
171
197
|
|
172
198
|
This pattern occurs so frequently that `rlet` not includes a `LazyOptions` concern.
|
173
199
|
|
174
|
-
require 'rlet/lazy_options'
|
175
200
|
module Intentions
|
176
201
|
class Promise
|
177
202
|
include Let
|
178
|
-
include LazyOptions
|
203
|
+
include RLet::LazyOptions
|
179
204
|
extend Intentions::Concerns::Register
|
180
205
|
|
181
206
|
let(:promiser) { options[:promiser] }
|
data/lib/rlet.rb
CHANGED
data/lib/rlet/expose.rb
CHANGED
data/lib/rlet/let.rb
CHANGED
@@ -6,9 +6,16 @@ module Let
|
|
6
6
|
module ClassMethods
|
7
7
|
def let(name, &block)
|
8
8
|
define_method(name) do
|
9
|
-
__memoized
|
9
|
+
__memoized.fetch(name) do
|
10
|
+
__memoized[name] = instance_eval(&block)
|
11
|
+
end
|
10
12
|
end
|
11
13
|
end
|
14
|
+
|
15
|
+
def letp(name, &block)
|
16
|
+
let(name, &block)
|
17
|
+
protected(name)
|
18
|
+
end
|
12
19
|
end
|
13
20
|
|
14
21
|
# Implementation based on Rspec let()
|
data/lib/rlet/version.rb
ADDED
metadata
CHANGED
@@ -1,15 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rlet
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.8.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ho-Sheng Hsiao
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
12
|
-
dependencies:
|
11
|
+
date: 2016-03-31 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rspec
|
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'
|
13
27
|
description: Use rspec's let() outside of rspec with concerns and functional operators
|
14
28
|
email:
|
15
29
|
- talktohosh@gmail.com
|
@@ -25,6 +39,7 @@ files:
|
|
25
39
|
- lib/rlet/functional.rb
|
26
40
|
- lib/rlet/lazy_options.rb
|
27
41
|
- lib/rlet/let.rb
|
42
|
+
- lib/rlet/version.rb
|
28
43
|
homepage: http://github.com/hosh/rlet
|
29
44
|
licenses: []
|
30
45
|
metadata: {}
|
@@ -44,7 +59,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
44
59
|
version: 1.3.6
|
45
60
|
requirements: []
|
46
61
|
rubyforge_project: rlet
|
47
|
-
rubygems_version: 2.
|
62
|
+
rubygems_version: 2.4.5.1
|
48
63
|
signing_key:
|
49
64
|
specification_version: 4
|
50
65
|
summary: Lazy-eval and functional helpers
|