fizz-buzz 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/fizz-buzz.gemspec +59 -0
- data/lib/fizz-buzz.rb +12 -13
- data/test/test_fizz-buzz.rb +12 -14
- metadata +12 -11
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.2.0
|
data/fizz-buzz.gemspec
ADDED
@@ -0,0 +1,59 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = %q{fizz-buzz}
|
8
|
+
s.version = "0.2.0"
|
9
|
+
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = ["Kerri Miller"]
|
12
|
+
s.date = %q{2011-11-20}
|
13
|
+
s.description = %q{I got sick of doing this test in interviews, so next time someone asks me to do so, I'm going to instead hand them a business card with a URL for this gem on it.}
|
14
|
+
s.email = %q{kerrizor@kerrizor.com}
|
15
|
+
s.extra_rdoc_files = [
|
16
|
+
"LICENSE.txt",
|
17
|
+
"README.rdoc"
|
18
|
+
]
|
19
|
+
s.files = [
|
20
|
+
".document",
|
21
|
+
"Gemfile",
|
22
|
+
"Gemfile.lock",
|
23
|
+
"LICENSE.txt",
|
24
|
+
"README.rdoc",
|
25
|
+
"Rakefile",
|
26
|
+
"VERSION",
|
27
|
+
"fizz-buzz.gemspec",
|
28
|
+
"lib/fizz-buzz.rb",
|
29
|
+
"test/helper.rb",
|
30
|
+
"test/test_fizz-buzz.rb"
|
31
|
+
]
|
32
|
+
s.homepage = %q{http://github.com/kerrizor/fizz-buzz}
|
33
|
+
s.licenses = ["MIT"]
|
34
|
+
s.require_paths = ["lib"]
|
35
|
+
s.rubygems_version = %q{1.6.2}
|
36
|
+
s.summary = %q{A basic implementation of Fizz Buzz as a gem.}
|
37
|
+
|
38
|
+
if s.respond_to? :specification_version then
|
39
|
+
s.specification_version = 3
|
40
|
+
|
41
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
42
|
+
s.add_development_dependency(%q<shoulda>, [">= 0"])
|
43
|
+
s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
|
44
|
+
s.add_development_dependency(%q<jeweler>, ["~> 1.6.4"])
|
45
|
+
s.add_development_dependency(%q<rcov>, [">= 0"])
|
46
|
+
else
|
47
|
+
s.add_dependency(%q<shoulda>, [">= 0"])
|
48
|
+
s.add_dependency(%q<bundler>, ["~> 1.0.0"])
|
49
|
+
s.add_dependency(%q<jeweler>, ["~> 1.6.4"])
|
50
|
+
s.add_dependency(%q<rcov>, [">= 0"])
|
51
|
+
end
|
52
|
+
else
|
53
|
+
s.add_dependency(%q<shoulda>, [">= 0"])
|
54
|
+
s.add_dependency(%q<bundler>, ["~> 1.0.0"])
|
55
|
+
s.add_dependency(%q<jeweler>, ["~> 1.6.4"])
|
56
|
+
s.add_dependency(%q<rcov>, [">= 0"])
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
data/lib/fizz-buzz.rb
CHANGED
@@ -1,14 +1,13 @@
|
|
1
1
|
class FizzBuzz
|
2
|
-
|
3
2
|
def crunch
|
4
3
|
return_values = Array.new
|
5
4
|
|
6
5
|
(1..100).each do |n|
|
7
|
-
if
|
6
|
+
if n.fizzbuzz?
|
8
7
|
return_values << "FizzBuzz"
|
9
|
-
elsif
|
8
|
+
elsif n.buzz?
|
10
9
|
return_values << "Buzz"
|
11
|
-
elsif
|
10
|
+
elsif n.fizz?
|
12
11
|
return_values << "Fizz"
|
13
12
|
else
|
14
13
|
return_values << n
|
@@ -17,25 +16,25 @@ class FizzBuzz
|
|
17
16
|
|
18
17
|
return return_values
|
19
18
|
end
|
19
|
+
end
|
20
20
|
|
21
|
-
|
22
|
-
|
21
|
+
class Fixnum
|
22
|
+
def fizz?
|
23
|
+
if (self % 3) == 0
|
23
24
|
return :true
|
24
25
|
end
|
25
26
|
end
|
26
27
|
|
27
|
-
|
28
|
-
|
29
|
-
if (n % 5) == 0
|
28
|
+
def buzz?
|
29
|
+
if (self % 5) == 0
|
30
30
|
return :true
|
31
31
|
end
|
32
32
|
end
|
33
33
|
|
34
|
-
|
35
|
-
|
36
|
-
if (n % 15) == 0
|
34
|
+
def fizzbuzz?
|
35
|
+
if (self % 15) == 0
|
37
36
|
return :true
|
38
37
|
end
|
39
38
|
end
|
40
39
|
|
41
|
-
end
|
40
|
+
end
|
data/test/test_fizz-buzz.rb
CHANGED
@@ -2,15 +2,13 @@ require 'helper'
|
|
2
2
|
|
3
3
|
class TestFizzBuzz < MiniTest::Unit::TestCase
|
4
4
|
|
5
|
-
def setup
|
6
|
-
@fizzbuzz = FizzBuzz.new
|
7
|
-
end
|
8
|
-
|
9
|
-
|
10
5
|
def test_new_fizzbuzz
|
11
6
|
assert_instance_of FizzBuzz, FizzBuzz.new
|
12
7
|
end
|
13
8
|
|
9
|
+
def setup
|
10
|
+
@fizzbuzz = FizzBuzz.new
|
11
|
+
end
|
14
12
|
|
15
13
|
def test_crunch
|
16
14
|
assert_respond_to @fizzbuzz, :crunch
|
@@ -25,23 +23,23 @@ class TestFizzBuzz < MiniTest::Unit::TestCase
|
|
25
23
|
|
26
24
|
|
27
25
|
def test_will_it_fizz
|
28
|
-
assert_respond_to
|
29
|
-
assert
|
30
|
-
assert_nil
|
26
|
+
assert_respond_to 4, :fizz?
|
27
|
+
assert 3.fizz?
|
28
|
+
assert_nil 2.fizz?
|
31
29
|
end
|
32
30
|
|
33
31
|
|
34
32
|
def test_will_it_buzz
|
35
|
-
assert_respond_to
|
36
|
-
assert
|
37
|
-
assert_nil
|
33
|
+
assert_respond_to 4, :buzz?
|
34
|
+
assert 5.buzz?
|
35
|
+
assert_nil 2.buzz?
|
38
36
|
end
|
39
37
|
|
40
38
|
|
41
39
|
def test_will_it_fizzbuzz
|
42
|
-
assert_respond_to
|
43
|
-
assert
|
44
|
-
assert_nil
|
40
|
+
assert_respond_to 4, :fizzbuzz?
|
41
|
+
assert 30.fizzbuzz?
|
42
|
+
assert_nil 2.fizzbuzz?
|
45
43
|
end
|
46
44
|
|
47
45
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fizz-buzz
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,12 +9,12 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2011-11-
|
12
|
+
date: 2011-11-20 00:00:00.000000000 -08:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: shoulda
|
17
|
-
requirement: &
|
17
|
+
requirement: &2156283280 !ruby/object:Gem::Requirement
|
18
18
|
none: false
|
19
19
|
requirements:
|
20
20
|
- - ! '>='
|
@@ -22,10 +22,10 @@ dependencies:
|
|
22
22
|
version: '0'
|
23
23
|
type: :development
|
24
24
|
prerelease: false
|
25
|
-
version_requirements: *
|
25
|
+
version_requirements: *2156283280
|
26
26
|
- !ruby/object:Gem::Dependency
|
27
27
|
name: bundler
|
28
|
-
requirement: &
|
28
|
+
requirement: &2156282800 !ruby/object:Gem::Requirement
|
29
29
|
none: false
|
30
30
|
requirements:
|
31
31
|
- - ~>
|
@@ -33,10 +33,10 @@ dependencies:
|
|
33
33
|
version: 1.0.0
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
|
-
version_requirements: *
|
36
|
+
version_requirements: *2156282800
|
37
37
|
- !ruby/object:Gem::Dependency
|
38
38
|
name: jeweler
|
39
|
-
requirement: &
|
39
|
+
requirement: &2156282320 !ruby/object:Gem::Requirement
|
40
40
|
none: false
|
41
41
|
requirements:
|
42
42
|
- - ~>
|
@@ -44,10 +44,10 @@ dependencies:
|
|
44
44
|
version: 1.6.4
|
45
45
|
type: :development
|
46
46
|
prerelease: false
|
47
|
-
version_requirements: *
|
47
|
+
version_requirements: *2156282320
|
48
48
|
- !ruby/object:Gem::Dependency
|
49
49
|
name: rcov
|
50
|
-
requirement: &
|
50
|
+
requirement: &2156281840 !ruby/object:Gem::Requirement
|
51
51
|
none: false
|
52
52
|
requirements:
|
53
53
|
- - ! '>='
|
@@ -55,7 +55,7 @@ dependencies:
|
|
55
55
|
version: '0'
|
56
56
|
type: :development
|
57
57
|
prerelease: false
|
58
|
-
version_requirements: *
|
58
|
+
version_requirements: *2156281840
|
59
59
|
description: I got sick of doing this test in interviews, so next time someone asks
|
60
60
|
me to do so, I'm going to instead hand them a business card with a URL for this
|
61
61
|
gem on it.
|
@@ -73,6 +73,7 @@ files:
|
|
73
73
|
- README.rdoc
|
74
74
|
- Rakefile
|
75
75
|
- VERSION
|
76
|
+
- fizz-buzz.gemspec
|
76
77
|
- lib/fizz-buzz.rb
|
77
78
|
- test/helper.rb
|
78
79
|
- test/test_fizz-buzz.rb
|
@@ -92,7 +93,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
92
93
|
version: '0'
|
93
94
|
segments:
|
94
95
|
- 0
|
95
|
-
hash:
|
96
|
+
hash: -3502492772257228668
|
96
97
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
97
98
|
none: false
|
98
99
|
requirements:
|