null_question 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: 7ae9904893d7df9703916cb6d8c43bdba8584113
4
+ data.tar.gz: a62a4053ec1be5675a255238754480d76d2dfc08
5
+ SHA512:
6
+ metadata.gz: 6cc71f2856ffe57a121df075701f791709090adeab869fbc28d64ed6fe4f9a4a9074a5d492d34c10df06d864af1f7108c20299bf1244b74deffc3d3be090dd25
7
+ data.tar.gz: f4260a83c233f32661ca130c02b6a04ee3b1cc2e7218d2844b4a52346cb1f636275293358b15773b83344ad0afb782b52317bb5c073318ad7b541d43434d527f
@@ -0,0 +1 @@
1
+ Gemfile.lock
@@ -0,0 +1,18 @@
1
+ sudo: false
2
+ language: ruby
3
+
4
+ script: bundle exec ruby spec/null_question_spec.rb
5
+
6
+ rvm:
7
+ - 2.2
8
+ - 2.1
9
+ - 2.0
10
+ - rbx-2
11
+ - jruby-head
12
+ - jruby-9000
13
+
14
+ cache:
15
+ - bundler
16
+
17
+ # matrix:
18
+ # fast_finish: true
@@ -0,0 +1,6 @@
1
+ ## CHANGELOG
2
+
3
+ ### 1.0.0
4
+
5
+ * Inital release
6
+
data/Gemfile ADDED
@@ -0,0 +1,5 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
4
+
5
+ gem 'minitest'
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2015 Jan Lelis, mail@janlelis.de
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,34 @@
1
+ # Object#null? [![[version]](https://badge.fury.io/rb/null_question.svg)](http://badge.fury.io/rb/null_question) [![[travis]](https://travis-ci.org/janlelis/null_question.png)](https://travis-ci.org/janlelis/null_question)
2
+
3
+ Adds NilClass#null? #=> true and Object#null? #=> false
4
+
5
+ Useful for implementing custom null objects that also return true for `#null?`
6
+
7
+
8
+ ## Setup
9
+
10
+ Add to your `Gemfile`:
11
+
12
+ ```ruby
13
+ gem 'null_question'
14
+ ```
15
+
16
+
17
+ ## Usage
18
+
19
+ ```ruby
20
+ class NullObject
21
+ def null?
22
+ true
23
+ end
24
+ end
25
+
26
+ nil.null? #=> true
27
+ NullObject.new.null? #=> true
28
+ Object.new.null? #=> false
29
+ ```
30
+
31
+
32
+ ## J-_-L
33
+
34
+ Copyright (C) 2015 Jan Lelis <http://janlelis.com>. Released under the MIT license.
@@ -0,0 +1,30 @@
1
+ # # #
2
+ # Get gemspec info
3
+
4
+ gemspec_file = Dir['*.gemspec'].first
5
+ gemspec = eval File.read(gemspec_file), binding, gemspec_file
6
+ info = "#{gemspec.name} | #{gemspec.version} | " \
7
+ "#{gemspec.runtime_dependencies.size} dependencies | " \
8
+ "#{gemspec.files.size} files"
9
+
10
+
11
+ # # #
12
+ # Gem build and install task
13
+
14
+ desc info
15
+ task :gem do
16
+ puts info + "\n\n"
17
+ print " "; sh "gem build #{gemspec_file}"
18
+ FileUtils.mkdir_p 'pkg'
19
+ FileUtils.mv "#{gemspec.name}-#{gemspec.version}.gem", 'pkg'
20
+ puts; sh %{gem install --no-document pkg/#{gemspec.name}-#{gemspec.version}.gem}
21
+ end
22
+
23
+
24
+ # # #
25
+ # Start an IRB session with the gem loaded
26
+
27
+ desc "#{gemspec.name} | IRB"
28
+ task :irb do
29
+ sh "irb -I ./lib -r #{gemspec.name.gsub '-','/'}"
30
+ end
@@ -0,0 +1,16 @@
1
+ module NullQuestion
2
+ VERSION = "1.0.0".freeze
3
+ end
4
+
5
+ class NilClass
6
+ def null?
7
+ true
8
+ end
9
+ end
10
+
11
+ class Object
12
+ def null?
13
+ false
14
+ end
15
+ end
16
+
@@ -0,0 +1,21 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ require File.dirname(__FILE__) + "/lib/null_question"
4
+
5
+ Gem::Specification.new do |gem|
6
+ gem.name = "null_question"
7
+ gem.version = NullQuestion::VERSION
8
+ gem.summary = "Object#null?"
9
+ gem.description = "Adds NilClass#null? #=> true and Object#null? #=> false"
10
+ gem.authors = ["Jan Lelis"]
11
+ gem.email = ["mail@janlelis.de"]
12
+ gem.homepage = "https://github.com/janlelis/null_question"
13
+ gem.license = "MIT"
14
+
15
+ gem.files = Dir["{**/}{.*,*}"].select{ |path| File.file?(path) && path !~ /^pkg/ }
16
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
17
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
18
+ gem.require_paths = ["lib"]
19
+
20
+ gem.required_ruby_version = "~> 2.0"
21
+ end
@@ -0,0 +1,17 @@
1
+ require_relative "../lib/null_question"
2
+ require "minitest/autorun"
3
+
4
+ describe NullQuestion do
5
+ describe "Object#null" do
6
+ it "returns true" do
7
+ assert_equal false, Object.new.null?
8
+ end
9
+ end
10
+
11
+ describe "nil.null?" do
12
+ it "returns false" do
13
+ assert_equal true, nil.null?
14
+ end
15
+ end
16
+ end
17
+
metadata ADDED
@@ -0,0 +1,56 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: null_question
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Jan Lelis
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-04-13 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: 'Adds NilClass#null? #=> true and Object#null? #=> false'
14
+ email:
15
+ - mail@janlelis.de
16
+ executables: []
17
+ extensions: []
18
+ extra_rdoc_files: []
19
+ files:
20
+ - ".gitignore"
21
+ - ".travis.yml"
22
+ - CHANGELOG.md
23
+ - Gemfile
24
+ - MIT-LICENSE.txt
25
+ - README.md
26
+ - Rakefile
27
+ - lib/null_question.rb
28
+ - null_question.gemspec
29
+ - spec/null_question_spec.rb
30
+ homepage: https://github.com/janlelis/null_question
31
+ licenses:
32
+ - MIT
33
+ metadata: {}
34
+ post_install_message:
35
+ rdoc_options: []
36
+ require_paths:
37
+ - lib
38
+ required_ruby_version: !ruby/object:Gem::Requirement
39
+ requirements:
40
+ - - "~>"
41
+ - !ruby/object:Gem::Version
42
+ version: '2.0'
43
+ required_rubygems_version: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ requirements: []
49
+ rubyforge_project:
50
+ rubygems_version: 2.4.6
51
+ signing_key:
52
+ specification_version: 4
53
+ summary: Object#null?
54
+ test_files:
55
+ - spec/null_question_spec.rb
56
+ has_rdoc: