multipart-post 1.1.4 → 1.1.5

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile CHANGED
@@ -9,3 +9,6 @@ platforms :mri_18 do
9
9
  gem 'ruby-debug'
10
10
  end
11
11
 
12
+ group :development, :test do
13
+ gem 'rake'
14
+ end
@@ -1,22 +1,23 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- multipart-post (1.1.3)
4
+ multipart-post (1.1.4)
5
5
 
6
6
  GEM
7
7
  remote: http://rubygems.org/
8
8
  specs:
9
9
  archive-tar-minitar (0.5.2)
10
- columnize (0.3.1)
10
+ columnize (0.3.6)
11
11
  linecache (0.43)
12
- linecache19 (0.5.11)
12
+ linecache19 (0.5.12)
13
13
  ruby_core_source (>= 0.1.4)
14
+ rake (0.9.2.2)
14
15
  ruby-debug (0.10.3)
15
16
  columnize (>= 0.1)
16
17
  ruby-debug-base (~> 0.10.3.0)
17
18
  ruby-debug-base (0.10.3)
18
19
  linecache (>= 0.3)
19
- ruby-debug-base19 (0.11.24)
20
+ ruby-debug-base19 (0.11.25)
20
21
  columnize (>= 0.3.1)
21
22
  linecache19 (>= 0.5.11)
22
23
  ruby_core_source (>= 0.1.4)
@@ -24,7 +25,7 @@ GEM
24
25
  columnize (>= 0.3.1)
25
26
  linecache19 (>= 0.5.11)
26
27
  ruby-debug-base19 (>= 0.11.19)
27
- ruby_core_source (0.1.4)
28
+ ruby_core_source (0.1.5)
28
29
  archive-tar-minitar (>= 0.5.2)
29
30
 
30
31
  PLATFORMS
@@ -33,5 +34,6 @@ PLATFORMS
33
34
 
34
35
  DEPENDENCIES
35
36
  multipart-post!
37
+ rake
36
38
  ruby-debug
37
39
  ruby-debug19
@@ -1,3 +1,13 @@
1
+ === 1.1.5 / 2012-02-12
2
+
3
+ - Fix length/bytesize of parts in 1.9 (#7, #14) (Jason Moore)
4
+ - Allow CompositeIO objects to be re-read by rewinding, like other IO
5
+ objects. (Luke Redpath)
6
+
7
+ === 1.1.4 / 2011-11-23
8
+
9
+ - Non-functional changes in release (switch to Bundler gem tasks)
10
+
1
11
  === 1.1.3 / 2011-07-25
2
12
 
3
13
  - More configurable header specification for parts (Gerrit Riessen)
data/README.txt CHANGED
@@ -40,7 +40,7 @@ gem install multipart-post
40
40
 
41
41
  (The MIT License)
42
42
 
43
- Copyright (c) 2007-2011 Nick Sieger <nick@nicksieger.com>
43
+ Copyright (c) 2007-2012 Nick Sieger <nick@nicksieger.com>
44
44
 
45
45
  Permission is hereby granted, free of charge, to any person obtaining
46
46
  a copy of this software and associated documentation files (the
@@ -1,5 +1,5 @@
1
1
  #--
2
- # (c) Copyright 2007-2011 Nick Sieger.
2
+ # Copyright (c) 2007-2012 Nick Sieger.
3
3
  # See the file README.txt included with the distribution for
4
4
  # software license details.
5
5
  #++
@@ -24,12 +24,13 @@ class CompositeReadIO
24
24
  buffer = buf || ''
25
25
  done = if amount; nil; else ''; end
26
26
  partial_amount = amount
27
+ parts = @ios.dup
27
28
 
28
29
  loop do
29
30
  result = done
30
31
 
31
- while !@ios.empty? && (result = @ios.first.read(partial_amount)) == done
32
- @ios.shift
32
+ while !parts.empty? && (result = parts.first.read(partial_amount)) == done
33
+ parts.shift
33
34
  end
34
35
 
35
36
  result.force_encoding("BINARY") if result.respond_to?(:force_encoding)
@@ -46,6 +47,10 @@ class CompositeReadIO
46
47
  done
47
48
  end
48
49
  end
50
+
51
+ def rewind
52
+ @ios.each { |io| io.rewind }
53
+ end
49
54
  end
50
55
 
51
56
  # Convenience methods for dealing with files and IO that are to be uploaded.
@@ -1,3 +1,9 @@
1
+ #--
2
+ # Copyright (c) 2007-2012 Nick Sieger.
3
+ # See the file README.txt included with the distribution for
4
+ # software license details.
5
+ #++
6
+
1
7
  module MultipartPost
2
- VERSION = "1.1.4"
8
+ VERSION = "1.1.5"
3
9
  end
@@ -1,3 +1,9 @@
1
+ #--
2
+ # Copyright (c) 2007-2012 Nick Sieger.
3
+ # See the file README.txt included with the distribution for
4
+ # software license details.
5
+ #++
6
+
1
7
  require 'parts'
2
8
  module Multipartable
3
9
  DEFAULT_BOUNDARY = "-----------RubyMultipartPost"
@@ -1,5 +1,5 @@
1
1
  #--
2
- # (c) Copyright 2007-2008 Nick Sieger.
2
+ # Copyright (c) 2007-2012 Nick Sieger.
3
3
  # See the file README.txt included with the distribution for
4
4
  # software license details.
5
5
  #++
@@ -1,3 +1,9 @@
1
+ #--
2
+ # Copyright (c) 2007-2012 Nick Sieger.
3
+ # See the file README.txt included with the distribution for
4
+ # software license details.
5
+ #++
6
+
1
7
  module Parts
2
8
  module Part #:nodoc:
3
9
  def self.new(boundary, name, value)
@@ -24,6 +30,10 @@ module Parts
24
30
  @io = StringIO.new(@part)
25
31
  end
26
32
 
33
+ def length
34
+ @part.bytesize
35
+ end
36
+
27
37
  def build_part(boundary, name, value)
28
38
  part = ''
29
39
  part << "--#{boundary}\r\n"
@@ -1,10 +1,11 @@
1
1
  #--
2
- # (c) Copyright 2007-2008 Nick Sieger.
2
+ # Copyright (c) 2007-2012 Nick Sieger.
3
3
  # See the file README.txt included with the distribution for
4
4
  # software license details.
5
5
  #++
6
6
 
7
7
  require 'net/http/post/multipart'
8
+ require 'test/unit'
8
9
 
9
10
  class Net::HTTP::Post::MultiPartTest < Test::Unit::TestCase
10
11
  TEMP_FILE = "temp.txt"
@@ -1,3 +1,9 @@
1
+ #--
2
+ # Copyright (c) 2007-2012 Nick Sieger.
3
+ # See the file README.txt included with the distribution for
4
+ # software license details.
5
+ #++
6
+
1
7
  require 'composite_io'
2
8
  require 'stringio'
3
9
  require 'test/unit'
@@ -56,6 +62,12 @@ class CompositeReadIOTest < Test::Unit::TestCase
56
62
  @io.read(32)
57
63
  assert_equal nil, @io.read(32)
58
64
  end
65
+
66
+ def test_second_full_read_after_rewinding
67
+ @io.read
68
+ @io.rewind
69
+ assert_equal 'the quick brown fox', @io.read
70
+ end
59
71
 
60
72
  def test_convert_error
61
73
  assert_raises(ArgumentError) {
@@ -1,11 +1,29 @@
1
+ #--
2
+ # Copyright (c) 2007-2012 Nick Sieger.
3
+ # See the file README.txt included with the distribution for
4
+ # software license details.
5
+ #++
6
+
1
7
  require 'test/unit'
2
8
 
3
9
  require 'parts'
4
10
  require 'stringio'
5
11
  require 'composite_io'
6
12
 
13
+
14
+ MULTIBYTE = File.dirname(__FILE__)+'/multibyte.txt'
15
+ TEMP_FILE = "temp.txt"
16
+
17
+ module AssertPartLength
18
+ def assert_part_length(part)
19
+ bytes = part.to_io.read
20
+ bytesize = bytes.respond_to?(:bytesize) ? bytes.bytesize : bytes.length
21
+ assert_equal bytesize, part.length
22
+ end
23
+ end
24
+
7
25
  class FilePartTest < Test::Unit::TestCase
8
- TEMP_FILE = "temp.txt"
26
+ include AssertPartLength
9
27
 
10
28
  def setup
11
29
  File.open(TEMP_FILE, "w") {|f| f << "1234567890"}
@@ -18,6 +36,22 @@ class FilePartTest < Test::Unit::TestCase
18
36
  end
19
37
 
20
38
  def test_correct_length
21
- assert_equal @part.length, @part.to_io.read.length
39
+ assert_part_length @part
40
+ end
41
+
42
+ def test_multibyte_file_length
43
+ assert_part_length Parts::FilePart.new("boundary", "multibyte", UploadIO.new(MULTIBYTE, "text/plain"))
44
+ end
45
+ end
46
+
47
+ class ParamPartTest < Test::Unit::TestCase
48
+ include AssertPartLength
49
+
50
+ def setup
51
+ @part = Parts::ParamPart.new("boundary", "multibyte", File.read(MULTIBYTE))
52
+ end
53
+
54
+ def test_correct_length
55
+ assert_part_length @part
22
56
  end
23
57
  end
metadata CHANGED
@@ -1,75 +1,68 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: multipart-post
3
- version: !ruby/object:Gem::Version
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.1.5
4
5
  prerelease:
5
- version: 1.1.4
6
6
  platform: ruby
7
- authors:
8
- - Nick Sieger
7
+ authors:
8
+ - Nick Sieger
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
-
13
- date: 2011-11-23 00:00:00 Z
12
+ date: 2012-02-13 00:00:00.000000000Z
14
13
  dependencies: []
15
-
16
- description: "Use with Net::HTTP to do multipart form posts. IO values that have #content_type, #original_filename, and #local_path will be posted as a binary file."
17
- email:
18
- - nick@nicksieger.com
14
+ description: ! 'Use with Net::HTTP to do multipart form posts. IO values that have
15
+ #content_type, #original_filename, and #local_path will be posted as a binary file.'
16
+ email:
17
+ - nick@nicksieger.com
19
18
  executables: []
20
-
21
19
  extensions: []
22
-
23
20
  extra_rdoc_files: []
24
-
25
- files:
26
- - .gitignore
27
- - .travis.yml
28
- - Gemfile
29
- - Gemfile.lock
30
- - History.txt
31
- - Manifest.txt
32
- - README.txt
33
- - Rakefile
34
- - lib/composite_io.rb
35
- - lib/multipart_post.rb
36
- - lib/multipartable.rb
37
- - lib/net/http/post/multipart.rb
38
- - lib/parts.rb
39
- - multipart-post.gemspec
40
- - test/multibyte.txt
41
- - test/net/http/post/test_multipart.rb
42
- - test/test_composite_io.rb
43
- - test/test_parts.rb
21
+ files:
22
+ - .gitignore
23
+ - .travis.yml
24
+ - Gemfile
25
+ - Gemfile.lock
26
+ - History.txt
27
+ - Manifest.txt
28
+ - README.txt
29
+ - Rakefile
30
+ - lib/composite_io.rb
31
+ - lib/multipart_post.rb
32
+ - lib/multipartable.rb
33
+ - lib/net/http/post/multipart.rb
34
+ - lib/parts.rb
35
+ - multipart-post.gemspec
36
+ - test/multibyte.txt
37
+ - test/net/http/post/test_multipart.rb
38
+ - test/test_composite_io.rb
39
+ - test/test_parts.rb
44
40
  homepage: https://github.com/nicksieger/multipart-post
45
41
  licenses: []
46
-
47
42
  post_install_message:
48
43
  rdoc_options: []
49
-
50
- require_paths:
51
- - lib
52
- required_ruby_version: !ruby/object:Gem::Requirement
44
+ require_paths:
45
+ - lib
46
+ required_ruby_version: !ruby/object:Gem::Requirement
53
47
  none: false
54
- requirements:
55
- - - ">="
56
- - !ruby/object:Gem::Version
57
- version: "0"
58
- required_rubygems_version: !ruby/object:Gem::Requirement
48
+ requirements:
49
+ - - ! '>='
50
+ - !ruby/object:Gem::Version
51
+ version: '0'
52
+ required_rubygems_version: !ruby/object:Gem::Requirement
59
53
  none: false
60
- requirements:
61
- - - ">="
62
- - !ruby/object:Gem::Version
63
- version: "0"
54
+ requirements:
55
+ - - ! '>='
56
+ - !ruby/object:Gem::Version
57
+ version: '0'
64
58
  requirements: []
65
-
66
59
  rubyforge_project: caldersphere
67
- rubygems_version: 1.8.9
60
+ rubygems_version: 1.8.6
68
61
  signing_key:
69
62
  specification_version: 3
70
63
  summary: A multipart form post accessory for Net::HTTP.
71
- test_files:
72
- - test/multibyte.txt
73
- - test/net/http/post/test_multipart.rb
74
- - test/test_composite_io.rb
75
- - test/test_parts.rb
64
+ test_files:
65
+ - test/multibyte.txt
66
+ - test/net/http/post/test_multipart.rb
67
+ - test/test_composite_io.rb
68
+ - test/test_parts.rb