reply 0.5.0 → 0.5.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/VERSION +1 -1
- data/lib/reply/reply.rb +6 -2
- data/readme.md +1 -1
- data/reply.gemspec +3 -3
- data/spec/lib/reply/reply_spec.rb +64 -30
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4af0f4c02de394ac3c9c0ef136327011accd1766
|
4
|
+
data.tar.gz: ff55a29937b2cf76ae2ceea6dc090968b0c36f55
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8fc1aca59c88a5d0ebc4cfdf98618453a24fc66f372313e6d2f7ee23fecd4b1b0f8663b87dcb9a16d85ecf8e002dfcdffbd4e8ca89777691651a9633c1edf0a4
|
7
|
+
data.tar.gz: b192c27a99beb86ffad139b9d7f946a50529fac715ae9a0922cfb911de93b7473f32c81b12ada01e1931a1d2ca1b8f3ec6961dc23d38ea3c2751e93c0562dc23
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.5.
|
1
|
+
0.5.1
|
data/lib/reply/reply.rb
CHANGED
@@ -50,8 +50,10 @@ class Reply
|
|
50
50
|
end
|
51
51
|
alias :add_error :add_errors
|
52
52
|
|
53
|
-
def mark_as_success
|
53
|
+
def mark_as_success(msg=nil)
|
54
54
|
@simple_status = SIMPLE_STATUS_SUCCESS
|
55
|
+
add_messages(msg) if msg
|
56
|
+
self
|
55
57
|
end
|
56
58
|
alias :success! :mark_as_success
|
57
59
|
|
@@ -63,8 +65,10 @@ class Reply
|
|
63
65
|
alias :error! :mark_as_error
|
64
66
|
alias :fail! :mark_as_error
|
65
67
|
|
66
|
-
def mark_as_warning
|
68
|
+
def mark_as_warning(msg=nil)
|
67
69
|
@simple_status = SIMPLE_STATUS_WARNING
|
70
|
+
add_messages(msg) if msg
|
71
|
+
self
|
68
72
|
end
|
69
73
|
alias :warning! :mark_as_warning
|
70
74
|
|
data/readme.md
CHANGED
@@ -32,7 +32,7 @@ Usage
|
|
32
32
|
# add error messages and mark as error
|
33
33
|
reply.add_error(["Error 1", "Error 2"])
|
34
34
|
|
35
|
-
# reply.error! also
|
35
|
+
# reply.error! .success!, .warning! also accept an optional message
|
36
36
|
reply.error!("I don't like you")
|
37
37
|
|
38
38
|
# reply.error returns the reply itself, so you can do one liners like:
|
data/reply.gemspec
CHANGED
@@ -2,16 +2,16 @@
|
|
2
2
|
# DO NOT EDIT THIS FILE DIRECTLY
|
3
3
|
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
|
-
# stub: reply 0.5.
|
5
|
+
# stub: reply 0.5.1 ruby lib
|
6
6
|
|
7
7
|
Gem::Specification.new do |s|
|
8
8
|
s.name = "reply"
|
9
|
-
s.version = "0.5.
|
9
|
+
s.version = "0.5.1"
|
10
10
|
|
11
11
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
12
12
|
s.require_paths = ["lib"]
|
13
13
|
s.authors = ["Sebastian Porto"]
|
14
|
-
s.date = "2014-03-
|
14
|
+
s.date = "2014-03-07"
|
15
15
|
s.description = "An standarized reply object"
|
16
16
|
s.email = "s@porto5.com"
|
17
17
|
s.extra_rdoc_files = [
|
@@ -13,7 +13,7 @@ describe Reply do
|
|
13
13
|
|
14
14
|
let(:reply) { Reply.new }
|
15
15
|
|
16
|
-
describe '
|
16
|
+
describe '#simple_status' do
|
17
17
|
|
18
18
|
it "is successful by default" do
|
19
19
|
expect(reply).to be_successful
|
@@ -34,7 +34,7 @@ describe Reply do
|
|
34
34
|
end
|
35
35
|
end
|
36
36
|
|
37
|
-
describe '
|
37
|
+
describe '#status' do
|
38
38
|
it 'can be set in the initialiser' do
|
39
39
|
reply = Reply.new(status: 401)
|
40
40
|
expect(reply.status).to eq(401)
|
@@ -46,7 +46,7 @@ describe Reply do
|
|
46
46
|
end
|
47
47
|
end
|
48
48
|
|
49
|
-
describe '
|
49
|
+
describe '#replace_messages' do
|
50
50
|
|
51
51
|
it 'accepts an array' do
|
52
52
|
arr = [1,2]
|
@@ -59,10 +59,9 @@ describe Reply do
|
|
59
59
|
reply.replace_messages(str)
|
60
60
|
expect(reply.messages).to eq([str])
|
61
61
|
end
|
62
|
-
|
63
62
|
end
|
64
63
|
|
65
|
-
describe '
|
64
|
+
describe '#add_messages' do
|
66
65
|
|
67
66
|
it 'accepts an array' do
|
68
67
|
arr = [1,2]
|
@@ -78,7 +77,7 @@ describe Reply do
|
|
78
77
|
|
79
78
|
end
|
80
79
|
|
81
|
-
describe "
|
80
|
+
describe "#add_error" do
|
82
81
|
before do
|
83
82
|
reply.add_error("Error")
|
84
83
|
end
|
@@ -92,7 +91,7 @@ describe Reply do
|
|
92
91
|
end
|
93
92
|
end
|
94
93
|
|
95
|
-
describe
|
94
|
+
describe '#add_errors' do
|
96
95
|
before do
|
97
96
|
reply.add_errors(["Error", "Another Error"])
|
98
97
|
end
|
@@ -106,27 +105,36 @@ describe Reply do
|
|
106
105
|
end
|
107
106
|
end
|
108
107
|
|
109
|
-
describe
|
108
|
+
describe '#mark_as_success' do
|
110
109
|
it "marks the reply as success" do
|
111
110
|
reply.mark_as_success
|
112
111
|
expect(reply).to be_successful
|
113
112
|
end
|
114
|
-
end
|
115
113
|
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
114
|
+
it "returns self" do
|
115
|
+
expect(reply.mark_as_success).to eq(reply)
|
116
|
+
end
|
117
|
+
|
118
|
+
it 'accepts a message' do
|
119
|
+
msg = "XYZ"
|
120
|
+
reply.mark_as_success(msg)
|
121
|
+
expect(reply.messages).to include(msg)
|
122
|
+
end
|
123
|
+
|
124
|
+
it 'doesnt remove previous messages' do
|
125
|
+
reply.mark_as_success('a')
|
126
|
+
reply.mark_as_success('b')
|
127
|
+
expect(reply.messages.count).to eq(2)
|
120
128
|
end
|
121
129
|
end
|
122
130
|
|
123
|
-
describe
|
131
|
+
describe '#mark_as_error' do
|
124
132
|
it "marks the reply as error" do
|
125
133
|
reply.mark_as_error
|
126
134
|
expect(reply).to be_failure
|
127
135
|
end
|
128
136
|
|
129
|
-
it "returns
|
137
|
+
it "returns self" do
|
130
138
|
expect(reply.mark_as_error).to eq(reply)
|
131
139
|
end
|
132
140
|
|
@@ -135,35 +143,62 @@ describe Reply do
|
|
135
143
|
reply.mark_as_error(err)
|
136
144
|
expect(reply.messages).to include(err)
|
137
145
|
end
|
146
|
+
|
147
|
+
it 'doesnt remove previous messages' do
|
148
|
+
reply.mark_as_error('a')
|
149
|
+
reply.mark_as_error('b')
|
150
|
+
expect(reply.messages.count).to eq(2)
|
151
|
+
end
|
138
152
|
end
|
139
153
|
|
140
|
-
describe
|
141
|
-
it
|
142
|
-
|
154
|
+
describe '#mark_as_warning' do
|
155
|
+
it "marks the reply as warning" do
|
156
|
+
reply.mark_as_warning
|
157
|
+
expect(reply).to be_warning
|
158
|
+
end
|
159
|
+
|
160
|
+
it "returns self" do
|
161
|
+
expect(reply.mark_as_warning).to eq(reply)
|
162
|
+
end
|
163
|
+
|
164
|
+
it 'accepts a message' do
|
165
|
+
msg = "XYZ"
|
166
|
+
reply.mark_as_warning(msg)
|
167
|
+
expect(reply.messages).to include(msg)
|
168
|
+
end
|
169
|
+
|
170
|
+
it 'doesnt remove previous messages' do
|
171
|
+
reply.mark_as_warning('a')
|
172
|
+
reply.mark_as_warning('b')
|
173
|
+
expect(reply.messages.count).to eq(2)
|
143
174
|
end
|
144
175
|
end
|
145
176
|
|
146
|
-
describe
|
177
|
+
describe '#success!' do
|
178
|
+
it "delegates to mark_as_success" do
|
179
|
+
expect(reply.method(:success!)).to eq(reply.method(:mark_as_success))
|
180
|
+
end
|
181
|
+
end
|
182
|
+
|
183
|
+
describe '#error!' do
|
147
184
|
it 'delegates to mark_as_error' do
|
148
|
-
expect(reply.method(:
|
185
|
+
expect(reply.method(:error!)).to eq(reply.method(:mark_as_error))
|
149
186
|
end
|
150
187
|
end
|
151
188
|
|
152
|
-
describe
|
153
|
-
it
|
154
|
-
reply.
|
155
|
-
expect(reply).to be_warning
|
189
|
+
describe '#fail!' do
|
190
|
+
it 'delegates to mark_as_error' do
|
191
|
+
expect(reply.method(:fail!)).to eq(reply.method(:mark_as_error))
|
156
192
|
end
|
157
193
|
end
|
158
194
|
|
159
|
-
describe
|
160
|
-
it "
|
161
|
-
reply.warning!
|
162
|
-
expect(reply).to be_warning
|
195
|
+
describe '#warning!' do
|
196
|
+
it "delegates to mark_as_warning" do
|
197
|
+
expect(reply.method(:warning!)).to eq(reply.method(:mark_as_warning))
|
163
198
|
end
|
164
199
|
end
|
165
200
|
|
166
|
-
describe
|
201
|
+
describe '#replace_messages_with_errors_for' do
|
167
202
|
let(:invalid_object) { Monkey.new }
|
168
203
|
|
169
204
|
before do
|
@@ -180,5 +215,4 @@ describe Reply do
|
|
180
215
|
end
|
181
216
|
end
|
182
217
|
|
183
|
-
|
184
218
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: reply
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sebastian Porto
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-03-
|
11
|
+
date: 2014-03-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: active_attr
|