web_service_documenter 0.0.3 → 0.0.4
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.
- data/lib/web_service_documenter.rb +25 -2
- metadata +21 -8
| @@ -1,8 +1,8 @@ | |
| 1 | 
            -
            require "rubygems"
         | 
| 2 1 | 
             
            require 'yaml'
         | 
| 3 2 | 
             
            require 'json'
         | 
| 4 3 | 
             
            require 'net/http'
         | 
| 5 4 | 
             
            require 'cgi'
         | 
| 5 | 
            +
            require 'net/http/post/multipart'
         | 
| 6 6 |  | 
| 7 7 | 
             
            class WebServiceDocumenter
         | 
| 8 8 | 
             
              class Service
         | 
| @@ -11,10 +11,25 @@ class WebServiceDocumenter | |
| 11 11 | 
             
                  @endpoint       = options["endpoint"]
         | 
| 12 12 | 
             
                  @params         = options["params"]
         | 
| 13 13 | 
             
                  @description    = options["description"]
         | 
| 14 | 
            +
                  @multipart      = options["multipart"] || false
         | 
| 14 15 | 
             
                  @method         = (options["method"] || "get").downcase
         | 
| 15 16 | 
             
                  @example_params = create_example_params
         | 
| 16 17 | 
             
                end
         | 
| 17 18 |  | 
| 19 | 
            +
                def transform_multipart_example_params
         | 
| 20 | 
            +
                  new_params = {}
         | 
| 21 | 
            +
             | 
| 22 | 
            +
                  @example_params.map do |key, value|
         | 
| 23 | 
            +
                    if value =~ /file\((.*)\,(.*)\,(.*)\)/
         | 
| 24 | 
            +
                      new_params[key] = UploadIO.new($1.strip, $2.strip, $3.strip)
         | 
| 25 | 
            +
                    else
         | 
| 26 | 
            +
                      new_params[key] = value
         | 
| 27 | 
            +
                    end
         | 
| 28 | 
            +
                  end
         | 
| 29 | 
            +
             | 
| 30 | 
            +
                  new_params
         | 
| 31 | 
            +
                end
         | 
| 32 | 
            +
             | 
| 18 33 | 
             
                def to_s
         | 
| 19 34 | 
             
                  body = ""
         | 
| 20 35 |  | 
| @@ -22,7 +37,15 @@ class WebServiceDocumenter | |
| 22 37 | 
             
                  uri = URI.parse(url)
         | 
| 23 38 |  | 
| 24 39 | 
             
                  result = if @method =~ /post/
         | 
| 25 | 
            -
                     | 
| 40 | 
            +
                    if @multipart == true
         | 
| 41 | 
            +
                      request = Net::HTTP::Post::Multipart.new uri.path, transform_multipart_example_params
         | 
| 42 | 
            +
             | 
| 43 | 
            +
                      Net::HTTP.start(uri.host, uri.port) do |http|
         | 
| 44 | 
            +
                        http.request(request)
         | 
| 45 | 
            +
                      end
         | 
| 46 | 
            +
                    else
         | 
| 47 | 
            +
                      Net::HTTP.post_form(uri, @example_params)
         | 
| 48 | 
            +
                    end
         | 
| 26 49 | 
             
                  else
         | 
| 27 50 | 
             
                    http = Net::HTTP.new(uri.host, uri.port)
         | 
| 28 51 | 
             
                    request = Net::HTTP::Get.new(uri.path)
         | 
    
        metadata
    CHANGED
    
    | @@ -1,29 +1,42 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification 
         | 
| 2 2 | 
             
            name: web_service_documenter
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version 
         | 
| 4 | 
            -
              hash:  | 
| 4 | 
            +
              hash: 23
         | 
| 5 5 | 
             
              prerelease: false
         | 
| 6 6 | 
             
              segments: 
         | 
| 7 7 | 
             
              - 0
         | 
| 8 8 | 
             
              - 0
         | 
| 9 | 
            -
              -  | 
| 10 | 
            -
              version: 0.0. | 
| 9 | 
            +
              - 4
         | 
| 10 | 
            +
              version: 0.0.4
         | 
| 11 11 | 
             
            platform: ruby
         | 
| 12 12 | 
             
            authors: 
         | 
| 13 | 
            -
            - Scott Taylor
         | 
| 14 13 | 
             
            - Stephen Schor
         | 
| 14 | 
            +
            - Scott Taylor
         | 
| 15 15 | 
             
            autorequire: 
         | 
| 16 16 | 
             
            bindir: bin
         | 
| 17 17 | 
             
            cert_chain: []
         | 
| 18 18 |  | 
| 19 | 
            -
            date: 2011-06- | 
| 19 | 
            +
            date: 2011-06-13 00:00:00 -04:00
         | 
| 20 20 | 
             
            default_executable: 
         | 
| 21 | 
            -
            dependencies:  | 
| 22 | 
            -
             | 
| 21 | 
            +
            dependencies: 
         | 
| 22 | 
            +
            - !ruby/object:Gem::Dependency 
         | 
| 23 | 
            +
              name: multipart-post
         | 
| 24 | 
            +
              prerelease: false
         | 
| 25 | 
            +
              requirement: &id001 !ruby/object:Gem::Requirement 
         | 
| 26 | 
            +
                none: false
         | 
| 27 | 
            +
                requirements: 
         | 
| 28 | 
            +
                - - ">="
         | 
| 29 | 
            +
                  - !ruby/object:Gem::Version 
         | 
| 30 | 
            +
                    hash: 3
         | 
| 31 | 
            +
                    segments: 
         | 
| 32 | 
            +
                    - 0
         | 
| 33 | 
            +
                    version: "0"
         | 
| 34 | 
            +
              type: :runtime
         | 
| 35 | 
            +
              version_requirements: *id001
         | 
| 23 36 | 
             
            description: 
         | 
| 24 37 | 
             
            email: 
         | 
| 25 | 
            -
            - scott@railsnewbie.com
         | 
| 26 38 | 
             
            - beholdthepanda@gmail.com
         | 
| 39 | 
            +
            - scott@railsnewbie.com
         | 
| 27 40 | 
             
            executables: 
         | 
| 28 41 | 
             
            - web_service_documenter
         | 
| 29 42 | 
             
            extensions: []
         |