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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7d69627436946126f320e9f894de3b0d6e4e39de31aae25340bd6b17304115ac
4
- data.tar.gz: d223cd05ddd508dfb4ddb276b5b06a80af3474926e1147a9f4d33c39736caaeb
3
+ metadata.gz: 000d74e4fd57b9e745e2b57511ef09611b53b1264453922c25dbd483bb7ef476
4
+ data.tar.gz: b4fbd274ce5d6d06d1415f0714f0f17fa9df43080fcbfb66ead42dbe59046c88
5
5
  SHA512:
6
- metadata.gz: 32c625a41433fad92a72a1d860cf604ef821c3b8c3aebaea38c69433713e7ac661e7477673f8f2faa06a3650c0e12a48c15415112963f209958d58530bc8e917
7
- data.tar.gz: 6942257f0edfebc116636e3c2f3c47b016d69b9417159ee93af3378bde74bd6270393369e8e17c03004c83f1595f17b5f4fe94bac95b6ee9d6f17b11c6fcddeb
6
+ metadata.gz: 852ec2f18776f69d534a4574c6a201698accf8313e9cce2cbb0596cf4c5adac88dafb21fbe779454121e1e21d7171c24ce9acbcb5d5e95241f9996902ae85b95
7
+ data.tar.gz: 9a4e6b1d0dc9a706207498ca8a5be00000979e0ba1027cd41591a0381e1cdc3d63748f55cdfddade69f919f39c7bbeb90669e41d14be03a33ae8a4395a3ed207
data/.gitignore CHANGED
@@ -54,3 +54,5 @@ build-iPhoneSimulator/
54
54
 
55
55
  # Used by RuboCop. Remote config files pulled in from inherit_from directive.
56
56
  # .rubocop-https?--*
57
+
58
+ .rspec_status
@@ -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 team at TODO: Write your email address. All
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
@@ -2,3 +2,5 @@ source "https://rubygems.org"
2
2
 
3
3
  # Specify your gem's dependencies in iamsure.gemspec
4
4
  gemspec
5
+
6
+ gem 'coveralls', require: false
@@ -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
- 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/iamsure`. To experiment with that code, run `bin/console` for an interactive prompt.
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
- TODO: Delete this and the text above, and describe your gem
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
- TODO: Write usage instructions here
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/[USERNAME]/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.
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/[USERNAME]/iamsure/blob/master/CODE_OF_CONDUCT.md).
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).
@@ -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__)
@@ -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
@@ -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
- #spec.metadata["allowed_push_host"] = "TODO: Set to 'http://mygemserver.com'"
20
+ spec.metadata["allowed_push_host"] = "https://rubygems.org"
21
21
 
22
- #spec.metadata["homepage_uri"] = spec.homepage
23
- #spec.metadata["source_code_uri"] = "TODO: Put your gem's public repo URL here."
24
- #spec.metadata["changelog_uri"] = "TODO: Put your gem's CHANGELOG.md URL here."
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."
@@ -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 Initiator.new(@obj) if initiator.is_a?(Initiator)
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
@@ -1,6 +1,6 @@
1
1
  module Iamsure
2
2
  class Initiator
3
- def initiate(arg)
3
+ def init(arg)
4
4
  raise 'It should be implemented in inherited class'
5
5
  end
6
6
  end
@@ -1,10 +1,7 @@
1
1
  module Iamsure
2
2
  class Unpacker
3
- def initialize
4
- raise 'Should be implemented in derived class'
5
- end
6
-
7
3
  def unpack
4
+ raise 'Should be implemented in derived class'
8
5
  end
9
6
  end
10
7
  end
@@ -1,3 +1,3 @@
1
1
  module Iamsure
2
- VERSION = "0.1.0"
2
+ VERSION = "0.9.0"
3
3
  end
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.1.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:
@@ -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 |
@@ -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.