unboolean 0.0.1 → 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8df8e469c66e608d5c2f73f260af72aa3e81c211
4
- data.tar.gz: a4b70e389958355b3e1b240f99dfd250303feff5
3
+ metadata.gz: 39636868a0c0e24b9b6bee769408372e8837aa65
4
+ data.tar.gz: 419bd39b845e45630702fe65f8e740ec6b6bfe78
5
5
  SHA512:
6
- metadata.gz: 100d94aec46eb5e3ed573a54b25d45e63cd167694a8ac22e90d99d6579f0358cc0215059a52d617d497720744316f36a58f5191e6e4cc5dd894a5afcb6476703
7
- data.tar.gz: bdad018835d7ff7d15d6f6e3c5e423c95b9a0b3a25cca3d08dd1d091e7f84fb094b0bfb195d8f2d9862bec99311ad9b33f895e0fe5acc0c79248b27763f68462
6
+ metadata.gz: 184b4498979b9384180518e6105627973b4a8895b934fa991ee28786d0482c89d5def81c35b5181ead591362e0d58270f48e353e64e2be55c54f46f76921342d
7
+ data.tar.gz: b9297aba442e75b50885ae7a716cdd98afab62e58dbb52733c70915f890f22ec83cb7c076cc6e232b6928f17ccb0bb7ff435e184a37c77f06cf0ed2fbf01f5db
@@ -0,0 +1,12 @@
1
+ == 0.0.2
2
+
3
+ * Better inspect value for `Unboolean::Maybe` instance.
4
+ * Fix `true` and `false` methods: `:&`, `:|`, `:^`, `:!` (covered with RSpec)
5
+ * Structured code has a bit more logic. Maybe
6
+ * 100%-coverage of code
7
+
8
+ == 0.0.1
9
+
10
+ * Namespace `Unboolean`
11
+ * `Unboolean::Maybe` class that represents companion for `TrueClass` and `FalseClass` from Ruby core
12
+ * Kernel extension to provide convenient method to use `maybe` function in code
data/Gemfile CHANGED
@@ -2,3 +2,8 @@ source 'https://rubygems.org'
2
2
 
3
3
  # Specify your gem's dependencies in unboolean.gemspec
4
4
  gemspec
5
+
6
+ group :documentation do
7
+ gem 'redcarpet', platforms: :ruby
8
+ gem 'kramdown', platforms: :jruby
9
+ end
data/README.md CHANGED
@@ -1,37 +1,66 @@
1
1
  # Unboolean
2
2
 
3
+ [![Build Status](https://travis-ci.org/alsemyonov/unboolean.png)](https://travis-ci.org/alsemyonov/unboolean)
4
+ [![Dependency Status](https://gemnasium.com/alsemyonov/unboolean.png)](https://gemnasium.com/alsemyonov/unboolean)
5
+ [![Code Climate](https://codeclimate.com/github/alsemyonov/unboolean.png)](https://codeclimate.com/github/alsemyonov/unboolean)
6
+ [![Coverage Status](https://coveralls.io/repos/alsemyonov/unboolean/badge.png)](https://coveralls.io/r/alsemyonov/unboolean)
7
+ [![Roadmap and Changelog](https://roadchange.com/alsemyonov/unboolean/badge.png)](https://roadchange.com/alsemyonov/unboolean)
8
+
3
9
  Boolean is too boring. Let’s add `maybe` to `true` and `false`.
4
10
 
11
+ ## Project links
12
+
13
+ * [Source](https://github.com/alsemyonov/unboolean)
14
+ * [Issues](https://github.com/alsemyonov/unboolean/issues)
15
+ * Documentation: [Stable](https://rubydoc.info/gems/unboolean) and [Edge](https://rubydoc.info/github/alsemyonov/unboolean)
16
+ * [Wiki](https://github.com/alsemyonov/unboolean/wiki)
17
+
5
18
  ## Installation
6
19
 
7
20
  Add this line to your application's Gemfile:
8
21
 
9
- gem 'unboolean'
22
+ ```ruby
23
+ gem 'unboolean'
24
+ ```
10
25
 
11
26
  And then execute:
12
27
 
13
- $ bundle
28
+ ```bash
29
+ $ bundle
30
+ ```
14
31
 
15
32
  Or install it yourself as:
16
33
 
17
- $ gem install unboolean
34
+ ```bash
35
+ $ gem install unboolean
36
+ ```
18
37
 
19
38
  ## Usage
20
39
 
21
40
  ```ruby
22
41
  maybe == maybe # => maybe
42
+ maybe == true # => maybe
43
+ maybe == false # => maybe
44
+ true == maybe # => maybe
45
+ false == true # => maybe
23
46
 
24
47
  maybe & true # => maybe
25
48
  maybe & false # => false
26
49
  maybe & maybe # => maybe
50
+ true & maybe # => maybe
51
+ false & maybe # => false
27
52
 
28
53
  maybe | true # => true
29
54
  maybe | false # => maybe
30
55
  maybe | maybe # => maybe
56
+ true | maybe # => true
57
+ false | maybe # => maybe
31
58
 
32
59
  maybe ^ true # => maybe
33
60
  maybe ^ false # => maybe
34
61
  maybe ^ maybe # => maybe # Do you think it may not be? No! Everything may be.
62
+ true ^ maybe # => maybe
63
+ false ^ maybe # => maybe
35
64
 
36
65
  !maybe # => maybe # Yes, it is still may be.
37
66
  ```
@@ -43,3 +72,7 @@ maybe ^ maybe # => maybe # Do you think it may not be? No! Everything may be.
43
72
  3. Commit your changes (`git commit -am 'Add some feature'`)
44
73
  4. Push to the branch (`git push origin my-new-feature`)
45
74
  5. Create new Pull Request
75
+
76
+ ## Copyright
77
+
78
+ © [Alexander Semyonov](mailto:al@semyonov.us), 2013, MIT License.
@@ -0,0 +1,14 @@
1
+ == 0.0.5
2
+
3
+ * `Unboolean::Probably` representing `maybe` with less standard deviation
4
+ * Kernel extension to provide convenient method `probably` and `hardly`
5
+
6
+ == 0.0.4
7
+
8
+ * `Unboolean::Unlikely` and `Unboolean::Hardly` representing more unlikely values than `maybe`
9
+ * Kernel extension to provide convenient methods `unlikely` and `hardly`
10
+
11
+ == 0.0.3
12
+
13
+ * `Unboolean::Certainly` and `Unboolean::Likely` representing more likely values than `maybe`
14
+ * Kernel extension to provide convenient methods `certainly` and `likely`
data/Rakefile CHANGED
@@ -1,6 +1,21 @@
1
1
  require 'bundler/gem_tasks'
2
- require 'rspec/core/rake_task'
3
2
 
4
- RSpec::Core::RakeTask.new(:spec)
3
+ begin
4
+ require 'yard'
5
+ YARD::Rake::YardocTask.new(:doc)
6
+ rescue LoadError
7
+ task :doc do
8
+ abort "YARD is not available. In order to run yardoc, you must: gem install yard"
9
+ end
10
+ end
5
11
 
6
- task :default => :spec
12
+ begin
13
+ require 'rspec/core/rake_task'
14
+ RSpec::Core::RakeTask.new(:spec)
15
+ rescue LoadError
16
+ task :spec do
17
+ abort "RSpec is not available. In order to run specs, you must: gem install rspec"
18
+ end
19
+ end
20
+
21
+ task default: :spec
@@ -1,8 +1,3 @@
1
- require 'unboolean'
2
- require 'unboolean/maybe'
3
-
4
- module Kernel
5
- def maybe
6
- @__unboolean_maybe ||= Unboolean::Maybe.new
7
- end
8
- end
1
+ require 'unboolean/core_ext/kernel'
2
+ require 'unboolean/core_ext/true_class'
3
+ require 'unboolean/core_ext/false_class'
@@ -0,0 +1,16 @@
1
+ require 'unboolean'
2
+ require 'unboolean/maybe'
3
+
4
+ class FalseClass
5
+ def |(other)
6
+ other.is_a?(Unboolean::Maybe) ? other | self : !!(other)
7
+ end
8
+
9
+ def ^(other)
10
+ other.is_a?(Unboolean::Maybe) ? other ^ self : (!other).is_a?(FalseClass)
11
+ end
12
+
13
+ def ==(other)
14
+ other.is_a?(Unboolean::Maybe) ? other == self : (!!other).is_a?(FalseClass)
15
+ end
16
+ end
@@ -0,0 +1,8 @@
1
+ require 'unboolean'
2
+ require 'unboolean/maybe'
3
+
4
+ module Kernel
5
+ def maybe
6
+ @__unboolean_maybe ||= Unboolean::Maybe.new
7
+ end
8
+ end
@@ -0,0 +1,16 @@
1
+ require 'unboolean'
2
+ require 'unboolean/maybe'
3
+
4
+ class TrueClass
5
+ def &(other)
6
+ other.is_a?(Unboolean::Maybe) ? other & self : !!(other)
7
+ end
8
+
9
+ def ^(other)
10
+ other.is_a?(Unboolean::Maybe) ? other ^ self : (!other).is_a?(TrueClass)
11
+ end
12
+
13
+ def ==(other)
14
+ other.is_a?(Unboolean::Maybe) ? other == self : (!!other).is_a?(TrueClass)
15
+ end
16
+ end
@@ -3,6 +3,7 @@ require 'singleton'
3
3
 
4
4
  module Unboolean
5
5
  class Maybe
6
+ # May be singleton?
6
7
  def self.new
7
8
  @__unboolean_maybe_instance ||= super
8
9
  end
@@ -26,5 +27,9 @@ module Unboolean
26
27
  def ==(*)
27
28
  Maybe.new
28
29
  end
30
+
31
+ def inspect
32
+ 'maybe'
33
+ end
29
34
  end
30
35
  end
@@ -1,3 +1,3 @@
1
1
  module Unboolean
2
- VERSION = '0.0.1'
2
+ VERSION = '0.0.2'
3
3
  end
@@ -1,2 +1,11 @@
1
+ require 'simplecov'
2
+ require 'coveralls'
3
+
4
+ SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[
5
+ SimpleCov::Formatter::HTMLFormatter,
6
+ Coveralls::SimpleCov::Formatter
7
+ ]
8
+ SimpleCov.start
9
+
1
10
  $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
2
11
  require 'unboolean'
@@ -0,0 +1,35 @@
1
+ require 'spec_helper'
2
+
3
+ describe false do
4
+ subject { false }
5
+
6
+ specify('#=> false') { expect(subject).to eql(false) }
7
+
8
+ context '!' do
9
+ specify('#=> true') { expect(!subject).to eql(true) }
10
+ end
11
+
12
+ context '==' do
13
+ specify('true #=> false') { expect(subject == true).to eql(false) }
14
+ specify('false #=> true') { expect(subject == false).to eql(true) }
15
+ specify('maybe #=> maybe') { expect(subject == maybe).to eql(maybe) }
16
+ end
17
+
18
+ context '&' do
19
+ specify('true #=> false') { expect(subject & true).to eql(false) }
20
+ specify('false #=> false') { expect(subject & false).to eql(false) }
21
+ specify('maybe #=> false') { expect(subject & maybe).to eql(false) }
22
+ end
23
+
24
+ context '|' do
25
+ specify('true #=> true') { expect(subject | true).to eql(true) }
26
+ specify('false #=> false') { expect(subject | false).to eql(false) }
27
+ specify('maybe #=> maybe') { expect(subject | maybe).to eql(maybe) }
28
+ end
29
+
30
+ context '^' do
31
+ specify('true #=> true') { expect(subject ^ true).to eql(true) }
32
+ specify('false #=> false') { expect(subject ^ false).to eql(false) }
33
+ specify('maybe #=> maybe') { expect(subject ^ maybe).to eql(maybe) }
34
+ end
35
+ end
@@ -0,0 +1,35 @@
1
+ require 'spec_helper'
2
+
3
+ describe true do
4
+ subject { true }
5
+
6
+ specify('#=> true') { expect(subject).to eql(true) }
7
+
8
+ context '!' do
9
+ specify('#=> false') { expect(!subject).to eql(false) }
10
+ end
11
+
12
+ context '==' do
13
+ specify('true #=> true') { expect(subject == true).to eql(true) }
14
+ specify('false #=> false') { expect(subject == false).to eql(false) }
15
+ specify('maybe #=> maybe') { expect(subject == maybe).to eql(maybe) }
16
+ end
17
+
18
+ context '&' do
19
+ specify('true #=> true') { expect(subject & true).to eql(true) }
20
+ specify('false #=> false') { expect(subject & false).to eql(false) }
21
+ specify('maybe #=> maybe') { expect(subject & maybe).to eql(maybe) }
22
+ end
23
+
24
+ context '|' do
25
+ specify('true #=> true') { expect(subject | true).to eql(true) }
26
+ specify('false #=> true') { expect(subject | false).to eql(true) }
27
+ specify('maybe #=> true') { expect(subject | maybe).to eql(true) }
28
+ end
29
+
30
+ context '^' do
31
+ specify('true #=> false') { expect(subject ^ true).to eql(false) }
32
+ specify('false #=> true') { expect(subject ^ false).to eql(true) }
33
+ specify('maybe #=> maybe') { expect(subject ^ maybe).to eql(maybe) }
34
+ end
35
+ end
@@ -1,24 +1,37 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe Unboolean::Maybe do
4
- subject(:maybe) { described_class.new }
3
+ describe 'maybe' do
4
+ subject(:maybe) { Unboolean::Maybe.new }
5
5
 
6
- specify('maybe MAY BE maybe') { expect(maybe).to eql(maybe) }
7
- specify('NOT maybe may be maybe') { expect(!maybe).to eql(maybe) }
6
+ its(:inspect) { should == 'maybe' }
8
7
 
9
- specify('maybe MAY BE equal to maybe') { expect(maybe == maybe).to eql(maybe) }
10
- specify('maybe MAY BE equal to true') { expect(maybe == true).to eql(maybe) }
11
- specify('maybe MAY BE equal to false') { expect(maybe == false).to eql(maybe) }
8
+ specify('#=> maybe') { expect(subject).to eql(maybe) }
12
9
 
13
- specify('maybe AND true may be maybe') { expect(maybe & true).to eql(maybe) }
14
- specify('maybe AND false may be false') { expect(maybe & false).to eql(false) }
15
- specify('maybe AND maybe may be maybe') { expect(maybe & maybe).to eql(maybe) }
10
+ context '!' do
11
+ specify('#=> maybe') { expect(!subject).to eql(maybe) }
12
+ end
16
13
 
17
- specify('maybe OR true should be true') { expect(maybe | true).to eql(true) }
18
- specify('maybe OR false may be maybe') { expect(maybe | false).to eql(maybe) }
19
- specify('maybe OR maybe may be maybe') { expect(maybe | maybe).to eql(maybe) }
14
+ context '==' do
15
+ specify('true #=> maybe') { expect(subject == true).to eql(maybe) }
16
+ specify('false #=> maybe') { expect(subject == false).to eql(maybe) }
17
+ specify('maybe #=> maybe') { expect(subject == maybe).to eql(maybe) }
18
+ end
20
19
 
21
- specify('maybe XOR true may be maybe') { expect(maybe ^ true).to eql(maybe) }
22
- specify('maybe XOR false may be maybe') { expect(maybe ^ false).to eql(maybe) }
23
- specify('maybe XOR maybe may be maybe') { expect(maybe ^ maybe).to eql(maybe) }
20
+ context '&' do
21
+ specify('true #=> maybe') { expect(subject & true).to eql(maybe) }
22
+ specify('false #=> false') { expect(subject & false).to eql(false) }
23
+ specify('maybe #=> maybe') { expect(subject & maybe).to eql(maybe) }
24
+ end
25
+
26
+ context '|' do
27
+ specify('true #=> true') { expect(subject | true).to eql(true) }
28
+ specify('false #=> maybe') { expect(subject | false).to eql(maybe) }
29
+ specify('maybe #=> maybe') { expect(subject | maybe).to eql(maybe) }
30
+ end
31
+
32
+ context '^' do
33
+ specify('true #=> maybe') { expect(subject ^ true).to eql(maybe) }
34
+ specify('false #=> maybe') { expect(subject ^ false).to eql(maybe) }
35
+ specify('maybe #=> maybe') { expect(subject ^ maybe).to eql(maybe) }
36
+ end
24
37
  end
@@ -10,7 +10,7 @@ Gem::Specification.new do |spec|
10
10
  spec.email = %w(al@semyonov.us)
11
11
  spec.description = %q{Boolean is too boring. Let’s add Maybe value.}
12
12
  spec.summary = %q{True, false, or Maybe?}
13
- spec.homepage = ''
13
+ spec.homepage = 'https://github.com/alsemyonov/unboolean'
14
14
  spec.license = 'MIT'
15
15
 
16
16
  spec.files = `git ls-files`.split($INPUT_RECORD_SEPARATOR)
@@ -21,4 +21,7 @@ Gem::Specification.new do |spec|
21
21
  spec.add_development_dependency 'bundler', '~> 1.3'
22
22
  spec.add_development_dependency 'rake'
23
23
  spec.add_development_dependency 'rspec'
24
+ spec.add_development_dependency 'simplecov'
25
+ spec.add_development_dependency 'coveralls'
26
+ spec.add_development_dependency 'yard'
24
27
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: unboolean
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alexander Semyonov
@@ -52,6 +52,48 @@ dependencies:
52
52
  - - '>='
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: simplecov
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
+ - !ruby/object:Gem::Dependency
70
+ name: coveralls
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - '>='
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - '>='
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: yard
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - '>='
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - '>='
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
55
97
  description: Boolean is too boring. Let’s add Maybe value.
56
98
  email:
57
99
  - al@semyonov.us
@@ -62,19 +104,26 @@ files:
62
104
  - .gitignore
63
105
  - .rspec
64
106
  - .travis.yml
107
+ - CHANGELOG.md
65
108
  - Gemfile
66
109
  - LICENSE.txt
67
110
  - README.md
111
+ - ROADMAP.md
68
112
  - Rakefile
69
113
  - lib/unboolean.rb
70
114
  - lib/unboolean/core_ext.rb
115
+ - lib/unboolean/core_ext/false_class.rb
116
+ - lib/unboolean/core_ext/kernel.rb
117
+ - lib/unboolean/core_ext/true_class.rb
71
118
  - lib/unboolean/maybe.rb
72
119
  - lib/unboolean/version.rb
73
120
  - spec/spec_helper.rb
121
+ - spec/unboolean/core_ext/false_class_spec.rb
122
+ - spec/unboolean/core_ext/true_class_spec.rb
74
123
  - spec/unboolean/maybe_spec.rb
75
124
  - spec/unboolean_spec.rb
76
125
  - unboolean.gemspec
77
- homepage: ''
126
+ homepage: https://github.com/alsemyonov/unboolean
78
127
  licenses:
79
128
  - MIT
80
129
  metadata: {}
@@ -100,5 +149,8 @@ specification_version: 4
100
149
  summary: True, false, or Maybe?
101
150
  test_files:
102
151
  - spec/spec_helper.rb
152
+ - spec/unboolean/core_ext/false_class_spec.rb
153
+ - spec/unboolean/core_ext/true_class_spec.rb
103
154
  - spec/unboolean/maybe_spec.rb
104
155
  - spec/unboolean_spec.rb
156
+ has_rdoc: