encapsulators 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +12 -0
- data/.rspec +2 -0
- data/.travis.yml +5 -0
- data/Gemfile +4 -0
- data/LICENSE +21 -0
- data/README.md +59 -0
- data/Rakefile +11 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/encapsulators.gemspec +29 -0
- data/lib/encapsulators.rb +34 -0
- data/lib/encapsulators/helpers.rb +7 -0
- data/lib/encapsulators/version.rb +3 -0
- metadata +140 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: bc3647a64cd44aeecde1de39745abe318b988277
|
4
|
+
data.tar.gz: 0b5016b2e5e0a2d97fcb7cd84f77e08a4cc23244
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 591d00613af60da46eab03c4402d143a5a7197072a0bc4490e45013066b3a2d34da5efdcd96dac4aa223cdefbdae3409d9551b22d17a88843a31db1c6c68e07f
|
7
|
+
data.tar.gz: 15ec169eb987e2e1aff20a2e08c1faf20122a4ad2aeb9acd41c5caba97ae690de3ceab6f05eb34880121448ca782f99ddb596eeb615562d8eff7f67a84133fb4
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2017
|
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 all
|
13
|
+
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 THE
|
21
|
+
SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,59 @@
|
|
1
|
+
# Encapsulators
|
2
|
+
|
3
|
+
#### Collection of practical functions to be used with the 'encapsulate' gem.
|
4
|
+
|
5
|
+
| Branch | Status |
|
6
|
+
| ------ | ------ |
|
7
|
+
| Release | [![Build Status](https://travis-ci.org/thisismydesign/encapsulators.svg?branch=release)](https://travis-ci.org/thisismydesign/encapsulators) [![Coverage Status](https://coveralls.io/repos/github/thisismydesign/encapsulators/badge.svg?branch=release)](https://coveralls.io/github/thisismydesign/encapsulators?branch=release) [![Gem Version](https://badge.fury.io/rb/encapsulators.svg)](https://badge.fury.io/rb/encapsulators) [![Total Downloads](http://ruby-gem-downloads-badge.herokuapp.com/encapsulators?type=total)](https://rubygems.org/gems/encapsulators) |
|
8
|
+
| Development | [![Build Status](https://travis-ci.org/thisismydesign/encapsulators.svg?branch=master)](https://travis-ci.org/thisismydesign/encapsulators) [![Coverage Status](https://coveralls.io/repos/github/thisismydesign/encapsulators/badge.svg?branch=master)](https://coveralls.io/github/thisismydesign/encapsulators?branch=master) |
|
9
|
+
|
10
|
+
## Installation
|
11
|
+
|
12
|
+
Add this line to your application's Gemfile:
|
13
|
+
|
14
|
+
```ruby
|
15
|
+
gem 'encapsulators'
|
16
|
+
```
|
17
|
+
|
18
|
+
And then execute:
|
19
|
+
|
20
|
+
$ bundle
|
21
|
+
|
22
|
+
Or install it yourself as:
|
23
|
+
|
24
|
+
$ gem install encapsulators
|
25
|
+
|
26
|
+
## Usage
|
27
|
+
|
28
|
+
See the [encapsulate](https://github.com/thisismydesign/encapsulate) gem.
|
29
|
+
|
30
|
+
```ruby
|
31
|
+
require 'encapsulate'
|
32
|
+
require 'encapsulators'
|
33
|
+
|
34
|
+
def base_function
|
35
|
+
# ...
|
36
|
+
end
|
37
|
+
|
38
|
+
Encapsulate.run callback: base_function, with: [Encapsulators.user_interaction_before_return, Encapsulators.exception_handling]
|
39
|
+
```
|
40
|
+
|
41
|
+
## Feedback
|
42
|
+
|
43
|
+
Any feedback is much appreciated.
|
44
|
+
|
45
|
+
I can only tailor this project to fit use-cases I know about - which are usually my own ones. If you find that this might be the right direction to solve your problem too but you find that it's suboptimal or lacks features don't hesitate to contact me.
|
46
|
+
|
47
|
+
Please let me know if you make use of this project so that I can prioritize further efforts.
|
48
|
+
|
49
|
+
## Development
|
50
|
+
|
51
|
+
This gem is developed using Bundler conventions. A good overview can be found [here](http://bundler.io/v1.14/guides/creating_gem.html).
|
52
|
+
|
53
|
+
## Contributing
|
54
|
+
|
55
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/thisismydesign/encapsulators.
|
56
|
+
|
57
|
+
## License
|
58
|
+
|
59
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
2
|
+
require "rspec/core/rake_task"
|
3
|
+
|
4
|
+
RSpec::Core::RakeTask.new(:spec)
|
5
|
+
|
6
|
+
desc "Check if source can be required locally"
|
7
|
+
task :require do
|
8
|
+
sh "ruby -e \"require '#{File.dirname __FILE__}/lib/encapsulators'\""
|
9
|
+
end
|
10
|
+
|
11
|
+
task :default => [:require, :spec]
|
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "encapsulators"
|
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,29 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'encapsulators/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "encapsulators"
|
8
|
+
spec.version = Encapsulators::VERSION
|
9
|
+
spec.authors = ["thisismydesign"]
|
10
|
+
spec.email = ["thisismydesign@users.noreply.github.com"]
|
11
|
+
|
12
|
+
spec.summary = "Collection of practical functions to be used with the 'encapsulate' gem."
|
13
|
+
spec.homepage = "https://github.com/thisismydesign/encapsulators"
|
14
|
+
|
15
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
16
|
+
f.match(%r{^(test|spec|features)/})
|
17
|
+
end
|
18
|
+
spec.bindir = "exe"
|
19
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
20
|
+
spec.require_paths = ["lib"]
|
21
|
+
|
22
|
+
spec.add_dependency "easy_logging"
|
23
|
+
spec.add_dependency "reflection_utils"
|
24
|
+
|
25
|
+
spec.add_development_dependency "bundler", "~> 1.14"
|
26
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
27
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
28
|
+
spec.add_development_dependency "coveralls"
|
29
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
require 'easy_logging'
|
2
|
+
require 'reflection_utils'
|
3
|
+
|
4
|
+
require_relative 'encapsulators/helpers'
|
5
|
+
|
6
|
+
module Encapsulators
|
7
|
+
include EasyLogging
|
8
|
+
|
9
|
+
attr_reader :exception_handling, :user_interaction_before_return, :lifecycle_signals
|
10
|
+
|
11
|
+
def self.exception_handling(callback:, params: nil)
|
12
|
+
begin
|
13
|
+
ReflectionUtils.call(callback, params)
|
14
|
+
rescue Exception => e
|
15
|
+
logger.error(Helpers.ruby_style_trace(e))
|
16
|
+
end
|
17
|
+
end
|
18
|
+
@exception_handling = self.method(:exception_handling)
|
19
|
+
|
20
|
+
def self.user_interaction_before_return(callback:, params: nil)
|
21
|
+
ReflectionUtils.call(callback, params)
|
22
|
+
logger.info('Press any key to continue')
|
23
|
+
gets
|
24
|
+
end
|
25
|
+
@user_interaction_before_return = self.method(:user_interaction_before_return)
|
26
|
+
|
27
|
+
def self.lifecycle_signals(callback:, params: nil)
|
28
|
+
logger.debug("Method '#{callback}' started")
|
29
|
+
ReflectionUtils.call(callback, params)
|
30
|
+
logger.debug("Method '#{callback}' finished")
|
31
|
+
end
|
32
|
+
@lifecycle_signals = self.method(:lifecycle_signals)
|
33
|
+
|
34
|
+
end
|
metadata
ADDED
@@ -0,0 +1,140 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: encapsulators
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- thisismydesign
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2017-06-17 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: easy_logging
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: reflection_utils
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: bundler
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '1.14'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '1.14'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rake
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '10.0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '10.0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rspec
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '3.0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '3.0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: coveralls
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
description:
|
98
|
+
email:
|
99
|
+
- thisismydesign@users.noreply.github.com
|
100
|
+
executables: []
|
101
|
+
extensions: []
|
102
|
+
extra_rdoc_files: []
|
103
|
+
files:
|
104
|
+
- ".gitignore"
|
105
|
+
- ".rspec"
|
106
|
+
- ".travis.yml"
|
107
|
+
- Gemfile
|
108
|
+
- LICENSE
|
109
|
+
- README.md
|
110
|
+
- Rakefile
|
111
|
+
- bin/console
|
112
|
+
- bin/setup
|
113
|
+
- encapsulators.gemspec
|
114
|
+
- lib/encapsulators.rb
|
115
|
+
- lib/encapsulators/helpers.rb
|
116
|
+
- lib/encapsulators/version.rb
|
117
|
+
homepage: https://github.com/thisismydesign/encapsulators
|
118
|
+
licenses: []
|
119
|
+
metadata: {}
|
120
|
+
post_install_message:
|
121
|
+
rdoc_options: []
|
122
|
+
require_paths:
|
123
|
+
- lib
|
124
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
125
|
+
requirements:
|
126
|
+
- - ">="
|
127
|
+
- !ruby/object:Gem::Version
|
128
|
+
version: '0'
|
129
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
130
|
+
requirements:
|
131
|
+
- - ">="
|
132
|
+
- !ruby/object:Gem::Version
|
133
|
+
version: '0'
|
134
|
+
requirements: []
|
135
|
+
rubyforge_project:
|
136
|
+
rubygems_version: 2.5.2
|
137
|
+
signing_key:
|
138
|
+
specification_version: 4
|
139
|
+
summary: Collection of practical functions to be used with the 'encapsulate' gem.
|
140
|
+
test_files: []
|