letters 0.2.4 → 0.2.5
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +7 -7
- data/lib/letters/core_ext.rb +1 -1
- data/lib/letters/version.rb +1 -1
- data/spec/letters/core_ext_spec.rb +5 -5
- data/spec/letters/patch_spec.rb +2 -2
- metadata +15 -15
data/README.md
CHANGED
@@ -18,10 +18,10 @@ With Letters installed, you have a suite of methods available wherever you want
|
|
18
18
|
|
19
19
|
There are almost 20 Letters methods so far. You can find them [in the documentation](http://lettersrb.com/api).
|
20
20
|
|
21
|
-
Let's use with the `
|
21
|
+
Let's use with the `o` method as an example. It is one of the most familiar methods. Calling it prints the receiver to STDOUT and returns the receiver:
|
22
22
|
|
23
23
|
```ruby
|
24
|
-
{ foo: "bar" }.
|
24
|
+
{ foo: "bar" }.o
|
25
25
|
# => { foo: "bar" }
|
26
26
|
# prints { foo: "bar" }
|
27
27
|
```
|
@@ -37,20 +37,20 @@ words.grep(/interesting/).
|
|
37
37
|
join(", ")
|
38
38
|
```
|
39
39
|
|
40
|
-
If I want to know the state of your code after lines 3 and 5, all I have to do is add `.
|
40
|
+
If I want to know the state of your code after lines 3 and 5, all I have to do is add `.o` to each one:
|
41
41
|
|
42
42
|
```ruby
|
43
43
|
words.grep(/interesting/).
|
44
44
|
map(&:downcase).
|
45
|
-
group_by(&:length).
|
45
|
+
group_by(&:length).o.
|
46
46
|
values_at(5, 10).
|
47
|
-
slice(0..2).
|
47
|
+
slice(0..2).o.
|
48
48
|
join(", ")
|
49
49
|
```
|
50
50
|
|
51
|
-
Because the `
|
51
|
+
Because the `o` method (and nearly every Letters method) returns the original object, introducing it is only ever for side effects -- it won't change the output of your code.
|
52
52
|
|
53
53
|
This is significantly easier than breaking apart the pipeline using variable assignment or a hefty `tap` block.
|
54
54
|
|
55
|
-
The `
|
55
|
+
The `o` method takes options, too, so you can add a prefix message to the output or choose another output format -- like [YAML]() or [pretty print]().
|
56
56
|
|
data/lib/letters/core_ext.rb
CHANGED
data/lib/letters/version.rb
CHANGED
@@ -32,7 +32,7 @@ module Letters
|
|
32
32
|
|
33
33
|
# Methods that can take a block
|
34
34
|
hash.j { nil }.should == hash
|
35
|
-
hash.
|
35
|
+
hash.o { nil }.should == hash
|
36
36
|
end
|
37
37
|
|
38
38
|
describe "#a (assert)" do
|
@@ -182,25 +182,25 @@ module Letters
|
|
182
182
|
end
|
183
183
|
end
|
184
184
|
|
185
|
-
describe "#
|
185
|
+
describe "#o (print)" do
|
186
186
|
describe "when no format is given" do
|
187
187
|
it "writes the object as awesome_print to STDOUT" do
|
188
188
|
$stdout.should_receive(:puts).with(hash.awesome_inspect)
|
189
|
-
hash.
|
189
|
+
hash.o
|
190
190
|
end
|
191
191
|
end
|
192
192
|
|
193
193
|
describe "when a format is given" do
|
194
194
|
it "writes the object as that format to STDOUT" do
|
195
195
|
$stdout.should_receive(:puts).with(hash.to_yaml)
|
196
|
-
hash.
|
196
|
+
hash.o(:format => :yaml)
|
197
197
|
end
|
198
198
|
end
|
199
199
|
|
200
200
|
describe "when a block is given" do
|
201
201
|
it "write the result of the block, executed in the object's context" do
|
202
202
|
$stdout.should_receive(:puts).with(hash.length.awesome_inspect)
|
203
|
-
hash.
|
203
|
+
hash.o { length }.should == hash
|
204
204
|
end
|
205
205
|
end
|
206
206
|
end
|
data/spec/letters/patch_spec.rb
CHANGED
@@ -11,13 +11,13 @@ module Letters
|
|
11
11
|
Klass = Class.new
|
12
12
|
Letters.patch! Klass
|
13
13
|
k = Klass.new
|
14
|
-
k.
|
14
|
+
k.o.should == k
|
15
15
|
end
|
16
16
|
|
17
17
|
it "adds Letters::CoreExt to objects" do
|
18
18
|
obj = Object.new
|
19
19
|
Letters.patch! obj
|
20
|
-
obj.
|
20
|
+
obj.o.should == obj
|
21
21
|
end
|
22
22
|
end
|
23
23
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: letters
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.5
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -13,7 +13,7 @@ date: 2012-10-02 00:00:00.000000000Z
|
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: awesome_print
|
16
|
-
requirement: &
|
16
|
+
requirement: &70197105220140 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70197105220140
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: activesupport
|
27
|
-
requirement: &
|
27
|
+
requirement: &70197105219700 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: '0'
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *70197105219700
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: xml-simple
|
38
|
-
requirement: &
|
38
|
+
requirement: &70197105219280 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ! '>='
|
@@ -43,10 +43,10 @@ dependencies:
|
|
43
43
|
version: '0'
|
44
44
|
type: :runtime
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *70197105219280
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: colorize
|
49
|
-
requirement: &
|
49
|
+
requirement: &70197105218860 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ! '>='
|
@@ -54,10 +54,10 @@ dependencies:
|
|
54
54
|
version: '0'
|
55
55
|
type: :runtime
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *70197105218860
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
59
|
name: debugger
|
60
|
-
requirement: &
|
60
|
+
requirement: &70197105218440 !ruby/object:Gem::Requirement
|
61
61
|
none: false
|
62
62
|
requirements:
|
63
63
|
- - ! '>='
|
@@ -65,10 +65,10 @@ dependencies:
|
|
65
65
|
version: '0'
|
66
66
|
type: :runtime
|
67
67
|
prerelease: false
|
68
|
-
version_requirements: *
|
68
|
+
version_requirements: *70197105218440
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: timecop
|
71
|
-
requirement: &
|
71
|
+
requirement: &70197105218020 !ruby/object:Gem::Requirement
|
72
72
|
none: false
|
73
73
|
requirements:
|
74
74
|
- - ! '>='
|
@@ -76,10 +76,10 @@ dependencies:
|
|
76
76
|
version: '0'
|
77
77
|
type: :development
|
78
78
|
prerelease: false
|
79
|
-
version_requirements: *
|
79
|
+
version_requirements: *70197105218020
|
80
80
|
- !ruby/object:Gem::Dependency
|
81
81
|
name: rspec
|
82
|
-
requirement: &
|
82
|
+
requirement: &70197089101100 !ruby/object:Gem::Requirement
|
83
83
|
none: false
|
84
84
|
requirements:
|
85
85
|
- - ! '>='
|
@@ -87,7 +87,7 @@ dependencies:
|
|
87
87
|
version: '0'
|
88
88
|
type: :development
|
89
89
|
prerelease: false
|
90
|
-
version_requirements: *
|
90
|
+
version_requirements: *70197089101100
|
91
91
|
description: Letters brings Ruby debugging into the 21st century. It leverages print,
|
92
92
|
the debugger, control transfer, even computer beeps to let you see into your code's
|
93
93
|
state.
|