nil-if-zero 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: dbfe00ed2dd5b11b01a060636b4e5d3545faaf99
4
+ data.tar.gz: e964a34b3aa7c5ff3512d98e4327e331e5058c8f
5
+ SHA512:
6
+ metadata.gz: 3f94118679f636cb8e6cea52a91276f084b2cb071726ee0a86d952f8b397972c1a5deafd21cacea4f9b78e683a186f102c5be2b1630d28ea85a3228171e90be4
7
+ data.tar.gz: 74dcf6f6da6ab7491caa0e311f2a1de06f0539a8d8f7b46c789f1ae0fbc72154798890d355ba00493c2423602a1d0ebf5f87513ffc8983103dc5991e9d26ccaf
@@ -0,0 +1,6 @@
1
+ *.gem
2
+ .bundle
3
+ .ruby-version
4
+ pkg/
5
+ tmp/
6
+ /.idea/
@@ -0,0 +1,6 @@
1
+ language: ruby
2
+
3
+ rvm:
4
+ - 2.4.0
5
+
6
+ cache: bundler
data/Gemfile ADDED
@@ -0,0 +1,5 @@
1
+ # encoding: UTF-8
2
+ # frozen_string_literal: true
3
+
4
+ source 'https://rubygems.org'
5
+ gemspec
@@ -0,0 +1,23 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ nil-if-zero (1.0.0)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ power_assert (1.0.1)
10
+ rake (12.0.0)
11
+ test-unit (3.2.3)
12
+ power_assert
13
+
14
+ PLATFORMS
15
+ ruby
16
+
17
+ DEPENDENCIES
18
+ nil-if-zero!
19
+ rake (~> 12.0)
20
+ test-unit (~> 3.2)
21
+
22
+ BUNDLED WITH
23
+ 1.14.3
@@ -0,0 +1,26 @@
1
+ ## Adds `Integer#nil_if_zero` and `Integer#nil_unless_zero`.
2
+
3
+ [![Gem Version](https://badge.fury.io/rb/nil-if-zero.svg)](https://badge.fury.io/rb/nil-if-zero)
4
+ [![Build Status](https://travis-ci.org/yivo/nil-if-zero.svg?branch=master)](https://travis-ci.org/yivo/nil-if-zero)
5
+
6
+ ## Installing gem
7
+ Add to your Gemfile:
8
+ ```ruby
9
+ gem 'nil-if-zero', '~> 1.0'
10
+ ```
11
+
12
+ ## Running Tests
13
+ Install bundler:
14
+ ```bash
15
+ gem install bundler
16
+ ```
17
+
18
+ Install dependencies:
19
+ ```bash
20
+ cd nil-if-zero && bundle
21
+ ```
22
+
23
+ Run tests:
24
+ ```bash
25
+ cd nil-if-zero && bundle exec rake test
26
+ ```
@@ -0,0 +1,8 @@
1
+ # encoding: UTF-8
2
+ # frozen_string_literal: true
3
+
4
+ require 'rake/testtask'
5
+
6
+ Rake::TestTask.new { |t| t.libs << 'test' }
7
+
8
+ task default: :test
@@ -0,0 +1,16 @@
1
+ # encoding: UTF-8
2
+ # frozen_string_literal: true
3
+
4
+ module NilIfZero
5
+ module Extension
6
+ def nil_if_zero
7
+ self unless zero?
8
+ end
9
+
10
+ def nil_unless_zero
11
+ self if zero?
12
+ end
13
+ end
14
+ end
15
+
16
+ Integer.include NilIfZero::Extension
@@ -0,0 +1,6 @@
1
+ # encoding: UTF-8
2
+ # frozen_string_literal: true
3
+
4
+ module NilIfZero
5
+ VERSION = '1.0.0'
6
+ end
@@ -0,0 +1,22 @@
1
+ # encoding: UTF-8
2
+ # frozen_string_literal: true
3
+
4
+ require File.expand_path('../lib/nil-if-zero/version', __FILE__)
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = 'nil-if-zero'
8
+ s.version = NilIfZero::VERSION
9
+ s.author = 'Yaroslav Konoplov'
10
+ s.email = 'eahome00@gmail.com'
11
+ s.summary = 'Adds Integer#nil_if_zero and Integer#nil_unless_zero.'
12
+ s.description = 'Adds Integer#nil_if_zero and Integer#nil_unless_zero.'
13
+ s.homepage = 'https://github.com/yivo/nil-if-zero'
14
+ s.license = 'MIT'
15
+
16
+ s.files = `git ls-files -z`.split("\x0")
17
+ s.test_files = `git ls-files -z -- {test,spec,features}/*`.split("\x0")
18
+ s.require_paths = ['lib']
19
+
20
+ s.add_development_dependency 'rake', '~> 12.0'
21
+ s.add_development_dependency 'test-unit', '~> 3.2'
22
+ end
@@ -0,0 +1,19 @@
1
+ # encoding: UTF-8
2
+ # frozen_string_literal: true
3
+
4
+ require 'test-unit'
5
+ require 'nil-if-zero'
6
+
7
+ class NilIfZeroTest < Test::Unit::TestCase
8
+ def test_nil_if_zero
9
+ assert_equal 1, 1.nil_if_zero
10
+ assert_nil 0.nil_if_zero
11
+ assert_raise(NoMethodError) { 1.0.nil_if_zero }
12
+ end
13
+
14
+ def test_nil_unless_zero
15
+ assert_nil 1.nil_unless_zero
16
+ assert_equal 0, 0.nil_unless_zero
17
+ assert_raise(NoMethodError) { 1.0.nil_unless_zero }
18
+ end
19
+ end
metadata ADDED
@@ -0,0 +1,82 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: nil-if-zero
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Yaroslav Konoplov
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2017-03-25 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rake
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '12.0'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '12.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: test-unit
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '3.2'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '3.2'
41
+ description: Adds Integer#nil_if_zero and Integer#nil_unless_zero.
42
+ email: eahome00@gmail.com
43
+ executables: []
44
+ extensions: []
45
+ extra_rdoc_files: []
46
+ files:
47
+ - ".gitignore"
48
+ - ".travis.yml"
49
+ - Gemfile
50
+ - Gemfile.lock
51
+ - README.md
52
+ - Rakefile
53
+ - lib/nil-if-zero.rb
54
+ - lib/nil-if-zero/version.rb
55
+ - nil-if-zero.gemspec
56
+ - test/test-nil-if-zero.rb
57
+ homepage: https://github.com/yivo/nil-if-zero
58
+ licenses:
59
+ - MIT
60
+ metadata: {}
61
+ post_install_message:
62
+ rdoc_options: []
63
+ require_paths:
64
+ - lib
65
+ required_ruby_version: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - ">="
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
70
+ required_rubygems_version: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - ">="
73
+ - !ruby/object:Gem::Version
74
+ version: '0'
75
+ requirements: []
76
+ rubyforge_project:
77
+ rubygems_version: 2.6.8
78
+ signing_key:
79
+ specification_version: 4
80
+ summary: Adds Integer#nil_if_zero and Integer#nil_unless_zero.
81
+ test_files:
82
+ - test/test-nil-if-zero.rb