encapsulators 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: bc3647a64cd44aeecde1de39745abe318b988277
4
- data.tar.gz: 0b5016b2e5e0a2d97fcb7cd84f77e08a4cc23244
3
+ metadata.gz: 91b24b7c80570b4cc5f2161f4d3c2850b01b2a1f
4
+ data.tar.gz: 4fbaa230bd83245c86b6cce637367348a33f75e7
5
5
  SHA512:
6
- metadata.gz: 591d00613af60da46eab03c4402d143a5a7197072a0bc4490e45013066b3a2d34da5efdcd96dac4aa223cdefbdae3409d9551b22d17a88843a31db1c6c68e07f
7
- data.tar.gz: 15ec169eb987e2e1aff20a2e08c1faf20122a4ad2aeb9acd41c5caba97ae690de3ceab6f05eb34880121448ca782f99ddb596eeb615562d8eff7f67a84133fb4
6
+ metadata.gz: e75b88c05365633b4c2e8eed630996d06e2d6d1a7661d123010ea503ab9901a2b916f36788d21bba563face178e8e3c1f7e0a4196e4d9f478f9f0362f63c7db6
7
+ data.tar.gz: 20642296bbf893cb2aa57bcd903869bbaa6a31db7e92ede851b11d4f306de6e470fb47328cd969f82dc2f8fded2da1ca57f0bbbcc76580b75ce49370c2a3d989
data/README.md CHANGED
@@ -1,59 +1,61 @@
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).
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
+ include Encapsulators::References
35
+
36
+ base_function = lambda do
37
+ # ...
38
+ end
39
+
40
+ Encapsulate.run callback: base_function, with: [user_interaction_before_return, exception_handling]
41
+ ```
42
+
43
+ ## Feedback
44
+
45
+ Any feedback is much appreciated.
46
+
47
+ 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.
48
+
49
+ Please let me know if you make use of this project so that I can prioritize further efforts.
50
+
51
+ ## Development
52
+
53
+ This gem is developed using Bundler conventions. A good overview can be found [here](http://bundler.io/v1.14/guides/creating_gem.html).
54
+
55
+ ## Contributing
56
+
57
+ Bug reports and pull requests are welcome on GitHub at https://github.com/thisismydesign/encapsulators.
58
+
59
+ ## License
60
+
61
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
@@ -1,29 +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
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", ">= 0.2.0"
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
data/lib/encapsulators.rb CHANGED
@@ -4,9 +4,6 @@ require 'reflection_utils'
4
4
  require_relative 'encapsulators/helpers'
5
5
 
6
6
  module Encapsulators
7
- include EasyLogging
8
-
9
- attr_reader :exception_handling, :user_interaction_before_return, :lifecycle_signals
10
7
 
11
8
  def self.exception_handling(callback:, params: nil)
12
9
  begin
@@ -15,20 +12,34 @@ module Encapsulators
15
12
  logger.error(Helpers.ruby_style_trace(e))
16
13
  end
17
14
  end
18
- @exception_handling = self.method(:exception_handling)
19
15
 
20
16
  def self.user_interaction_before_return(callback:, params: nil)
21
17
  ReflectionUtils.call(callback, params)
22
18
  logger.info('Press any key to continue')
23
19
  gets
24
20
  end
25
- @user_interaction_before_return = self.method(:user_interaction_before_return)
26
21
 
27
22
  def self.lifecycle_signals(callback:, params: nil)
28
23
  logger.debug("Method '#{callback}' started")
29
24
  ReflectionUtils.call(callback, params)
30
25
  logger.debug("Method '#{callback}' finished")
31
26
  end
32
- @lifecycle_signals = self.method(:lifecycle_signals)
27
+
28
+ # Should remain between encapsulators and `include EasyLogging`, cannot be moved to separate file
29
+ module References
30
+ include ReflectionUtils::CreateClassMethodsUponInclude
31
+
32
+ (Encapsulators.methods - Object.methods).each do |encapsulator|
33
+ define_method(encapsulator) do
34
+ Encapsulators.method(encapsulator)
35
+ end
36
+
37
+ define_singleton_method(encapsulator) do
38
+ Encapsulators.method(encapsulator)
39
+ end
40
+ end
41
+ end
42
+
43
+ include EasyLogging
33
44
 
34
45
  end
@@ -1,3 +1,3 @@
1
1
  module Encapsulators
2
- VERSION = "0.1.0"
2
+ VERSION = "0.2.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: encapsulators
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - thisismydesign
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-06-17 00:00:00.000000000 Z
11
+ date: 2017-06-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: easy_logging
@@ -30,14 +30,14 @@ dependencies:
30
30
  requirements:
31
31
  - - ">="
32
32
  - !ruby/object:Gem::Version
33
- version: '0'
33
+ version: 0.2.0
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - ">="
39
39
  - !ruby/object:Gem::Version
40
- version: '0'
40
+ version: 0.2.0
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: bundler
43
43
  requirement: !ruby/object:Gem::Requirement