rest-client 2.0.2-x86-mswin32 → 2.1.0.rc1-x86-mswin32

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 00660e02d30b9b9314ed16d6d0f402a02d07009c
4
- data.tar.gz: e7296cd34437dea6f54165815d50b9841cad7bd3
3
+ metadata.gz: 4e279ff3da868d9ab8feb6b3313a0245573a9276
4
+ data.tar.gz: 6c6bb3a706a21be2126fc66b0344a6ba25e098dc
5
5
  SHA512:
6
- metadata.gz: 8399eefbe80c36e7402809912bae76ad57b05010ddc725898de50e0cf2203bd4e926e8de62ff8df7a7cd23d274038f055a6124d295ac0a2b7d7f4628722ec7d4
7
- data.tar.gz: 36141eadf551b012f25fb69f0fab9ce2fc50085ad9d6c87f8951fd2fcdb926e350e17acea5910868f5227aef716cde8c782eab7fd0f797a8ad46e82b54e7aab5
6
+ metadata.gz: edf8a744bf0499f2e84ddfdd61c3c8ca488c02ab33c30937fae5b84687b5552315c98140391447e50d8e8518bc7a919538f961e969ce14c18e7d2bac744754cb
7
+ data.tar.gz: 2629f94db0774ec70c2fa83cab3431f68ae99a07fa51bb5d649f02eebc38c00c1b7c307593876902cc7a99ab127641a3265457d8a205c7df8de5b1d4433e8c33
data/.gitignore CHANGED
@@ -6,3 +6,4 @@
6
6
  /pkg
7
7
  /rdoc
8
8
  /.yardoc
9
+ /tmp
@@ -0,0 +1,10 @@
1
+ Blake Mizerany <blake.mizerany@gmail.com>
2
+ Lawrence Leonard Gilbert <larry@l2g.to>
3
+ <larry@l2g.to> <larry@L2G.to>
4
+ Marc-André Cournoyer <macournoyer@gmail.com>
5
+ Matthew Manning <matt.manning@gmail.com>
6
+ Nicholas Wieland <nicholas.wieland@gmail.com>
7
+ Rafael Ssouza <rafael.ssouza@gmail.com>
8
+ Richard Schneeman <richard.schneeman@gmail.com>
9
+ Rick Olson <technoweenie@gmail.com>
10
+ T. Watanabe <wtnabe@wt-srv.watanabe>
@@ -0,0 +1,2 @@
1
+ --display-cop-names
2
+ --fail-level=W
@@ -17,7 +17,7 @@ Lint/StringConversionInInterpolation:
17
17
  Lint/UnusedBlockArgument:
18
18
  Enabled: false
19
19
 
20
- Lint/Eval:
20
+ Security/Eval:
21
21
  Exclude:
22
22
  - rest-client.windows.gemspec
23
23
 
@@ -110,10 +110,8 @@ Style/ConstantName:
110
110
  Metrics/CyclomaticComplexity:
111
111
  Max: 22
112
112
 
113
- # Offense count: 1
114
- # Cop supports --auto-correct.
115
- Style/DeprecatedHashMethods:
116
- Enabled: false
113
+ Style/PreferredHashMethods:
114
+ EnforcedStyle: verbose
117
115
 
118
116
  # TODO: docs
119
117
  # Offense count: 17
@@ -122,7 +120,7 @@ Style/Documentation:
122
120
 
123
121
  # Offense count: 9
124
122
  # Configuration parameters: EnforcedStyle, SupportedStyles.
125
- Style/DotPosition:
123
+ Layout/DotPosition:
126
124
  Enabled: false
127
125
 
128
126
  # Offense count: 1
@@ -136,24 +134,27 @@ Style/EachWithObject:
136
134
 
137
135
  # Offense count: 5
138
136
  # Cop supports --auto-correct.
139
- Style/EmptyLines:
137
+ Layout/EmptyLines:
140
138
  Enabled: false
141
139
 
142
140
  # Offense count: 11
143
141
  # Cop supports --auto-correct.
144
142
  # Configuration parameters: EnforcedStyle, SupportedStyles.
145
- Style/EmptyLinesAroundClassBody:
143
+ Layout/EmptyLinesAroundClassBody:
146
144
  Enabled: false
147
145
 
148
146
  # Offense count: 1
149
147
  # Cop supports --auto-correct.
150
- Style/EmptyLinesAroundMethodBody:
148
+ Layout/EmptyLinesAroundMethodBody:
151
149
  Enabled: false
152
150
 
153
151
  # Offense count: 9
154
152
  # Cop supports --auto-correct.
155
153
  # Configuration parameters: EnforcedStyle, SupportedStyles.
156
- Style/EmptyLinesAroundModuleBody:
154
+ Layout/EmptyLinesAroundModuleBody:
155
+ Enabled: false
156
+
157
+ Layout/EmptyLinesAroundExceptionHandlingKeywords:
157
158
  Enabled: false
158
159
 
159
160
  # Offense count: 31
@@ -188,7 +189,7 @@ Style/IfUnlessModifier:
188
189
  # Offense count: 6
189
190
  # Cop supports --auto-correct.
190
191
  # Configuration parameters: EnforcedStyle, SupportedStyles.
191
- Style/IndentHash:
192
+ Layout/IndentHash:
192
193
  Enabled: false
193
194
 
194
195
  # NOTABUG
@@ -199,14 +200,13 @@ Style/Lambda:
199
200
  # TODO
200
201
  # Offense count: 14
201
202
  # Cop supports --auto-correct.
202
- Style/LeadingCommentSpace:
203
+ Layout/LeadingCommentSpace:
203
204
  Enabled: false
204
205
 
205
- # TODO
206
- # Offense count: 218
207
- # Configuration parameters: AllowURI.
208
206
  Metrics/LineLength:
209
- Max: 340
207
+ Exclude:
208
+ - 'spec/**/*.rb'
209
+ - 'Rakefile'
210
210
 
211
211
  # TODO
212
212
  # Offense count: 28
@@ -298,47 +298,50 @@ Style/SignalException:
298
298
  # TODO
299
299
  # Offense count: 2
300
300
  # Cop supports --auto-correct.
301
- Style/SpaceAfterNot:
301
+ Layout/SpaceAfterNot:
302
302
  Enabled: false
303
303
 
304
304
  # Offense count: 19
305
305
  # Cop supports --auto-correct.
306
306
  # Configuration parameters: EnforcedStyle, SupportedStyles.
307
- Style/SpaceAroundEqualsInParameterDefault:
307
+ Layout/SpaceAroundEqualsInParameterDefault:
308
308
  Enabled: false
309
309
 
310
310
  # Offense count: 20
311
311
  # Cop supports --auto-correct.
312
- Style/SpaceAroundOperators:
312
+ Layout/SpaceAroundOperators:
313
313
  Enabled: false
314
314
 
315
315
  # Offense count: 9
316
316
  # Cop supports --auto-correct.
317
317
  # Configuration parameters: EnforcedStyle, SupportedStyles.
318
- Style/SpaceBeforeBlockBraces:
318
+ Layout/SpaceBeforeBlockBraces:
319
+ Enabled: false
320
+
321
+ Layout/EmptyLinesAroundBlockBody:
319
322
  Enabled: false
320
323
 
321
324
  # Offense count: 37
322
325
  # Cop supports --auto-correct.
323
326
  # Configuration parameters: EnforcedStyle, SupportedStyles, EnforcedStyleForEmptyBraces, SpaceBeforeBlockParameters.
324
- Style/SpaceInsideBlockBraces:
327
+ Layout/SpaceInsideBlockBraces:
325
328
  Enabled: false
326
329
 
327
330
  # Offense count: 6
328
331
  # Cop supports --auto-correct.
329
- Style/SpaceInsideBrackets:
332
+ Layout/SpaceInsideBrackets:
330
333
  Enabled: false
331
334
 
332
335
  # Offense count: 181
333
336
  # Cop supports --auto-correct.
334
337
  # Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBraces, SupportedStyles.
335
- Style/SpaceInsideHashLiteralBraces:
338
+ Layout/SpaceInsideHashLiteralBraces:
336
339
  Enabled: false
337
340
 
338
341
  # TODO
339
342
  # Offense count: 9
340
343
  # Cop supports --auto-correct.
341
- Style/SpaceInsideParens:
344
+ Layout/SpaceInsideParens:
342
345
  Enabled: false
343
346
 
344
347
  # Offense count: 414
@@ -1,3 +1,8 @@
1
1
  ---
2
2
  inherit_from:
3
3
  - .rubocop-disables.yml
4
+
5
+ AllCops:
6
+ Exclude:
7
+ - 'tmp/*.rb'
8
+ - 'vendor/**/*'
@@ -20,7 +20,8 @@ rvm:
20
20
  cache: bundler
21
21
 
22
22
  script:
23
- bundle exec rake test
23
+ - bundle exec rake test
24
+ - bundle exec rake rubocop
24
25
 
25
26
  branches:
26
27
  except:
data/AUTHORS CHANGED
@@ -7,6 +7,7 @@ Adrian Rangel
7
7
  Alex Tomlins
8
8
  Aman Gupta
9
9
  Andy Brody
10
+ Avi Deitcher
10
11
  Blake Mizerany
11
12
  Brad Ediger
12
13
  Braintree
@@ -38,10 +39,12 @@ Harm Aarts
38
39
  Hiro Asari
39
40
  Hugh McGowan
40
41
  Ian Warshak
42
+ Igor Zubkov
41
43
  Ivan Makfinsky
42
44
  JH. Chabran
43
45
  James Edward Gray II
44
46
  Jari Bakken
47
+ Jeff Pereira
45
48
  Jeff Remer
46
49
  Jeffrey Hardy
47
50
  Jeremy Kemper
@@ -59,12 +62,14 @@ Keith Rarick
59
62
  Kenichi Kamiya
60
63
  Kevin Read
61
64
  Kosuke Asami
65
+ Kyle Meyer
62
66
  Kyle VanderBeek
63
67
  Lars Gierth
64
68
  Lawrence Leonard Gilbert
65
69
  Lee Jarvis
66
70
  Lennon Day-Reynolds
67
71
  Lin Jen-Shin
72
+ Magne Matre Gåsland
68
73
  Marc-André Cournoyer
69
74
  Marius Butuc
70
75
  Matthew Manning
@@ -77,6 +82,7 @@ Nicholas Wieland
77
82
  Nick Hammond
78
83
  Nick Plante
79
84
  Niko Dittmann
85
+ Nikolay Shebanov
80
86
  Oscar Del Ben
81
87
  Pablo Astigarraga
82
88
  Paul Dlug
@@ -85,9 +91,11 @@ Pedro Chambino
85
91
  Philip Corliss
86
92
  Pierre-Louis Gottfrois
87
93
  Rafael Ssouza
94
+ Richard Schneeman
88
95
  Rick Olson
89
96
  Robert Eanes
90
97
  Rodrigo Panachi
98
+ Sam Norbury
91
99
  Samuel Cochran
92
100
  Syl Turner
93
101
  T. Watanabe
data/README.md CHANGED
@@ -39,6 +39,7 @@ The rest-client gem depends on these other gems for usage at runtime:
39
39
 
40
40
  * [mime-types](http://rubygems.org/gems/mime-types)
41
41
  * [netrc](http://rubygems.org/gems/netrc)
42
+ * [http-accept](https://rubygems.org/gems/http-accept)
42
43
  * [http-cookie](https://rubygems.org/gems/http-cookie)
43
44
 
44
45
  There are also several development dependencies. It's recommended to use
@@ -359,7 +360,7 @@ RestClient.get('http://example.com/resource') { |response, request, result, &blo
359
360
  when 423
360
361
  raise SomeCustomExceptionIfYouWant
361
362
  else
362
- response.return!(request, result, &block)
363
+ response.return!(&block)
363
364
  end
364
365
  }
365
366
  ```
@@ -446,6 +447,106 @@ You can:
446
447
 
447
448
  See `RestClient::Request`'s documentation for more information.
448
449
 
450
+ ### Streaming request payload
451
+
452
+ RestClient will try to stream any file-like payload rather than reading it into
453
+ memory. This happens through `RestClient::Payload::Streamed`, which is
454
+ automatically called internally by `RestClient::Payload.generate` on anything
455
+ with a `read` method.
456
+
457
+ ```ruby
458
+ >> r = RestClient.put('http://httpbin.org/put', File.open('/tmp/foo.txt', 'r'),
459
+ content_type: 'text/plain')
460
+ => <RestClient::Response 200 "{\n \"args\":...">
461
+ ```
462
+
463
+ In Multipart requests, RestClient will also stream file handles passed as Hash
464
+ (or __new in 2.1__ ParamsArray).
465
+
466
+ ```ruby
467
+ >> r = RestClient.put('http://httpbin.org/put',
468
+ {file_a: File.open('a.txt', 'r'),
469
+ file_b: File.open('b.txt', 'r')})
470
+ => <RestClient::Response 200 "{\n \"args\":...">
471
+
472
+ # received by server as two file uploads with multipart/form-data
473
+ >> JSON.parse(r)['files'].keys
474
+ => ['file_a', 'file_b']
475
+ ```
476
+
477
+ ### Streaming responses
478
+
479
+ Normally, when you use `RestClient.get` or the lower level
480
+ `RestClient::Request.execute method: :get` to retrieve data, the entire
481
+ response is buffered in memory and returned as the response to the call.
482
+
483
+ However, if you are retrieving a large amount of data, for example a Docker
484
+ image, an iso, or any other large file, you may want to stream the response
485
+ directly to disk rather than loading it in memory. If you have a very large
486
+ file, it may become *impossible* to load it into memory.
487
+
488
+ There are two main ways to do this:
489
+
490
+ #### `raw_response`, saves into Tempfile
491
+
492
+ If you pass `raw_response: true` to `RestClient::Request.execute`, it will save
493
+ the response body to a temporary file (using `Tempfile`) and return a
494
+ `RestClient::RawResponse` object rather than a `RestClient::Response`.
495
+
496
+ Note that the tempfile created by `Tempfile.new` will be in `Dir.tmpdir`
497
+ (usually `/tmp/`), which you can override to store temporary files in a
498
+ different location. This file will be unlinked when it is dereferenced.
499
+
500
+ If logging is enabled, this will also print download progress.
501
+ __New in 2.1:__ Customize the interval with `:stream_log_percent` (defaults to
502
+ 10 for printing a message every 10% complete).
503
+
504
+ For example:
505
+
506
+ ```ruby
507
+ >> raw = RestClient::Request.execute(
508
+ method: :get,
509
+ url: 'http://releases.ubuntu.com/16.04.2/ubuntu-16.04.2-desktop-amd64.iso',
510
+ raw_response: true)
511
+ => <RestClient::RawResponse @code=200, @file=#<Tempfile:/tmp/rest-client.20170522-5346-1pptjm1>, @request=<RestClient::Request @method="get", @url="http://releases.ubuntu.com/16.04.2/ubuntu-16.04.2-desktop-amd64.iso">>
512
+ >> raw.file.size
513
+ => 1554186240
514
+ >> raw.file.path
515
+ => "/tmp/rest-client.20170522-5346-1pptjm1"
516
+ raw.file.path
517
+ => "/tmp/rest-client.20170522-5346-1pptjm1"
518
+
519
+ >> require 'digest/sha1'
520
+ >> Digest::SHA1.file(raw.file.path).hexdigest
521
+ => "4375b73e3a1aa305a36320ffd7484682922262b3"
522
+ ```
523
+
524
+ #### `block_response`, receives raw Net::HTTPResponse
525
+
526
+ If you want to stream the data from the response to a file as it comes, rather
527
+ than entirely in memory, you can also pass `RestClient::Request.execute` a
528
+ parameter `:block_response` to which you pass a block/proc. This block receives
529
+ the raw unmodified Net::HTTPResponse object from Net::HTTP, which you can use
530
+ to stream directly to a file as each chunk is received.
531
+
532
+ Note that this bypasses all the usual HTTP status code handling, so you will
533
+ want to do you own checking for HTTP 20x response codes, redirects, etc.
534
+
535
+ The following is an example:
536
+
537
+ ````ruby
538
+ File.open('/some/output/file', 'w') {|f|
539
+ block = proc { |response|
540
+ response.read_body do |chunk|
541
+ f.write chunk
542
+ end
543
+ }
544
+ RestClient::Request.execute(method: :get,
545
+ url: 'http://example.com/some/really/big/file.img',
546
+ block_response: block)
547
+ }
548
+ ````
549
+
449
550
  ## Shell
450
551
 
451
552
  The restclient shell command gives an IRB session with RestClient already loaded:
@@ -498,7 +599,7 @@ $ restclient put http://example.com/resource < input_body
498
599
 
499
600
  ## Logging
500
601
 
501
- To enable logging you can:
602
+ To enable logging globally you can:
502
603
 
503
604
  - set RestClient.log with a Ruby Logger, or
504
605
  - set an environment variable to avoid modifying the code (in this case you can use a file name, "stdout" or "stderr"):
@@ -506,7 +607,19 @@ To enable logging you can:
506
607
  ```ruby
507
608
  $ RESTCLIENT_LOG=stdout path/to/my/program
508
609
  ```
509
- Either produces logs like this:
610
+
611
+ You can also set individual loggers when instantiating a Resource or making an
612
+ individual request:
613
+
614
+ ```ruby
615
+ resource = RestClient::Resource.new 'http://example.com/resource', log: Logger.new(STDOUT)
616
+ ```
617
+
618
+ ```ruby
619
+ RestClient::Request.execute(method: :get, url: 'http://example.com/foo', log: Logger.new(STDERR))
620
+ ```
621
+
622
+ All options produce logs like this:
510
623
 
511
624
  ```ruby
512
625
  RestClient.get "http://some/resource"
@@ -774,11 +887,10 @@ See AUTHORS for the full list.
774
887
 
775
888
  ## Legal
776
889
 
777
- Released under the MIT License: http://www.opensource.org/licenses/mit-license.php
890
+ Released under the MIT License: https://opensource.org/licenses/MIT
778
891
 
779
- "Master Shake" photo (http://www.flickr.com/photos/solgrundy/924205581/) by
780
- "SolGrundy"; used under terms of the Creative Commons Attribution-ShareAlike 2.0
781
- Generic license (http://creativecommons.org/licenses/by-sa/2.0/)
892
+ Photo of the International Space Station was produced by NASA and is in the
893
+ public domain.
782
894
 
783
895
  Code for reading Windows root certificate store derived from work by Puppet;
784
896
  used under terms of the Apache License, Version 2.0.
data/Rakefile CHANGED
@@ -38,12 +38,11 @@ desc 'Regenerate authors file'
38
38
  task :authors do
39
39
  Dir.chdir(File.dirname(__FILE__)) do
40
40
  File.open('AUTHORS', 'w') do |f|
41
- f.write( <<-EOM
41
+ f.write <<-EOM
42
42
  The Ruby REST Client would not be what it is today without the help of
43
43
  the following kind souls:
44
44
 
45
45
  EOM
46
- )
47
46
  end
48
47
 
49
48
  sh 'git shortlog -s | cut -f 2 >> AUTHORS'
@@ -70,8 +69,8 @@ namespace :all do
70
69
  task :build => ['ruby:build'] + \
71
70
  WindowsPlatforms.map {|p| "windows:#{p}:build"}
72
71
 
73
- desc "Create tag v#{RestClient::VERSION} and for all platforms build and push " \
74
- "rest-client #{RestClient::VERSION} to Rubygems"
72
+ desc "Create tag v#{RestClient::VERSION} and for all platforms build and " \
73
+ "push rest-client #{RestClient::VERSION} to Rubygems"
75
74
  task :release => ['build', 'ruby:release'] + \
76
75
  WindowsPlatforms.map {|p| "windows:#{p}:push"}
77
76
 
@@ -130,3 +129,12 @@ Rake::RDocTask.new do |t|
130
129
  t.rdoc_files.include('README.md')
131
130
  t.rdoc_files.include('lib/*.rb')
132
131
  end
132
+
133
+ ############################
134
+
135
+ require 'rubocop/rake_task'
136
+
137
+ RuboCop::RakeTask.new(:rubocop) do |t|
138
+ t.options = ['--display-cop-names']
139
+ end
140
+ alias_task(:lint, :rubocop)