iamsure 0.1.0 → 0.9.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +2 -0
- data/CODE_OF_CONDUCT.md +1 -1
- data/Gemfile +2 -0
- data/Gemfile.lock +20 -0
- data/README.md +52 -6
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/iamsure.gemspec +4 -4
- data/lib/iamsure.rb +3 -2
- data/lib/iamsure/initiator.rb +1 -1
- data/lib/iamsure/unpacker.rb +1 -4
- data/lib/iamsure/version.rb +1 -1
- metadata +7 -4
- data/.rspec_status +0 -12
- data/LICENSE.txt +0 -21
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 000d74e4fd57b9e745e2b57511ef09611b53b1264453922c25dbd483bb7ef476
|
4
|
+
data.tar.gz: b4fbd274ce5d6d06d1415f0714f0f17fa9df43080fcbfb66ead42dbe59046c88
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 852ec2f18776f69d534a4574c6a201698accf8313e9cce2cbb0596cf4c5adac88dafb21fbe779454121e1e21d7171c24ce9acbcb5d5e95241f9996902ae85b95
|
7
|
+
data.tar.gz: 9a4e6b1d0dc9a706207498ca8a5be00000979e0ba1027cd41591a0381e1cdc3d63748f55cdfddade69f919f39c7bbeb90669e41d14be03a33ae8a4395a3ed207
|
data/.gitignore
CHANGED
data/CODE_OF_CONDUCT.md
CHANGED
@@ -55,7 +55,7 @@ further defined and clarified by project maintainers.
|
|
55
55
|
## Enforcement
|
56
56
|
|
57
57
|
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
58
|
-
reported by contacting the project
|
58
|
+
reported by contacting the project under the issues of the repository. All
|
59
59
|
complaints will be reviewed and investigated and will result in a response that
|
60
60
|
is deemed necessary and appropriate to the circumstances. The project team is
|
61
61
|
obligated to maintain confidentiality with regard to the reporter of an incident.
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -6,7 +6,15 @@ PATH
|
|
6
6
|
GEM
|
7
7
|
remote: https://rubygems.org/
|
8
8
|
specs:
|
9
|
+
coveralls (0.8.23)
|
10
|
+
json (>= 1.8, < 3)
|
11
|
+
simplecov (~> 0.16.1)
|
12
|
+
term-ansicolor (~> 1.3)
|
13
|
+
thor (>= 0.19.4, < 2.0)
|
14
|
+
tins (~> 1.6)
|
9
15
|
diff-lcs (1.3)
|
16
|
+
docile (1.3.2)
|
17
|
+
json (2.3.0)
|
10
18
|
rake (13.0.1)
|
11
19
|
rspec (3.9.0)
|
12
20
|
rspec-core (~> 3.9.0)
|
@@ -21,12 +29,24 @@ GEM
|
|
21
29
|
diff-lcs (>= 1.2.0, < 2.0)
|
22
30
|
rspec-support (~> 3.9.0)
|
23
31
|
rspec-support (3.9.3)
|
32
|
+
simplecov (0.16.1)
|
33
|
+
docile (~> 1.1)
|
34
|
+
json (>= 1.8, < 3)
|
35
|
+
simplecov-html (~> 0.10.0)
|
36
|
+
simplecov-html (0.10.2)
|
37
|
+
sync (0.5.0)
|
38
|
+
term-ansicolor (1.7.1)
|
39
|
+
tins (~> 1.0)
|
40
|
+
thor (1.0.1)
|
41
|
+
tins (1.25.0)
|
42
|
+
sync
|
24
43
|
|
25
44
|
PLATFORMS
|
26
45
|
ruby
|
27
46
|
|
28
47
|
DEPENDENCIES
|
29
48
|
bundler (~> 2.0)
|
49
|
+
coveralls
|
30
50
|
iamsure!
|
31
51
|
rake (~> 13.0)
|
32
52
|
rspec (~> 3.9)
|
data/README.md
CHANGED
@@ -1,8 +1,9 @@
|
|
1
|
-
# Iamsure
|
2
1
|
|
3
|
-
|
2
|
+
![Travis (.org)](https://img.shields.io/travis/torokmark/iamsure)
|
3
|
+
![Coveralls github](https://img.shields.io/coveralls/github/torokmark/iamsure)
|
4
|
+
# Iamsure
|
4
5
|
|
5
|
-
|
6
|
+
IamSure is a precondition checker by chaining conditions next one another.
|
6
7
|
|
7
8
|
## Installation
|
8
9
|
|
@@ -22,7 +23,52 @@ Or install it yourself as:
|
|
22
23
|
|
23
24
|
## Usage
|
24
25
|
|
25
|
-
|
26
|
+
```ruby
|
27
|
+
def fun(arg)
|
28
|
+
IamSure.of(arg)
|
29
|
+
.not_nil("argument cannot be null")
|
30
|
+
.get # => arg
|
31
|
+
end
|
32
|
+
```
|
33
|
+
|
34
|
+
```ruby
|
35
|
+
class CustomUnpacker < Iamsure::Unpacker
|
36
|
+
def unpack(arg)
|
37
|
+
"#{ arg }/some.rb"
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
class CustomInitiator < Iamsure::Initiator
|
42
|
+
def init(arg)
|
43
|
+
arg.to_s
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
def fun(arg)
|
48
|
+
IamSure.of(arg)
|
49
|
+
.not_nil('arg cannot be nil!')
|
50
|
+
.unpack(CustomUnpacker.new)
|
51
|
+
.not_empty("arg cannot be empty")
|
52
|
+
.exist(as: :file)
|
53
|
+
.get(CustomInitiator.new) # =>
|
54
|
+
end
|
55
|
+
```
|
56
|
+
## Documentation
|
57
|
+
|
58
|
+
`IamSure.of(arg): IamSure` creates new instance with the given argument.
|
59
|
+
|
60
|
+
`IamSure#not_nil(msg): IamSure` check whether the value is not `nil`.
|
61
|
+
|
62
|
+
`IamSure#not_empty(msg): IamSure` check whether the value is not empty.
|
63
|
+
|
64
|
+
`IamSure#exist(as): IamSure` check whether the value is file (`as: :file`) or directory (`as: :dir`).
|
65
|
+
|
66
|
+
`IamSure#unpack(unpacker): IamSure` transforms the value into a new one.
|
67
|
+
|
68
|
+
`IamSure#get(initiator): object` returns the the checked object or its initiated value.
|
69
|
+
|
70
|
+
|
71
|
+
|
26
72
|
|
27
73
|
## Development
|
28
74
|
|
@@ -32,7 +78,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
|
|
32
78
|
|
33
79
|
## Contributing
|
34
80
|
|
35
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/
|
81
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/torokmark/iamsure. 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
82
|
|
37
83
|
## License
|
38
84
|
|
@@ -40,4 +86,4 @@ The gem is available as open source under the terms of the [MIT License](https:/
|
|
40
86
|
|
41
87
|
## Code of Conduct
|
42
88
|
|
43
|
-
Everyone interacting in the Iamsure project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/
|
89
|
+
Everyone interacting in the Iamsure project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/torokmark/iamsure/blob/master/CODE_OF_CONDUCT.md).
|
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "iamsure"
|
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
data/iamsure.gemspec
CHANGED
@@ -17,11 +17,11 @@ Gem::Specification.new do |spec|
|
|
17
17
|
# Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
|
18
18
|
# to allow pushing to a single host or delete this section to allow pushing to any host.
|
19
19
|
if spec.respond_to?(:metadata)
|
20
|
-
|
20
|
+
spec.metadata["allowed_push_host"] = "https://rubygems.org"
|
21
21
|
|
22
|
-
|
23
|
-
|
24
|
-
#spec.metadata["changelog_uri"] = "
|
22
|
+
spec.metadata["homepage_uri"] = spec.homepage
|
23
|
+
spec.metadata["source_code_uri"] = spec.homepage
|
24
|
+
#spec.metadata["changelog_uri"] = ""
|
25
25
|
else
|
26
26
|
raise "RubyGems 2.0 or newer is required to protect against " \
|
27
27
|
"public gem pushes."
|
data/lib/iamsure.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
require "iamsure/version"
|
2
|
-
|
2
|
+
require 'iamsure/initiator'
|
3
|
+
require 'iamsure/unpacker'
|
3
4
|
|
4
5
|
module Iamsure
|
5
6
|
class IamSure
|
@@ -49,7 +50,7 @@ module Iamsure
|
|
49
50
|
|
50
51
|
def get(initiator=nil)
|
51
52
|
return @obj if initiator.nil?
|
52
|
-
return
|
53
|
+
return initiator.init(@obj) if initiator.is_a?(Iamsure::Initiator)
|
53
54
|
raise ArgumentError.new "initiator should be empty or inherited from Initiator"
|
54
55
|
end
|
55
56
|
end
|
data/lib/iamsure/initiator.rb
CHANGED
data/lib/iamsure/unpacker.rb
CHANGED
data/lib/iamsure/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: iamsure
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.9.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mark Torok
|
@@ -61,17 +61,17 @@ extra_rdoc_files: []
|
|
61
61
|
files:
|
62
62
|
- ".gitignore"
|
63
63
|
- ".rspec"
|
64
|
-
- ".rspec_status"
|
65
64
|
- ".ruby-version"
|
66
65
|
- ".travis.yml"
|
67
66
|
- CODE_OF_CONDUCT.md
|
68
67
|
- Gemfile
|
69
68
|
- Gemfile.lock
|
70
69
|
- LICENSE
|
71
|
-
- LICENSE.txt
|
72
70
|
- README.md
|
73
71
|
- Rakefile
|
74
72
|
- _config.yml
|
73
|
+
- bin/console
|
74
|
+
- bin/setup
|
75
75
|
- iamsure.gemspec
|
76
76
|
- lib/iamsure.rb
|
77
77
|
- lib/iamsure/initiator.rb
|
@@ -80,7 +80,10 @@ files:
|
|
80
80
|
homepage: https://torokmark.github.io/iamsure/
|
81
81
|
licenses:
|
82
82
|
- MIT
|
83
|
-
metadata:
|
83
|
+
metadata:
|
84
|
+
allowed_push_host: https://rubygems.org
|
85
|
+
homepage_uri: https://torokmark.github.io/iamsure/
|
86
|
+
source_code_uri: https://torokmark.github.io/iamsure/
|
84
87
|
post_install_message:
|
85
88
|
rdoc_options: []
|
86
89
|
require_paths:
|
data/.rspec_status
DELETED
@@ -1,12 +0,0 @@
|
|
1
|
-
example_id | status | run_time |
|
2
|
-
----------------------------------- | ------ | --------------- |
|
3
|
-
./spec/iamsure_spec.rb[1:1:1] | passed | 0.00081 seconds |
|
4
|
-
./spec/iamsure_spec.rb[1:3:1:1] | passed | 0.00006 seconds |
|
5
|
-
./spec/iamsure_spec.rb[1:3:2:1] | passed | 0.00006 seconds |
|
6
|
-
./spec/iamsure_spec.rb[1:4:1:1] | passed | 0.00007 seconds |
|
7
|
-
./spec/iamsure_spec.rb[1:4:2:1] | passed | 0.00075 seconds |
|
8
|
-
./spec/iamsure_spec.rb[1:4:3:1] | passed | 0.00027 seconds |
|
9
|
-
./spec/iamsure_spec.rb[1:5:1:1] | passed | 0.00006 seconds |
|
10
|
-
./spec/iamsure_spec.rb[1:5:2:1] | passed | 0.00006 seconds |
|
11
|
-
./spec/iamsure_spec.rb[1:5:3:1:1] | passed | 0.00006 seconds |
|
12
|
-
./spec/iamsure_spec.rb[1:5:3:2:1:1] | passed | 0.00007 seconds |
|
data/LICENSE.txt
DELETED
@@ -1,21 +0,0 @@
|
|
1
|
-
The MIT License (MIT)
|
2
|
-
|
3
|
-
Copyright (c) 2020 TODO: Write your name
|
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.
|