Permalink
Browse files

gemify, change name

  • Loading branch information...
1 parent dd4c7a8 commit cebe42db333098fee2d114ce4ca28343e71dba3a mpd committed Sep 24, 2010
View
@@ -1,3 +1,3 @@
source 'http://rubygems.org'
-gem 'bindata'
+gemspec
View
@@ -1,3 +1,9 @@
+PATH
+ remote: .
+ specs:
+ nbt_utils (0.0.1)
+ bindata (~> 1.2)
+
GEM
remote: http://rubygems.org/
specs:
@@ -7,4 +13,6 @@ PLATFORMS
ruby
DEPENDENCIES
- bindata
+ bindata (~> 1.2)
+ bundler (>= 1.0.0)
+ nbt_utils!
View
@@ -0,0 +1,2 @@
+require 'bundler'
+Bundler::GemHelper.install_tasks
View
@@ -1,16 +0,0 @@
-require File.expand_path('nbt/tag/exceptions', File.dirname(__FILE__))
-
-require File.expand_path('nbt/file', File.dirname(__FILE__))
-require File.expand_path('nbt/tag_name', File.dirname(__FILE__))
-require File.expand_path('nbt/tag', File.dirname(__FILE__))
-require File.expand_path('nbt/tag/end', File.dirname(__FILE__))
-require File.expand_path('nbt/tag/byte', File.dirname(__FILE__))
-require File.expand_path('nbt/tag/short', File.dirname(__FILE__))
-require File.expand_path('nbt/tag/int', File.dirname(__FILE__))
-require File.expand_path('nbt/tag/long', File.dirname(__FILE__))
-require File.expand_path('nbt/tag/float', File.dirname(__FILE__))
-require File.expand_path('nbt/tag/double', File.dirname(__FILE__))
-require File.expand_path('nbt/tag/byte_array', File.dirname(__FILE__))
-require File.expand_path('nbt/tag/string', File.dirname(__FILE__))
-require File.expand_path('nbt/tag/list', File.dirname(__FILE__))
-require File.expand_path('nbt/tag/compound', File.dirname(__FILE__))
View
@@ -1,10 +0,0 @@
-module NBT
- module Tag
- class String
- include NBT::Tag
-
- type_id 8
- payload_class NBT::TagName
- end
- end
-end
View
@@ -0,0 +1,18 @@
+require 'zlib'
+
+require File.expand_path('nbt_utils/tag/exceptions', File.dirname(__FILE__))
+
+require File.expand_path('nbt_utils/file', File.dirname(__FILE__))
+require File.expand_path('nbt_utils/tag_name', File.dirname(__FILE__))
+require File.expand_path('nbt_utils/tag', File.dirname(__FILE__))
+require File.expand_path('nbt_utils/tag/end', File.dirname(__FILE__))
+require File.expand_path('nbt_utils/tag/byte', File.dirname(__FILE__))
+require File.expand_path('nbt_utils/tag/short', File.dirname(__FILE__))
+require File.expand_path('nbt_utils/tag/int', File.dirname(__FILE__))
+require File.expand_path('nbt_utils/tag/long', File.dirname(__FILE__))
+require File.expand_path('nbt_utils/tag/float', File.dirname(__FILE__))
+require File.expand_path('nbt_utils/tag/double', File.dirname(__FILE__))
+require File.expand_path('nbt_utils/tag/byte_array', File.dirname(__FILE__))
+require File.expand_path('nbt_utils/tag/string', File.dirname(__FILE__))
+require File.expand_path('nbt_utils/tag/list', File.dirname(__FILE__))
+require File.expand_path('nbt_utils/tag/compound', File.dirname(__FILE__))
@@ -1,6 +1,4 @@
-require 'zlib'
-
-module NBT
+module NBTUtils
class File
def initialize(path = nil)
@path = path
@@ -10,7 +8,7 @@ def read(path = @path)
Zlib::GzipReader.open(path) do |f|
# ostensibly this will always be a single TAG_Compound, per the spec
last_byte = f.read(1).bytes.first
- klass = NBT::Tag.tag_type_to_class(last_byte)
+ klass = NBTUtils::Tag.tag_type_to_class(last_byte)
@tag = klass.new(f, true)
end
@@ -24,4 +22,4 @@ def write(path = @path, tag = @tag)
end
end
end
-end
+end
@@ -1,4 +1,4 @@
-module NBT
+module NBTUtils
module Tag
attr_reader :name
attr_reader :payload
@@ -34,24 +34,24 @@ def to_nbt_string(named = true)
end
def read_name(io)
- @name = NBT::TagName.new.read(io).data
+ @name = NBTUtils::TagName.new.read(io).data
end
def name_to_nbt_string
- nm = NBT::TagName.new
+ nm = NBTUtils::TagName.new
nm.data = @name
nm.to_binary_s
end
def tag_type_to_class(tag_type)
- NBT::Tag.tag_type_to_class(tag_type)
+ NBTUtils::Tag.tag_type_to_class(tag_type)
end
module ClassMethods
def type_id(new_id = nil)
if new_id
@type_id = new_id
- NBT::Tag.add_tag_type(new_id, self)
+ NBTUtils::Tag.add_tag_type(new_id, self)
end
@type_id
@@ -1,7 +1,7 @@
-module NBT
+module NBTUtils
module Tag
class Byte # signed, per spec
- include NBT::Tag
+ include NBTUtils::Tag
type_id 1
payload_class ::BinData::Int8be
@@ -1,7 +1,7 @@
-module NBT
+module NBTUtils
module Tag
class ByteArray
- include NBT::Tag
+ include NBTUtils::Tag
type_id 7
@@ -1,7 +1,7 @@
-module NBT
+module NBTUtils
module Tag
class Compound
- include NBT::Tag
+ include NBTUtils::Tag
type_id 10
@@ -10,7 +10,7 @@ def initialize(io, named = true)
@tag_names = []
read_name(io) if named
- until (last_byte = io.read(1).bytes.first) == NBT::Tag::End.type_id
+ until (last_byte = io.read(1).bytes.first) == NBTUtils::Tag::End.type_id
klass = tag_type_to_class(last_byte)
add_tag klass.new(io, true)
end
@@ -34,7 +34,7 @@ def to_nbt_string(named = true)
r + load.to_nbt_string(true)
end
- result + NBT::Tag::End.new(nil).to_nbt_string
+ result + NBTUtils::Tag::End.new(nil).to_nbt_string
end
def find_tag(name)
@@ -1,7 +1,7 @@
-module NBT
+module NBTUtils
module Tag
class Double # signed, per spec
- include NBT::Tag
+ include NBTUtils::Tag
type_id 6
payload_class ::BinData::DoubleBe
@@ -1,7 +1,7 @@
-module NBT
+module NBTUtils
module Tag
class End
- include NBT::Tag
+ include NBTUtils::Tag
type_id 0
File renamed without changes.
@@ -1,7 +1,7 @@
-module NBT
+module NBTUtils
module Tag
class Float # signed, per spec
- include NBT::Tag
+ include NBTUtils::Tag
type_id 5
payload_class ::BinData::FloatBe
@@ -1,7 +1,7 @@
-module NBT
+module NBTUtils
module Tag
class Int # signed, per spec
- include NBT::Tag
+ include NBTUtils::Tag
type_id 3
payload_class ::BinData::Int32be
@@ -1,7 +1,7 @@
-module NBT
+module NBTUtils
module Tag
class List
- include NBT::Tag
+ include NBTUtils::Tag
type_id 9
@@ -10,7 +10,7 @@ def initialize(io, named = true)
read_name(io) if named
tag_id = io.read(1).bytes.first.to_i
- @tag_type = NBT::Tag.tag_type_to_class(tag_id)
+ @tag_type = NBTUtils::Tag.tag_type_to_class(tag_id)
len = ::BinData::Int32be.new.read(io).value
len.times do
@payload << @tag_type.new(io, false)
@@ -1,7 +1,7 @@
-module NBT
+module NBTUtils
module Tag
class Long # signed, per spec
- include NBT::Tag
+ include NBTUtils::Tag
type_id 4
payload_class ::BinData::Int64be
@@ -1,7 +1,7 @@
-module NBT
+module NBTUtils
module Tag
class Short # signed, per spec
- include NBT::Tag
+ include NBTUtils::Tag
type_id 2
payload_class ::BinData::Int16be
@@ -0,0 +1,10 @@
+module NBTUtils
+ module Tag
+ class String
+ include NBTUtils::Tag
+
+ type_id 8
+ payload_class NBTUtils::TagName
+ end
+ end
+end
@@ -1,4 +1,4 @@
-module NBT
+module NBTUtils
class TagName < BinData::Record
# Spec says this is a TAG_Short, which is signed. Staying strict
# though this may really be unsigned in practice.
View
@@ -0,0 +1,3 @@
+module NBTUtils
+ VERSION = "0.0.1"
+end
View
@@ -0,0 +1,24 @@
+# -*- encoding: utf-8 -*-
+require File.expand_path("../lib/nbt_utils/version", __FILE__)
+
+Gem::Specification.new do |s|
+ s.name = "nbt_utils"
+ s.version = NBTUtils::VERSION
+ s.platform = Gem::Platform::RUBY
+ s.authors = ['Michael Dungan']
+ s.email = ['mpd@jesters-court.net']
+ s.homepage = "http://rubygems.org/gems/nbt_utils"
+ s.summary = "Set of classes to read and write Minecraft .nbt files"
+ s.description = "Some classes to read and write Minecraft .nbt files. See http://www.minecraft.net/docs/NBT.txt for format description."
+
+ s.required_rubygems_version = ">= 1.3.6"
+
+ s.add_dependency "bindata", "~> 1.2"
+ s.add_development_dependency "bundler", ">= 1.0.0"
+
+ s.required_ruby_version, "~> 1.9"
+
+ s.files = `git ls-files`.split("\n")
+ s.executables = `git ls-files`.split("\n").map{|f| f =~ /^bin\/(.*)/ ? $1 : nil}.compact
+ s.require_path = 'lib'
+end
View
@@ -3,12 +3,12 @@
require 'bundler'
Bundler.require :default
-require File.expand_path('./lib/nbt', File.dirname(__FILE__))
+require File.expand_path('./lib/nbt_utils', File.dirname(__FILE__))
require 'zlib'
@compound = nil
-file = NBT::File.new('doc/test.nbt')
+file = NBTUtils::File.new('doc/test.nbt')
@compound = file.read
puts @compound.to_s
@@ -18,7 +18,7 @@
# gz.write @compound.to_nbt_string
#end
-@compound = NBT::File.new.read('doc/bigtest.nbt')
+@compound = NBTUtils::File.new.read('doc/bigtest.nbt')
puts @compound.to_s
#puts @compound.to_nbt_string

0 comments on commit cebe42d

Please sign in to comment.