trybool 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 +12 -0
- data/.rspec +2 -0
- data/.travis.yml +5 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +83 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/lib/trybool.rb +31 -0
- data/lib/trybool/version.rb +3 -0
- data/trybool.gemspec +37 -0
- metadata +113 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 88e45149494d4ea9e0c25e2e546219ab0ce5bd28
|
4
|
+
data.tar.gz: 68e800d858ffc9a83bc28df6a323a6ee758e258f
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 1730fab83f2255b43a8e597dc83ebaae86e2370e394a739f5864302c73093f055cd28701048b1829d863c299c45c0cdf1d5fc6b38c1584809c2df03ff4749742
|
7
|
+
data.tar.gz: 0930150dc2a3a99633613d79da92b3171a34c47d3efbb20a096def9f78612c80cd1d0c22917be9e3c56bdf5d883bacedcd95d92f3f5883e221d7aec488ea52a9
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2017 Matt Polito
|
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.
|
data/README.md
ADDED
@@ -0,0 +1,83 @@
|
|
1
|
+
# Trybool
|
2
|
+
|
3
|
+
[![Gem Version](http://img.shields.io/gem/v/trybool.svg?style=flat)](http://badge.fury.io/rb/trybool)
|
4
|
+
[![Build Status](http://img.shields.io/travis/hashrocket/trybool/master.svg?style=flat)](https://travis-ci.org/hashrocket/trybool)
|
5
|
+
[![Code Climate](http://img.shields.io/codeclimate/github/hashrocket/trybool.svg?style=flat)](https://codeclimate.com/github/hashrocket/trybool)
|
6
|
+
|
7
|
+
The value parsing tool to return a boolean that you never knew you needed!
|
8
|
+
|
9
|
+
## Installation
|
10
|
+
|
11
|
+
Add this line to your application's Gemfile:
|
12
|
+
|
13
|
+
```ruby
|
14
|
+
gem 'trybool'
|
15
|
+
```
|
16
|
+
|
17
|
+
And then execute:
|
18
|
+
|
19
|
+
$ bundle
|
20
|
+
|
21
|
+
Or install it yourself as:
|
22
|
+
|
23
|
+
$ gem install trybool
|
24
|
+
|
25
|
+
## Usage
|
26
|
+
|
27
|
+
Tried to make this as straight forward a tool as possible.
|
28
|
+
|
29
|
+
```ruby
|
30
|
+
Trybool.parse("1")
|
31
|
+
=> true
|
32
|
+
```
|
33
|
+
|
34
|
+
```ruby
|
35
|
+
Trybool.parse("off")
|
36
|
+
=> false
|
37
|
+
```
|
38
|
+
|
39
|
+
You can even configure it for additional values you may want.
|
40
|
+
|
41
|
+
A once falsey value:
|
42
|
+
|
43
|
+
```ruby
|
44
|
+
Trybool.parse("applesauce")
|
45
|
+
=> false
|
46
|
+
```
|
47
|
+
|
48
|
+
With a little configuration:
|
49
|
+
|
50
|
+
```ruby
|
51
|
+
Trybool.configure do |config|
|
52
|
+
config << "applesauce"
|
53
|
+
end
|
54
|
+
```
|
55
|
+
|
56
|
+
Is now known as the truth!
|
57
|
+
|
58
|
+
```ruby
|
59
|
+
Trybool.parse("applesauce")
|
60
|
+
=> true
|
61
|
+
```
|
62
|
+
|
63
|
+
Just remember a Boolean only has two states, so we only define 'truthy' values. Now we can make a powerful assumption that if it's not the truth... it's false.
|
64
|
+
|
65
|
+
## Development
|
66
|
+
|
67
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
68
|
+
|
69
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
70
|
+
|
71
|
+
## Contributing
|
72
|
+
|
73
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/hashrocket/trybool.
|
74
|
+
|
75
|
+
## About
|
76
|
+
|
77
|
+
[![Hashrocket logo](https://hashrocket.com/hashrocket_logo.svg)](https://hashrocket.com)
|
78
|
+
|
79
|
+
Trybool is supported by the team at [Hashrocket](https://hashrocket.com), a multidisciplinary design & development consultancy. If you'd like to [work with us](https://hashrocket.com/contact) or [join our team](https://hashrocket.com/careers), don't hesitate to get in touch.
|
80
|
+
|
81
|
+
## License
|
82
|
+
|
83
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "trybool"
|
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/lib/trybool.rb
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
require "trybool/version"
|
2
|
+
|
3
|
+
module Trybool
|
4
|
+
TRUTHY_VALUES = [
|
5
|
+
true,
|
6
|
+
1,
|
7
|
+
"1",
|
8
|
+
"t",
|
9
|
+
"T",
|
10
|
+
"true",
|
11
|
+
"TRUE",
|
12
|
+
"on",
|
13
|
+
"ON",
|
14
|
+
]
|
15
|
+
|
16
|
+
def self.configure
|
17
|
+
yield(self)
|
18
|
+
end
|
19
|
+
|
20
|
+
def self.<<(value)
|
21
|
+
Array(value).each { |v| truthy_values << v }
|
22
|
+
end
|
23
|
+
|
24
|
+
def self.parse(value)
|
25
|
+
truthy_values.include?(value)
|
26
|
+
end
|
27
|
+
|
28
|
+
def self.truthy_values
|
29
|
+
@truthy_values ||= Set[*TRUTHY_VALUES]
|
30
|
+
end
|
31
|
+
end
|
data/trybool.gemspec
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'trybool/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "trybool"
|
8
|
+
spec.version = Trybool::VERSION
|
9
|
+
spec.authors = ["Matt Polito"]
|
10
|
+
spec.email = ["matt.polito@gmail.com"]
|
11
|
+
|
12
|
+
spec.summary = %q{Confidently return a boolean from a value}
|
13
|
+
spec.description = %q{The value parser for returning Booleans you never knew you needed.}
|
14
|
+
spec.homepage = "https://github.com/hashrocket/trybool"
|
15
|
+
spec.license = "MIT"
|
16
|
+
|
17
|
+
# Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
|
18
|
+
# to allow pushing to a single host or delete this section to allow pushing to any host.
|
19
|
+
if spec.respond_to?(:metadata)
|
20
|
+
spec.metadata['allowed_push_host'] = "https://rubygems.org"
|
21
|
+
else
|
22
|
+
raise "RubyGems 2.0 or newer is required to protect against " \
|
23
|
+
"public gem pushes."
|
24
|
+
end
|
25
|
+
|
26
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
27
|
+
f.match(%r{^(test|spec|features)/})
|
28
|
+
end
|
29
|
+
spec.bindir = "exe"
|
30
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
31
|
+
spec.require_paths = ["lib"]
|
32
|
+
|
33
|
+
spec.add_development_dependency "bundler", "~> 1.14"
|
34
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
35
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
36
|
+
spec.add_development_dependency "pry"
|
37
|
+
end
|
metadata
ADDED
@@ -0,0 +1,113 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: trybool
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Matt Polito
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2017-03-11 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.14'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.14'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '3.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '3.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: pry
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
description: The value parser for returning Booleans you never knew you needed.
|
70
|
+
email:
|
71
|
+
- matt.polito@gmail.com
|
72
|
+
executables: []
|
73
|
+
extensions: []
|
74
|
+
extra_rdoc_files: []
|
75
|
+
files:
|
76
|
+
- ".gitignore"
|
77
|
+
- ".rspec"
|
78
|
+
- ".travis.yml"
|
79
|
+
- Gemfile
|
80
|
+
- LICENSE.txt
|
81
|
+
- README.md
|
82
|
+
- Rakefile
|
83
|
+
- bin/console
|
84
|
+
- bin/setup
|
85
|
+
- lib/trybool.rb
|
86
|
+
- lib/trybool/version.rb
|
87
|
+
- trybool.gemspec
|
88
|
+
homepage: https://github.com/hashrocket/trybool
|
89
|
+
licenses:
|
90
|
+
- MIT
|
91
|
+
metadata:
|
92
|
+
allowed_push_host: https://rubygems.org
|
93
|
+
post_install_message:
|
94
|
+
rdoc_options: []
|
95
|
+
require_paths:
|
96
|
+
- lib
|
97
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
98
|
+
requirements:
|
99
|
+
- - ">="
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
version: '0'
|
102
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
103
|
+
requirements:
|
104
|
+
- - ">="
|
105
|
+
- !ruby/object:Gem::Version
|
106
|
+
version: '0'
|
107
|
+
requirements: []
|
108
|
+
rubyforge_project:
|
109
|
+
rubygems_version: 2.6.10
|
110
|
+
signing_key:
|
111
|
+
specification_version: 4
|
112
|
+
summary: Confidently return a boolean from a value
|
113
|
+
test_files: []
|