svarog 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 83a6c4a2dd864dca060f9df16497539be4617062
4
+ data.tar.gz: ffc7b2bee7264f5fefe4503fcc954b356a378b98
5
+ SHA512:
6
+ metadata.gz: 2b6a4448e7a61903656a99fed23d5ad01c8f7ad39db6fb9f09e5a1efdafaeea93ddc2ff5aaa274d20950f8c9813bd859ef6a8356e49b1d4a38b64a26991fc01c
7
+ data.tar.gz: d8790d0fc4ab2520778476c75ee5d40d7468599400ad14c699aa5facf05635027477928d6d0cbfe52a0f74e288523822911e0274e7c47e08dc413c1e8ee169ab
data/.gitignore ADDED
@@ -0,0 +1,12 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+
10
+ # rspec failure tracking
11
+ .rspec_status
12
+ .byebug_histor
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/.travis.yml ADDED
@@ -0,0 +1,5 @@
1
+ sudo: false
2
+ language: ruby
3
+ rvm:
4
+ - 2.3.1
5
+ before_install: gem install bundler -v 1.16.1
@@ -0,0 +1,74 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to making participation in our project and
7
+ our community a harassment-free experience for everyone, regardless of age, body
8
+ size, disability, ethnicity, gender identity and expression, level of experience,
9
+ nationality, personal appearance, race, religion, or sexual identity and
10
+ orientation.
11
+
12
+ ## Our Standards
13
+
14
+ Examples of behavior that contributes to creating a positive environment
15
+ include:
16
+
17
+ * Using welcoming and inclusive language
18
+ * Being respectful of differing viewpoints and experiences
19
+ * Gracefully accepting constructive criticism
20
+ * Focusing on what is best for the community
21
+ * Showing empathy towards other community members
22
+
23
+ Examples of unacceptable behavior by participants include:
24
+
25
+ * The use of sexualized language or imagery and unwelcome sexual attention or
26
+ advances
27
+ * Trolling, insulting/derogatory comments, and personal or political attacks
28
+ * Public or private harassment
29
+ * Publishing others' private information, such as a physical or electronic
30
+ address, without explicit permission
31
+ * Other conduct which could reasonably be considered inappropriate in a
32
+ professional setting
33
+
34
+ ## Our Responsibilities
35
+
36
+ Project maintainers are responsible for clarifying the standards of acceptable
37
+ behavior and are expected to take appropriate and fair corrective action in
38
+ response to any instances of unacceptable behavior.
39
+
40
+ Project maintainers have the right and responsibility to remove, edit, or
41
+ reject comments, commits, code, wiki edits, issues, and other contributions
42
+ that are not aligned to this Code of Conduct, or to ban temporarily or
43
+ permanently any contributor for other behaviors that they deem inappropriate,
44
+ threatening, offensive, or harmful.
45
+
46
+ ## Scope
47
+
48
+ This Code of Conduct applies both within project spaces and in public spaces
49
+ when an individual is representing the project or its community. Examples of
50
+ representing a project or community include using an official project e-mail
51
+ address, posting via an official social media account, or acting as an appointed
52
+ representative at an online or offline event. Representation of a project may be
53
+ further defined and clarified by project maintainers.
54
+
55
+ ## Enforcement
56
+
57
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
+ reported by contacting the project team at b.bonislawski@hotmail.com. All
59
+ complaints will be reviewed and investigated and will result in a response that
60
+ is deemed necessary and appropriate to the circumstances. The project team is
61
+ obligated to maintain confidentiality with regard to the reporter of an incident.
62
+ Further details of specific enforcement policies may be posted separately.
63
+
64
+ Project maintainers who do not follow or enforce the Code of Conduct in good
65
+ faith may face temporary or permanent repercussions as determined by other
66
+ members of the project's leadership.
67
+
68
+ ## Attribution
69
+
70
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
+ available at [http://contributor-covenant.org/version/1/4][version]
72
+
73
+ [homepage]: http://contributor-covenant.org
74
+ [version]: http://contributor-covenant.org/version/1/4/
data/Gemfile ADDED
@@ -0,0 +1,8 @@
1
+ source "https://rubygems.org"
2
+
3
+ git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
4
+
5
+ gem 'mutant-rspec', git: 'https://github.com/mbj/mutant.git'
6
+ gem 'byebug'
7
+ # Specify your gem's dependencies in svarog.gemspec
8
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,101 @@
1
+ GIT
2
+ remote: https://github.com/mbj/mutant.git
3
+ revision: 2beac2ccba1de938ff79175b31c16bef845e98d1
4
+ specs:
5
+ mutant (0.8.14)
6
+ abstract_type (~> 0.0.7)
7
+ adamantium (~> 0.2.0)
8
+ anima (~> 0.3.0)
9
+ ast (~> 2.2)
10
+ concord (~> 0.1.5)
11
+ diff-lcs (~> 1.3)
12
+ equalizer (~> 0.0.9)
13
+ ice_nine (~> 0.11.1)
14
+ memoizable (~> 0.4.2)
15
+ morpher (~> 0.2.6)
16
+ parallel (~> 1.3)
17
+ parser (>= 2.3.1.4, < 2.5)
18
+ procto (~> 0.0.2)
19
+ regexp_parser (~> 0.4.9)
20
+ unparser (~> 0.2.5)
21
+ mutant-rspec (0.8.14)
22
+ mutant (~> 0.8.14)
23
+ rspec-core (>= 3.4.0, < 3.8.0)
24
+
25
+ PATH
26
+ remote: .
27
+ specs:
28
+ svarog (0.1.0)
29
+
30
+ GEM
31
+ remote: https://rubygems.org/
32
+ specs:
33
+ abstract_type (0.0.7)
34
+ adamantium (0.2.0)
35
+ ice_nine (~> 0.11.0)
36
+ memoizable (~> 0.4.0)
37
+ anima (0.3.0)
38
+ abstract_type (~> 0.0.7)
39
+ adamantium (~> 0.2)
40
+ equalizer (~> 0.0.11)
41
+ ast (2.4.0)
42
+ byebug (10.0.1)
43
+ concord (0.1.5)
44
+ adamantium (~> 0.2.0)
45
+ equalizer (~> 0.0.9)
46
+ diff-lcs (1.3)
47
+ equalizer (0.0.11)
48
+ ice_nine (0.11.2)
49
+ memoizable (0.4.2)
50
+ thread_safe (~> 0.3, >= 0.3.1)
51
+ morpher (0.2.6)
52
+ abstract_type (~> 0.0.7)
53
+ adamantium (~> 0.2.0)
54
+ anima (~> 0.3.0)
55
+ ast (~> 2.2)
56
+ concord (~> 0.1.5)
57
+ equalizer (~> 0.0.9)
58
+ ice_nine (~> 0.11.0)
59
+ procto (~> 0.0.2)
60
+ parallel (1.12.1)
61
+ parser (2.4.0.2)
62
+ ast (~> 2.3)
63
+ procto (0.0.3)
64
+ rake (10.4.2)
65
+ regexp_parser (0.4.11)
66
+ rspec (3.7.0)
67
+ rspec-core (~> 3.7.0)
68
+ rspec-expectations (~> 3.7.0)
69
+ rspec-mocks (~> 3.7.0)
70
+ rspec-core (3.7.1)
71
+ rspec-support (~> 3.7.0)
72
+ rspec-expectations (3.7.0)
73
+ diff-lcs (>= 1.2.0, < 2.0)
74
+ rspec-support (~> 3.7.0)
75
+ rspec-mocks (3.7.0)
76
+ diff-lcs (>= 1.2.0, < 2.0)
77
+ rspec-support (~> 3.7.0)
78
+ rspec-support (3.7.1)
79
+ thread_safe (0.3.6)
80
+ unparser (0.2.7)
81
+ abstract_type (~> 0.0.7)
82
+ adamantium (~> 0.2.0)
83
+ concord (~> 0.1.5)
84
+ diff-lcs (~> 1.3)
85
+ equalizer (~> 0.0.9)
86
+ parser (>= 2.3.1.2, < 2.6)
87
+ procto (~> 0.0.2)
88
+
89
+ PLATFORMS
90
+ ruby
91
+
92
+ DEPENDENCIES
93
+ bundler (~> 1.16)
94
+ byebug
95
+ mutant-rspec!
96
+ rake (~> 10.0)
97
+ rspec (~> 3.0)
98
+ svarog!
99
+
100
+ BUNDLED WITH
101
+ 1.16.1
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2018 Bartosz Bonisławski
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,43 @@
1
+ # Svarog
2
+
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/svarog`. To experiment with that code, run `bin/console` for an interactive prompt.
4
+
5
+ TODO: Delete this and the text above, and describe your gem
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'svarog'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install svarog
22
+
23
+ ## Usage
24
+
25
+ TODO: Write usage instructions here
26
+
27
+ ## Development
28
+
29
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
30
+
31
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
32
+
33
+ ## Contributing
34
+
35
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/svarog. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
36
+
37
+ ## License
38
+
39
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
40
+
41
+ ## Code of Conduct
42
+
43
+ Everyone interacting in the Svarog project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/svarog/blob/master/CODE_OF_CONDUCT.md).
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "svarog"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start(__FILE__)
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
data/lib/svarog.rb ADDED
@@ -0,0 +1,59 @@
1
+ require "svarog/version"
2
+
3
+ module Svarog
4
+ class MethodNotImplemented < StandardError; end
5
+ class WrongDataPassed < StandardError; end
6
+ class NonCallablePassedToRun < StandardError; end
7
+ class CallMethodNotImplemented < StandardError; end
8
+
9
+ Result = Struct.new(:success, :value) do
10
+ def success?
11
+ success
12
+ end
13
+
14
+ def failure?
15
+ !success
16
+ end
17
+ end
18
+
19
+ module Base
20
+ def call(input = nil)
21
+ input ||= {}
22
+ @_passed_input = Result.new(true, input)
23
+ begin
24
+ super
25
+ rescue NoMethodError
26
+ raise CallMethodNotImplemented, "You have to implement `call` method in your class before using it"
27
+ end
28
+ enforce_data_format
29
+ @_passed_input
30
+ end
31
+
32
+ private
33
+
34
+ def run(callable)
35
+ return unless @_passed_input.success?
36
+
37
+ if callable.instance_of? Symbol
38
+ raise MethodNotImplemented, "You didn't implement #{callable} method. Implement it before calling this class" unless respond_to?(callable, true)
39
+ callable = method(callable)
40
+ end
41
+
42
+ raise NonCallablePassedToRun, "You can pass only symbol with method name of instance of callable class to run method" unless callable.respond_to?(:call)
43
+
44
+ @_passed_input = callable.call(@_passed_input.value)
45
+ end
46
+
47
+ def success(value)
48
+ Result.new(true, value)
49
+ end
50
+
51
+ def failure(value)
52
+ Result.new(false, value)
53
+ end
54
+
55
+ def enforce_data_format
56
+ raise WrongDataPassed, "You didn't use `success` or `failure` method to return value from method." unless @_passed_input.instance_of? Result
57
+ end
58
+ end
59
+ end
@@ -0,0 +1,3 @@
1
+ module Svarog
2
+ VERSION = "0.1.0"
3
+ end
data/svarog.gemspec ADDED
@@ -0,0 +1,27 @@
1
+
2
+ lib = File.expand_path("../lib", __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require "svarog/version"
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "svarog"
8
+ spec.version = Svarog::VERSION
9
+ spec.authors = ["Bartosz Bonisławski", "Bogusław Tolarz", "Nathaniel Nande", "Michał Wrzosek"]
10
+ spec.email = ["b.bonislawski@hotmail.com"]
11
+
12
+ spec.summary = %q{Svarog is a gem to help you with definition of service objects}
13
+ spec.homepage = "https://github.com/bbonislawski/svarog"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
17
+ f.match(%r{^(test|spec|features)/})
18
+ end
19
+ spec.bindir = "exe"
20
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
21
+ spec.require_paths = ["lib"]
22
+
23
+ spec.add_development_dependency "bundler", "~> 1.16"
24
+ spec.add_development_dependency "rake", "~> 10.0"
25
+ spec.add_development_dependency "rspec", "~> 3.0"
26
+ spec.add_development_dependency "mutant-rspec", "~> 0.8.14"
27
+ end
metadata ADDED
@@ -0,0 +1,117 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: svarog
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Bartosz Bonisławski
8
+ - Bogusław Tolarz
9
+ - Nathaniel Nande
10
+ - Michał Wrzosek
11
+ autorequire:
12
+ bindir: exe
13
+ cert_chain: []
14
+ date: 2018-05-11 00:00:00.000000000 Z
15
+ dependencies:
16
+ - !ruby/object:Gem::Dependency
17
+ name: bundler
18
+ requirement: !ruby/object:Gem::Requirement
19
+ requirements:
20
+ - - "~>"
21
+ - !ruby/object:Gem::Version
22
+ version: '1.16'
23
+ type: :development
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - "~>"
28
+ - !ruby/object:Gem::Version
29
+ version: '1.16'
30
+ - !ruby/object:Gem::Dependency
31
+ name: rake
32
+ requirement: !ruby/object:Gem::Requirement
33
+ requirements:
34
+ - - "~>"
35
+ - !ruby/object:Gem::Version
36
+ version: '10.0'
37
+ type: :development
38
+ prerelease: false
39
+ version_requirements: !ruby/object:Gem::Requirement
40
+ requirements:
41
+ - - "~>"
42
+ - !ruby/object:Gem::Version
43
+ version: '10.0'
44
+ - !ruby/object:Gem::Dependency
45
+ name: rspec
46
+ requirement: !ruby/object:Gem::Requirement
47
+ requirements:
48
+ - - "~>"
49
+ - !ruby/object:Gem::Version
50
+ version: '3.0'
51
+ type: :development
52
+ prerelease: false
53
+ version_requirements: !ruby/object:Gem::Requirement
54
+ requirements:
55
+ - - "~>"
56
+ - !ruby/object:Gem::Version
57
+ version: '3.0'
58
+ - !ruby/object:Gem::Dependency
59
+ name: mutant-rspec
60
+ requirement: !ruby/object:Gem::Requirement
61
+ requirements:
62
+ - - "~>"
63
+ - !ruby/object:Gem::Version
64
+ version: 0.8.14
65
+ type: :development
66
+ prerelease: false
67
+ version_requirements: !ruby/object:Gem::Requirement
68
+ requirements:
69
+ - - "~>"
70
+ - !ruby/object:Gem::Version
71
+ version: 0.8.14
72
+ description:
73
+ email:
74
+ - b.bonislawski@hotmail.com
75
+ executables: []
76
+ extensions: []
77
+ extra_rdoc_files: []
78
+ files:
79
+ - ".gitignore"
80
+ - ".rspec"
81
+ - ".travis.yml"
82
+ - CODE_OF_CONDUCT.md
83
+ - Gemfile
84
+ - Gemfile.lock
85
+ - LICENSE.txt
86
+ - README.md
87
+ - Rakefile
88
+ - bin/console
89
+ - bin/setup
90
+ - lib/svarog.rb
91
+ - lib/svarog/version.rb
92
+ - svarog.gemspec
93
+ homepage: https://github.com/bbonislawski/svarog
94
+ licenses:
95
+ - MIT
96
+ metadata: {}
97
+ post_install_message:
98
+ rdoc_options: []
99
+ require_paths:
100
+ - lib
101
+ required_ruby_version: !ruby/object:Gem::Requirement
102
+ requirements:
103
+ - - ">="
104
+ - !ruby/object:Gem::Version
105
+ version: '0'
106
+ required_rubygems_version: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ requirements: []
112
+ rubyforge_project:
113
+ rubygems_version: 2.6.14
114
+ signing_key:
115
+ specification_version: 4
116
+ summary: Svarog is a gem to help you with definition of service objects
117
+ test_files: []