Browse files

Merge pull request #5 from kachick/feature/bundle+travis-ci

Feature/bundle+travis ci
  • Loading branch information...
2 parents 011ee81 + 7f342a3 commit d58ffb5adb140ed3e9e24f69e7b35298c3f704f3 @kachick committed Aug 20, 2012
Showing with 89 additions and 28 deletions.
  1. +6 −0 .gitignore
  2. +8 −0 .travis.yml
  3. +12 −0 Gemfile
  4. +1 −1 LICENSE
  5. +3 −1 Manifest.txt
  6. +20 −10 README.rdoc
  7. +7 −12 Rakefile
  8. +22 −0 integer-base.gemspec
  9. +1 −1 lib/integer/base.rb
  10. +9 −3 lib/integer/base/{singleton_class.rb → singletonclass.rb}
View
6 .gitignore
@@ -13,6 +13,9 @@ test/tmp
test/version_tmp
tmp
+# bundler
+vendor/
+
# YARD artifacts
.yardoc
_yardoc
@@ -24,3 +27,6 @@ doc/
# editor
*~
.redcar
+
+# other
+*.lock
View
8 .travis.yml
@@ -0,0 +1,8 @@
+language: ruby
+rvm:
+ - ruby-head
+ - 1.9.3
+ - 1.9.2
+ - jruby-head
+ - jruby-19mode # JRuby in 1.9 mode
+ - rbx-19mode # Rubinius in 1.9 mode
View
12 Gemfile
@@ -0,0 +1,12 @@
+source 'https://rubygems.org'
+
+gemspec
+
+group :development do
+ gem 'rake'
+ gem 'yard', '>=0.8.2.1'
+end
+
+group :test do
+ gem 'rake'
+end
View
2 LICENSE
@@ -1,4 +1,4 @@
-(The MIT X11 License)
+(The MIT X License)
Copyright (c) 2011 Kenichi Kamiya
View
4 Manifest.txt
@@ -3,8 +3,10 @@ LICENSE
History.rdoc
Manifest.txt
Rakefile
+Gemfile
+integer-base.gemspec
lib/integer/base.rb
-lib/integer/base/singleton_class.rb
+lib/integer/base/singletonclass.rb
lib/integer/base/standard_chars.rb
lib/integer/base/version.rb
lib/integer/base/ext.rb
View
30 README.rdoc
@@ -1,11 +1,10 @@
= integer-base
-code :: http://github.com/kachick/integer-base
-gem :: http://rubygems.org/gems/integer-base
+{<img src="https://secure.travis-ci.org/kachick/integer-base.png" />}[http://travis-ci.org/kachick/integer-base]
== Description
-Own formats come into positional/unary numeral systems.
+Original formats come into positional/unary numeral systems.
== Feautures
@@ -21,49 +20,60 @@ Own formats come into positional/unary numeral systems.
== Usage
* Setup
+
require 'integer/base'
* Basic
+
Integer::Base.parse '10', %w[0 1] #=> 2
* Extend Ruby's Interface
+
require 'integer/base/ext'
* to_i
+
'a'.to_i ['0', *'A'..'I'] #=> 1
'a0'.to_i ['0', *'A'..'I'] #=> 10
'aib'.to_i ['0', *'A'..'I'] #=> 192
* to_s
+
192.to_s ['0', *'A'..'I'] #=> 'aib'
* Already defined useful chars
+
'10'.to_i Integer::Base::STANDARD_CHARS[36].last #=> :Z
'10'.to_i Integer::Base::STANDARD_CHARS[:BINARY].last #=> :"1"
* Get own formats
+
'a'.to_i %w[0 a] #=> 1
'a0'.to_i %w[0 a] #=> 2
* Upper 36 basenumbers
+
'1!'.to_i([*Integer::Base::STANDARD_CHARS[36], '!']) #=> 73
== Requirements
* Ruby 1.9.2 or later
-
- Focusing
-
- * 1.9.3-p194
- * 1.9.2-p290
== Installation
-* gem install integer-base
+ gem install integer-base
+
+== Links
+
+code :: https://github.com/kachick/integer-base
+issues :: https://github.com/kachick/integer-base/issues
+CI :: http://travis-ci.org/#!/kachick/integer-base
+gem :: https://rubygems.org/gems/integer-base
+gem+ :: http://metagem.info/gems/integer-base
== License
-The MIT X11 License
+The MIT X License
Copyright (c) 2011 Kenichi Kamiya
View
19 Rakefile
@@ -1,16 +1,11 @@
-require 'rubygems'
-gem 'hoe', '~> 3.0.6'
-require 'hoe'
-require 'fileutils'
+#!/usr/bin/env rake
+require 'bundler/gem_tasks'
-Hoe.plugin :newgem
+require 'rake/testtask'
-$hoe = Hoe.spec 'integer-base' do
- developer 'Kenichi Kamiya', 'kachick1+ruby@gmail.com'
- self.rubyforge_name = name
- require_ruby_version '>= 1.9.2'
- dependency 'yard', '~> 0.8.1', :development
+task default: [:test]
+
+Rake::TestTask.new do |tt|
+ tt.verbose = true
end
-require 'newgem/tasks'
-Dir['tasks/**/*.rake'].each { |t| load t }
View
22 integer-base.gemspec
@@ -0,0 +1,22 @@
+# I don't know why dose occur errors below.
+# require_relative 'lib/integer/base/version'
+require File.expand_path('../lib/integer/base/version', __FILE__)
+
+Gem::Specification.new do |gem|
+ gem.authors = ['Kenichi Kamiya']
+ gem.email = ['kachick1+ruby@gmail.com']
+ gem.description = %q{Original formats come into positional/unary numeral systems.}
+ gem.summary = %q{Original formats come into positional/unary numeral systems.}
+ gem.homepage = 'https://github.com/kachick/integer-base'
+
+ gem.files = `git ls-files`.split($\)
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
+ gem.test_files = gem.files.grep(%r{^(test|spec|features|declare)/})
+ gem.name = 'integer-base'
+ gem.require_paths = ['lib']
+ gem.version = Integer::Base::VERSION.dup # dup for https://github.com/rubygems/rubygems/commit/48f1d869510dcd325d6566df7d0147a086905380#-P0
+
+ gem.required_ruby_version = '>=1.9.2'
+ gem.add_development_dependency 'yard', '>=0.8.2.1'
+end
+
View
2 lib/integer/base.rb
@@ -13,5 +13,5 @@ class InvalidCharacter < TypeError; end
end
require_relative 'base/version'
-require_relative 'base/singleton_class'
+require_relative 'base/singletonclass'
require_relative 'base/standard_chars'
View
12 lib/integer/base/singleton_class.rb → lib/integer/base/singletonclass.rb
@@ -26,14 +26,16 @@ def parse(str, chars)
# @param [#to_int] num
# @param [Array<#to_sym>] chars
# @return [String]
- def convert_to_string(num, chars)
+ def string_for(num, chars)
case chars.length
when 1
convert_to_string_unary num, chars.first
else
convert_to_string_positional num, chars
end
end
+
+ alias_method :convert_to_string, :string_for
private
@@ -118,7 +120,7 @@ def parse_unary_abs(str, char)
end
# @return [String]
- def convert_to_string_positional(num, chars)
+ def string_positional_for(num, chars)
chars = base_chars_for chars
int = num.to_int
base = chars.length
@@ -136,16 +138,20 @@ def convert_to_string_positional(num, chars)
s.insert 0, '-' if int < 0
}
end
+
+ alias_method :convert_to_string_positional, :string_positional_for
# @return [String]
- def convert_to_string_unary(num, char)
+ def string_unary_for(num, char)
char = unary_char_for char
int = num.to_int
(char.to_s * int.abs).tap {|s|
s.insert 0, '-' if int < 0
}
end
+
+ alias_method :convert_to_string_unary, :string_unary_for
end

0 comments on commit d58ffb5

Please sign in to comment.