rcurl 0.1.0 → 0.2.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.
- checksums.yaml +4 -4
- data/README.md +45 -15
- data/lib/rcurl.rb +1 -0
- data/lib/rcurl/configure.rb +1 -1
- data/lib/rcurl/curl.rb +2 -1
- data/lib/rcurl/method/post.rb +31 -0
- data/lib/rcurl/version.rb +1 -1
- metadata +3 -2
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA256:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: 63c14c614a9dd88c35d801d2a718169ca2937baa97c86f04f419b8e010902014
         | 
| 4 | 
            +
              data.tar.gz: 4e96a32288b16a8aac8e725ae1fbd2b1c1f287a7235ce3d7e5adf5607632b379
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: 0fa945aed7446a567e5a0dc6d3ea55ed81423faf01f4bad7accb393eb17335ced8d5b6e49280ce8d09be55dd84646d26a46559d928e390389e49ea49214edd3f
         | 
| 7 | 
            +
              data.tar.gz: cd022efeaebb0ac6a10f569c0935200854d6443a64469324491d0370b50d380ef7c2fa42fb79ab3a3488d1cd973874da9d31a03db07c4ea62b847ae181c26b9d
         | 
    
        data/README.md
    CHANGED
    
    | @@ -1,34 +1,64 @@ | |
| 1 1 | 
             
            # Rcurl
         | 
| 2 2 |  | 
| 3 | 
            -
             | 
| 4 | 
            -
             | 
| 5 | 
            -
            TODO: Delete this and the text above, and describe your gem
         | 
| 3 | 
            +
            Simple curl command wrapper
         | 
| 6 4 |  | 
| 7 5 | 
             
            ## Installation
         | 
| 8 6 |  | 
| 9 | 
            -
             | 
| 7 | 
            +
                $ gem install rcurl
         | 
| 8 | 
            +
             | 
| 9 | 
            +
            ## Usage
         | 
| 10 | 
            +
             | 
| 11 | 
            +
            ### GET
         | 
| 10 12 |  | 
| 11 | 
            -
             | 
| 12 | 
            -
             | 
| 13 | 
            +
            Create example.yaml
         | 
| 14 | 
            +
             | 
| 15 | 
            +
            ```yaml
         | 
| 16 | 
            +
            method: GET
         | 
| 17 | 
            +
            params:
         | 
| 18 | 
            +
              hoge: fuga
         | 
| 13 19 | 
             
            ```
         | 
| 14 20 |  | 
| 15 | 
            -
             | 
| 21 | 
            +
            execute `rcurl` command with option `-d`
         | 
| 16 22 |  | 
| 17 | 
            -
             | 
| 23 | 
            +
            ```console
         | 
| 24 | 
            +
            $ rcurl -d @path/to/example.yaml http://example.com
         | 
| 18 25 |  | 
| 19 | 
            -
             | 
| 26 | 
            +
            # => curl -sS -X GET http://example.com?hoge=fuga
         | 
| 27 | 
            +
            ```
         | 
| 20 28 |  | 
| 21 | 
            -
             | 
| 29 | 
            +
            ### POST (application/x-www-form-urlencoded)
         | 
| 22 30 |  | 
| 23 | 
            -
             | 
| 31 | 
            +
            example.yaml
         | 
| 24 32 |  | 
| 25 | 
            -
             | 
| 33 | 
            +
            ```yaml
         | 
| 34 | 
            +
            method: POST
         | 
| 35 | 
            +
            params:
         | 
| 36 | 
            +
              hoge: fuga
         | 
| 37 | 
            +
            ```
         | 
| 38 | 
            +
             | 
| 39 | 
            +
            ```console
         | 
| 40 | 
            +
            $ rcurl -d @path/to/example.yaml http://example.com
         | 
| 41 | 
            +
             | 
| 42 | 
            +
            # => curl -sS -X POST -d 'hoge=fuga' http://example.com
         | 
| 43 | 
            +
            ```
         | 
| 26 44 |  | 
| 27 | 
            -
             | 
| 45 | 
            +
            ### POST (application/json)
         | 
| 28 46 |  | 
| 29 | 
            -
             | 
| 47 | 
            +
            example.yaml
         | 
| 30 48 |  | 
| 31 | 
            -
             | 
| 49 | 
            +
            ```yaml
         | 
| 50 | 
            +
            method: POST
         | 
| 51 | 
            +
            headers:
         | 
| 52 | 
            +
              - 'Content-type: application/json'
         | 
| 53 | 
            +
            params:
         | 
| 54 | 
            +
              hoge: fuga
         | 
| 55 | 
            +
            ```
         | 
| 56 | 
            +
             | 
| 57 | 
            +
            ```console
         | 
| 58 | 
            +
            $ rcurl -d @path/to/example.yaml http://example.com
         | 
| 59 | 
            +
             | 
| 60 | 
            +
            # => curl -sS -X POST -H 'Content-type: application/json' -d '{"hoge":"fuga"}' http://example.com
         | 
| 61 | 
            +
            ```
         | 
| 32 62 |  | 
| 33 63 | 
             
            ## Contributing
         | 
| 34 64 |  | 
    
        data/lib/rcurl.rb
    CHANGED
    
    
    
        data/lib/rcurl/configure.rb
    CHANGED
    
    | @@ -38,7 +38,7 @@ module Rcurl | |
| 38 38 |  | 
| 39 39 | 
             
                def yaml
         | 
| 40 40 | 
             
                  raise ConfigFileNotFound, "Config not found. #{@file}" unless File.exist?(file)
         | 
| 41 | 
            -
                  @yaml  | 
| 41 | 
            +
                  @yaml ||= YAML.load(read).symbolize_keys
         | 
| 42 42 | 
             
                rescue Psych::SyntaxError
         | 
| 43 43 | 
             
                  raise InvalidConfig, 'invalid config file'
         | 
| 44 44 | 
             
                end
         | 
    
        data/lib/rcurl/curl.rb
    CHANGED
    
    
| @@ -0,0 +1,31 @@ | |
| 1 | 
            +
            require 'json'
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            module Rcurl
         | 
| 4 | 
            +
              module Method
         | 
| 5 | 
            +
                class Post < Base
         | 
| 6 | 
            +
                  def method
         | 
| 7 | 
            +
                    '-X POST'
         | 
| 8 | 
            +
                  end
         | 
| 9 | 
            +
             | 
| 10 | 
            +
                  def url
         | 
| 11 | 
            +
                    config.url
         | 
| 12 | 
            +
                  end
         | 
| 13 | 
            +
             | 
| 14 | 
            +
                  def params
         | 
| 15 | 
            +
                    if json?
         | 
| 16 | 
            +
                      "-d '#{config.params.to_json}'"
         | 
| 17 | 
            +
                    else
         | 
| 18 | 
            +
                      config.params.map{|k, v| "-d '#{k}=#{v}'"}.join(' ')
         | 
| 19 | 
            +
                    end
         | 
| 20 | 
            +
                  end
         | 
| 21 | 
            +
             | 
| 22 | 
            +
                  private
         | 
| 23 | 
            +
             | 
| 24 | 
            +
                  def json?
         | 
| 25 | 
            +
                    config.headers.any? do |header|
         | 
| 26 | 
            +
                      header.downcase =~ /content-type: application\/json/
         | 
| 27 | 
            +
                    end
         | 
| 28 | 
            +
                  end
         | 
| 29 | 
            +
                end
         | 
| 30 | 
            +
              end
         | 
| 31 | 
            +
            end
         | 
    
        data/lib/rcurl/version.rb
    CHANGED
    
    
    
        metadata
    CHANGED
    
    | @@ -1,14 +1,14 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: rcurl
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 0. | 
| 4 | 
            +
              version: 0.2.0
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - kimromi
         | 
| 8 8 | 
             
            autorequire: 
         | 
| 9 9 | 
             
            bindir: exe
         | 
| 10 10 | 
             
            cert_chain: []
         | 
| 11 | 
            -
            date: 2018-03 | 
| 11 | 
            +
            date: 2018-04-03 00:00:00.000000000 Z
         | 
| 12 12 | 
             
            dependencies:
         | 
| 13 13 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 14 14 | 
             
              name: thor
         | 
| @@ -88,6 +88,7 @@ files: | |
| 88 88 | 
             
            - lib/rcurl/error.rb
         | 
| 89 89 | 
             
            - lib/rcurl/method/base.rb
         | 
| 90 90 | 
             
            - lib/rcurl/method/get.rb
         | 
| 91 | 
            +
            - lib/rcurl/method/post.rb
         | 
| 91 92 | 
             
            - lib/rcurl/version.rb
         | 
| 92 93 | 
             
            - rcurl.gemspec
         | 
| 93 94 | 
             
            homepage: https://github.com/kimromi/rcurl
         |