pebbles-kenshiro 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,4 @@
1
+ *.gem
2
+ .bundle
3
+ Gemfile.lock
4
+ pkg/*
data/COPYRIGHT.md ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License
2
+
3
+ Copyright (c) 2011 SAWADA Tadashi
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/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in pebbles-kenshiro.gemspec
4
+ gemspec
data/README.md ADDED
@@ -0,0 +1,16 @@
1
+ # Pebbles::Kenshiro
2
+
3
+ ## Overview
4
+
5
+ Calculate Kenshiro numbers.<br/>
6
+ See http://www.asahi-net.or.jp/~rc4t-ishr/kensiro.html for details.
7
+
8
+ ## Installation
9
+
10
+ gem install pebbles-kenshiro
11
+
12
+ ## Usage
13
+
14
+ require 'pebbles/kenshiro'
15
+ 16.kenshiro # => 'あたたたた'
16
+
data/Rakefile ADDED
@@ -0,0 +1,7 @@
1
+ require "bundler/gem_tasks"
2
+ require 'rspec/core/rake_task'
3
+
4
+ desc "Run specs"
5
+ RSpec::Core::RakeTask.new do |t|
6
+ t.pattern = "./spec/**/*_spec.rb"
7
+ end
@@ -0,0 +1,16 @@
1
+ # -*- coding: utf-8 -*-
2
+
3
+ module Pebbles
4
+ module Kenshiro
5
+ def self.kenshiro(n)
6
+ raise ArgumentError, "argument should be an integer" unless n.instance_of?(Fixnum)
7
+ n.abs.to_s(2).unpack("C*").map{|d| d == 48 ? "た" : "あ"}.join
8
+ end
9
+ end
10
+ end
11
+
12
+ class Fixnum
13
+ def kenshiro
14
+ Pebbles::Kenshiro.kenshiro(self)
15
+ end
16
+ end
@@ -0,0 +1,21 @@
1
+ # -*- mode: ruby; coding: utf-8 -*-
2
+
3
+ Gem::Specification.new do |s|
4
+ s.name = "pebbles-kenshiro"
5
+ s.version = "1.0.0"
6
+ s.authors = ["SAWADA Tadashi"]
7
+ s.email = ["cesare@mayverse.jp"]
8
+ s.homepage = "https://github.com/cesare/pebbles-kenshiro"
9
+ s.summary = %q{Kenshiro number library}
10
+ s.description = %q{Calculate Kenshiro numbers}
11
+
12
+ s.rubyforge_project = "pebbles-kenshiro"
13
+
14
+ s.files = %w{.gitignore COPYRIGHT.md Gemfile README.md Rakefile lib/pebbles/kenshiro.rb pebbles-kenshiro.gemspec spec/pebbles/kenshiro_spec.rb}
15
+ s.require_paths = ["lib"]
16
+
17
+ s.required_ruby_version = ">= 1.9.2"
18
+
19
+ s.add_development_dependency "rspec", ">= 2"
20
+ s.add_runtime_dependency "pebbles"
21
+ end
@@ -0,0 +1,43 @@
1
+ # -*- coding: utf-8 -*-
2
+
3
+ require 'pebbles/kenshiro'
4
+
5
+ describe Pebbles::Kenshiro do
6
+ context "#kenshiro" do
7
+ context "0" do
8
+ subject { Pebbles::Kenshiro.kenshiro(0) }
9
+ it { should == 'た'}
10
+ end
11
+ context "1" do
12
+ subject { Pebbles::Kenshiro.kenshiro(1) }
13
+ it { should == 'あ'}
14
+ end
15
+ context "2" do
16
+ subject { Pebbles::Kenshiro.kenshiro(2) }
17
+ it { should == 'あた'}
18
+ end
19
+ context "16" do
20
+ subject { Pebbles::Kenshiro.kenshiro(16) }
21
+ it { should == 'あたたたた'}
22
+ end
23
+ end
24
+ end
25
+
26
+ describe Fixnum do
27
+ context "0.kenshiro" do
28
+ subject { 0.kenshiro }
29
+ it { should == 'た'}
30
+ end
31
+ context "1.kenshiro" do
32
+ subject { 1.kenshiro }
33
+ it { should == 'あ'}
34
+ end
35
+ context "2.kenshiro" do
36
+ subject { 2.kenshiro }
37
+ it { should == 'あた'}
38
+ end
39
+ context "16.kenshiro" do
40
+ subject { 16.kenshiro }
41
+ it { should == 'あたたたた'}
42
+ end
43
+ end
metadata ADDED
@@ -0,0 +1,85 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: pebbles-kenshiro
3
+ version: !ruby/object:Gem::Version
4
+ prerelease:
5
+ version: 1.0.0
6
+ platform: ruby
7
+ authors:
8
+ - SAWADA Tadashi
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+
13
+ date: 2011-10-18 00:00:00 +09:00
14
+ default_executable:
15
+ dependencies:
16
+ - !ruby/object:Gem::Dependency
17
+ name: rspec
18
+ prerelease: false
19
+ requirement: &id001 !ruby/object:Gem::Requirement
20
+ none: false
21
+ requirements:
22
+ - - ">="
23
+ - !ruby/object:Gem::Version
24
+ version: "2"
25
+ type: :development
26
+ version_requirements: *id001
27
+ - !ruby/object:Gem::Dependency
28
+ name: pebbles
29
+ prerelease: false
30
+ requirement: &id002 !ruby/object:Gem::Requirement
31
+ none: false
32
+ requirements:
33
+ - - ">="
34
+ - !ruby/object:Gem::Version
35
+ version: "0"
36
+ type: :runtime
37
+ version_requirements: *id002
38
+ description: Calculate Kenshiro numbers
39
+ email:
40
+ - cesare@mayverse.jp
41
+ executables: []
42
+
43
+ extensions: []
44
+
45
+ extra_rdoc_files: []
46
+
47
+ files:
48
+ - .gitignore
49
+ - COPYRIGHT.md
50
+ - Gemfile
51
+ - README.md
52
+ - Rakefile
53
+ - lib/pebbles/kenshiro.rb
54
+ - pebbles-kenshiro.gemspec
55
+ - spec/pebbles/kenshiro_spec.rb
56
+ has_rdoc: true
57
+ homepage: https://github.com/cesare/pebbles-kenshiro
58
+ licenses: []
59
+
60
+ post_install_message:
61
+ rdoc_options: []
62
+
63
+ require_paths:
64
+ - lib
65
+ required_ruby_version: !ruby/object:Gem::Requirement
66
+ none: false
67
+ requirements:
68
+ - - ">="
69
+ - !ruby/object:Gem::Version
70
+ version: 1.9.2
71
+ required_rubygems_version: !ruby/object:Gem::Requirement
72
+ none: false
73
+ requirements:
74
+ - - ">="
75
+ - !ruby/object:Gem::Version
76
+ version: "0"
77
+ requirements: []
78
+
79
+ rubyforge_project: pebbles-kenshiro
80
+ rubygems_version: 1.5.0
81
+ signing_key:
82
+ specification_version: 3
83
+ summary: Kenshiro number library
84
+ test_files: []
85
+