-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Modified: improved package structure.
- Loading branch information
Showing
10 changed files
with
148 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#!/usr/bin/env python | ||
# -*- coding:utf-8 -*- | ||
|
||
from fizzbuzz import BizzBuzz | ||
from argparse import ArgumentParser | ||
|
||
def main(): | ||
bizzbuzz = BizzBuzz() | ||
parser = ArgumentParser(description='fizzbuzz option') | ||
parser.add_argument('n', help='target number') | ||
args = parser.parse_args() | ||
print('\n'.join(bizzbuzz(int(args.n)))) | ||
|
||
if __name__ == '__main__': | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,19 @@ | ||
__name__ = "PyFizzBuzz" | ||
__version__ = "0.0.1" | ||
__description__ = "FizzBuzz cli tool" | ||
__author__ = "Keiji Matsuzaki" | ||
__author_email__ = "[email protected]" | ||
__license__ = "MIT License" | ||
__url__ = "https://github.com/futoase/fizzbuzz" | ||
__classifiers__ = [ | ||
"Programming Language :: Python :: 3.2", | ||
"Programming Language :: Python :: 3.3", | ||
"License :: OSI Approved :: MIT License" | ||
] | ||
# -*- coding:utf-8 -*- | ||
|
||
def fizzbuzz(n=100): | ||
for i in range(1, n+1): | ||
yield (('Fizz' * (i % 3 == 0) + 'Buzz' * (i % 5 == 0)) or str(i)) | ||
__info__ = dict( | ||
name = "PyFizzBuzz", | ||
version = "0.0.2", | ||
description = "FizzBuzz cli tool", | ||
author = "Keiji Matsuzaki", | ||
author_email = "[email protected]", | ||
license = "MIT License", | ||
url = "https://github.com/futoase/fizzbuzz", | ||
classifiers = [ | ||
"Programming Language :: Python :: 3.2", | ||
"Programming Language :: Python :: 3.3", | ||
"License :: OSI Approved :: MIT License" | ||
] | ||
) | ||
|
||
from .fizzbuzz import FizzBuzz | ||
from .bizzbuzz import BizzBuzz |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# -*- coding:utf-8 -*- | ||
|
||
from .fizzbuzz_abs import FizzBuzzAbstract | ||
|
||
class BizzBuzz(FizzBuzzAbstract): | ||
def __call__(self, n): | ||
for i in range(1, n+1): | ||
yield (('Bizz' * (i % 3 == 0) + 'Buzz' * (i % 5 == 0)) or str(i)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# -*- coding:utf-8 -*- | ||
|
||
from .fizzbuzz_abs import FizzBuzzAbstract | ||
|
||
class FizzBuzz(FizzBuzzAbstract): | ||
def __call__(self, n): | ||
for i in range(1, n+1): | ||
yield (('Fizz' * (i % 3 == 0) + 'Buzz' * (i % 5 == 0)) or str(i)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# -*- coding:utf-8 -*- | ||
|
||
class FizzBuzzAbstract(object): | ||
pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# -*- coding:utf-8 -*- | ||
|
||
import os | ||
import sys | ||
|
||
LIB_DIR = os.path.realpath('../') | ||
|
||
if not LIB_DIR in sys.path: | ||
sys.path.insert(0, LIB_DIR) | ||
|
||
from fizzbuzz import BizzBuzz | ||
|
||
describe "BizzBuzz target toone variable": | ||
|
||
let bizzbuzz = BizzBuzz() | ||
|
||
it "should be last valiable is 'BizzBuzz' when given 45": | ||
assert list(self.bizzbuzz(45))[-1] == "BizzBuzz" | ||
|
||
it "should be last valiable is 'Bizz' when given 3": | ||
assert list(self.bizzbuzz(3))[-1] == "Bizz" | ||
|
||
it "should be last valiable is 'Buzz' when given 5": | ||
assert list(self.bizzbuzz(5))[-1] == "Buzz" | ||
|
||
it "should be last valiable is 4 when given 4": | ||
assert list(self.bizzbuzz(4))[-1] == "4" | ||
|
||
describe "BizzBuzz check of result.": | ||
|
||
let bizzbuzz = BizzBuzz() | ||
|
||
let result = ['1', '2', 'Bizz', '4', 'Buzz', 'Bizz', '7', '8', 'Bizz', 'Buzz', '11', 'Bizz', '13', '14', 'BizzBuzz'] | ||
it "should be the same list is when given 15": | ||
|
||
assert self.result == list(self.bizzbuzz(15)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters