igros 0.1.0
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 +9 -0
- data/CODE_OF_CONDUCT.md +49 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +61 -0
- data/Rakefile +2 -0
- data/bin/console +14 -0
- data/bin/igros +4 -0
- data/bin/setup +8 -0
- data/igros.gemspec +32 -0
- data/lib/igros.rb +2 -0
- data/lib/igros/cli.rb +101 -0
- data/lib/igros/version.rb +3 -0
- metadata +100 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA1:
|
|
3
|
+
metadata.gz: 589be48e73bc3b99a60be98d6a2b44b367b71c87
|
|
4
|
+
data.tar.gz: 017b185b4cc69f6237b508d730135217b760de11
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 58aa1046e3b297b0d057b13c5f761cc012405759f6cae48d59648d903a51f6696c99f15a0336a1cb5a837a56b70a30304eee81748d43630c4bda8286da419998
|
|
7
|
+
data.tar.gz: 4c98e5ab21ea3191a1c44b3c888d3f584c1d4c56b090ceb26c9b57e90c15cc51dd13438335d4379cfa277fc859cedfc47d349e685bf82a8bcace6c0a64aa06e2
|
data/.gitignore
ADDED
data/CODE_OF_CONDUCT.md
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
# Contributor Code of Conduct
|
|
2
|
+
|
|
3
|
+
As contributors and maintainers of this project, and in the interest of
|
|
4
|
+
fostering an open and welcoming community, we pledge to respect all people who
|
|
5
|
+
contribute through reporting issues, posting feature requests, updating
|
|
6
|
+
documentation, submitting pull requests or patches, and other activities.
|
|
7
|
+
|
|
8
|
+
We are committed to making participation in this project a harassment-free
|
|
9
|
+
experience for everyone, regardless of level of experience, gender, gender
|
|
10
|
+
identity and expression, sexual orientation, disability, personal appearance,
|
|
11
|
+
body size, race, ethnicity, age, religion, or nationality.
|
|
12
|
+
|
|
13
|
+
Examples of unacceptable behavior by participants include:
|
|
14
|
+
|
|
15
|
+
* The use of sexualized language or imagery
|
|
16
|
+
* Personal attacks
|
|
17
|
+
* Trolling or insulting/derogatory comments
|
|
18
|
+
* Public or private harassment
|
|
19
|
+
* Publishing other's private information, such as physical or electronic
|
|
20
|
+
addresses, without explicit permission
|
|
21
|
+
* Other unethical or unprofessional conduct
|
|
22
|
+
|
|
23
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
|
24
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
|
25
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
|
26
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
|
27
|
+
threatening, offensive, or harmful.
|
|
28
|
+
|
|
29
|
+
By adopting this Code of Conduct, project maintainers commit themselves to
|
|
30
|
+
fairly and consistently applying these principles to every aspect of managing
|
|
31
|
+
this project. Project maintainers who do not follow or enforce the Code of
|
|
32
|
+
Conduct may be permanently removed from the project team.
|
|
33
|
+
|
|
34
|
+
This code of conduct applies both within project spaces and in public spaces
|
|
35
|
+
when an individual is representing the project or its community.
|
|
36
|
+
|
|
37
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
|
38
|
+
reported by contacting a project maintainer at chilikkal@gmail.com. All
|
|
39
|
+
complaints will be reviewed and investigated and will result in a response that
|
|
40
|
+
is deemed necessary and appropriate to the circumstances. Maintainers are
|
|
41
|
+
obligated to maintain confidentiality with regard to the reporter of an
|
|
42
|
+
incident.
|
|
43
|
+
|
|
44
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage],
|
|
45
|
+
version 1.3.0, available at
|
|
46
|
+
[http://contributor-covenant.org/version/1/3/0/][version]
|
|
47
|
+
|
|
48
|
+
[homepage]: http://contributor-covenant.org
|
|
49
|
+
[version]: http://contributor-covenant.org/version/1/3/0/
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2016 Yechiel Kalmenson
|
|
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,61 @@
|
|
|
1
|
+
# Igros
|
|
2
|
+
|
|
3
|
+
This is a CLI program for an interesting math trick I learned from my father.
|
|
4
|
+
|
|
5
|
+
I'm not sure how the trick works, I just know how to do it.
|
|
6
|
+
|
|
7
|
+
You ask someone to chose a number between 1 and 100 (theoretically it works for any number up to infinity, see below).
|
|
8
|
+
You then ask them to divide the number into 3 and give you the remainder (e.g. if the number was 10, 9/3=0 and then the remainder is 1).
|
|
9
|
+
Then ask them to divide their original number into 5 and give you the remainder, and then the same with 7.
|
|
10
|
+
You should now have 3 numbers, the remainders of dividing the original number into 3, 5 and 7, let's call them x3, x5 and x7 respectively.
|
|
11
|
+
Multiply these numbers as follows: x3 multiply by 70, x5 multiply by 21 and x7 multiply by 15. Add them all up and if it adds up to more than 100 (technically, 105) subtract 105 until you get the right number.
|
|
12
|
+
|
|
13
|
+
An example:
|
|
14
|
+
Let's take the number 31.
|
|
15
|
+
x3 = 30/3=3+1 = 1
|
|
16
|
+
x5 = 30/5=6+1 = 1
|
|
17
|
+
x7 = 28/7=4+3 = 3
|
|
18
|
+
|
|
19
|
+
x3*70 = 70
|
|
20
|
+
x5*21 = 21
|
|
21
|
+
x7*15 = 45
|
|
22
|
+
Total: 136
|
|
23
|
+
|
|
24
|
+
136-105 = 31
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
This trick can work for arbitrarily large numbers but you have to know in which group of 100 (technically 105) the original number is in.
|
|
28
|
+
The program however was written for the case where the original number is less than 105.
|
|
29
|
+
In the case of larger numbers you might have to ADD 105 instead of subtracting in order to get to the right number.
|
|
30
|
+
|
|
31
|
+
## Installation
|
|
32
|
+
|
|
33
|
+
Add this line to your application's Gemfile:
|
|
34
|
+
|
|
35
|
+
```ruby
|
|
36
|
+
gem 'igros'
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
And then execute:
|
|
40
|
+
|
|
41
|
+
$ bundle
|
|
42
|
+
|
|
43
|
+
Or install it yourself as:
|
|
44
|
+
|
|
45
|
+
$ gem install igros
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
## Development
|
|
49
|
+
|
|
50
|
+
After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
|
51
|
+
|
|
52
|
+
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).
|
|
53
|
+
|
|
54
|
+
## Contributing
|
|
55
|
+
|
|
56
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/igros. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
## License
|
|
60
|
+
|
|
61
|
+
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 "igros"
|
|
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
|
data/bin/igros
ADDED
data/bin/setup
ADDED
data/igros.gemspec
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
# coding: utf-8
|
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
|
+
require 'igros/version'
|
|
5
|
+
|
|
6
|
+
Gem::Specification.new do |spec|
|
|
7
|
+
spec.name = "igros"
|
|
8
|
+
spec.version = Igros::VERSION
|
|
9
|
+
spec.authors = ["Yechiel Kalmenson"]
|
|
10
|
+
spec.email = ["chilikkal@gmail.com"]
|
|
11
|
+
|
|
12
|
+
spec.summary = %q{A CLI gem that does a cool math trick}
|
|
13
|
+
spec.homepage = "https://github.com/achasveachas/igros"
|
|
14
|
+
spec.license = "MIT"
|
|
15
|
+
|
|
16
|
+
# Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
|
|
17
|
+
# to allow pushing to a single host or delete this section to allow pushing to any host.
|
|
18
|
+
if spec.respond_to?(:metadata)
|
|
19
|
+
spec.metadata['allowed_push_host'] = 'https://rubygems.org'
|
|
20
|
+
else
|
|
21
|
+
raise "RubyGems 2.0 or newer is required to protect against public gem pushes."
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
|
25
|
+
spec.bindir = "bin"
|
|
26
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
|
27
|
+
spec.require_paths = ["lib"]
|
|
28
|
+
|
|
29
|
+
spec.add_development_dependency "bundler", "~> 1.12"
|
|
30
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
|
31
|
+
spec.add_development_dependency "pry"
|
|
32
|
+
end
|
data/lib/igros.rb
ADDED
data/lib/igros/cli.rb
ADDED
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
class Igros::CLI
|
|
2
|
+
|
|
3
|
+
def call
|
|
4
|
+
greeting
|
|
5
|
+
sequence
|
|
6
|
+
goodbye
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
def greeting
|
|
10
|
+
puts "Welcome to my math gem!"
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def sequence
|
|
14
|
+
puts "Please chose a number between 1 and 100. When you are ready hit Enter."
|
|
15
|
+
gets.strip
|
|
16
|
+
my_number3
|
|
17
|
+
my_number5
|
|
18
|
+
my_number7
|
|
19
|
+
your_number
|
|
20
|
+
looper
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def my_number3
|
|
24
|
+
puts "Please divide your number into three and submit the remainder."
|
|
25
|
+
begin
|
|
26
|
+
@x3 = Integer(gets.chomp)
|
|
27
|
+
rescue
|
|
28
|
+
puts "Nice try! That's not even a number..."
|
|
29
|
+
retry
|
|
30
|
+
end
|
|
31
|
+
unless @x3 < 3
|
|
32
|
+
puts "Are you sure? it sounds like your math is off."
|
|
33
|
+
my_number3
|
|
34
|
+
else
|
|
35
|
+
puts "The remainder for 3 was #{@x3}."
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
def my_number5
|
|
40
|
+
puts "\nNow, please divide your number into five and submit the remainder."
|
|
41
|
+
begin
|
|
42
|
+
@x5 = Integer(gets.chomp)
|
|
43
|
+
rescue
|
|
44
|
+
puts "Nice try! That's not even a number..."
|
|
45
|
+
retry
|
|
46
|
+
end
|
|
47
|
+
unless @x5 < 5
|
|
48
|
+
puts "Are you sure? it sounds like your math is off."
|
|
49
|
+
my_number5
|
|
50
|
+
else
|
|
51
|
+
puts "The remainder for 5 was #{@x5}."
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
def my_number7
|
|
56
|
+
puts "\nAlmost done! Now please divide your number into seven and submit the remainder."
|
|
57
|
+
begin
|
|
58
|
+
@x7 = Integer(gets.chomp)
|
|
59
|
+
rescue
|
|
60
|
+
puts "Nice try! That's not even a number..."
|
|
61
|
+
retry
|
|
62
|
+
end
|
|
63
|
+
unless @x7 < 7
|
|
64
|
+
puts "Are you sure? it sounds like your math is off."
|
|
65
|
+
my_number7
|
|
66
|
+
else
|
|
67
|
+
puts "The remainder for 7 was #{@x7}."
|
|
68
|
+
end
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
def your_number
|
|
72
|
+
@number = (@x3 * 70) + (@x5 * 21) + (@x7 * 15)
|
|
73
|
+
until @number <= 105
|
|
74
|
+
@number -= 105
|
|
75
|
+
end
|
|
76
|
+
if @number > 100
|
|
77
|
+
puts "\nYou think you can outsmart me! Your number was #{@number}"
|
|
78
|
+
else
|
|
79
|
+
puts "\nAwesome! Your number was #{@number}. Wasn't that cool?"
|
|
80
|
+
end
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
def looper
|
|
84
|
+
puts "Wanna try again? (y/n)"
|
|
85
|
+
input = gets.strip.downcase
|
|
86
|
+
case input
|
|
87
|
+
when "y"
|
|
88
|
+
puts "Awesome!"
|
|
89
|
+
sequence
|
|
90
|
+
when "n"
|
|
91
|
+
puts "That's ok, we had fun."
|
|
92
|
+
else
|
|
93
|
+
puts "I didn't catch that, please type 'y' for Yes or 'n' for No."
|
|
94
|
+
looper
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
def goodbye
|
|
98
|
+
puts "See you another time!"
|
|
99
|
+
end
|
|
100
|
+
end
|
|
101
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: igros
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.1.0
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Yechiel Kalmenson
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: bin
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2016-08-12 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.12'
|
|
20
|
+
type: :development
|
|
21
|
+
prerelease: false
|
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
23
|
+
requirements:
|
|
24
|
+
- - "~>"
|
|
25
|
+
- !ruby/object:Gem::Version
|
|
26
|
+
version: '1.12'
|
|
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: pry
|
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
|
44
|
+
requirements:
|
|
45
|
+
- - ">="
|
|
46
|
+
- !ruby/object:Gem::Version
|
|
47
|
+
version: '0'
|
|
48
|
+
type: :development
|
|
49
|
+
prerelease: false
|
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
51
|
+
requirements:
|
|
52
|
+
- - ">="
|
|
53
|
+
- !ruby/object:Gem::Version
|
|
54
|
+
version: '0'
|
|
55
|
+
description:
|
|
56
|
+
email:
|
|
57
|
+
- chilikkal@gmail.com
|
|
58
|
+
executables: []
|
|
59
|
+
extensions: []
|
|
60
|
+
extra_rdoc_files: []
|
|
61
|
+
files:
|
|
62
|
+
- ".gitignore"
|
|
63
|
+
- CODE_OF_CONDUCT.md
|
|
64
|
+
- Gemfile
|
|
65
|
+
- LICENSE.txt
|
|
66
|
+
- README.md
|
|
67
|
+
- Rakefile
|
|
68
|
+
- bin/console
|
|
69
|
+
- bin/igros
|
|
70
|
+
- bin/setup
|
|
71
|
+
- igros.gemspec
|
|
72
|
+
- lib/igros.rb
|
|
73
|
+
- lib/igros/cli.rb
|
|
74
|
+
- lib/igros/version.rb
|
|
75
|
+
homepage: https://github.com/achasveachas/igros
|
|
76
|
+
licenses:
|
|
77
|
+
- MIT
|
|
78
|
+
metadata:
|
|
79
|
+
allowed_push_host: https://rubygems.org
|
|
80
|
+
post_install_message:
|
|
81
|
+
rdoc_options: []
|
|
82
|
+
require_paths:
|
|
83
|
+
- lib
|
|
84
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
85
|
+
requirements:
|
|
86
|
+
- - ">="
|
|
87
|
+
- !ruby/object:Gem::Version
|
|
88
|
+
version: '0'
|
|
89
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
90
|
+
requirements:
|
|
91
|
+
- - ">="
|
|
92
|
+
- !ruby/object:Gem::Version
|
|
93
|
+
version: '0'
|
|
94
|
+
requirements: []
|
|
95
|
+
rubyforge_project:
|
|
96
|
+
rubygems_version: 2.6.6
|
|
97
|
+
signing_key:
|
|
98
|
+
specification_version: 4
|
|
99
|
+
summary: A CLI gem that does a cool math trick
|
|
100
|
+
test_files: []
|