orc 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +37 -0
- data/.rspec +4 -0
- data/.ruby-gemset +1 -0
- data/.ruby-version +1 -0
- data/.travis.yml +21 -0
- data/CONTRIBUTING.md +11 -0
- data/Changelog.md +1 -0
- data/Gemfile +12 -0
- data/Gemfile.devtools +71 -0
- data/Guardfile +18 -0
- data/LICENSE +20 -0
- data/README.md +70 -0
- data/Rakefile +6 -0
- data/TODO.md +1 -0
- data/config/devtools.yml +2 -0
- data/config/flay.yml +3 -0
- data/config/flog.yml +2 -0
- data/config/mutant.yml +3 -0
- data/config/reek.yml +104 -0
- data/config/rubocop.yml +75 -0
- data/config/yardstick.yml +2 -0
- data/lib/orc.rb +71 -0
- data/lib/orc/version.rb +5 -0
- data/orc.gemspec +25 -0
- data/spec/spec_helper.rb +29 -0
- data/spec/unit/orc/.gitkeep +0 -0
- data/spec/unit/orc/result_spec.rb +42 -0
- metadata +155 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 57771a0ccf6f041a6fa4b078d8e1afd949a45109
|
4
|
+
data.tar.gz: d516bad7021c748534a91cba5a83e0128631fb48
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 6473d492c84c8c6a7f5cd620470199e19af61762043c9e9ab9cadfb135dc1b83c0f53e7c0752203d5c699f2f3c9f07565c1e6a3e90e1fa28a9d91578df46d26b
|
7
|
+
data.tar.gz: a0433644c852466a2efaba48dbaf11e7d9a35ca6d2614cc24f98e3d9019d90c97a49cb98dc7d597e203aa8150a0cc7ef4df0ca07389c4568a7737cecd28c46cb
|
data/.gitignore
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
## MAC OS
|
2
|
+
.DS_Store
|
3
|
+
|
4
|
+
## TEXTMATE
|
5
|
+
*.tmproj
|
6
|
+
tmtags
|
7
|
+
|
8
|
+
## EMACS
|
9
|
+
*~
|
10
|
+
\#*
|
11
|
+
.\#*
|
12
|
+
|
13
|
+
## VIM
|
14
|
+
*.swp
|
15
|
+
|
16
|
+
## Rubinius
|
17
|
+
*.rbc
|
18
|
+
.rbx
|
19
|
+
|
20
|
+
## PROJECT::GENERAL
|
21
|
+
*.gem
|
22
|
+
coverage
|
23
|
+
profiling
|
24
|
+
turbulence
|
25
|
+
rdoc
|
26
|
+
pkg
|
27
|
+
tmp
|
28
|
+
doc
|
29
|
+
log
|
30
|
+
.yardoc
|
31
|
+
measurements
|
32
|
+
|
33
|
+
## BUNDLER
|
34
|
+
.bundle
|
35
|
+
Gemfile.lock
|
36
|
+
|
37
|
+
## PROJECT::SPECIFIC
|
data/.rspec
ADDED
data/.ruby-gemset
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
orc
|
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
2.1.2
|
data/.travis.yml
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
language: ruby
|
2
|
+
before_install: gem install bundler
|
3
|
+
bundler_args: --without yard guard benchmarks
|
4
|
+
script: "bundle exec rake ci"
|
5
|
+
rvm:
|
6
|
+
- 1.9.3
|
7
|
+
- 2.1.2
|
8
|
+
- ruby-head
|
9
|
+
- jruby-19mode
|
10
|
+
- jruby-head
|
11
|
+
- rbx-2
|
12
|
+
matrix:
|
13
|
+
include:
|
14
|
+
- rvm: jruby-19mode
|
15
|
+
env: JRUBY_OPTS="$JRUBY_OPTS --debug"
|
16
|
+
- rvm: jruby-head
|
17
|
+
env: JRUBY_OPTS="$JRUBY_OPTS --debug"
|
18
|
+
allow_failures:
|
19
|
+
- rvm: ruby-head
|
20
|
+
notifications:
|
21
|
+
email: false
|
data/CONTRIBUTING.md
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
Contributing
|
2
|
+
------------
|
3
|
+
|
4
|
+
* If you want your code merged into the mainline, please discuss the proposed changes with me before doing any work on it.
|
5
|
+
* Fork the project.
|
6
|
+
* Make your feature addition or bug fix.
|
7
|
+
* Follow this [style guide](https://github.com/dkubb/styleguide).
|
8
|
+
* Add specs for it. This is important so I don't break it in a future version unintentionally. Tests must cover all branches within the code, and code must be fully covered.
|
9
|
+
* Commit, do not mess with Rakefile, version, or history. (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
|
10
|
+
* Run "rake ci". This must pass and not show any regressions in the metrics for the code to be merged.
|
11
|
+
* Send me a pull request. Bonus points for topic branches.
|
data/Changelog.md
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
# v0.0.1 (Not yet released)
|
data/Gemfile
ADDED
data/Gemfile.devtools
ADDED
@@ -0,0 +1,71 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
group :development do
|
4
|
+
gem 'rake', '~> 10.3.2'
|
5
|
+
gem 'rspec', '~> 3.0.0'
|
6
|
+
gem 'rspec-its', '~> 1.0.1'
|
7
|
+
gem 'yard', '~> 0.8.7.4'
|
8
|
+
|
9
|
+
platform :rbx do
|
10
|
+
gem 'rubysl-singleton', '~> 2.0.0'
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
group :yard do
|
15
|
+
gem 'kramdown', '~> 1.3.3'
|
16
|
+
end
|
17
|
+
|
18
|
+
group :guard do
|
19
|
+
gem 'guard', '~> 2.6.1'
|
20
|
+
gem 'guard-bundler', '~> 2.0.0'
|
21
|
+
gem 'guard-rspec', '~> 4.2.9'
|
22
|
+
gem 'guard-rubocop', '~> 1.1.0'
|
23
|
+
|
24
|
+
# file system change event handling
|
25
|
+
gem 'listen', '~> 2.7.7'
|
26
|
+
gem 'rb-fchange', '~> 0.0.6', require: false
|
27
|
+
gem 'rb-fsevent', '~> 0.9.4', require: false
|
28
|
+
gem 'rb-inotify', '~> 0.9.5', require: false
|
29
|
+
|
30
|
+
# notification handling
|
31
|
+
gem 'libnotify', '~> 0.8.3', require: false
|
32
|
+
gem 'rb-notifu', '~> 0.0.4', require: false
|
33
|
+
gem 'terminal-notifier-guard', '~> 1.5.3', require: false
|
34
|
+
end
|
35
|
+
|
36
|
+
group :metrics do
|
37
|
+
gem 'coveralls', '~> 0.7.0'
|
38
|
+
gem 'flay', '~> 2.5.0'
|
39
|
+
gem 'flog', '~> 4.2.1'
|
40
|
+
gem 'reek', '~> 1.3.7'
|
41
|
+
gem 'rubocop', '~> 0.23.0'
|
42
|
+
gem 'simplecov', '~> 0.7.1'
|
43
|
+
gem 'yardstick', '~> 0.9.9'
|
44
|
+
|
45
|
+
platforms :mri do
|
46
|
+
gem 'mutant', '~> 0.5.23'
|
47
|
+
gem 'mutant-rspec', '~> 0.5.21'
|
48
|
+
end
|
49
|
+
|
50
|
+
platforms :ruby_19, :ruby_20 do
|
51
|
+
gem 'yard-spellcheck', '~> 0.1.5'
|
52
|
+
end
|
53
|
+
|
54
|
+
platform :rbx do
|
55
|
+
gem 'json', '~> 1.8.1'
|
56
|
+
gem 'racc', '~> 1.4.11'
|
57
|
+
gem 'rubysl-logger', '~> 2.0.0'
|
58
|
+
gem 'rubysl-open-uri', '~> 2.0.0'
|
59
|
+
gem 'rubysl-prettyprint', '~> 2.0.3'
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
group :benchmarks do
|
64
|
+
gem 'rbench', '~> 0.2.3'
|
65
|
+
end
|
66
|
+
|
67
|
+
platform :jruby do
|
68
|
+
group :jruby do
|
69
|
+
gem 'jruby-openssl', '~> 0.9.4'
|
70
|
+
end
|
71
|
+
end
|
data/Guardfile
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
guard :bundler do
|
4
|
+
watch('Gemfile')
|
5
|
+
end
|
6
|
+
|
7
|
+
guard :rspec, :all_on_start => false, :all_after_pass => false, :cli => '--fail-fast --seed 1' do
|
8
|
+
# run all specs if the spec_helper or supporting files files are modified
|
9
|
+
watch('spec/spec_helper.rb') { 'spec/unit' }
|
10
|
+
watch(%r{\Aspec/(?:lib|support|shared)/.+\.rb\z}) { 'spec/unit' }
|
11
|
+
|
12
|
+
# run unit specs if associated lib code is modified
|
13
|
+
watch(%r{\Alib/(.+)\.rb\z}) { |m| Dir["spec/unit/#{m[1]}"] }
|
14
|
+
watch("lib/#{File.basename(File.expand_path('../', __FILE__))}.rb") { 'spec/unit' }
|
15
|
+
|
16
|
+
# run a spec if it is modified
|
17
|
+
watch(%r{\Aspec/(?:unit|integration)/.+_spec\.rb\z})
|
18
|
+
end
|
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2014 Martin Gamsjaeger (snusnu)
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,70 @@
|
|
1
|
+
# orc
|
2
|
+
|
3
|
+
[![Gem Version](https://badge.fury.io/rb/orc.png)][gem]
|
4
|
+
[![Build Status](https://secure.travis-ci.org/snusnu/orc.png?branch=master)][travis]
|
5
|
+
[![Dependency Status](https://gemnasium.com/snusnu/orc.png)][gemnasium]
|
6
|
+
[![Code Climate](https://codeclimate.com/github/snusnu/orc.png)][codeclimate]
|
7
|
+
[![Coverage Status](https://coveralls.io/repos/snusnu/orc/badge.png?branch=master)][coveralls]
|
8
|
+
|
9
|
+
[gem]: https://rubygems.org/gems/orc
|
10
|
+
[travis]: https://travis-ci.org/snusnu/orc
|
11
|
+
[gemnasium]: https://gemnasium.com/snusnu/orc
|
12
|
+
[codeclimate]: https://codeclimate.com/github/snusnu/orc
|
13
|
+
[coveralls]: https://coveralls.io/r/snusnu/orc
|
14
|
+
|
15
|
+
## Usage
|
16
|
+
|
17
|
+
Whenever you want to communicate success or failure of an operation, the following might be handy
|
18
|
+
|
19
|
+
```ruby
|
20
|
+
describe Orc::Result do
|
21
|
+
describe '.success' do
|
22
|
+
subject { Orc::Result.success(object) }
|
23
|
+
|
24
|
+
let(:object) { :object }
|
25
|
+
|
26
|
+
it 'signals success' do
|
27
|
+
expect(subject.success?).to be(true)
|
28
|
+
end
|
29
|
+
|
30
|
+
it 'returns :success state' do
|
31
|
+
expect(subject.status).to be(:success)
|
32
|
+
end
|
33
|
+
|
34
|
+
it 'exposes the associated object' do
|
35
|
+
expect(subject.object).to be(object)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
describe '.failure' do
|
40
|
+
subject { Orc::Result.failure(status, context) }
|
41
|
+
|
42
|
+
let(:status) { :confused }
|
43
|
+
let(:context) { :context }
|
44
|
+
|
45
|
+
it 'signals failure' do
|
46
|
+
expect(subject.success?).to be(false)
|
47
|
+
end
|
48
|
+
|
49
|
+
it 'returns :success state' do
|
50
|
+
expect(subject.status).to be(status)
|
51
|
+
end
|
52
|
+
|
53
|
+
it 'exposes the associated context' do
|
54
|
+
expect(subject.context).to be(context)
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
```
|
59
|
+
|
60
|
+
## Credits
|
61
|
+
|
62
|
+
* [snusnu](https://github.com/snusnu)
|
63
|
+
|
64
|
+
## Contributing
|
65
|
+
|
66
|
+
See [CONTRIBUTING.md](CONTRIBUTING.md) for details.
|
67
|
+
|
68
|
+
## Copyright
|
69
|
+
|
70
|
+
Copyright © 2014 Martin Gamsjaeger (snusnu). See [LICENSE](LICENSE) for details.
|
data/Rakefile
ADDED
data/TODO.md
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
*
|
data/config/devtools.yml
ADDED
data/config/flay.yml
ADDED
data/config/flog.yml
ADDED
data/config/mutant.yml
ADDED
data/config/reek.yml
ADDED
@@ -0,0 +1,104 @@
|
|
1
|
+
---
|
2
|
+
Attribute:
|
3
|
+
enabled: true
|
4
|
+
exclude: []
|
5
|
+
BooleanParameter:
|
6
|
+
enabled: true
|
7
|
+
exclude: []
|
8
|
+
ClassVariable:
|
9
|
+
enabled: true
|
10
|
+
exclude: []
|
11
|
+
ControlParameter:
|
12
|
+
enabled: true
|
13
|
+
exclude: []
|
14
|
+
DataClump:
|
15
|
+
enabled: true
|
16
|
+
exclude: []
|
17
|
+
max_copies: 2
|
18
|
+
min_clump_size: 2
|
19
|
+
DuplicateMethodCall:
|
20
|
+
enabled: true
|
21
|
+
exclude: []
|
22
|
+
max_calls: 1
|
23
|
+
allow_calls: []
|
24
|
+
FeatureEnvy:
|
25
|
+
enabled: true
|
26
|
+
exclude: []
|
27
|
+
IrresponsibleModule:
|
28
|
+
enabled: true
|
29
|
+
exclude: []
|
30
|
+
LongParameterList:
|
31
|
+
enabled: true
|
32
|
+
exclude: []
|
33
|
+
max_params: 3
|
34
|
+
overrides:
|
35
|
+
initialize:
|
36
|
+
max_params: 3
|
37
|
+
LongYieldList:
|
38
|
+
enabled: true
|
39
|
+
exclude: []
|
40
|
+
max_params: 2
|
41
|
+
NestedIterators:
|
42
|
+
enabled: true
|
43
|
+
exclude: []
|
44
|
+
max_allowed_nesting: 1
|
45
|
+
ignore_iterators: []
|
46
|
+
NilCheck:
|
47
|
+
enabled: true
|
48
|
+
exclude: []
|
49
|
+
RepeatedConditional:
|
50
|
+
enabled: true
|
51
|
+
exclude: []
|
52
|
+
max_ifs: 1
|
53
|
+
TooManyInstanceVariables:
|
54
|
+
enabled: true
|
55
|
+
exclude: []
|
56
|
+
max_instance_variables: 3
|
57
|
+
TooManyMethods:
|
58
|
+
enabled: true
|
59
|
+
exclude: []
|
60
|
+
max_methods: 10
|
61
|
+
TooManyStatements:
|
62
|
+
enabled: true
|
63
|
+
exclude:
|
64
|
+
- each
|
65
|
+
max_statements: 3
|
66
|
+
UncommunicativeMethodName:
|
67
|
+
enabled: true
|
68
|
+
exclude: []
|
69
|
+
reject:
|
70
|
+
- !ruby/regexp /^[a-z]$/
|
71
|
+
- !ruby/regexp /[0-9]$/
|
72
|
+
- !ruby/regexp /[A-Z]/
|
73
|
+
accept: []
|
74
|
+
UncommunicativeModuleName:
|
75
|
+
enabled: true
|
76
|
+
exclude: []
|
77
|
+
reject:
|
78
|
+
- !ruby/regexp /^.$/
|
79
|
+
- !ruby/regexp /[0-9]$/
|
80
|
+
accept: []
|
81
|
+
UncommunicativeParameterName:
|
82
|
+
enabled: true
|
83
|
+
exclude: []
|
84
|
+
reject:
|
85
|
+
- !ruby/regexp /^.$/
|
86
|
+
- !ruby/regexp /[0-9]$/
|
87
|
+
- !ruby/regexp /[A-Z]/
|
88
|
+
accept: []
|
89
|
+
UncommunicativeVariableName:
|
90
|
+
enabled: true
|
91
|
+
exclude:
|
92
|
+
- "r" # used in routes block
|
93
|
+
reject:
|
94
|
+
- !ruby/regexp /^.$/
|
95
|
+
- !ruby/regexp /[0-9]$/
|
96
|
+
- !ruby/regexp /[A-Z]/
|
97
|
+
accept: []
|
98
|
+
UnusedParameters:
|
99
|
+
enabled: true
|
100
|
+
exclude: []
|
101
|
+
UtilityFunction:
|
102
|
+
enabled: true
|
103
|
+
exclude: []
|
104
|
+
max_helper_calls: 0
|
data/config/rubocop.yml
ADDED
@@ -0,0 +1,75 @@
|
|
1
|
+
AllCops:
|
2
|
+
Includes:
|
3
|
+
- '**/*.rake'
|
4
|
+
- 'Gemfile'
|
5
|
+
- 'Gemfile.devtools'
|
6
|
+
Excludes:
|
7
|
+
- '**/vendor/**'
|
8
|
+
- '**/benchmarks/**'
|
9
|
+
|
10
|
+
# Avoid parameter lists longer than five parameters.
|
11
|
+
ParameterLists:
|
12
|
+
Max: 3
|
13
|
+
CountKeywordArgs: true
|
14
|
+
|
15
|
+
# Avoid more than `Max` levels of nesting.
|
16
|
+
BlockNesting:
|
17
|
+
Max: 3
|
18
|
+
|
19
|
+
# Align with the style guide.
|
20
|
+
CollectionMethods:
|
21
|
+
PreferredMethods:
|
22
|
+
collect: 'map'
|
23
|
+
inject: 'reduce'
|
24
|
+
find: 'detect'
|
25
|
+
find_all: 'select'
|
26
|
+
|
27
|
+
# Limit line length
|
28
|
+
LineLength:
|
29
|
+
Max: 81
|
30
|
+
|
31
|
+
# Disable documentation checking until a class needs to be documented once
|
32
|
+
Documentation:
|
33
|
+
Enabled: false
|
34
|
+
|
35
|
+
# Do not favor modifier if/unless usage when you have a single-line body
|
36
|
+
IfUnlessModifier:
|
37
|
+
Enabled: false
|
38
|
+
|
39
|
+
# Allow case equality operator (in limited use within the specs)
|
40
|
+
CaseEquality:
|
41
|
+
Enabled: false
|
42
|
+
|
43
|
+
# Constants do not always have to use SCREAMING_SNAKE_CASE
|
44
|
+
ConstantName:
|
45
|
+
Enabled: false
|
46
|
+
|
47
|
+
# Not all trivial readers/writers can be defined with attr_* methods
|
48
|
+
TrivialAccessors:
|
49
|
+
Enabled: false
|
50
|
+
|
51
|
+
# Do not prefer do/end over {} for multiline blocks
|
52
|
+
Blocks:
|
53
|
+
Enabled: false
|
54
|
+
|
55
|
+
# Do not favor aligned parameters in method calls
|
56
|
+
AlignParameters:
|
57
|
+
Enabled: false
|
58
|
+
|
59
|
+
HashSyntax:
|
60
|
+
Enabled: false
|
61
|
+
|
62
|
+
SpaceInsideBrackets:
|
63
|
+
Enabled: false
|
64
|
+
|
65
|
+
Lambda:
|
66
|
+
Enabled: false # i personally like the look of multiline ->(arg) {} lambdas
|
67
|
+
|
68
|
+
AndOr:
|
69
|
+
Enabled: false # we agree to use and/or for control flow
|
70
|
+
|
71
|
+
Style/SingleSpaceBeforeFirstArg:
|
72
|
+
Enabled: false
|
73
|
+
|
74
|
+
Style/EmptyLinesAroundBody:
|
75
|
+
Enabled: false
|
data/lib/orc.rb
ADDED
@@ -0,0 +1,71 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'concord'
|
4
|
+
require 'abstract_type'
|
5
|
+
|
6
|
+
# Operation result class
|
7
|
+
module Orc
|
8
|
+
|
9
|
+
# Abstract base class for a result returned from some computation
|
10
|
+
class Result
|
11
|
+
|
12
|
+
# Create a result indicating success
|
13
|
+
#
|
14
|
+
# @param [Object] object
|
15
|
+
# arbitrary data associated with the result
|
16
|
+
#
|
17
|
+
# @return [Success]
|
18
|
+
def self.success(object)
|
19
|
+
Success.new(object)
|
20
|
+
end
|
21
|
+
|
22
|
+
# Create a result indicating failure
|
23
|
+
#
|
24
|
+
# @param [Object] status
|
25
|
+
# an arbitrary status description (symbol)
|
26
|
+
#
|
27
|
+
# @param [Object] context
|
28
|
+
# context information associated with the failure
|
29
|
+
#
|
30
|
+
# @return [Success]
|
31
|
+
def self.failure(status, context)
|
32
|
+
Failure.new(status, context)
|
33
|
+
end
|
34
|
+
|
35
|
+
include AbstractType
|
36
|
+
|
37
|
+
abstract_method :success?
|
38
|
+
abstract_method :status
|
39
|
+
|
40
|
+
# Result object indicating success along with associated data
|
41
|
+
class Success < self
|
42
|
+
include Concord::Public.new(:object)
|
43
|
+
|
44
|
+
# Indicate success
|
45
|
+
#
|
46
|
+
# @return [true]
|
47
|
+
def success?
|
48
|
+
true
|
49
|
+
end
|
50
|
+
|
51
|
+
# Status description
|
52
|
+
#
|
53
|
+
# @return [:success]
|
54
|
+
def status
|
55
|
+
:success
|
56
|
+
end
|
57
|
+
end # Success
|
58
|
+
|
59
|
+
# Result object indicating failure along with status and context
|
60
|
+
class Failure < self
|
61
|
+
include Concord::Public.new(:status, :context)
|
62
|
+
|
63
|
+
# Indicate success
|
64
|
+
#
|
65
|
+
# @return [false]
|
66
|
+
def success?
|
67
|
+
false
|
68
|
+
end
|
69
|
+
end # Failure
|
70
|
+
end # Result
|
71
|
+
end # Orc
|
data/lib/orc/version.rb
ADDED
data/orc.gemspec
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
require File.expand_path('../lib/orc/version', __FILE__)
|
4
|
+
|
5
|
+
Gem::Specification.new do |gem|
|
6
|
+
gem.name = "orc"
|
7
|
+
gem.version = Orc::VERSION.dup
|
8
|
+
gem.authors = [ "Martin Gamsjaeger (snusnu)" ]
|
9
|
+
gem.email = [ "gamsnjaga@gmail.com" ]
|
10
|
+
gem.description = "Operation result class"
|
11
|
+
gem.summary = "Provides Result.success(object) and Result.failure(status, context)"
|
12
|
+
gem.homepage = "https://github.com/snusnu/orc"
|
13
|
+
|
14
|
+
gem.require_paths = [ "lib" ]
|
15
|
+
gem.files = `git ls-files`.split("\n")
|
16
|
+
gem.test_files = `git ls-files -- {spec}/*`.split("\n")
|
17
|
+
gem.extra_rdoc_files = %w[LICENSE README.md TODO.md]
|
18
|
+
gem.license = 'MIT'
|
19
|
+
|
20
|
+
gem.add_dependency 'concord', '~> 0.1', '>= 0.1.5'
|
21
|
+
gem.add_dependency 'abstract_type', '~> 0.0', '>= 0.0.7'
|
22
|
+
|
23
|
+
gem.add_development_dependency 'bundler', '~> 1.6', '>= 1.6.5'
|
24
|
+
gem.add_development_dependency 'rspec', '~> 3.0', '>= 3.0.0'
|
25
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
if ENV['COVERAGE'] == 'true'
|
4
|
+
require 'simplecov'
|
5
|
+
require 'coveralls'
|
6
|
+
|
7
|
+
SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[
|
8
|
+
SimpleCov::Formatter::HTMLFormatter,
|
9
|
+
Coveralls::SimpleCov::Formatter
|
10
|
+
]
|
11
|
+
|
12
|
+
SimpleCov.start do
|
13
|
+
command_name 'spec:unit'
|
14
|
+
add_filter 'config'
|
15
|
+
add_filter 'spec'
|
16
|
+
minimum_coverage 100
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
require 'orc'
|
21
|
+
|
22
|
+
RSpec.configure do |config|
|
23
|
+
config.expect_with :rspec do |c|
|
24
|
+
c.syntax = :expect
|
25
|
+
end
|
26
|
+
config.mock_with :rspec do |c|
|
27
|
+
c.syntax = :expect
|
28
|
+
end
|
29
|
+
end
|
File without changes
|
@@ -0,0 +1,42 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe Orc::Result do
|
6
|
+
describe '.success' do
|
7
|
+
subject { Orc::Result.success(object) }
|
8
|
+
|
9
|
+
let(:object) { :object }
|
10
|
+
|
11
|
+
it 'signals success' do
|
12
|
+
expect(subject.success?).to be(true)
|
13
|
+
end
|
14
|
+
|
15
|
+
it 'returns :success state' do
|
16
|
+
expect(subject.status).to be(:success)
|
17
|
+
end
|
18
|
+
|
19
|
+
it 'exposes the associated object' do
|
20
|
+
expect(subject.object).to be(object)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
describe '.failure' do
|
25
|
+
subject { Orc::Result.failure(status, context) }
|
26
|
+
|
27
|
+
let(:status) { :confused }
|
28
|
+
let(:context) { :context }
|
29
|
+
|
30
|
+
it 'signals failure' do
|
31
|
+
expect(subject.success?).to be(false)
|
32
|
+
end
|
33
|
+
|
34
|
+
it 'returns :success state' do
|
35
|
+
expect(subject.status).to be(status)
|
36
|
+
end
|
37
|
+
|
38
|
+
it 'exposes the associated context' do
|
39
|
+
expect(subject.context).to be(context)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
metadata
ADDED
@@ -0,0 +1,155 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: orc
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Martin Gamsjaeger (snusnu)
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-08-01 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: concord
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0.1'
|
20
|
+
- - ">="
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: 0.1.5
|
23
|
+
type: :runtime
|
24
|
+
prerelease: false
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
26
|
+
requirements:
|
27
|
+
- - "~>"
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0.1'
|
30
|
+
- - ">="
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: 0.1.5
|
33
|
+
- !ruby/object:Gem::Dependency
|
34
|
+
name: abstract_type
|
35
|
+
requirement: !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - "~>"
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: '0.0'
|
40
|
+
- - ">="
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
version: 0.0.7
|
43
|
+
type: :runtime
|
44
|
+
prerelease: false
|
45
|
+
version_requirements: !ruby/object:Gem::Requirement
|
46
|
+
requirements:
|
47
|
+
- - "~>"
|
48
|
+
- !ruby/object:Gem::Version
|
49
|
+
version: '0.0'
|
50
|
+
- - ">="
|
51
|
+
- !ruby/object:Gem::Version
|
52
|
+
version: 0.0.7
|
53
|
+
- !ruby/object:Gem::Dependency
|
54
|
+
name: bundler
|
55
|
+
requirement: !ruby/object:Gem::Requirement
|
56
|
+
requirements:
|
57
|
+
- - "~>"
|
58
|
+
- !ruby/object:Gem::Version
|
59
|
+
version: '1.6'
|
60
|
+
- - ">="
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: 1.6.5
|
63
|
+
type: :development
|
64
|
+
prerelease: false
|
65
|
+
version_requirements: !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - "~>"
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '1.6'
|
70
|
+
- - ">="
|
71
|
+
- !ruby/object:Gem::Version
|
72
|
+
version: 1.6.5
|
73
|
+
- !ruby/object:Gem::Dependency
|
74
|
+
name: rspec
|
75
|
+
requirement: !ruby/object:Gem::Requirement
|
76
|
+
requirements:
|
77
|
+
- - "~>"
|
78
|
+
- !ruby/object:Gem::Version
|
79
|
+
version: '3.0'
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: 3.0.0
|
83
|
+
type: :development
|
84
|
+
prerelease: false
|
85
|
+
version_requirements: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '3.0'
|
90
|
+
- - ">="
|
91
|
+
- !ruby/object:Gem::Version
|
92
|
+
version: 3.0.0
|
93
|
+
description: Operation result class
|
94
|
+
email:
|
95
|
+
- gamsnjaga@gmail.com
|
96
|
+
executables: []
|
97
|
+
extensions: []
|
98
|
+
extra_rdoc_files:
|
99
|
+
- LICENSE
|
100
|
+
- README.md
|
101
|
+
- TODO.md
|
102
|
+
files:
|
103
|
+
- ".gitignore"
|
104
|
+
- ".rspec"
|
105
|
+
- ".ruby-gemset"
|
106
|
+
- ".ruby-version"
|
107
|
+
- ".travis.yml"
|
108
|
+
- CONTRIBUTING.md
|
109
|
+
- Changelog.md
|
110
|
+
- Gemfile
|
111
|
+
- Gemfile.devtools
|
112
|
+
- Guardfile
|
113
|
+
- LICENSE
|
114
|
+
- README.md
|
115
|
+
- Rakefile
|
116
|
+
- TODO.md
|
117
|
+
- config/devtools.yml
|
118
|
+
- config/flay.yml
|
119
|
+
- config/flog.yml
|
120
|
+
- config/mutant.yml
|
121
|
+
- config/reek.yml
|
122
|
+
- config/rubocop.yml
|
123
|
+
- config/yardstick.yml
|
124
|
+
- lib/orc.rb
|
125
|
+
- lib/orc/version.rb
|
126
|
+
- orc.gemspec
|
127
|
+
- spec/spec_helper.rb
|
128
|
+
- spec/unit/orc/.gitkeep
|
129
|
+
- spec/unit/orc/result_spec.rb
|
130
|
+
homepage: https://github.com/snusnu/orc
|
131
|
+
licenses:
|
132
|
+
- MIT
|
133
|
+
metadata: {}
|
134
|
+
post_install_message:
|
135
|
+
rdoc_options: []
|
136
|
+
require_paths:
|
137
|
+
- lib
|
138
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
139
|
+
requirements:
|
140
|
+
- - ">="
|
141
|
+
- !ruby/object:Gem::Version
|
142
|
+
version: '0'
|
143
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
144
|
+
requirements:
|
145
|
+
- - ">="
|
146
|
+
- !ruby/object:Gem::Version
|
147
|
+
version: '0'
|
148
|
+
requirements: []
|
149
|
+
rubyforge_project:
|
150
|
+
rubygems_version: 2.2.2
|
151
|
+
signing_key:
|
152
|
+
specification_version: 4
|
153
|
+
summary: Provides Result.success(object) and Result.failure(status, context)
|
154
|
+
test_files: []
|
155
|
+
has_rdoc:
|