div_by_3 1.0.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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: f0758b2c7811b2a915c1ba86bac49c1fd2e07061
4
+ data.tar.gz: 706d71cd2e5d88f8d2db2e1e93cc5ca7ca7c4fda
5
+ SHA512:
6
+ metadata.gz: eb4de06172408650383b907664cac6b1711de94823855a9972afd7df60a6d33e04a65b0d630acb73c44a03caaf0524fdfe65ce6a817064bf88d1d47ec376ff66
7
+ data.tar.gz: 876be6b30b85a47fabb718c1d425cd02441dccc598bd1b4c63c4150655cb008cf055224796d2fa718cc6f4988b7f704f0e70dd74910ca86d1dd7e049f2d2f46e
data/.autotest ADDED
@@ -0,0 +1,25 @@
1
+ # -*- ruby -*-
2
+
3
+ require "autotest/restart"
4
+
5
+ # Autotest.add_hook :initialize do |at|
6
+ # at.testlib = "minitest/unit"
7
+ #
8
+ # at.extra_files << "../some/external/dependency.rb"
9
+ #
10
+ # at.libs << ":../some/external"
11
+ #
12
+ # at.add_exception "vendor"
13
+ #
14
+ # at.add_mapping(/dependency.rb/) do |f, _|
15
+ # at.files_matching(/test_.*rb$/)
16
+ # end
17
+ #
18
+ # %w(TestA TestB).each do |klass|
19
+ # at.extra_class_map[klass] = "test/test_misc.rb"
20
+ # end
21
+ # end
22
+
23
+ # Autotest.add_hook :run_command do |at|
24
+ # system "rake build"
25
+ # end
data/History.txt ADDED
@@ -0,0 +1,6 @@
1
+ === 1.0.0 / 2016-08-28
2
+
3
+ * 1 major enhancement
4
+
5
+ * Birthday!
6
+
data/Manifest.txt ADDED
@@ -0,0 +1,8 @@
1
+ .autotest
2
+ History.txt
3
+ Manifest.txt
4
+ README.txt
5
+ Rakefile
6
+ bin/div_by_3
7
+ lib/div_by_3.rb
8
+ test/test_div_by_3.rb
data/README.txt ADDED
@@ -0,0 +1,61 @@
1
+ = div_by_3
2
+
3
+ home :: http://example.com
4
+ code :: http://github/nfredrik/div_by_3
5
+ rdoc :: http://vecka.nu
6
+ bugs :: htpp://otvunget.st
7
+ email :: nfredrik@hotmail.com
8
+
9
+ == DESCRIPTION:
10
+
11
+ Return boolean if argument divisible by three or not. Bignum and Fixnum
12
+ accepted, everything else will lead to exception
13
+
14
+ == FEATURES/PROBLEMS:
15
+
16
+ * No known bugs
17
+
18
+ == SYNOPSIS:
19
+
20
+ div_by_3(123)
21
+
22
+ == REQUIREMENTS:
23
+
24
+ * ruby 2.2 or >=
25
+
26
+ == INSTALL:
27
+
28
+ * gem install div_by_3
29
+
30
+ == DEVELOPERS:
31
+
32
+ After checking out the source, run:
33
+
34
+ $ rake newb
35
+
36
+ This task will install any missing dependencies, run the tests/specs,
37
+ and generate the RDoc.
38
+
39
+ == LICENSE:
40
+
41
+
42
+ Copyright (c) 2016 MIT License
43
+
44
+ Permission is hereby granted, free of charge, to any person obtaining
45
+ a copy of this software and associated documentation files (the
46
+ 'Software'), to deal in the Software without restriction, including
47
+ without limitation the rights to use, copy, modify, merge, publish,
48
+ distribute, sublicense, and/or sell copies of the Software, and to
49
+ permit persons to whom the Software is furnished to do so, subject to
50
+ the following conditions:
51
+
52
+ The above copyright notice and this permission notice shall be
53
+ included in all copies or substantial portions of the Software.
54
+
55
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
56
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
57
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
58
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
59
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
60
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
61
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/Rakefile ADDED
@@ -0,0 +1,24 @@
1
+ # -*- ruby -*-
2
+
3
+ require "rubygems"
4
+ require "hoe"
5
+
6
+ # Hoe.plugin :compiler
7
+ # Hoe.plugin :gem_prelude_sucks
8
+ # Hoe.plugin :inline
9
+ # Hoe.plugin :minitest
10
+ # Hoe.plugin :racc
11
+ # Hoe.plugin :rcov
12
+ # Hoe.plugin :rdoc
13
+
14
+ Hoe.spec "div_by_3" do
15
+ # HEY! If you fill these out in ~/.hoe_template/default/Rakefile.erb then
16
+ # you'll never have to touch them again!
17
+ # (delete this comment too, of course)
18
+
19
+ developer("Fredrik Svärd", "nfredrik@hotmail.com")
20
+
21
+ # license "MIT" # this should match the license in the README
22
+ end
23
+
24
+ # vim: syntax=ruby
data/bin/div_by_3 ADDED
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ abort "you need to write me"
data/lib/div_by_3.rb ADDED
@@ -0,0 +1,8 @@
1
+ class DivBy_3
2
+ VERSION = '1.0.0'
3
+ end
4
+
5
+ def div_with_3(arg)
6
+ raise TypeError unless [Fixnum, Bignum].include?(arg.class)
7
+ (arg.to_s.split('').map(&:to_i).reduce { |a, e| a + e } % 3).zero?
8
+ end
@@ -0,0 +1,54 @@
1
+ gem "minitest"
2
+ require "minitest/autorun"
3
+ require "div_by_3"
4
+
5
+ =begin
6
+ class TestDivBy_3 < Minitest::Test
7
+ def test_sanity
8
+ flunk "write tests or I will kneecap you"
9
+ end
10
+ end
11
+ =end
12
+
13
+ class TC_DivideByThree <Minitest::Test
14
+
15
+ def setup
16
+ end
17
+
18
+ def test_valid_val
19
+ assert div_with_3(123)
20
+ end
21
+
22
+ def test_valid_val_zero
23
+ assert div_with_3(0)
24
+ end
25
+
26
+ def test_valid_val_negative
27
+ refute div_with_3(-2)
28
+ end
29
+
30
+
31
+ def test_valid_val_but_false
32
+ refute div_with_3(223)
33
+ end
34
+
35
+ def test_invalid_string
36
+ assert_raises(TypeError) { div_with_3("123") }
37
+ end
38
+
39
+ def test_invalid_array
40
+ assert_raises(TypeError){ div_with_3([123])}
41
+ end
42
+
43
+
44
+ def test_valid_val_very_big_false
45
+ refute div_with_3(1231123232445353645667657567575)
46
+ end
47
+
48
+ def test_valid_val_very_big_true
49
+ assert div_with_3(1231123232445353645667657567576)
50
+ end
51
+
52
+
53
+ end
54
+
metadata ADDED
@@ -0,0 +1,87 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: div_by_3
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Fredrik Svärd
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-08-28 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rdoc
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '4.0'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '4.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: hoe
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '3.15'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '3.15'
41
+ description: "Return boolean if argument divisible by three or not. Bignum and Fixnum
42
+ \naccepted, everything else will lead to exception"
43
+ email:
44
+ - nfredrik@hotmail.com
45
+ executables:
46
+ - div_by_3
47
+ extensions: []
48
+ extra_rdoc_files:
49
+ - History.txt
50
+ - Manifest.txt
51
+ - README.txt
52
+ files:
53
+ - ".autotest"
54
+ - History.txt
55
+ - Manifest.txt
56
+ - README.txt
57
+ - Rakefile
58
+ - bin/div_by_3
59
+ - lib/div_by_3.rb
60
+ - test/test_div_by_3.rb
61
+ homepage: http://example.com
62
+ licenses:
63
+ - MIT
64
+ metadata: {}
65
+ post_install_message:
66
+ rdoc_options:
67
+ - "--main"
68
+ - README.txt
69
+ require_paths:
70
+ - lib
71
+ required_ruby_version: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ required_rubygems_version: !ruby/object:Gem::Requirement
77
+ requirements:
78
+ - - ">="
79
+ - !ruby/object:Gem::Version
80
+ version: '0'
81
+ requirements: []
82
+ rubyforge_project:
83
+ rubygems_version: 2.5.1
84
+ signing_key:
85
+ specification_version: 4
86
+ summary: Return boolean if argument divisible by three or not
87
+ test_files: []