curb 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of curb might be problematic. Click here for more details.
- data/LICENSE +51 -0
- data/README +106 -0
- data/Rakefile +302 -0
- data/doc.rb +42 -0
- data/ext/curb.c +333 -0
- data/ext/curb.h +39 -0
- data/ext/curb.rb +46 -0
- data/ext/curb_easy.c +2138 -0
- data/ext/curb_easy.h +73 -0
- data/ext/curb_errors.c +471 -0
- data/ext/curb_errors.h +106 -0
- data/ext/curb_macros.h +114 -0
- data/ext/curb_postfield.c +499 -0
- data/ext/curb_postfield.h +40 -0
- data/ext/curl.rb +2 -0
- data/ext/extconf.rb +24 -0
- data/samples/gmail.rb +46 -0
- data/tests/alltests.rb +3 -0
- data/tests/bug_instance_post_differs_from_class_post.rb +53 -0
- data/tests/bug_require_last_or_segfault.rb +40 -0
- data/tests/helper.rb +15 -0
- data/tests/require_last_or_segfault_script.rb +36 -0
- data/tests/tc_curl_easy.rb +415 -0
- data/tests/tc_curl_postfield.rb +141 -0
- data/tests/unittests.rb +2 -0
- metadata +80 -0
| @@ -0,0 +1,141 @@ | |
| 1 | 
            +
            require File.join(File.dirname(__FILE__), 'helper')
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            class TestCurbCurlPostfield < Test::Unit::TestCase
         | 
| 4 | 
            +
              def test_private_new
         | 
| 5 | 
            +
                assert_raise(NoMethodError) { Curl::PostField.new }  
         | 
| 6 | 
            +
              end
         | 
| 7 | 
            +
              
         | 
| 8 | 
            +
              def test_new_content_01
         | 
| 9 | 
            +
                pf = Curl::PostField.content('foo', 'bar')
         | 
| 10 | 
            +
                
         | 
| 11 | 
            +
                assert_equal 'foo', pf.name
         | 
| 12 | 
            +
                assert_equal 'bar', pf.content
         | 
| 13 | 
            +
                assert_nil pf.content_type
         | 
| 14 | 
            +
                assert_nil pf.local_file
         | 
| 15 | 
            +
                assert_nil pf.remote_file    
         | 
| 16 | 
            +
                assert_nil pf.set_content_proc
         | 
| 17 | 
            +
              end
         | 
| 18 | 
            +
                
         | 
| 19 | 
            +
              def test_new_content_02
         | 
| 20 | 
            +
                pf = Curl::PostField.content('foo', 'bar', 'text/html')
         | 
| 21 | 
            +
                
         | 
| 22 | 
            +
                assert_equal 'foo', pf.name
         | 
| 23 | 
            +
                assert_equal 'bar', pf.content
         | 
| 24 | 
            +
                assert_equal 'text/html', pf.content_type
         | 
| 25 | 
            +
                assert_nil pf.local_file
         | 
| 26 | 
            +
                assert_nil pf.remote_file
         | 
| 27 | 
            +
                assert_nil pf.set_content_proc    
         | 
| 28 | 
            +
              end    
         | 
| 29 | 
            +
              
         | 
| 30 | 
            +
              def test_new_content_03
         | 
| 31 | 
            +
                l = lambda { |field| "never gets run" }
         | 
| 32 | 
            +
                pf = Curl::PostField.content('foo', &l)
         | 
| 33 | 
            +
                
         | 
| 34 | 
            +
                assert_equal 'foo', pf.name
         | 
| 35 | 
            +
                assert_nil pf.content
         | 
| 36 | 
            +
                assert_nil pf.content_type
         | 
| 37 | 
            +
                assert_nil pf.local_file
         | 
| 38 | 
            +
                assert_nil pf.remote_file
         | 
| 39 | 
            +
                
         | 
| 40 | 
            +
                # N.B. This doesn't just get the proc, but also removes it.
         | 
| 41 | 
            +
                assert_equal l, pf.set_content_proc
         | 
| 42 | 
            +
              end    
         | 
| 43 | 
            +
             | 
| 44 | 
            +
              def test_new_content_04
         | 
| 45 | 
            +
                l = lambda { |field| "never gets run" }
         | 
| 46 | 
            +
                pf = Curl::PostField.content('foo', 'text/html', &l)
         | 
| 47 | 
            +
                
         | 
| 48 | 
            +
                assert_equal 'foo', pf.name
         | 
| 49 | 
            +
                assert_nil pf.content
         | 
| 50 | 
            +
                assert_equal 'text/html', pf.content_type
         | 
| 51 | 
            +
                assert_nil pf.local_file
         | 
| 52 | 
            +
                assert_nil pf.remote_file
         | 
| 53 | 
            +
                
         | 
| 54 | 
            +
                # N.B. This doesn't just get the proc, but also removes it.
         | 
| 55 | 
            +
                assert_equal l, pf.set_content_proc
         | 
| 56 | 
            +
              end    
         | 
| 57 | 
            +
             | 
| 58 | 
            +
             | 
| 59 | 
            +
              def test_new_file_01
         | 
| 60 | 
            +
                pf = Curl::PostField.file('foo', 'localname')
         | 
| 61 | 
            +
                
         | 
| 62 | 
            +
                assert_equal 'foo', pf.name
         | 
| 63 | 
            +
                assert_equal 'localname', pf.local_file
         | 
| 64 | 
            +
                assert_equal 'localname', pf.remote_file
         | 
| 65 | 
            +
                assert_nil pf.content_type
         | 
| 66 | 
            +
                assert_nil pf.content
         | 
| 67 | 
            +
                assert_nil pf.set_content_proc
         | 
| 68 | 
            +
              end
         | 
| 69 | 
            +
                
         | 
| 70 | 
            +
              def test_new_file_02
         | 
| 71 | 
            +
                pf = Curl::PostField.file('foo', 'localname', 'remotename')
         | 
| 72 | 
            +
                
         | 
| 73 | 
            +
                assert_equal 'foo', pf.name
         | 
| 74 | 
            +
                assert_equal 'localname', pf.local_file
         | 
| 75 | 
            +
                assert_equal 'remotename', pf.remote_file
         | 
| 76 | 
            +
                assert_nil pf.content_type
         | 
| 77 | 
            +
                assert_nil pf.content
         | 
| 78 | 
            +
                assert_nil pf.set_content_proc
         | 
| 79 | 
            +
              end    
         | 
| 80 | 
            +
              
         | 
| 81 | 
            +
              def test_new_file_03
         | 
| 82 | 
            +
                l = lambda { |field| "never gets run" }
         | 
| 83 | 
            +
                pf = Curl::PostField.file('foo', 'remotename', &l)
         | 
| 84 | 
            +
                
         | 
| 85 | 
            +
                assert_equal 'foo', pf.name
         | 
| 86 | 
            +
                assert_equal 'remotename', pf.remote_file
         | 
| 87 | 
            +
                assert_nil pf.local_file
         | 
| 88 | 
            +
                assert_nil pf.content_type
         | 
| 89 | 
            +
                assert_nil pf.content
         | 
| 90 | 
            +
                
         | 
| 91 | 
            +
                # N.B. This doesn't just get the proc, but also removes it.
         | 
| 92 | 
            +
                assert_equal l, pf.set_content_proc
         | 
| 93 | 
            +
              end    
         | 
| 94 | 
            +
             | 
| 95 | 
            +
              def test_new_file_04
         | 
| 96 | 
            +
                assert_raise(ArgumentError) do
         | 
| 97 | 
            +
                  # no local name, no block
         | 
| 98 | 
            +
                  Curl::PostField.file('foo')
         | 
| 99 | 
            +
                end
         | 
| 100 | 
            +
                
         | 
| 101 | 
            +
                assert_raise(ArgumentError) do
         | 
| 102 | 
            +
                  # no remote name with block
         | 
| 103 | 
            +
                  Curl::PostField.file('foo') { |field| "never runs" }
         | 
| 104 | 
            +
                end
         | 
| 105 | 
            +
              end
         | 
| 106 | 
            +
              
         | 
| 107 | 
            +
              def test_new_file_05
         | 
| 108 | 
            +
                # local gets ignored when supplying a block, but remote
         | 
| 109 | 
            +
                # is still set up properly.
         | 
| 110 | 
            +
                l = lambda { |field| "never runs" }
         | 
| 111 | 
            +
                pf = Curl::PostField.file('foo', 'local', 'remote', &l)
         | 
| 112 | 
            +
             | 
| 113 | 
            +
                assert_equal 'foo', pf.name
         | 
| 114 | 
            +
                assert_equal 'remote', pf.remote_file
         | 
| 115 | 
            +
                assert_nil pf.local_file
         | 
| 116 | 
            +
                assert_nil pf.content_type
         | 
| 117 | 
            +
                assert_nil pf.content
         | 
| 118 | 
            +
             | 
| 119 | 
            +
                assert_equal l, pf.set_content_proc
         | 
| 120 | 
            +
              end    
         | 
| 121 | 
            +
              
         | 
| 122 | 
            +
              def test_to_s_01
         | 
| 123 | 
            +
                pf = Curl::PostField.content('foo', 'bar')    
         | 
| 124 | 
            +
                assert_equal "foo=bar", pf.to_s
         | 
| 125 | 
            +
              end
         | 
| 126 | 
            +
             | 
| 127 | 
            +
              def test_to_s_02
         | 
| 128 | 
            +
                pf = Curl::PostField.content('foo', 'bar ton')    
         | 
| 129 | 
            +
                assert_equal "foo=bar%20ton", pf.to_s
         | 
| 130 | 
            +
              end
         | 
| 131 | 
            +
             | 
| 132 | 
            +
              def test_to_s_03
         | 
| 133 | 
            +
                pf = Curl::PostField.content('foo') { |field| field.name.upcase + "BAR" }
         | 
| 134 | 
            +
                assert_equal "foo=FOOBAR", pf.to_s
         | 
| 135 | 
            +
              end
         | 
| 136 | 
            +
             | 
| 137 | 
            +
              def test_to_s_04
         | 
| 138 | 
            +
                pf = Curl::PostField.file('foo.file', 'bar.file')
         | 
| 139 | 
            +
                assert_raise(Curl::Err::InvalidPostFieldError) { pf.to_s }
         | 
| 140 | 
            +
              end
         | 
| 141 | 
            +
            end
         | 
    
        data/tests/unittests.rb
    ADDED
    
    
    
        metadata
    ADDED
    
    | @@ -0,0 +1,80 @@ | |
| 1 | 
            +
            --- !ruby/object:Gem::Specification 
         | 
| 2 | 
            +
            rubygems_version: 0.9.0
         | 
| 3 | 
            +
            specification_version: 1
         | 
| 4 | 
            +
            name: curb
         | 
| 5 | 
            +
            version: !ruby/object:Gem::Version 
         | 
| 6 | 
            +
              version: 0.1.0
         | 
| 7 | 
            +
            date: 2006-12-23 00:00:00 +00:00
         | 
| 8 | 
            +
            summary: Ruby bindings for the libcurl(3) URL transfer library.
         | 
| 9 | 
            +
            require_paths: 
         | 
| 10 | 
            +
            - lib
         | 
| 11 | 
            +
            email: curb-devel@rubyforge.org
         | 
| 12 | 
            +
            homepage: http://curb.rubyforge.org
         | 
| 13 | 
            +
            rubyforge_project: curb
         | 
| 14 | 
            +
            description: C-language Ruby bindings for the libcurl(3) URL transfer library.
         | 
| 15 | 
            +
            autorequire: 
         | 
| 16 | 
            +
            default_executable: 
         | 
| 17 | 
            +
            bindir: bin
         | 
| 18 | 
            +
            has_rdoc: true
         | 
| 19 | 
            +
            required_ruby_version: !ruby/object:Gem::Version::Requirement 
         | 
| 20 | 
            +
              requirements: 
         | 
| 21 | 
            +
              - - ">"
         | 
| 22 | 
            +
                - !ruby/object:Gem::Version 
         | 
| 23 | 
            +
                  version: 0.0.0
         | 
| 24 | 
            +
              version: 
         | 
| 25 | 
            +
            platform: ruby
         | 
| 26 | 
            +
            signing_key: 
         | 
| 27 | 
            +
            cert_chain: 
         | 
| 28 | 
            +
            post_install_message: 
         | 
| 29 | 
            +
            authors: 
         | 
| 30 | 
            +
            - Ross Bamford
         | 
| 31 | 
            +
            files: 
         | 
| 32 | 
            +
            - ext/curl.rb
         | 
| 33 | 
            +
            - ext/extconf.rb
         | 
| 34 | 
            +
            - ext/curb.rb
         | 
| 35 | 
            +
            - ext/curb.c
         | 
| 36 | 
            +
            - ext/curb_easy.c
         | 
| 37 | 
            +
            - ext/curb_errors.c
         | 
| 38 | 
            +
            - ext/curb_postfield.c
         | 
| 39 | 
            +
            - ext/curb_macros.h
         | 
| 40 | 
            +
            - ext/curb_postfield.h
         | 
| 41 | 
            +
            - ext/curb.h
         | 
| 42 | 
            +
            - ext/curb_errors.h
         | 
| 43 | 
            +
            - ext/curb_easy.h
         | 
| 44 | 
            +
            - tests/bug_require_last_or_segfault.rb
         | 
| 45 | 
            +
            - tests/tc_curl_easy.rb
         | 
| 46 | 
            +
            - tests/helper.rb
         | 
| 47 | 
            +
            - tests/alltests.rb
         | 
| 48 | 
            +
            - tests/bug_instance_post_differs_from_class_post.rb
         | 
| 49 | 
            +
            - tests/unittests.rb
         | 
| 50 | 
            +
            - tests/tc_curl_postfield.rb
         | 
| 51 | 
            +
            - tests/require_last_or_segfault_script.rb
         | 
| 52 | 
            +
            - samples/gmail.rb
         | 
| 53 | 
            +
            - doc.rb
         | 
| 54 | 
            +
            - Rakefile
         | 
| 55 | 
            +
            - README
         | 
| 56 | 
            +
            - LICENSE
         | 
| 57 | 
            +
            test_files: 
         | 
| 58 | 
            +
            - tests/tc_curl_easy.rb
         | 
| 59 | 
            +
            - tests/tc_curl_postfield.rb
         | 
| 60 | 
            +
            rdoc_options: 
         | 
| 61 | 
            +
            - --title
         | 
| 62 | 
            +
            - Curb API
         | 
| 63 | 
            +
            - --main
         | 
| 64 | 
            +
            - README
         | 
| 65 | 
            +
            extra_rdoc_files: 
         | 
| 66 | 
            +
            - ext/curb.c
         | 
| 67 | 
            +
            - ext/curb_easy.c
         | 
| 68 | 
            +
            - ext/curb_errors.c
         | 
| 69 | 
            +
            - ext/curb_postfield.c
         | 
| 70 | 
            +
            - ext/curb.rb
         | 
| 71 | 
            +
            - README
         | 
| 72 | 
            +
            - LICENSE
         | 
| 73 | 
            +
            executables: []
         | 
| 74 | 
            +
             | 
| 75 | 
            +
            extensions: 
         | 
| 76 | 
            +
            - ext/extconf.rb
         | 
| 77 | 
            +
            requirements: []
         | 
| 78 | 
            +
             | 
| 79 | 
            +
            dependencies: []
         | 
| 80 | 
            +
             |