-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8101965
commit 9a89041
Showing
6 changed files
with
64 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
source 'https://rubygems.org' | ||
|
||
# Specify your gem's dependencies in to_boolean.gemspec | ||
gemspec |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
require 'rake/testtask' | ||
|
||
Rake::TestTask.new do |t| | ||
t.libs << 'spec' | ||
t.test_files = FileList['spec/spec_*.rb'] | ||
t.verbose = true | ||
end | ||
|
||
task :default => :test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
class Object | ||
def to_boolean | ||
value = self.is_a?(String) ? self.downcase : self | ||
[true, 'true', 1, '1'].include?(value) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
require 'minitest/spec' | ||
require 'minitest/autorun' | ||
require 'minitest/reporters' | ||
|
||
require 'to_boolean' | ||
|
||
Minitest::Reporters.use! Minitest::Reporters::SpecReporter.new |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
require_relative 'spec_helper' | ||
|
||
class TestToBoolean < Minitest::Spec | ||
describe TestToBoolean do | ||
it 'should return true' do | ||
[true, 'true', 'TRUE', 1, '1'].each do |value| | ||
value.to_boolean.must_equal(true) | ||
end | ||
end | ||
|
||
it 'should return false' do | ||
[false, 'false', 'FALSE', 0, '0', nil, :symbol].each do |value| | ||
value.to_boolean.must_equal(false) | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
Gem::Specification.new do |gem| | ||
gem.name = 'to_boolean' | ||
gem.version = '1.0.0' | ||
gem.platform = Gem::Platform::RUBY | ||
gem.authors = ['Jani Jegoroff'] | ||
gem.date = '2014-09-10' | ||
gem.email = ['[email protected]'] | ||
gem.summary = 'Simple gem that provides to_boolean method.' | ||
gem.description = 'Ruby core extension that converts string and integer values to boolean.' | ||
gem.homepage = 'http://github.com/JaniJegoroff/to_boolean' | ||
gem.license = 'MIT' | ||
|
||
gem.files = %w[lib/to_boolean.rb] | ||
gem.require_paths = ['lib'] | ||
|
||
gem.test_files = %w[spec/spec_helper.rb spec/spec_to_boolean.rb] | ||
|
||
gem.add_development_dependency 'rake', '~> 0' | ||
gem.add_development_dependency 'minitest', '~> 0' | ||
gem.add_development_dependency 'minitest-reporters', '~> 0' | ||
end |