refactor all codes

reorganize as rubygem library