reply 0.3.0 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 84e5fad805dc4cab2fe9e826bc77cb5791fd59a9
4
+ data.tar.gz: 60dd5002b7358d651b624dfb7a11ab09fe3373b5
5
+ SHA512:
6
+ metadata.gz: 4d5381706a43524c06584cf7d1e7072a9b1ac6b75519fca327f2be0fc949a8162cf7b9744e3dcf0e2c3754267f35f0e176dc501f44f1344803bd64e10b7e373a
7
+ data.tar.gz: 6630adb3454a143d1e22ae4306b76351f3a04dea9db528fa2e4ae6bfdf53de290f35845d81d2732bd75c53a9f0147a5eb35dc7f1f3f9c91f69982aa8804ad793
data/Gemfile CHANGED
@@ -6,10 +6,11 @@ source "http://rubygems.org"
6
6
  # Add dependencies to develop your gem here.
7
7
  # Include everything needed to run rake, tests, features, etc.
8
8
  group :development do
9
- gem 'rspec'
10
- gem 'guard-rspec'
11
- gem "rdoc", "~> 3.12"
12
- gem "bundler", "~> 1.0"
13
- gem "jeweler", "~> 1.8.7"
14
9
  gem 'active_attr', '~> 0.8'
10
+ gem 'bundler', '~> 1.0'
11
+ gem 'bogus', '~> 0.1'
12
+ gem 'guard-rspec', '~> 3.1'
13
+ gem 'jeweler', '~> 2.0'
14
+ gem 'rdoc', '~> 3.12'
15
+ gem 'rspec', '~> 2.14'
15
16
  end
@@ -15,8 +15,11 @@ GEM
15
15
  tzinfo (~> 0.3.37)
16
16
  addressable (2.3.5)
17
17
  atomic (1.1.14)
18
+ bogus (0.1.4)
19
+ dependor (>= 0.0.4)
18
20
  builder (3.1.4)
19
21
  coderay (1.0.9)
22
+ dependor (1.0.1)
20
23
  diff-lcs (1.2.4)
21
24
  faraday (0.8.8)
22
25
  multipart-post (~> 1.2.0)
@@ -43,13 +46,13 @@ GEM
43
46
  highline (1.6.19)
44
47
  httpauth (0.2.0)
45
48
  i18n (0.6.5)
46
- jeweler (1.8.7)
49
+ jeweler (2.0.1)
47
50
  builder
48
- bundler (~> 1.0)
51
+ bundler (>= 1.0)
49
52
  git (>= 1.2.5)
50
- github_api (= 0.10.1)
53
+ github_api
51
54
  highline (>= 1.6.15)
52
- nokogiri (= 1.5.10)
55
+ nokogiri (>= 1.5.10)
53
56
  rake
54
57
  rdoc
55
58
  json (1.8.0)
@@ -105,8 +108,9 @@ PLATFORMS
105
108
 
106
109
  DEPENDENCIES
107
110
  active_attr (~> 0.8)
111
+ bogus (~> 0.1)
108
112
  bundler (~> 1.0)
109
- guard-rspec
110
- jeweler (~> 1.8.7)
113
+ guard-rspec (~> 3.1)
114
+ jeweler (~> 2.0)
111
115
  rdoc (~> 3.12)
112
- rspec
116
+ rspec (~> 2.14)
data/Rakefile CHANGED
@@ -37,6 +37,7 @@ RSpec::Core::RakeTask.new(:spec)
37
37
  # end
38
38
 
39
39
  task :default => :spec
40
+ task :test => :spec
40
41
 
41
42
  # require 'rdoc/task'
42
43
  # Rake::RDocTask.new do |rdoc|
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.3.0
1
+ 0.5.0
@@ -55,10 +55,13 @@ class Reply
55
55
  end
56
56
  alias :success! :mark_as_success
57
57
 
58
- def mark_as_error
58
+ def mark_as_error(msg=nil)
59
59
  @simple_status = SIMPLE_STATUS_ERROR
60
+ add_errors(msg) if msg
61
+ self
60
62
  end
61
63
  alias :error! :mark_as_error
64
+ alias :fail! :mark_as_error
62
65
 
63
66
  def mark_as_warning
64
67
  @simple_status = SIMPLE_STATUS_WARNING
data/readme.md CHANGED
@@ -1,7 +1,7 @@
1
1
  Reply
2
2
  ======
3
3
 
4
- A simple class used to encapsulate the reply from a service
4
+ A simple class used to encapsulate the reply from a service / interactor
5
5
 
6
6
  [![Build Status](https://travis-ci.org/sporto/reply.png)](https://travis-ci.org/sporto/reply)
7
7
 
@@ -29,9 +29,15 @@ Usage
29
29
  # add error message and mark as error at the same time
30
30
  reply.add_error("Something bad happend")
31
31
 
32
- # add erroor messages and mark as error
32
+ # add error messages and mark as error
33
33
  reply.add_error(["Error 1", "Error 2"])
34
34
 
35
+ # reply.error! also accepts an optional message
36
+ reply.error!("I don't like you")
37
+
38
+ # reply.error returns the reply itself, so you can do one liners like:
39
+ return reply.error!("Didn't work")
40
+
35
41
  # check if reply was successful
36
42
  reply.successful?
37
43
  reply.success?
@@ -51,6 +57,25 @@ Usage
51
57
  reply.replace_messages_with_errors_for(active_record_object)
52
58
  ```
53
59
 
60
+ Testing
61
+ --------
62
+
63
+ rake spec
64
+
65
+ or
66
+
67
+ guard start
68
+
69
+ Release
70
+ ------
71
+
72
+ This gem uses jeweler
73
+ https://github.com/technicalpickles/jeweler
74
+
75
+ rake version:bump:minor
76
+ rake release
77
+
78
+
54
79
  Copyright
55
80
  ---------
56
- Copyright © 2013 Sebastian Porto. See LICENSE.txt for further details.
81
+ Copyright © 2014 Sebastian Porto. See LICENSE.txt for further details.
@@ -2,14 +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.0 ruby lib
5
6
 
6
7
  Gem::Specification.new do |s|
7
8
  s.name = "reply"
8
- s.version = "0.3.0"
9
+ s.version = "0.5.0"
9
10
 
10
11
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
12
+ s.require_paths = ["lib"]
11
13
  s.authors = ["Sebastian Porto"]
12
- s.date = "2013-09-25"
14
+ s.date = "2014-03-05"
13
15
  s.description = "An standarized reply object"
14
16
  s.email = "s@porto5.com"
15
17
  s.extra_rdoc_files = [
@@ -30,41 +32,41 @@ Gem::Specification.new do |s|
30
32
  "readme.md",
31
33
  "reply.gemspec",
32
34
  "spec/lib/reply/reply_spec.rb",
33
- "spec/spec_helper.rb",
34
- "test/helper.rb",
35
- "test/test_reply.rb"
35
+ "spec/spec_helper.rb"
36
36
  ]
37
37
  s.homepage = "http://github.com/sporto/reply"
38
38
  s.licenses = ["MIT"]
39
- s.require_paths = ["lib"]
40
- s.rubygems_version = "1.8.25"
39
+ s.rubygems_version = "2.2.1"
41
40
  s.summary = "An standarized reply object"
42
41
 
43
42
  if s.respond_to? :specification_version then
44
- s.specification_version = 3
43
+ s.specification_version = 4
45
44
 
46
45
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
47
- s.add_development_dependency(%q<rspec>, [">= 0"])
48
- s.add_development_dependency(%q<guard-rspec>, [">= 0"])
49
- s.add_development_dependency(%q<rdoc>, ["~> 3.12"])
50
- s.add_development_dependency(%q<bundler>, ["~> 1.0"])
51
- s.add_development_dependency(%q<jeweler>, ["~> 1.8.7"])
52
46
  s.add_development_dependency(%q<active_attr>, ["~> 0.8"])
47
+ s.add_development_dependency(%q<bundler>, ["~> 1.0"])
48
+ s.add_development_dependency(%q<bogus>, ["~> 0.1"])
49
+ s.add_development_dependency(%q<guard-rspec>, ["~> 3.1"])
50
+ s.add_development_dependency(%q<jeweler>, ["~> 2.0"])
51
+ s.add_development_dependency(%q<rdoc>, ["~> 3.12"])
52
+ s.add_development_dependency(%q<rspec>, ["~> 2.14"])
53
53
  else
54
- s.add_dependency(%q<rspec>, [">= 0"])
55
- s.add_dependency(%q<guard-rspec>, [">= 0"])
56
- s.add_dependency(%q<rdoc>, ["~> 3.12"])
57
- s.add_dependency(%q<bundler>, ["~> 1.0"])
58
- s.add_dependency(%q<jeweler>, ["~> 1.8.7"])
59
54
  s.add_dependency(%q<active_attr>, ["~> 0.8"])
55
+ s.add_dependency(%q<bundler>, ["~> 1.0"])
56
+ s.add_dependency(%q<bogus>, ["~> 0.1"])
57
+ s.add_dependency(%q<guard-rspec>, ["~> 3.1"])
58
+ s.add_dependency(%q<jeweler>, ["~> 2.0"])
59
+ s.add_dependency(%q<rdoc>, ["~> 3.12"])
60
+ s.add_dependency(%q<rspec>, ["~> 2.14"])
60
61
  end
61
62
  else
62
- s.add_dependency(%q<rspec>, [">= 0"])
63
- s.add_dependency(%q<guard-rspec>, [">= 0"])
64
- s.add_dependency(%q<rdoc>, ["~> 3.12"])
65
- s.add_dependency(%q<bundler>, ["~> 1.0"])
66
- s.add_dependency(%q<jeweler>, ["~> 1.8.7"])
67
63
  s.add_dependency(%q<active_attr>, ["~> 0.8"])
64
+ s.add_dependency(%q<bundler>, ["~> 1.0"])
65
+ s.add_dependency(%q<bogus>, ["~> 0.1"])
66
+ s.add_dependency(%q<guard-rspec>, ["~> 3.1"])
67
+ s.add_dependency(%q<jeweler>, ["~> 2.0"])
68
+ s.add_dependency(%q<rdoc>, ["~> 3.12"])
69
+ s.add_dependency(%q<rspec>, ["~> 2.14"])
68
70
  end
69
71
  end
70
72
 
@@ -113,24 +113,39 @@ describe Reply do
113
113
  end
114
114
  end
115
115
 
116
- describe ".success!" do
116
+ describe "#success!" do
117
117
  it "marks the reply as success" do
118
118
  reply.success!
119
119
  expect(reply).to be_successful
120
120
  end
121
121
  end
122
122
 
123
- describe ".mark_as_error" do
123
+ describe "#mark_as_error" do
124
124
  it "marks the reply as error" do
125
125
  reply.mark_as_error
126
126
  expect(reply).to be_failure
127
127
  end
128
+
129
+ it "returns the reply" do
130
+ expect(reply.mark_as_error).to eq(reply)
131
+ end
132
+
133
+ it "accepts an optional message" do
134
+ err = "XYZ"
135
+ reply.mark_as_error(err)
136
+ expect(reply.messages).to include(err)
137
+ end
128
138
  end
129
139
 
130
- describe ".error!" do
131
- it "marks the reply as error" do
132
- reply.error!
133
- expect(reply).to be_failure
140
+ describe "#error!" do
141
+ it 'delegates to mark_as_error' do
142
+ expect(reply.method(:error!)).to eq(reply.method(:mark_as_error))
143
+ end
144
+ end
145
+
146
+ describe "#fail!" do
147
+ it 'delegates to mark_as_error' do
148
+ expect(reply.method(:fail!)).to eq(reply.method(:mark_as_error))
134
149
  end
135
150
  end
136
151
 
@@ -4,6 +4,7 @@
4
4
  # loaded once.
5
5
 
6
6
  require 'active_attr'
7
+ require 'bogus/rspec'
7
8
 
8
9
  require File.expand_path('../../lib/reply', __FILE__)
9
10
  #
metadata CHANGED
@@ -1,112 +1,113 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: reply
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
5
- prerelease:
4
+ version: 0.5.0
6
5
  platform: ruby
7
6
  authors:
8
7
  - Sebastian Porto
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2013-09-25 00:00:00.000000000 Z
11
+ date: 2014-03-05 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
- name: rspec
14
+ name: active_attr
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
- - - ! '>='
17
+ - - ~>
20
18
  - !ruby/object:Gem::Version
21
- version: '0'
19
+ version: '0.8'
22
20
  type: :development
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
- - - ! '>='
24
+ - - ~>
28
25
  - !ruby/object:Gem::Version
29
- version: '0'
26
+ version: '0.8'
30
27
  - !ruby/object:Gem::Dependency
31
- name: guard-rspec
28
+ name: bundler
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
- - - ! '>='
31
+ - - ~>
36
32
  - !ruby/object:Gem::Version
37
- version: '0'
33
+ version: '1.0'
38
34
  type: :development
39
35
  prerelease: false
40
36
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
37
  requirements:
43
- - - ! '>='
38
+ - - ~>
44
39
  - !ruby/object:Gem::Version
45
- version: '0'
40
+ version: '1.0'
46
41
  - !ruby/object:Gem::Dependency
47
- name: rdoc
42
+ name: bogus
48
43
  requirement: !ruby/object:Gem::Requirement
49
- none: false
50
44
  requirements:
51
45
  - - ~>
52
46
  - !ruby/object:Gem::Version
53
- version: '3.12'
47
+ version: '0.1'
54
48
  type: :development
55
49
  prerelease: false
56
50
  version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
51
  requirements:
59
52
  - - ~>
60
53
  - !ruby/object:Gem::Version
61
- version: '3.12'
54
+ version: '0.1'
62
55
  - !ruby/object:Gem::Dependency
63
- name: bundler
56
+ name: guard-rspec
64
57
  requirement: !ruby/object:Gem::Requirement
65
- none: false
66
58
  requirements:
67
59
  - - ~>
68
60
  - !ruby/object:Gem::Version
69
- version: '1.0'
61
+ version: '3.1'
70
62
  type: :development
71
63
  prerelease: false
72
64
  version_requirements: !ruby/object:Gem::Requirement
73
- none: false
74
65
  requirements:
75
66
  - - ~>
76
67
  - !ruby/object:Gem::Version
77
- version: '1.0'
68
+ version: '3.1'
78
69
  - !ruby/object:Gem::Dependency
79
70
  name: jeweler
80
71
  requirement: !ruby/object:Gem::Requirement
81
- none: false
82
72
  requirements:
83
73
  - - ~>
84
74
  - !ruby/object:Gem::Version
85
- version: 1.8.7
75
+ version: '2.0'
86
76
  type: :development
87
77
  prerelease: false
88
78
  version_requirements: !ruby/object:Gem::Requirement
89
- none: false
90
79
  requirements:
91
80
  - - ~>
92
81
  - !ruby/object:Gem::Version
93
- version: 1.8.7
82
+ version: '2.0'
94
83
  - !ruby/object:Gem::Dependency
95
- name: active_attr
84
+ name: rdoc
96
85
  requirement: !ruby/object:Gem::Requirement
97
- none: false
98
86
  requirements:
99
87
  - - ~>
100
88
  - !ruby/object:Gem::Version
101
- version: '0.8'
89
+ version: '3.12'
102
90
  type: :development
103
91
  prerelease: false
104
92
  version_requirements: !ruby/object:Gem::Requirement
105
- none: false
106
93
  requirements:
107
94
  - - ~>
108
95
  - !ruby/object:Gem::Version
109
- version: '0.8'
96
+ version: '3.12'
97
+ - !ruby/object:Gem::Dependency
98
+ name: rspec
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ~>
102
+ - !ruby/object:Gem::Version
103
+ version: '2.14'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ~>
109
+ - !ruby/object:Gem::Version
110
+ version: '2.14'
110
111
  description: An standarized reply object
111
112
  email: s@porto5.com
112
113
  executables: []
@@ -129,34 +130,28 @@ files:
129
130
  - reply.gemspec
130
131
  - spec/lib/reply/reply_spec.rb
131
132
  - spec/spec_helper.rb
132
- - test/helper.rb
133
- - test/test_reply.rb
134
133
  homepage: http://github.com/sporto/reply
135
134
  licenses:
136
135
  - MIT
136
+ metadata: {}
137
137
  post_install_message:
138
138
  rdoc_options: []
139
139
  require_paths:
140
140
  - lib
141
141
  required_ruby_version: !ruby/object:Gem::Requirement
142
- none: false
143
142
  requirements:
144
- - - ! '>='
143
+ - - '>='
145
144
  - !ruby/object:Gem::Version
146
145
  version: '0'
147
- segments:
148
- - 0
149
- hash: -1892639974551080489
150
146
  required_rubygems_version: !ruby/object:Gem::Requirement
151
- none: false
152
147
  requirements:
153
- - - ! '>='
148
+ - - '>='
154
149
  - !ruby/object:Gem::Version
155
150
  version: '0'
156
151
  requirements: []
157
152
  rubyforge_project:
158
- rubygems_version: 1.8.25
153
+ rubygems_version: 2.2.1
159
154
  signing_key:
160
- specification_version: 3
155
+ specification_version: 4
161
156
  summary: An standarized reply object
162
157
  test_files: []
@@ -1,18 +0,0 @@
1
- require 'rubygems'
2
- require 'bundler'
3
- begin
4
- Bundler.setup(:default, :development)
5
- rescue Bundler::BundlerError => e
6
- $stderr.puts e.message
7
- $stderr.puts "Run `bundle install` to install missing gems"
8
- exit e.status_code
9
- end
10
- require 'test/unit'
11
- require 'shoulda'
12
-
13
- $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
14
- $LOAD_PATH.unshift(File.dirname(__FILE__))
15
- require 'reply'
16
-
17
- class Test::Unit::TestCase
18
- end
@@ -1,7 +0,0 @@
1
- require 'helper'
2
-
3
- class TestReply < Test::Unit::TestCase
4
- should "probably rename this file and start testing for real" do
5
- flunk "hey buddy, you should probably rename this file and start testing for real"
6
- end
7
- end