toolrack 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 +8 -0
- data/.travis.yml +6 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +7 -0
- data/README.md +60 -0
- data/Rakefile +10 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/lib/toolrack/condition_utils.rb +19 -0
- data/lib/toolrack/exception_utils.rb +49 -0
- data/lib/toolrack/version.rb +6 -0
- data/lib/toolrack.rb +11 -0
- data/toolrack.gemspec +28 -0
- metadata +55 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 9de65ce9c244ee6178fcd96d2e1073dbd9067c7a1f9906e89de614e8a58c329f
|
4
|
+
data.tar.gz: f9943c8203a7cc47c0ab05557ed3c8ad327336288b439d736fc15f7b78deee51
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 03d12fe2c6e1da0c3581ab424a4145f88aad0f0afbca472f5f1c1e2257b93438fba2cfb6591a33eb730751977257adc74b01acd875ce4b54fa8ce46cb08297fe
|
7
|
+
data.tar.gz: 6d089a8429ce18c130fee89b5524a202f6860402b68d6111a1aca80240cf8ecaec38663af2f22a30c42784984c2995c54613d121ff11fcd5eaac27f45d593f82
|
data/.gitignore
ADDED
data/.travis.yml
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -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 chrisliaw@antrapol.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 [https://contributor-covenant.org/version/1/4][version]
|
72
|
+
|
73
|
+
[homepage]: https://contributor-covenant.org
|
74
|
+
[version]: https://contributor-covenant.org/version/1/4/
|
data/Gemfile
ADDED
data/README.md
ADDED
@@ -0,0 +1,60 @@
|
|
1
|
+
# Toolrack
|
2
|
+
|
3
|
+
Toolrack just the collection of utilities that helps in my code clarity
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'toolrack'
|
11
|
+
```
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle install
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install toolrack
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
Toolrack is meant to be utilities hence it is prefixed with an entity.
|
24
|
+
Therefore the two utilities are both packaged in namespace:
|
25
|
+
|
26
|
+
```ruby
|
27
|
+
module Antrapol::MyToolRack::ConditionUtils
|
28
|
+
end
|
29
|
+
```
|
30
|
+
|
31
|
+
```ruby
|
32
|
+
module Antrapol::MyToolRack::ExceptionUtils
|
33
|
+
end
|
34
|
+
```
|
35
|
+
|
36
|
+
Besides, all the utilities so far is a module by itself, which means it is meant to be included/extended into application classes.
|
37
|
+
|
38
|
+
For example:
|
39
|
+
```ruby
|
40
|
+
class EditController
|
41
|
+
include Antrapol::MyToolRack::ConditionUtils
|
42
|
+
include Antrapol::MyToolRack::ExceptionUtils
|
43
|
+
end
|
44
|
+
```
|
45
|
+
|
46
|
+
Currently it has only 2 modules:
|
47
|
+
* Condition Utilities
|
48
|
+
* is_empty?(obj) - I find rather effort intensive to call if not (obj.nil? or obj.empty?) for items that I want to check for validity before process. Hence this method shall test for .nil?. If the object also respond to :empty? it shall be called again. For example integer type does not support .empty?
|
49
|
+
|
50
|
+
* Exception Utilities
|
51
|
+
* raise_if_empty(obj, message, error) - Extension from the is_empty?() above, usually if it is empty, an exception shall be raised. It is just combined the conditions with raise of exception.
|
52
|
+
* obj is the object to test for is_empty
|
53
|
+
* message is the one that shall be thrown with the exception.
|
54
|
+
* error is the exception type
|
55
|
+
* raise_if_false(obj, message, error) - As the name implied
|
56
|
+
* raise_if_true(obj, message, error) - As the name implied
|
57
|
+
|
58
|
+
|
59
|
+
|
60
|
+
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "toolrack"
|
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,19 @@
|
|
1
|
+
|
2
|
+
|
3
|
+
module Antrapol
|
4
|
+
module MyToolRack
|
5
|
+
module ConditionUtils
|
6
|
+
|
7
|
+
def is_empty?(obj)
|
8
|
+
if obj.nil?
|
9
|
+
true
|
10
|
+
elsif obj.respond_to?(:empty?)
|
11
|
+
obj.empty?
|
12
|
+
else
|
13
|
+
false
|
14
|
+
end
|
15
|
+
end # is_empty?
|
16
|
+
|
17
|
+
end # ConditionUtils
|
18
|
+
end # MyToolRack
|
19
|
+
end # Antrapol
|
@@ -0,0 +1,49 @@
|
|
1
|
+
|
2
|
+
require_relative 'conditions_utils'
|
3
|
+
|
4
|
+
module Antrapol
|
5
|
+
module MyToolRack
|
6
|
+
module ExceptionUtils
|
7
|
+
include Antrapol::MyToolRack::ConditionUtils
|
8
|
+
|
9
|
+
# raise_if_empty
|
10
|
+
# Raise the given (or default if not given) exception if the val given is empty
|
11
|
+
# val - variable/object that shall be tested for emptiness
|
12
|
+
# message - message to be thrown if it is true
|
13
|
+
# error - exception object to be thrown
|
14
|
+
def raise_if_empty(val, message, error = Antrapol::MyToolRack::Error)
|
15
|
+
raise_error(message,error) if is_empty?(val)
|
16
|
+
end # raise_if_empty
|
17
|
+
|
18
|
+
#
|
19
|
+
# raise_if_false
|
20
|
+
#
|
21
|
+
def raise_if_false(bool, message, error = Antrapol::MyToolRack::Error)
|
22
|
+
if not bool
|
23
|
+
raise_error(message,error)
|
24
|
+
end
|
25
|
+
end # raise_if_false
|
26
|
+
|
27
|
+
#
|
28
|
+
# raise_if_true
|
29
|
+
#
|
30
|
+
def raise_if_true(bool, message, error = Antrapol::MyToolRack::Error)
|
31
|
+
raise_if_false(!bool, message, error)
|
32
|
+
end # raise_if_true
|
33
|
+
|
34
|
+
protected
|
35
|
+
def raise_error(message, error = Antrapol::MyToolRack::Error)
|
36
|
+
if error.nil?
|
37
|
+
if @default_exception.nil?
|
38
|
+
raise Antrapol::MyToolRack::Error, message
|
39
|
+
else
|
40
|
+
raise @default_exception, message
|
41
|
+
end
|
42
|
+
else
|
43
|
+
raise error, message
|
44
|
+
end
|
45
|
+
end # raise_error
|
46
|
+
|
47
|
+
end # ExceptionUtils
|
48
|
+
end # MyToolRack
|
49
|
+
end # Antrapol
|
data/lib/toolrack.rb
ADDED
data/toolrack.gemspec
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
require_relative 'lib/toolrack/version'
|
2
|
+
|
3
|
+
Gem::Specification.new do |spec|
|
4
|
+
spec.name = "toolrack"
|
5
|
+
spec.version = Antrapol::MyToolRack::VERSION
|
6
|
+
spec.authors = ["Chris"]
|
7
|
+
spec.email = ["chrisliaw@antrapol.com"]
|
8
|
+
|
9
|
+
spec.summary = %q{Collection of simple utilities but I find it increase clarity}
|
10
|
+
spec.description = %q{Just collections of utilities}
|
11
|
+
spec.homepage = ""
|
12
|
+
spec.required_ruby_version = Gem::Requirement.new(">= 2.3.0")
|
13
|
+
|
14
|
+
#spec.metadata["allowed_push_host"] = "TODO: Set to 'http://mygemserver.com'"
|
15
|
+
|
16
|
+
#spec.metadata["homepage_uri"] = spec.homepage
|
17
|
+
#spec.metadata["source_code_uri"] = "TODO: Put your gem's public repo URL here."
|
18
|
+
#spec.metadata["changelog_uri"] = "TODO: Put your gem's CHANGELOG.md URL here."
|
19
|
+
|
20
|
+
# Specify which files should be added to the gem when it is released.
|
21
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
22
|
+
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
|
23
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
24
|
+
end
|
25
|
+
spec.bindir = "exe"
|
26
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
27
|
+
spec.require_paths = ["lib"]
|
28
|
+
end
|
metadata
ADDED
@@ -0,0 +1,55 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: toolrack
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Chris
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2020-05-13 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: Just collections of utilities
|
14
|
+
email:
|
15
|
+
- chrisliaw@antrapol.com
|
16
|
+
executables: []
|
17
|
+
extensions: []
|
18
|
+
extra_rdoc_files: []
|
19
|
+
files:
|
20
|
+
- ".gitignore"
|
21
|
+
- ".travis.yml"
|
22
|
+
- CODE_OF_CONDUCT.md
|
23
|
+
- Gemfile
|
24
|
+
- README.md
|
25
|
+
- Rakefile
|
26
|
+
- bin/console
|
27
|
+
- bin/setup
|
28
|
+
- lib/toolrack.rb
|
29
|
+
- lib/toolrack/condition_utils.rb
|
30
|
+
- lib/toolrack/exception_utils.rb
|
31
|
+
- lib/toolrack/version.rb
|
32
|
+
- toolrack.gemspec
|
33
|
+
homepage: ''
|
34
|
+
licenses: []
|
35
|
+
metadata: {}
|
36
|
+
post_install_message:
|
37
|
+
rdoc_options: []
|
38
|
+
require_paths:
|
39
|
+
- lib
|
40
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
41
|
+
requirements:
|
42
|
+
- - ">="
|
43
|
+
- !ruby/object:Gem::Version
|
44
|
+
version: 2.3.0
|
45
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
46
|
+
requirements:
|
47
|
+
- - ">="
|
48
|
+
- !ruby/object:Gem::Version
|
49
|
+
version: '0'
|
50
|
+
requirements: []
|
51
|
+
rubygems_version: 3.0.8
|
52
|
+
signing_key:
|
53
|
+
specification_version: 4
|
54
|
+
summary: Collection of simple utilities but I find it increase clarity
|
55
|
+
test_files: []
|