ffi-http-parser 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
data/ChangeLog.md CHANGED
@@ -1,3 +1,10 @@
1
+ ### 0.2.0 / 2012-06-25
2
+
3
+ * Default {FFI::HTTP::Parser::Instance#type} to `:both`, for compatibility
4
+ with [http-parser-lite].
5
+ * {FFI::HTTP::Parser::Instance#reset!} now accepts a new type argument,
6
+ for compatibility with [http-parser-lite].
7
+
1
8
  ### 0.1.0 / 2012-06-23
2
9
 
3
10
  * Initial release:
data/README.md CHANGED
@@ -7,7 +7,7 @@
7
7
 
8
8
  ## Description
9
9
 
10
- Ruby FFI bindings to the [http-parser][1] library.
10
+ Ruby FFI bindings to the Joyent's [http-parser][1] library.
11
11
 
12
12
  ## Features
13
13
 
@@ -43,7 +43,10 @@ module FFI
43
43
  #
44
44
  def initialize(ptr=nil)
45
45
  if ptr then super(ptr)
46
- else super()
46
+ else
47
+ super()
48
+
49
+ self.type = :both
47
50
  end
48
51
 
49
52
  @settings = Settings.new
@@ -233,8 +236,11 @@ module FFI
233
236
  #
234
237
  # Resets the parser.
235
238
  #
236
- def reset!
237
- Parser.http_parser_init(self,type)
239
+ # @param [:request, :response, :both] new_type
240
+ # The new type for the parser.
241
+ #
242
+ def reset!(new_type=self.type)
243
+ Parser.http_parser_init(self,new_type)
238
244
  end
239
245
 
240
246
  alias reset reset!
@@ -1,10 +1,8 @@
1
- require 'ffi'
2
-
3
1
  module FFI
4
2
  module HTTP
5
3
  module Parser
6
4
  # ffi-http-parser version
7
- VERSION = "0.1.0"
5
+ VERSION = "0.2.0"
8
6
  end
9
7
  end
10
8
  end
@@ -35,37 +35,37 @@ describe Instance do
35
35
  end
36
36
 
37
37
  describe "#type" do
38
- it "should default to :request" do
39
- subject.type.should == :request
38
+ it "should default to :both" do
39
+ subject.type.should == :both
40
40
  end
41
41
 
42
42
  it "should convert the type to a Symbol" do
43
- subject[:type_flags] = TYPES[:both]
43
+ subject[:type_flags] = TYPES[:request]
44
44
 
45
- subject.type.should == :both
45
+ subject.type.should == :request
46
46
  end
47
47
 
48
48
  it "should extract the type from the type_flags field" do
49
- subject[:type_flags] = ((0xff & ~0x3) | TYPES[:both])
49
+ subject[:type_flags] = ((0xff & ~0x3) | TYPES[:response])
50
50
 
51
- subject.type.should == :both
51
+ subject.type.should == :response
52
52
  end
53
53
  end
54
54
 
55
55
  describe "#type=" do
56
56
  it "should set the type" do
57
- subject.type = :both
57
+ subject.type = :response
58
58
 
59
- subject.type.should == :both
59
+ subject.type.should == :response
60
60
  end
61
61
 
62
62
  it "should not change flags" do
63
63
  flags = (0xff & ~0x3)
64
64
  subject[:type_flags] = flags
65
65
 
66
- subject.type = :both
66
+ subject.type = :request
67
67
 
68
- subject[:type_flags].should == (flags | TYPES[:both])
68
+ subject[:type_flags].should == (flags | TYPES[:request])
69
69
  end
70
70
  end
71
71
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ffi-http-parser
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-06-24 00:00:00.000000000 Z
12
+ date: 2012-06-26 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: ffi