wadl 0.2.0 → 0.2.1
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/README +1 -1
- data/lib/wadl/cli.rb +23 -14
- data/lib/wadl/version.rb +1 -1
- metadata +3 -3
    
        data/README
    CHANGED
    
    
    
        data/lib/wadl/cli.rb
    CHANGED
    
    | @@ -26,6 +26,7 @@ | |
| 26 26 |  | 
| 27 27 | 
             
            require 'optparse'
         | 
| 28 28 | 
             
            require 'yaml'
         | 
| 29 | 
            +
            require 'cgi'
         | 
| 29 30 | 
             
            require 'highline'
         | 
| 30 31 | 
             
            require 'stringio'
         | 
| 31 32 | 
             
            require 'wadl'
         | 
| @@ -51,7 +52,7 @@ module WADL | |
| 51 52 | 
             
                  :authorize_url     => '%s/oauth/authorize'
         | 
| 52 53 | 
             
                }
         | 
| 53 54 |  | 
| 54 | 
            -
                OPTION_RE = %r{\A--?( | 
| 55 | 
            +
                OPTION_RE = %r{\A--?(.+?)(?:=(.+))?\z}
         | 
| 55 56 | 
             
                RESOURCE_PATH_RE = %r{[. /]}
         | 
| 56 57 |  | 
| 57 58 | 
             
                def self.execute(*args)
         | 
| @@ -104,8 +105,8 @@ module WADL | |
| 104 105 |  | 
| 105 106 | 
             
                def resource
         | 
| 106 107 | 
             
                  @resource ||= begin
         | 
| 107 | 
            -
                    path = [options[:api_base], *resource_path].compact.join('/')
         | 
| 108 | 
            -
                    path. | 
| 108 | 
            +
                    path = [options[:api_base], *resource_path].compact.join('/').split(RESOURCE_PATH_RE)
         | 
| 109 | 
            +
                    path.inject(api) { |m, n| m.send(:find_resource_by_path, n) } or abort "Resource not found: #{path.join('/')}"
         | 
| 109 110 | 
             
                  end
         | 
| 110 111 | 
             
                end
         | 
| 111 112 |  | 
| @@ -143,23 +144,25 @@ module WADL | |
| 143 144 | 
             
                end
         | 
| 144 145 |  | 
| 145 146 | 
             
                def parse_arguments(arguments)
         | 
| 146 | 
            -
                  @resource_path, @opts,  | 
| 147 | 
            +
                  @resource_path, @opts, skip_next = [], {}, false
         | 
| 148 | 
            +
                  @opts.update(options[:query]) if options[:query]
         | 
| 147 149 |  | 
| 148 150 | 
             
                  arguments.each_with_index { |arg, index|
         | 
| 149 | 
            -
                    if  | 
| 150 | 
            -
                       | 
| 151 | 
            +
                    if skip_next
         | 
| 152 | 
            +
                      skip_next = false
         | 
| 151 153 | 
             
                      next
         | 
| 152 154 | 
             
                    end
         | 
| 153 155 |  | 
| 154 | 
            -
                     | 
| 155 | 
            -
                       | 
| 156 | 
            -
             | 
| 157 | 
            -
             | 
| 158 | 
            -
                        value =~ OPTION_RE ? value = '1' : skip = true
         | 
| 159 | 
            -
             | 
| 160 | 
            -
                        opts[key] = value
         | 
| 156 | 
            +
                    if arg =~ OPTION_RE
         | 
| 157 | 
            +
                      key, value, next_arg = $1, $2, arguments[index + 1]
         | 
| 158 | 
            +
                      opts[key] = value || if next_arg =~ OPTION_RE
         | 
| 159 | 
            +
                        '1'  # "true"
         | 
| 161 160 | 
             
                      else
         | 
| 162 | 
            -
                         | 
| 161 | 
            +
                        skip_next = true
         | 
| 162 | 
            +
                        next_arg
         | 
| 163 | 
            +
                      end
         | 
| 164 | 
            +
                    else
         | 
| 165 | 
            +
                      resource_path << arg
         | 
| 163 166 | 
             
                    end
         | 
| 164 167 | 
             
                  }
         | 
| 165 168 | 
             
                end
         | 
| @@ -248,6 +251,12 @@ module WADL | |
| 248 251 | 
             
                      options[:api_base] = api_base
         | 
| 249 252 | 
             
                    }
         | 
| 250 253 |  | 
| 254 | 
            +
                    opts.on('-q', '--query QUERY', "Query string to pass to request") { |query|
         | 
| 255 | 
            +
                      options[:query] = CGI.parse(query).inject({}) { |params, (key, values)|
         | 
| 256 | 
            +
                        params[key] = values.last; params
         | 
| 257 | 
            +
                      }
         | 
| 258 | 
            +
                    }
         | 
| 259 | 
            +
             | 
| 251 260 | 
             
                    opts.separator ''
         | 
| 252 261 |  | 
| 253 262 | 
             
                    opts.on('--skip-auth', "Skip any authentication") {
         | 
    
        data/lib/wadl/version.rb
    CHANGED
    
    
    
        metadata
    CHANGED
    
    | @@ -1,13 +1,13 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification 
         | 
| 2 2 | 
             
            name: wadl
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version 
         | 
| 4 | 
            -
              hash:  | 
| 4 | 
            +
              hash: 21
         | 
| 5 5 | 
             
              prerelease: false
         | 
| 6 6 | 
             
              segments: 
         | 
| 7 7 | 
             
              - 0
         | 
| 8 8 | 
             
              - 2
         | 
| 9 | 
            -
              -  | 
| 10 | 
            -
              version: 0.2. | 
| 9 | 
            +
              - 1
         | 
| 10 | 
            +
              version: 0.2.1
         | 
| 11 11 | 
             
            platform: ruby
         | 
| 12 12 | 
             
            authors: 
         | 
| 13 13 | 
             
            - Leonard Richardson
         |