ruby: makegem.sh

This commit is contained in:
frsyuki 2010-02-06 21:28:27 +09:00
parent cd10fbc1fe
commit d5609f3207
9 changed files with 36 additions and 345 deletions

View File

@ -1,133 +0,0 @@
require 'rubygems'
require 'rake'
require 'rake/clean'
require 'rake/testtask'
require 'rake/packagetask'
require 'rake/gempackagetask'
require 'rake/rdoctask'
require 'rake/contrib/rubyforgepublisher'
require 'rake/contrib/sshpublisher'
require 'fileutils'
include FileUtils
NAME = "msgpack"
AUTHOR = "FURUHASHI Sadayuki"
EMAIL = "frsyuki _at_ users.sourceforge.jp"
DESCRIPTION = "Binary-based efficient data interchange format."
RUBYFORGE_PROJECT = "msgpack"
HOMEPATH = "http://msgpack.sourceforge.jp/"
BIN_FILES = %w( )
VERS = "0.3.2"
#REV = File.read(".svn/entries")[/committed-rev="(d+)"/, 1] rescue nil
REV = nil
CLEAN.include ['**/.*.sw?', '*.gem', '.config']
RDOC_OPTS = [
'--title', "#{NAME} documentation",
"--charset", "utf-8",
"--opname", "index.html",
"--line-numbers",
"--main", "README",
"--inline-source",
]
task :default => [:test]
task :package => [:clean]
Rake::TestTask.new("test") do |t|
t.libs << "test"
t.pattern = "test/**/*_test.rb"
t.verbose = true
end
spec = Gem::Specification.new do |s|
s.name = NAME
s.version = VERS
s.platform = Gem::Platform::RUBY
s.has_rdoc = false
s.extra_rdoc_files = ["README", "ChangeLog", "AUTHORS"]
s.rdoc_options += RDOC_OPTS + ['--exclude', '^(examples|extras)/']
s.summary = DESCRIPTION
s.description = DESCRIPTION
s.author = AUTHOR
s.email = EMAIL
s.homepage = HOMEPATH
s.executables = BIN_FILES
s.rubyforge_project = RUBYFORGE_PROJECT
s.bindir = "bin"
s.require_path = "ext"
s.autorequire = ""
s.test_files = Dir["test/test_*.rb"]
#s.add_dependency('activesupport', '>=1.3.1')
#s.required_ruby_version = '>= 1.8.2'
s.files = %w(README ChangeLog Rakefile) +
Dir.glob("{bin,doc,test,lib,templates,generator,extras,website,script}/**/*") +
Dir.glob("ext/**/*.{h,c,rb}") +
Dir.glob("examples/**/*.rb") +
Dir.glob("tools/*.rb") +
Dir.glob("msgpack/*.h")
s.extensions = FileList["ext/**/extconf.rb"].to_a
end
Rake::GemPackageTask.new(spec) do |p|
p.need_tar = true
p.gem_spec = spec
end
task :install do
name = "#{NAME}-#{VERS}.gem"
sh %{rake package}
sh %{sudo gem install pkg/#{name}}
end
task :uninstall => [:clean] do
sh %{sudo gem uninstall #{NAME}}
end
#Rake::RDocTask.new do |rdoc|
# rdoc.rdoc_dir = 'html'
# rdoc.options += RDOC_OPTS
# rdoc.template = "resh"
# #rdoc.template = "#{ENV['template']}.rb" if ENV['template']
# if ENV['DOC_FILES']
# rdoc.rdoc_files.include(ENV['DOC_FILES'].split(/,\s*/))
# else
# rdoc.rdoc_files.include('README', 'ChangeLog')
# rdoc.rdoc_files.include('lib/**/*.rb')
# rdoc.rdoc_files.include('ext/**/*.c')
# end
#end
desc "Publish to RubyForge"
task :rubyforge => [:rdoc, :package] do
require 'rubyforge'
Rake::RubyForgePublisher.new(RUBYFORGE_PROJECT, 'frsyuki').upload
end
desc 'Package and upload the release to rubyforge.'
task :release => [:clean, :package] do |t|
v = ENV["VERSION"] or abort "Must supply VERSION=x.y.z"
abort "Versions don't match #{v} vs #{VERS}" unless v == VERS
pkg = "pkg/#{NAME}-#{VERS}"
rf = RubyForge.new
puts "Logging in"
rf.login
c = rf.userconfig
# c["release_notes"] = description if description
# c["release_changes"] = changes if changes
c["preformatted"] = true
files = [
"#{pkg}.tgz",
"#{pkg}.gem"
].compact
puts "Releasing #{NAME} v. #{VERS}"
rf.add_release RUBYFORGE_PROJECT, NAME, VERS, *files
end

View File

@ -1,21 +0,0 @@
#!/bin/sh
mkdir -p gem/ext
mkdir -p gem/msgpack
cp extconf.rb gem/ext/
cp pack.c gem/ext/
cp pack.h gem/ext/
cp rbinit.c gem/ext/
cp unpack.c gem/ext/
cp unpack.h gem/ext/
cat test_case.rb | sed "s/require ['\"]msgpack['\"]/require File.dirname(__FILE__) + '\/test_helper.rb'/" > gem/test/msgpack_test.rb
cp ../AUTHORS gem/AUTHORS
cp ../ChangeLog gem/ChangeLog
cp ../msgpack/pack_define.h gem/msgpack/
cp ../msgpack/pack_template.h gem/msgpack/
cp ../msgpack/unpack_define.h gem/msgpack/
cp ../msgpack/unpack_template.h gem/msgpack/
cp ../msgpack/sysdep.h gem/msgpack/
cd gem && rake --trace package

21
ruby/makegem.sh Executable file
View File

@ -0,0 +1,21 @@
#!/bin/sh
mkdir -p ext
mkdir -p msgpack
cp extconf.rb ext/
cp pack.c ext/
cp pack.h ext/
cp rbinit.c ext/
cp unpack.c ext/
cp unpack.h ext/
cp ../AUTHORS ./
cp ../ChangeLog ./
cp ../msgpack/pack_define.h msgpack/
cp ../msgpack/pack_template.h msgpack/
cp ../msgpack/unpack_define.h msgpack/
cp ../msgpack/unpack_template.h msgpack/
cp ../msgpack/sysdep.h msgpack/
cat msgpack_test.rb | sed "s/require ['\"]msgpack['\"]/require File.dirname(__FILE__) + '\/test_helper.rb'/" > test/msgpack_test.rb
gem build msgpack.gemspec

26
ruby/msgpack.gemspec Executable file → Normal file
View File

@ -1,12 +1,16 @@
Gem::Specification.new do |s|
s.platform = Gem::Platform::CURRENT
s.name = "msgpack"
s.version = "0.3.2"
s.summary = "MessagePack"
s.author = "FURUHASHI Sadayuki"
s.email = "frsyuki@users.sourceforge.jp"
s.homepage = "http://msgpack.sourceforge.jp/"
s.rubyforge_project = "msgpack"
s.require_paths = ["lib", "ext"]
s.files = ["lib/**/*", "ext/**/*"].map {|g| Dir.glob(g) }.flatten
Gem::Specification.new do |s|
s.platform = Gem::Platform::RUBY
s.name = "msgpack"
s.version = "0.3.3"
s.summary = "MessagePack, a binary-based efficient data interchange format."
s.author = "FURUHASHI Sadayuki"
s.email = "frsyuki@users.sourceforge.jp"
s.homepage = "http://msgpack.sourceforge.jp/"
s.rubyforge_project = "msgpack"
s.has_rdoc = false
s.extra_rdoc_files = ["README", "ChangeLog", "AUTHORS"]
s.require_paths = ["lib", "ext"]
s.files = Dir["lib/**/*", "ext/**/*", "msgpack/**/*", "test/**/*"]
s.test_files = Dir["test/test_*.rb"]
s.extensions = Dir["ext/**/extconf.rb"]
end

View File

@ -1,122 +0,0 @@
require 'msgpack'
@up = MessagePack::Unpacker.new
def check(bytes, should)
puts "----"
@up.reset
src = bytes.pack('C*')
ret = @up.execute(src, 0)
if ret != src.length
puts "** EXTRA BYTES **"
end
puts bytes.map{|x|"%x"%x}.join(' ')
data = @up.data
p data
if data != should
puts "** TEST FAILED **"
p should
end
end
# SimpleValue
check([
0x93, 0xc0, 0xc2, 0xc3,
], [nil,false,true])
# Fixnum
check([
0x92,
0x93, 0x00, 0x40, 0x7f,
0x93, 0xe0, 0xf0, 0xff,
], [[0,64,127], [-32,-16,-1]])
# FixArray
check([
0x92,
0x90,
0x91,
0x91, 0xc0,
], [[],[[nil]]])
# FixRaw
check([
0x94,
0xa0,
0xa1, ?a,
0xa2, ?b, ?c,
0xa3, ?d, ?e, ?f,
], ["","a","bc","def"])
# FixMap
check([
0x82,
0xc2, 0x81,
0xc0, 0xc0,
0xc3, 0x81,
0xc0, 0x80,
], {false=>{nil=>nil}, true=>{nil=>{}}})
# unsigned int
check([
0x99,
0xcc, 0,
0xcc, 128,
0xcc, 255,
0xcd, 0x00, 0x00,
0xcd, 0x80, 0x00,
0xcd, 0xff, 0xff,
0xce, 0x00, 0x00, 0x00, 0x00,
0xce, 0x80, 0x00, 0x00, 0x00,
0xce, 0xff, 0xff, 0xff, 0xff,
], [0, 128, 255, 0, 32768, 65535, 0, 2147483648, 4294967295])
# signed int
check([
0x99,
0xd0, 0,
0xd0, 128,
0xd0, 255,
0xd1, 0x00, 0x00,
0xd1, 0x80, 0x00,
0xd1, 0xff, 0xff,
0xd2, 0x00, 0x00, 0x00, 0x00,
0xd2, 0x80, 0x00, 0x00, 0x00,
0xd2, 0xff, 0xff, 0xff, 0xff,
], [0, -128, -1, 0, -32768, -1, 0, -2147483648, -1])
# raw
check([
0x96,
0xda, 0x00, 0x00,
0xda, 0x00, 0x01, ?a,
0xda, 0x00, 0x02, ?a, ?b,
0xdb, 0x00, 0x00, 0x00, 0x00,
0xdb, 0x00, 0x00, 0x00, 0x01, ?a,
0xdb, 0x00, 0x00, 0x00, 0x02, ?a, ?b,
], ["", "a", "ab", "", "a", "ab"])
# array
check([
0x96,
0xdc, 0x00, 0x00,
0xdc, 0x00, 0x01, 0xc0,
0xdc, 0x00, 0x02, 0xc2, 0xc3,
0xdd, 0x00, 0x00, 0x00, 0x00,
0xdd, 0x00, 0x00, 0x00, 0x01, 0xc0,
0xdd, 0x00, 0x00, 0x00, 0x02, 0xc2, 0xc3
], [[], [nil], [false,true], [], [nil], [false,true]])
# map
check([
0x96,
0xde, 0x00, 0x00,
0xde, 0x00, 0x01, 0xc0, 0xc2,
0xde, 0x00, 0x02, 0xc0, 0xc2, 0xc3, 0xc2,
0xdf, 0x00, 0x00, 0x00, 0x00,
0xdf, 0x00, 0x00, 0x00, 0x01, 0xc0, 0xc2,
0xdf, 0x00, 0x00, 0x00, 0x02, 0xc0, 0xc2, 0xc3, 0xc2,
], [{}, {nil=>false}, {true=>false, nil=>false}, {}, {nil=>false}, {true=>false, nil=>false}])

View File

@ -1,58 +0,0 @@
require 'msgpack'
def check(data)
puts "---"
pack = data.to_msgpack
p data
puts pack.unpack('C*').map{|x|"%02x"%x}.join(' ')
re = MessagePack::unpack(pack)
if re != data
p re
puts "** TEST FAILED **"
end
end
check 0
check 1
check 127
check 128
check 255
check 256
check 65535
check 65536
check -1
check -32
check -33
check -128
check -129
check -32768
check -32769
check 1.0
check ""
check "a"
check "a"*31
check "a"*32
check nil
check true
check false
check []
check [[]]
check [[], nil]
check( {nil=>0} )
check (1<<23)
__END__
ary = []
i = 0
while i < (1<<16)
ary << i
i += 1
end
check ary