Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 27d9430

Browse files
author
Kirill Shevchenko
authoredSep 7, 2017
Merge pull request #1 from operators-rb/refactoring
refactoring
2 parents e7dd1c6 + 4b3bfa6 commit 27d9430

File tree

8 files changed

+24
-18
lines changed

8 files changed

+24
-18
lines changed
 

‎README.md

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,14 @@
11
# Operators::Service
22

3-
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/operators/service`. To experiment with that code, run `bin/console` for an interactive prompt.
3+
Operators::Service is a lightweight implementation of Service Object based on Either Monad. That gives an home of application business logic.
44

5-
TODO: Delete this and the text above, and describe your gem
5+
Service Objects are created when an action:
6+
7+
* Uses integration with external services
8+
9+
* Uses several models
10+
11+
* Is complex (such as calculating sales statistics)
612

713
## Installation
814

@@ -32,7 +38,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
3238

3339
## Contributing
3440

35-
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/operators-service.
41+
Bug reports and pull requests are welcome on GitHub at https://github.com/operators-rb/operators-service.
3642

3743

3844
## License

‎Rakefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
require "bundler/gem_tasks"
2-
task :default => :spec
1+
require 'bundler/gem_tasks'
2+
task default: :spec

‎lib/operators-service.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
require 'dry-monads'
2+
require 'operators/service'

‎lib/operators/service.rb

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
require 'dry-monads'
2-
31
module Operators
42
class Service
53
def self.rescue_callbacks(*exceptions)
@@ -37,7 +35,7 @@ def success_wrap(result)
3735
end
3836

3937
def calling
40-
raise 'Must be redefined'
38+
raise 'Not implemented'
4139
end
4240
end
4341
end

‎lib/operators_service.rb

Lines changed: 0 additions & 1 deletion
This file was deleted.

‎operators-service.gemspec

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
11
# coding: utf-8
2+
23
lib = File.expand_path('../lib', __FILE__)
34
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
45

56
Gem::Specification.new do |spec|
67
spec.name = 'operators-service'
7-
spec.version = '0.1.1'
8+
spec.version = '0.2.0'
89
spec.authors = ['Yaroslav Bezrukavyi', 'Kirill Shevchenko']
910
spec.email = ['yaroslav.bezrukavyi@gmail.com', 'hello@kirillshevch.com']
1011

1112
spec.summary = 'You will always know the type of the result'
12-
spec.description = 'Service is based on Dry::Monads'
13+
spec.description = 'Service Object is based on Either Monad'
1314
spec.homepage = 'http://operators-rb.org'
1415
spec.license = 'MIT'
1516

@@ -20,7 +21,7 @@ Gem::Specification.new do |spec|
2021

2122
spec.add_dependency 'dry-monads', '~> 0.3.1'
2223

23-
spec.add_development_dependency 'bundler', '~> 1.15.4'
24+
spec.add_development_dependency 'bundler', '~> 1.14'
2425
spec.add_development_dependency 'rake', '~> 10.0'
2526
spec.add_development_dependency 'rspec', '~> 3.0'
2627
spec.add_development_dependency 'byebug', '~> 3.5.0'

‎spec/operators/service_spec.rb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
RSpec.describe Operators::Service do
1+
describe Operators::Service do
22
before do
3-
class TestSerivce < Operators::Service
3+
class TestService < Operators::Service
44
rescue_callbacks SyntaxError
55

66
def initialize(data, result)
@@ -19,17 +19,17 @@ def except_error(error)
1919
end
2020

2121
it 'success result' do
22-
result = TestSerivce.call('data', true)
22+
result = TestService.call('data', true)
2323
expect(result.success?).to be_truthy
2424
end
2525

2626
it 'failure result' do
27-
result = TestSerivce.call('data', false)
27+
result = TestService.call('data', false)
2828
expect(result.success?).to be_falsey
2929
end
3030

3131
context 'catch error' do
32-
subject { TestSerivce.new('error', true) }
32+
subject { TestService.new('error', true) }
3333

3434
it 'catch' do
3535
allow(subject).to receive(:calling).and_raise(SyntaxError)

‎spec/spec_helper.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
require 'bundler/setup'
22
require 'byebug'
3-
require 'operators/service'
3+
require 'operators-service'
44

55
RSpec.configure do |config|
66
config.order = :random

0 commit comments

Comments
 (0)
Please sign in to comment.