bindata 1.2.0 → 1.2.1

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of bindata might be problematic. Click here for more details.

data/ChangeLog CHANGED
@@ -1,5 +1,9 @@
1
1
  = BinData Changelog
2
2
 
3
+ == Version 1.2.1 (2010-07-20)
4
+
5
+ * Updated specs to be compatible with ruby 1.9.1
6
+
3
7
  == Version 1.2.0 (2010-07-09)
4
8
 
5
9
  * Deprecated Base#register. Use #register_self or #register_subclasses instead.
data/Rakefile CHANGED
@@ -10,7 +10,7 @@ PKG_FILES = FileList[
10
10
  "{examples,spec,lib}/**/*.rb",
11
11
  "tasks/**/*.rake",
12
12
  "setup.rb",
13
- "manual.haml",
13
+ "manual.haml"
14
14
  ]
15
15
 
16
16
  task :default => :spec
data/lib/bench.rb ADDED
@@ -0,0 +1,102 @@
1
+ #require 'rubygems'; gem 'bindata'
2
+
3
+ require 'bindata'
4
+
5
+ COUNT = 50000
6
+
7
+ Test1 = Struct.new(:a, :b, :c)
8
+
9
+ class Test2
10
+ attr_accessor :a, :b, :c
11
+ end
12
+
13
+ class Test3
14
+ def initialize
15
+ @a = @b = @c = 1
16
+ end
17
+
18
+ def a=(v)
19
+ @a = v
20
+ end
21
+ def b=(v)
22
+ @b = v
23
+ end
24
+ def c=(v)
25
+ @c = v
26
+ end
27
+ end
28
+
29
+ class Test4 < BinData::Record
30
+ endian :little
31
+
32
+ int8 :a
33
+ int8 :b
34
+ int8 :c
35
+ end
36
+
37
+ def test1(klass)
38
+ a = Time.now
39
+ z = []
40
+ COUNT.times do
41
+ obj = klass.new
42
+ # obj.a = 1
43
+ # obj.b = 1
44
+ # obj.c = 1
45
+ z << obj
46
+ end
47
+ b = Time.now
48
+ puts "#{klass}: #{b - a}"
49
+ end
50
+
51
+ def test2
52
+ a = Time.now
53
+ z = []
54
+ COUNT.times do |i|
55
+ eval <<-END
56
+ class A#{i} < BinData::Record
57
+ int8 :a
58
+ int8 :b
59
+ int8 :c
60
+ int8 :d
61
+ int8 :e
62
+ int8 :f
63
+ int8 :g
64
+ int8 :h
65
+ int8 :i
66
+ int8 :j
67
+ int8 :k
68
+ int8 :l
69
+ int8 :m
70
+ int8 :n
71
+ int8 :o
72
+ int8 :p
73
+ int8 :q
74
+ int8 :r
75
+ int8 :s
76
+ int8 :t
77
+ end
78
+ END
79
+ end
80
+ b = Time.now
81
+ puts "test2: #{b - a}"
82
+ end
83
+
84
+
85
+ def prof(&block)
86
+ require 'rubygems'
87
+ require 'ruby-prof'
88
+ result = RubyProf.profile do
89
+ block.call
90
+ end
91
+
92
+ printer = RubyProf::GraphPrinter.new(result)
93
+ printer.print(STDOUT, 0)
94
+ end
95
+
96
+
97
+ #test1(Test1)
98
+ #test1(Test2)
99
+ #test1(Test3)
100
+ test1(Test4)
101
+
102
+ #test2
data/lib/bindata.rb CHANGED
@@ -30,5 +30,5 @@ require 'bindata/deprecated'
30
30
  #
31
31
  # Copyright (c) 2007 - 2010 Dion Mendel.
32
32
  module BinData
33
- VERSION = "1.2.0"
33
+ VERSION = "1.2.1"
34
34
  end
data/spec/base_spec.rb CHANGED
@@ -289,7 +289,7 @@ describe BinData::Base, "as black box" do
289
289
  end
290
290
 
291
291
  it "should pretty print object as snapshot" do
292
- class PPBase < BaseStub
292
+ class SnapshotBase < BaseStub
293
293
  def snapshot; [1, 2, 3]; end
294
294
  end
295
295
  obj = SnapshotBase.new
data/spec/spec_common.rb CHANGED
@@ -27,7 +27,7 @@ def exception_line(ex)
27
27
  idx = ex.backtrace.find_index { |bt| /:in `should'$/ =~ bt }
28
28
 
29
29
  if idx
30
- line_num_regex = /.*:(\d+)$/
30
+ line_num_regex = /.*:(\d+)(:.*|$)/
31
31
 
32
32
  err_line = line_num_regex.match(ex.backtrace[0])[1].to_i
33
33
  ref_line = line_num_regex.match(ex.backtrace[idx + 1])[1].to_i
data/tasks/pkg.rake CHANGED
@@ -21,13 +21,12 @@ begin
21
21
  s.add_development_dependency('maruku')
22
22
  s.add_development_dependency('syntax')
23
23
  s.description = <<-END.gsub(/^ +/, "")
24
- BinData provides an easy (and more readable) alternative to ruby's
25
- #pack and #unpack methods.
24
+ BinData is a declarative way to read and write binary file formats.
26
25
 
27
- It does this by providing a declarative way of specifying structured
28
- binary data. This means the programmer specifies *what* the format
29
- of the binary data is, and BinData works out *how* to read and write
30
- data in this format.
26
+ This means the programmer specifies *what* the format of the binary
27
+ data is, and BinData works out *how* to read and write data in this
28
+ format. It is an easier ( and more readable ) alternative to
29
+ ruby's #pack and #unpack methods.
31
30
  END
32
31
  end
33
32
 
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bindata
3
3
  version: !ruby/object:Gem::Version
4
- hash: 31
4
+ hash: 29
5
5
  prerelease: false
6
6
  segments:
7
7
  - 1
8
8
  - 2
9
- - 0
10
- version: 1.2.0
9
+ - 1
10
+ version: 1.2.1
11
11
  platform: ruby
12
12
  authors:
13
13
  - Dion Mendel
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-07-09 00:00:00 +08:00
18
+ date: 2010-07-20 00:00:00 +08:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -75,13 +75,12 @@ dependencies:
75
75
  type: :development
76
76
  version_requirements: *id004
77
77
  description: |
78
- BinData provides an easy (and more readable) alternative to ruby's
79
- #pack and #unpack methods.
78
+ BinData is a declarative way to read and write binary file formats.
80
79
 
81
- It does this by providing a declarative way of specifying structured
82
- binary data. This means the programmer specifies *what* the format
83
- of the binary data is, and BinData works out *how* to read and write
84
- data in this format.
80
+ This means the programmer specifies *what* the format of the binary
81
+ data is, and BinData works out *how* to read and write data in this
82
+ format. It is an easier ( and more readable ) alternative to
83
+ ruby's #pack and #unpack methods.
85
84
 
86
85
  email: dion@lostrealm.com
87
86
  executables: []
@@ -123,6 +122,7 @@ files:
123
122
  - spec/spec_common.rb
124
123
  - spec/deprecated_spec.rb
125
124
  - lib/bindata.rb
125
+ - lib/bench.rb
126
126
  - lib/bindata/skip.rb
127
127
  - lib/bindata/choice.rb
128
128
  - lib/bindata/dsl.rb