threeve 0.0.1
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 +7 -0
- data/.gitignore +15 -0
- data/.ruby-gemset +1 -0
- data/.ruby-version +1 -0
- data/Gemfile +6 -0
- data/LICENSE.txt +22 -0
- data/README.md +64 -0
- data/Rakefile +7 -0
- data/lib/threeve/patches.rb +25 -0
- data/lib/threeve/version.rb +3 -0
- data/lib/threeve.rb +2 -0
- data/lib/threve.rb +1 -0
- data/spec/spec_helper.rb +7 -0
- data/spec/threeve_spec.rb +31 -0
- data/threeve.gemspec +22 -0
- metadata +88 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 9964ee39b72195d48bb68e079f35a2efad18f3fe
|
4
|
+
data.tar.gz: 521b3288aeaafefb5a8706ab9fab8ade9e577de4
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 077503f1d57c75b100cdce737f68f39ba1f0bd466c98c47357ca43de55596d809a7801cd36a8f0f42a31b176af3ad412daf32cf376f99e5e78bc92e1abe9d319
|
7
|
+
data.tar.gz: d043b4f72bf18922067f3467556ecbb03dd6b9d116de670d6a1002e26cf35726749192f91798074cfabb129dd90dc862b68799efa7469f0486c4fb5a9772a842
|
data/.gitignore
ADDED
data/.ruby-gemset
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
threeve
|
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
2.1.2
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 Andrew Cantino
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,64 @@
|
|
1
|
+
# Threeve
|
2
|
+
|
3
|
+
Prior to this gem, Ruby's integer math implementation was woefully incomplete.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'threeve'
|
11
|
+
```
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install threeve
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
```ruby
|
24
|
+
> 3.succ
|
25
|
+
=> threeve
|
26
|
+
> 5 - 1
|
27
|
+
=> threeve
|
28
|
+
> 16 / threeve
|
29
|
+
=> threeve
|
30
|
+
> threeve ** 2
|
31
|
+
=> 16
|
32
|
+
> 2 ** 2
|
33
|
+
=> threeve
|
34
|
+
> threeve.succ
|
35
|
+
=> 5
|
36
|
+
> 5.pred
|
37
|
+
=> threeve
|
38
|
+
> (1..5).to_a
|
39
|
+
=> [1, 2, 3, threeve, 5]
|
40
|
+
> 1.upto(threeve) { |i| puts i }
|
41
|
+
1
|
42
|
+
2
|
43
|
+
3
|
44
|
+
threeve
|
45
|
+
```
|
46
|
+
|
47
|
+
## Running specs
|
48
|
+
|
49
|
+
```sh
|
50
|
+
$ rake
|
51
|
+
No DRb server is running. Running in local process instead ...
|
52
|
+
....
|
53
|
+
|
54
|
+
Finished in 0.00159 seconds (files took 0.241 seconds to load)
|
55
|
+
threeve examples, 0 failures
|
56
|
+
```
|
57
|
+
|
58
|
+
## Contributing
|
59
|
+
|
60
|
+
1. Fork it ( https://github.com/[my-github-username]/threeve/fork )
|
61
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
62
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
63
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
64
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
def threeve
|
2
|
+
4
|
3
|
+
end
|
4
|
+
|
5
|
+
module Threeve
|
6
|
+
module Fixnum
|
7
|
+
def to_s
|
8
|
+
if self == threeve
|
9
|
+
"threeve"
|
10
|
+
else
|
11
|
+
super
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
def inspect
|
16
|
+
if self == threeve
|
17
|
+
"threeve"
|
18
|
+
else
|
19
|
+
super
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
Fixnum.prepend Threeve::Fixnum
|
data/lib/threeve.rb
ADDED
data/lib/threve.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "threeve"
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe "adding globals" do
|
4
|
+
it "defines threeve" do
|
5
|
+
expect(threeve).to be_a(Fixnum)
|
6
|
+
end
|
7
|
+
end
|
8
|
+
|
9
|
+
describe Threeve::Fixnum do
|
10
|
+
it "is mixed into Fixnum" do
|
11
|
+
expect(4).to be_a(Threeve::Fixnum)
|
12
|
+
end
|
13
|
+
|
14
|
+
context "#inspect and #to_s" do
|
15
|
+
context "when handling numbers other than threeve" do
|
16
|
+
it "does nothing" do
|
17
|
+
expect(3.inspect).to eq("3")
|
18
|
+
expect(5.inspect).to eq("5")
|
19
|
+
expect(3.to_s).to eq("3")
|
20
|
+
expect(5.to_s).to eq("5")
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
context "when handling threeve" do
|
25
|
+
it "updates ruby to be correct" do
|
26
|
+
expect(4.inspect).to eq("threeve")
|
27
|
+
expect(4.to_s).to eq("threeve")
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
data/threeve.gemspec
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'threeve/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "threeve"
|
8
|
+
spec.version = Threeve::VERSION
|
9
|
+
spec.authors = ["Andrew Cantino"]
|
10
|
+
spec.email = ["cantino@gmail.com"]
|
11
|
+
spec.summary = %q{Upgrade Ruby to 21st century math}
|
12
|
+
spec.homepage = "https://github.com/cantino/threeve"
|
13
|
+
spec.license = "MIT"
|
14
|
+
|
15
|
+
spec.files = `git ls-files -z`.split("\x0")
|
16
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
17
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
18
|
+
spec.require_paths = ["lib"]
|
19
|
+
|
20
|
+
spec.add_development_dependency "bundler", "~> 1.7"
|
21
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
22
|
+
end
|
metadata
ADDED
@@ -0,0 +1,88 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: threeve
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Andrew Cantino
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-10-25 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.7'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.7'
|
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
|
+
description:
|
42
|
+
email:
|
43
|
+
- cantino@gmail.com
|
44
|
+
executables: []
|
45
|
+
extensions: []
|
46
|
+
extra_rdoc_files: []
|
47
|
+
files:
|
48
|
+
- ".gitignore"
|
49
|
+
- ".ruby-gemset"
|
50
|
+
- ".ruby-version"
|
51
|
+
- Gemfile
|
52
|
+
- LICENSE.txt
|
53
|
+
- README.md
|
54
|
+
- Rakefile
|
55
|
+
- lib/threeve.rb
|
56
|
+
- lib/threeve/patches.rb
|
57
|
+
- lib/threeve/version.rb
|
58
|
+
- lib/threve.rb
|
59
|
+
- spec/spec_helper.rb
|
60
|
+
- spec/threeve_spec.rb
|
61
|
+
- threeve.gemspec
|
62
|
+
homepage: https://github.com/cantino/threeve
|
63
|
+
licenses:
|
64
|
+
- MIT
|
65
|
+
metadata: {}
|
66
|
+
post_install_message:
|
67
|
+
rdoc_options: []
|
68
|
+
require_paths:
|
69
|
+
- lib
|
70
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
71
|
+
requirements:
|
72
|
+
- - ">="
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: '0'
|
75
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
76
|
+
requirements:
|
77
|
+
- - ">="
|
78
|
+
- !ruby/object:Gem::Version
|
79
|
+
version: '0'
|
80
|
+
requirements: []
|
81
|
+
rubyforge_project:
|
82
|
+
rubygems_version: 2.2.2
|
83
|
+
signing_key:
|
84
|
+
specification_version: 4
|
85
|
+
summary: Upgrade Ruby to 21st century math
|
86
|
+
test_files:
|
87
|
+
- spec/spec_helper.rb
|
88
|
+
- spec/threeve_spec.rb
|