rufus-verbs 1.0.0 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -2,8 +2,15 @@
2
2
  = rufus-verbs CHANGELOG.txt
3
3
 
4
4
 
5
- == rufus-verbs - 1.0.0 not yet released
5
+ == rufus-verbs - 1.0.1 released 2012/02/01
6
6
 
7
+ - digest auth fix, thanks Pierre 'Catwell' Chapuis
8
+
9
+
10
+ == rufus-verbs - 1.0.0 released 2010/01/10
11
+
12
+ - Parses the response body if a parser in defined for its content-type (Dirk Geurs)
13
+ - EndPoint params merge with Request params (Dirk Geurs)
7
14
  - todo : upgraded to Rakefile, thanks Kenneth Kalmer
8
15
  - bug : poor escaping of parameters (URI -> CGI) fixed, thanks nmaisonneuve
9
16
 
@@ -1,6 +1,13 @@
1
1
 
2
2
  = CREDITS.txt
3
3
 
4
+
5
+ == contributors
6
+
7
+ Pierre 'Catwell' Chapuis - https://github.com/catwell
8
+ Dirk Geurs - https://github.com/Dirklectisch
9
+
10
+
4
11
  == Feedback
5
12
 
6
13
  Nicolas Maisonneuve : http://github.com/nmaisonneuve
@@ -1,5 +1,5 @@
1
1
 
2
- Copyright (c) 2008-2010, John Mettraux, jmettraux@gmail.com
2
+ Copyright (c) 2008-2012, John Mettraux, jmettraux@gmail.com
3
3
 
4
4
  Permission is hereby granted, free of charge, to any person obtaining a copy
5
5
  of this software and associated documentation files (the "Software"), to deal
@@ -1,7 +1,7 @@
1
1
 
2
- = 'rufus-verbs'
2
+ # 'rufus-verbs'
3
3
 
4
- == what is it ?
4
+ ## what is it ?
5
5
 
6
6
  'rufus-verbs' is an extended HTTP client library (gem). It provides the four main HTTP "verbs" as Ruby methods : get, put, post and delete.
7
7
 
@@ -10,7 +10,7 @@ It wraps a certain number of techniques that make it a decent tool for manipulat
10
10
  Head and Options are supported as well.
11
11
 
12
12
 
13
- == features
13
+ ## features
14
14
 
15
15
  currently :
16
16
 
@@ -36,14 +36,14 @@ maybe later :
36
36
  * persistent cookie jar
37
37
 
38
38
 
39
- == getting it
39
+ ## getting it
40
40
 
41
41
  gem install rufus-verbs
42
42
 
43
43
  or download[http://rubyforge.org/frs/?group_id=4812] it from RubyForge.
44
44
 
45
45
 
46
- == usage
46
+ ## usage
47
47
 
48
48
  The arguments to the "verbs" follow the schema <tt>method_name(uri, opts)</tt> or <tt>method_name(opts)</tt>. Post and put accept an optional block parameter.
49
49
 
@@ -62,14 +62,14 @@ using get(), post(), put() and delete() directly
62
62
 
63
63
  post "http://resta.farian.server:7080/inventory/tools/0", :d => "hammer"
64
64
  # passing the data via the :d (or :data) option
65
-
65
+
66
66
  res = post "http://resta.farian.server:7080/inventory/tools/1" do
67
67
  "sliver bullet"
68
68
  end
69
69
  # the data is generated by a block
70
70
 
71
71
  puts res.code.to_i
72
- # 201... resource created, note that by default,
72
+ # 201... resource created, note that by default,
73
73
  # an instance of Net::HTTPResponse is returned
74
74
 
75
75
  puts get("http://resta.farian.server:7080/inventory/tools/0", :body => true)
@@ -102,8 +102,8 @@ using get(), post(), put() and delete() directly
102
102
  Using get() and co via an EndPoint to share common options for a set of requests
103
103
 
104
104
  ep = EndPoint.new(
105
- :host => "resta.farian.host",
106
- :port => 7080,
105
+ :host => "resta.farian.host",
106
+ :port => 7080,
107
107
  :resource => "inventory/tools")
108
108
 
109
109
  res = ep.get :id => 1
@@ -116,15 +116,15 @@ Using get() and co via an EndPoint to share common options for a set of requests
116
116
  A ConditionalEndPoint is an EndPoint that will use conditional GETs whenever possible
117
117
 
118
118
  ep = ConditionalEndPoint.new(
119
- :host => "resta.farian.zion",
120
- :port => 7080,
119
+ :host => "resta.farian.zion",
120
+ :port => 7080,
121
121
  :resource => "inventory/tools")
122
122
 
123
123
  res = ep.get :id => 1
124
124
  # first call will retrieve the representation completely
125
125
 
126
126
  res = ep.get :id => 1
127
- # the server (provided that it supports conditional GETs) only
127
+ # the server (provided that it supports conditional GETs) only
128
128
  # returned a 304 answer, the response is returned from the
129
129
  # ConditionalEndPoint cache
130
130
 
@@ -146,7 +146,7 @@ Digest authentication and basic authentication are available at request or endpo
146
146
  res = get "http://server/doc0", :hba => [ "toto", "secretpass" ]
147
147
 
148
148
  res = get(
149
- "http://server/doc1",
149
+ "http://server/doc1",
150
150
  :digest_authentication => [ "toto", "secretpass" ])
151
151
 
152
152
  The Rufus::Verbs module provides as well a <tt>fopen</tt> method, which mostly feels like the <tt>open</tt> method of open-uri.
@@ -169,7 +169,7 @@ This fopen() method makes sure to return an object that has a read() method (lik
169
169
  The tests may provide good intel as on 'rufus-verbs' usage as well : http://rufus.rubyforge.org/svn/trunk/verbs/test/
170
170
 
171
171
 
172
- == the options
172
+ ## the options
173
173
 
174
174
  A list of options supported by rufus-verbs, in alphabetical order.
175
175
 
@@ -190,8 +190,8 @@ see :http_basic_authentication for the basic HTTP authentication mechanism
190
190
  * <b>:base</b> (string, RE)
191
191
  the base of a resource path
192
192
 
193
- :base / :resource / :id -->
194
- "inventory" / "tools" / "7" -->
193
+ :base / :resource / :id -->
194
+ "inventory" / "tools" / "7" -->
195
195
  "/inventory/tools/7"
196
196
 
197
197
  * <b>:body</b> (boolean, RE)
@@ -213,7 +213,7 @@ the data (request body) for a put or a post.
213
213
  * <b>:digest_authentication</b> (pair of strings, RE)
214
214
  the pair username/password to be used for digest authentication.
215
215
 
216
- * <b>:dry_run</b> (boolean, RE)
216
+ * <b>:dry_run</b> (boolean, RE)
217
217
  when <tt>:dry_run => true</tt>, the request will be prepared but not executed and will be returned instead of the HTTP response (used for testing)
218
218
 
219
219
  * <b>:fake_put</b> (boolean, RE)
@@ -225,13 +225,13 @@ the short version of :form_data
225
225
  * <b>:form_data</b>
226
226
  this option expects a hash. The (post or put) request body will then be built with this hash.
227
227
 
228
- * <b>:h</b> (a hash String => String, RE)
228
+ * <b>:h</b> (a hash String => String, RE)
229
229
  short for :headers
230
230
 
231
- * <b>:headers</b> (a hash String => String, RE)
231
+ * <b>:headers</b> (a hash String => String, RE)
232
232
  A Hash of additional request headers to pass
233
233
 
234
- * <b>:hba</b> (pair of strings, RE)
234
+ * <b>:hba</b> (pair of strings, RE)
235
235
  short for :http_basic_authentication
236
236
 
237
237
  * <b>:host</b> (string, RE)
@@ -311,42 +311,42 @@ can be set to true or to an IO instance. If set to true, messages will be direct
311
311
  Will produces verbose messages similar to those of the fine cURL utility.
312
312
 
313
313
 
314
- == dependencies
314
+ ## dependencies
315
315
 
316
316
  the gem rufus-lru[http://rufus.rubyforge.org/rufus-lru]
317
317
 
318
318
 
319
- == mailing list
319
+ ## mailing list
320
320
 
321
321
  On the Rufus-Ruby list[http://groups.google.com/group/rufus-ruby] :
322
322
 
323
323
  http://groups.google.com/group/rufus-ruby
324
324
 
325
325
 
326
- == issue tracker
326
+ ## issue tracker
327
327
 
328
328
  http://github.com/jmettraux/rufus-verbs/issues
329
329
 
330
330
 
331
- == source
331
+ ## source
332
332
 
333
333
  http://github.com/jmettraux/rufus-verbs
334
334
 
335
335
  git clone git://github.com/jmettraux/rufus-verbs.git
336
336
 
337
337
 
338
- == author
338
+ ## author
339
339
 
340
340
  John Mettraux, jmettraux@gmail.com,
341
341
  http://jmettraux.wordpress.com
342
342
 
343
343
 
344
- == the rest of Rufus
344
+ ## the rest of Rufus
345
345
 
346
346
  http://rufus.rubyforge.org
347
347
 
348
348
 
349
- == license
349
+ ## license
350
350
 
351
351
  MIT
352
352
 
data/Rakefile CHANGED
@@ -1,80 +1,87 @@
1
1
 
2
-
3
- require 'lib/rufus/verbs/version.rb'
2
+ $:.unshift('.') # 1.9.2
4
3
 
5
4
  require 'rubygems'
5
+ require 'rubygems/user_interaction' if Gem::RubyGemsVersion == '1.5.0'
6
+
6
7
  require 'rake'
8
+ require 'rake/clean'
9
+ #require 'rake/rdoctask'
10
+ require 'rdoc/task'
7
11
 
8
12
 
9
13
  #
10
- # CLEAN
14
+ # clean
11
15
 
12
- require 'rake/clean'
13
- CLEAN.include('pkg', 'tmp', 'html')
14
- task :default => [ :clean ]
16
+ CLEAN.include('pkg', 'rdoc')
15
17
 
16
18
 
17
19
  #
18
- # GEM
20
+ # test / spec
19
21
 
20
- require 'jeweler'
22
+ #task :spec => :check_dependencies do
23
+ task :spec do
24
+ exec 'rspec spec/'
25
+ end
26
+ task :test => :spec
21
27
 
22
- Jeweler::Tasks.new do |gem|
28
+ task :default => :spec
23
29
 
24
- gem.version = Rufus::Verbs::VERSION
25
- gem.name = 'rufus-verbs'
26
- gem.summary = 'GET, POST, PUT, DELETE, with something around'
27
30
 
28
- gem.description = %{
29
- GET, POST, PUT, DELETE, with something around.
31
+ #
32
+ # gem
30
33
 
31
- An HTTP client Ruby gem, with conditional GET, basic auth, and more.
32
- }
33
- gem.email = 'jmettraux@gmail.com'
34
- gem.homepage = 'http://github.com/jmettraux/rufus-verbs/'
35
- gem.authors = [ 'John Mettraux' ]
36
- gem.rubyforge_project = 'rufus'
34
+ GEMSPEC_FILE = Dir['*.gemspec'].first
35
+ GEMSPEC = eval(File.read(GEMSPEC_FILE))
36
+ GEMSPEC.validate
37
37
 
38
- gem.test_file = 'test/test.rb'
39
38
 
40
- gem.add_dependency 'rufus-lru'
41
- gem.add_development_dependency 'yard', '>= 0'
39
+ desc %{
40
+ builds the gem and places it in pkg/
41
+ }
42
+ task :build do
42
43
 
43
- # gemspec spec : http://www.rubygems.org/read/chapter/20
44
+ sh "gem build #{GEMSPEC_FILE}"
45
+ sh "mkdir pkg" rescue nil
46
+ sh "mv #{GEMSPEC.name}-#{GEMSPEC.version}.gem pkg/"
44
47
  end
45
- Jeweler::GemcutterTasks.new
46
48
 
49
+ desc %{
50
+ builds the gem and pushes it to rubygems.org
51
+ }
52
+ task :push => :build do
53
+
54
+ sh "gem push pkg/#{GEMSPEC.name}-#{GEMSPEC.version}.gem"
55
+ end
47
56
 
48
- #
49
- # DOC
50
57
 
51
- begin
58
+ #
59
+ # rdoc
60
+ #
61
+ # make sure to have rdoc 2.5.x to run that
52
62
 
53
- require 'yard'
63
+ Rake::RDocTask.new do |rd|
54
64
 
55
- YARD::Rake::YardocTask.new do |doc|
56
- doc.options = [
57
- '-o', 'html/rufus-verbs', '--title',
58
- "rufus-verbs #{Rufus::Verbs::VERSION}"
59
- ]
60
- end
65
+ rd.main = 'README.txt'
66
+ rd.rdoc_dir = "rdoc/#{GEMSPEC.name}"
61
67
 
62
- rescue LoadError
68
+ rd.rdoc_files.include('README.rdoc', 'CHANGELOG.txt', 'lib/**/*.rb')
63
69
 
64
- task :yard do
65
- abort "YARD is not available : sudo gem install yard"
66
- end
70
+ rd.title = "#{GEMSPEC.name} #{GEMSPEC.version}"
67
71
  end
68
72
 
69
73
 
70
74
  #
71
- # TO THE WEB
75
+ # upload_rdoc
72
76
 
73
- task :upload_website => [ :clean, :yard ] do
77
+ desc %{
78
+ upload the rdoc to rubyforge
79
+ }
80
+ task :upload_rdoc => [ :clean, :rdoc ] do
74
81
 
75
82
  account = 'jmettraux@rubyforge.org'
76
83
  webdir = '/var/www/gforge-projects/rufus'
77
84
 
78
- sh "rsync -azv -e ssh html/rufus-verbs #{account}:#{webdir}/"
85
+ sh "rsync -azv -e ssh rdoc/#{GEMSPEC.name} #{account}:#{webdir}/"
79
86
  end
80
87
 
@@ -1,5 +1,5 @@
1
1
  #--
2
- # Copyright (c) 2008-2010, John Mettraux, jmettraux@gmail.com
2
+ # Copyright (c) 2008-2012, John Mettraux, jmettraux@gmail.com
3
3
  #
4
4
  # Permission is hereby granted, free of charge, to any person obtaining a copy
5
5
  # of this software and associated documentation files (the "Software"), to deal
@@ -1,5 +1,5 @@
1
1
  #--
2
- # Copyright (c) 2008-2010, John Mettraux, jmettraux@gmail.com
2
+ # Copyright (c) 2008-2012, John Mettraux, jmettraux@gmail.com
3
3
  #
4
4
  # Permission is hereby granted, free of charge, to any person obtaining a copy
5
5
  # of this software and associated documentation files (the "Software"), to deal
@@ -1,5 +1,5 @@
1
1
  #--
2
- # Copyright (c) 2008-2010, John Mettraux, jmettraux@gmail.com
2
+ # Copyright (c) 2008-2012, John Mettraux, jmettraux@gmail.com
3
3
  #
4
4
  # Permission is hereby granted, free of charge, to any person obtaining a copy
5
5
  # of this software and associated documentation files (the "Software"), to deal
@@ -1,5 +1,5 @@
1
1
  #--
2
- # Copyright (c) 2008-2010, John Mettraux, jmettraux@gmail.com
2
+ # Copyright (c) 2008-2012, John Mettraux, jmettraux@gmail.com
3
3
  #
4
4
  # Permission is hereby granted, free of charge, to any person obtaining a copy
5
5
  # of this software and associated documentation files (the "Software"), to deal
@@ -110,6 +110,8 @@ module Verbs
110
110
 
111
111
  op[:digest_authentication] = false
112
112
  # preventing an infinite loop
113
+ op[:body] = false
114
+ # we want to check the error code
113
115
 
114
116
  method = req.class.const_get(:METHOD).downcase.to_sym
115
117
  #method = :get
@@ -142,7 +144,7 @@ module Verbs
142
144
  user, pass = o(opts, :digest_authentication)
143
145
  realm = @challenge.realm || ""
144
146
  method = req.class.const_get(:METHOD)
145
- path = opts[:path]
147
+ path = req.path
146
148
 
147
149
  a1 = if @challenge.algorithm == 'MD5-sess'
148
150
  h(h(user, realm, pass), @challenge.nonce, @cnonce)
@@ -1,5 +1,5 @@
1
1
  #--
2
- # Copyright (c) 2008-2010, John Mettraux, jmettraux@gmail.com
2
+ # Copyright (c) 2008-2012, John Mettraux, jmettraux@gmail.com
3
3
  #
4
4
  # Permission is hereby granted, free of charge, to any person obtaining a copy
5
5
  # of this software and associated documentation files (the "Software"), to deal
@@ -68,10 +68,19 @@ module Verbs
68
68
  # The endpoint initialization opts (Hash instance)
69
69
  #
70
70
  attr_reader :opts
71
+
72
+ #
73
+ # Configure default parsers for this EndPoint, example:
74
+ # ep.parsers['application/json'] = Yajl::Parser
75
+ # ep.parsers['application/xhtml+xml'] = Nokogiri::HTML::Document
76
+ #
77
+
78
+ attr_reader :parsers
71
79
 
72
80
  def initialize (opts)
73
81
 
74
82
  @opts = opts
83
+ @parsers = {}
75
84
 
76
85
  compute_target @opts
77
86
 
@@ -270,11 +279,19 @@ module Verbs
270
279
  opts[:host] = r[1] || @opts[:host]
271
280
  opts[:port] = r[2] || @opts[:port]
272
281
  opts[:path] = r[3] || @opts[:path]
273
-
282
+
283
+ # Merge EndPoint params and Request params
284
+
285
+ def_params = @opts[:query] || @opts[:params]
286
+ req_params = opts[:query] || opts[:params]
287
+
288
+ mer_params = def_params.merge req_params if def_params && req_params
289
+
274
290
  opts[:query] =
275
291
  r[4] ||
276
- opts[:params] || opts[:query] ||
277
- @opts[:query] || @opts[:params] ||
292
+ mer_params ||
293
+ req_params ||
294
+ def_params ||
278
295
  {}
279
296
 
280
297
  opts.delete :path if opts[:path] == ''
@@ -569,9 +586,11 @@ module Verbs
569
586
  #
570
587
  # following the redirection
571
588
  end
572
-
589
+
573
590
  decompress res
574
591
 
592
+ parse_body res
593
+
575
594
  res
576
595
  end
577
596
 
@@ -635,6 +654,35 @@ module Verbs
635
654
  gz.close
636
655
  end
637
656
  end
657
+
658
+ #
659
+ # Parses the response body if a parser in defined for it's content-type
660
+ #
661
+
662
+ def parse_body (res)
663
+
664
+ content_type = res.header['content-type']
665
+
666
+ if content_parser = self.parsers[content_type]
667
+
668
+ class << res
669
+ attr_accessor :parsed_body
670
+
671
+ alias :old_body :body
672
+
673
+ def body
674
+ parsed_body || old_body
675
+ end
676
+ end
677
+
678
+ res.parsed_body = content_parser.send(:parse, res.body)
679
+
680
+ end
681
+
682
+ res
683
+
684
+ end
685
+
638
686
  end
639
687
  end
640
688
  end
@@ -1,5 +1,5 @@
1
1
  #--
2
- # Copyright (c) 2008-2010, John Mettraux, jmettraux@gmail.com
2
+ # Copyright (c) 2008-2012, John Mettraux, jmettraux@gmail.com
3
3
  #
4
4
  # Permission is hereby granted, free of charge, to any person obtaining a copy
5
5
  # of this software and associated documentation files (the "Software"), to deal
@@ -1,5 +1,5 @@
1
1
  #--
2
- # Copyright (c) 2008-2010, John Mettraux, jmettraux@gmail.com
2
+ # Copyright (c) 2008-2012, John Mettraux, jmettraux@gmail.com
3
3
  #
4
4
  # Permission is hereby granted, free of charge, to any person obtaining a copy
5
5
  # of this software and associated documentation files (the "Software"), to deal
@@ -29,7 +29,7 @@ module Verbs
29
29
  #
30
30
  # The version of this rufus-verbs [gem]
31
31
  #
32
- VERSION = '1.0.0'
32
+ VERSION = '1.0.1'
33
33
  end
34
34
  end
35
35
 
@@ -1,87 +1,39 @@
1
- # Generated by jeweler
2
- # DO NOT EDIT THIS FILE DIRECTLY
3
- # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
4
- # -*- encoding: utf-8 -*-
5
1
 
6
2
  Gem::Specification.new do |s|
7
- s.name = %q{rufus-verbs}
8
- s.version = "1.0.0"
9
3
 
10
- s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
- s.authors = ["John Mettraux"]
12
- s.date = %q{2010-01-11}
13
- s.description = %q{
4
+ s.name = 'rufus-verbs'
5
+
6
+ s.version = File.read(
7
+ File.expand_path('../lib/rufus/verbs/version.rb', __FILE__)
8
+ ).match(/ VERSION *= *['"]([^'"]+)/)[1]
9
+ # avoiding requiring version.rb...
10
+
11
+ s.platform = Gem::Platform::RUBY
12
+ s.authors = [ 'John Mettraux' ]
13
+ s.email = [ 'jmettraux@gmail.com' ]
14
+ s.homepage = 'http://github.com/jmettraux/rufus-verbs'
15
+ s.rubyforge_project = 'rufus'
16
+ s.summary = 'GET, POST, PUT, DELETE, with something around'
17
+
18
+ s.description = %{
14
19
  GET, POST, PUT, DELETE, with something around.
15
20
 
16
- An HTTP client Ruby gem, with conditional GET, basic auth, and more.
17
- }
18
- s.email = %q{jmettraux@gmail.com}
19
- s.extra_rdoc_files = [
20
- "LICENSE.txt",
21
- "README.txt"
22
- ]
23
- s.files = [
24
- "CHANGELOG.txt",
25
- "CREDITS.txt",
26
- "LICENSE.txt",
27
- "README.txt",
28
- "Rakefile",
29
- "doc/rdoc-style.css",
30
- "lib/rufus-verbs.rb",
31
- "lib/rufus/verbs.rb",
32
- "lib/rufus/verbs/conditional.rb",
33
- "lib/rufus/verbs/cookies.rb",
34
- "lib/rufus/verbs/digest.rb",
35
- "lib/rufus/verbs/endpoint.rb",
36
- "lib/rufus/verbs/verbose.rb",
37
- "lib/rufus/verbs/version.rb",
38
- "rufus-verbs.gemspec",
39
- "test/auth0_test.rb",
40
- "test/auth1_test.rb",
41
- "test/base.rb",
42
- "test/block_test.rb",
43
- "test/bm.rb",
44
- "test/conditional_test.rb",
45
- "test/cookie0_test.rb",
46
- "test/cookie1_test.rb",
47
- "test/dryrun_test.rb",
48
- "test/escape_test.rb",
49
- "test/fopen_test.rb",
50
- "test/https_test.rb",
51
- "test/iconditional_test.rb",
52
- "test/items.rb",
53
- "test/proxy_test.rb",
54
- "test/redir_test.rb",
55
- "test/simple_test.rb",
56
- "test/test.htdigest",
57
- "test/test.rb",
58
- "test/timeout_test.rb",
59
- "test/uri_test.rb"
60
- ]
61
- s.homepage = %q{http://github.com/jmettraux/rufus-verbs/}
62
- s.rdoc_options = ["--charset=UTF-8"]
63
- s.require_paths = ["lib"]
64
- s.rubyforge_project = %q{rufus}
65
- s.rubygems_version = %q{1.3.5}
66
- s.summary = %q{GET, POST, PUT, DELETE, with something around}
67
- s.test_files = [
68
- "test/test.rb"
21
+ A HTTP client Ruby gem, with conditional GET, basic auth, and more.
22
+ }.strip
23
+
24
+ #s.required_ruby_version = '>= 1.8.6'
25
+
26
+ #s.files = `git ls-files`.split("\n")
27
+ s.files = Dir[
28
+ 'Rakefile',
29
+ 'lib/**/*.rb', 'spec/**/*.rb', 'test/**/*.rb',
30
+ '*.gemspec', '*.txt', '*.rdoc', '*.md'
69
31
  ]
70
32
 
71
- if s.respond_to? :specification_version then
72
- current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
73
- s.specification_version = 3
33
+ s.add_runtime_dependency 'rufus-lru'
34
+
35
+ s.add_development_dependency 'rake'
74
36
 
75
- if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
76
- s.add_runtime_dependency(%q<rufus-lru>, [">= 0"])
77
- s.add_development_dependency(%q<yard>, [">= 0"])
78
- else
79
- s.add_dependency(%q<rufus-lru>, [">= 0"])
80
- s.add_dependency(%q<yard>, [">= 0"])
81
- end
82
- else
83
- s.add_dependency(%q<rufus-lru>, [">= 0"])
84
- s.add_dependency(%q<yard>, [">= 0"])
85
- end
37
+ s.require_path = 'lib'
86
38
  end
87
39
 
@@ -41,3 +41,4 @@ class Auth0Test < Test::Unit::TestCase
41
41
  :http_basic_authentication => [ "toto", "toto" ])
42
42
  end
43
43
  end
44
+
@@ -0,0 +1,23 @@
1
+
2
+ require File.dirname(__FILE__) + '/base.rb'
3
+
4
+
5
+ class MergeTest < Test::Unit::TestCase
6
+
7
+ include Rufus::Verbs
8
+
9
+
10
+ def test_0
11
+
12
+ ep = EndPoint.new(
13
+ :dry_run => true,
14
+ :uri => 'http://host/path',
15
+ :params => { 'token' => 'apiaccess'})
16
+
17
+ req = ep.get(
18
+ :params => { 'extra' => 'param'})
19
+
20
+ assert_equal "/path?token=apiaccess&extra=param", req.path
21
+
22
+ end
23
+ end
@@ -0,0 +1,47 @@
1
+
2
+ require File.dirname(__FILE__) + '/base.rb'
3
+
4
+ class PlainText
5
+
6
+ def self.parse text
7
+ self.new text
8
+ end
9
+
10
+ def initialize text
11
+ @text = text
12
+ end
13
+
14
+ end
15
+
16
+ class ParseTest < Test::Unit::TestCase
17
+ include TestBaseMixin
18
+ include Rufus::Verbs
19
+
20
+ # def test_0
21
+ # ep = EndPoint.new(
22
+ # :host => "localhost",
23
+ # :port => 7777,
24
+ # :headers => {'Accept' => 'text/plain'})
25
+ #
26
+ # ep.parsers['text/plain'] = PlainText
27
+ #
28
+ # resp = ep.get(:resource => "items")
29
+ #
30
+ # assert_equal 'text/plain', resp.header['content-type']
31
+ # assert_equal PlainText, resp.body.class
32
+ #
33
+ # end
34
+
35
+ def test_1
36
+ require 'nokogiri'
37
+
38
+ ep = EndPoint.new(:host => 'rufus.rubyforge.org')
39
+ ep.parsers['text/html'] = Nokogiri::HTML::Document
40
+
41
+ res = ep.get
42
+
43
+ assert_equal Nokogiri::HTML::Document, res.body.class
44
+
45
+ end
46
+
47
+ end
@@ -1,24 +1,3 @@
1
1
 
2
- #require 'dryrun_test'
3
- #require 'iconditional_test'
4
- #require 'simple_test'
5
- #require 'auth0_test'
6
- #require 'auth1_test'
7
- #require 'redir_test'
8
- #require 'block_test'
9
- #require 'https_test'
10
- #require 'proxy_test'
11
- #require 'conditional_test'
12
- #require 'cookie0_test'
13
- #require 'cookie1_test'
14
- #require 'escape_test'
15
- #require 'uri_test'
16
- #require 'fopen_test'
17
- #require 'timeout_test'
18
-
19
- dirpath = File.dirname(__FILE__)
20
-
21
- tests = Dir.new(dirpath).entries.select { |e| e.match(/\_test\.rb$/) }.sort
22
-
23
- tests.each { |t| load "#{dirpath}/#{t}" }
2
+ Dir[File.expand_path("../*_test.rb", __FILE__)].each { |path| load(path) }
24
3
 
metadata CHANGED
@@ -1,7 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rufus-verbs
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ hash: 21
5
+ prerelease:
6
+ segments:
7
+ - 1
8
+ - 0
9
+ - 1
10
+ version: 1.0.1
5
11
  platform: ruby
6
12
  authors:
7
13
  - John Mettraux
@@ -9,56 +15,59 @@ autorequire:
9
15
  bindir: bin
10
16
  cert_chain: []
11
17
 
12
- date: 2010-01-11 00:00:00 +09:00
18
+ date: 2012-02-01 00:00:00 +09:00
13
19
  default_executable:
14
20
  dependencies:
15
21
  - !ruby/object:Gem::Dependency
16
22
  name: rufus-lru
17
- type: :runtime
18
- version_requirement:
19
- version_requirements: !ruby/object:Gem::Requirement
23
+ prerelease: false
24
+ requirement: &id001 !ruby/object:Gem::Requirement
25
+ none: false
20
26
  requirements:
21
27
  - - ">="
22
28
  - !ruby/object:Gem::Version
29
+ hash: 3
30
+ segments:
31
+ - 0
23
32
  version: "0"
24
- version:
33
+ type: :runtime
34
+ version_requirements: *id001
25
35
  - !ruby/object:Gem::Dependency
26
- name: yard
27
- type: :development
28
- version_requirement:
29
- version_requirements: !ruby/object:Gem::Requirement
36
+ name: rake
37
+ prerelease: false
38
+ requirement: &id002 !ruby/object:Gem::Requirement
39
+ none: false
30
40
  requirements:
31
41
  - - ">="
32
42
  - !ruby/object:Gem::Version
43
+ hash: 3
44
+ segments:
45
+ - 0
33
46
  version: "0"
34
- version:
35
- description: "\n\
36
- GET, POST, PUT, DELETE, with something around.\n\n\
37
- An HTTP client Ruby gem, with conditional GET, basic auth, and more.\n "
38
- email: jmettraux@gmail.com
47
+ type: :development
48
+ version_requirements: *id002
49
+ description: |-
50
+ GET, POST, PUT, DELETE, with something around.
51
+
52
+ A HTTP client Ruby gem, with conditional GET, basic auth, and more.
53
+ email:
54
+ - jmettraux@gmail.com
39
55
  executables: []
40
56
 
41
57
  extensions: []
42
58
 
43
- extra_rdoc_files:
44
- - LICENSE.txt
45
- - README.txt
59
+ extra_rdoc_files: []
60
+
46
61
  files:
47
- - CHANGELOG.txt
48
- - CREDITS.txt
49
- - LICENSE.txt
50
- - README.txt
51
62
  - Rakefile
52
- - doc/rdoc-style.css
53
- - lib/rufus-verbs.rb
54
- - lib/rufus/verbs.rb
55
63
  - lib/rufus/verbs/conditional.rb
56
64
  - lib/rufus/verbs/cookies.rb
57
65
  - lib/rufus/verbs/digest.rb
58
66
  - lib/rufus/verbs/endpoint.rb
59
67
  - lib/rufus/verbs/verbose.rb
60
68
  - lib/rufus/verbs/version.rb
61
- - rufus-verbs.gemspec
69
+ - lib/rufus/verbs.rb
70
+ - lib/rufus-verbs.rb
62
71
  - test/auth0_test.rb
63
72
  - test/auth1_test.rb
64
73
  - test/base.rb
@@ -73,40 +82,52 @@ files:
73
82
  - test/https_test.rb
74
83
  - test/iconditional_test.rb
75
84
  - test/items.rb
85
+ - test/merge_test.rb
86
+ - test/parse_test.rb
76
87
  - test/proxy_test.rb
77
88
  - test/redir_test.rb
78
89
  - test/simple_test.rb
79
- - test/test.htdigest
80
90
  - test/test.rb
81
91
  - test/timeout_test.rb
82
92
  - test/uri_test.rb
93
+ - rufus-verbs.gemspec
94
+ - CHANGELOG.txt
95
+ - CREDITS.txt
96
+ - LICENSE.txt
97
+ - README.md
83
98
  has_rdoc: true
84
- homepage: http://github.com/jmettraux/rufus-verbs/
99
+ homepage: http://github.com/jmettraux/rufus-verbs
85
100
  licenses: []
86
101
 
87
102
  post_install_message:
88
- rdoc_options:
89
- - --charset=UTF-8
103
+ rdoc_options: []
104
+
90
105
  require_paths:
91
106
  - lib
92
107
  required_ruby_version: !ruby/object:Gem::Requirement
108
+ none: false
93
109
  requirements:
94
110
  - - ">="
95
111
  - !ruby/object:Gem::Version
112
+ hash: 3
113
+ segments:
114
+ - 0
96
115
  version: "0"
97
- version:
98
116
  required_rubygems_version: !ruby/object:Gem::Requirement
117
+ none: false
99
118
  requirements:
100
119
  - - ">="
101
120
  - !ruby/object:Gem::Version
121
+ hash: 3
122
+ segments:
123
+ - 0
102
124
  version: "0"
103
- version:
104
125
  requirements: []
105
126
 
106
127
  rubyforge_project: rufus
107
- rubygems_version: 1.3.5
128
+ rubygems_version: 1.6.2
108
129
  signing_key:
109
130
  specification_version: 3
110
131
  summary: GET, POST, PUT, DELETE, with something around
111
- test_files:
112
- - test/test.rb
132
+ test_files: []
133
+
@@ -1,320 +0,0 @@
1
- html, body {
2
- height: 100%; }
3
-
4
- body {
5
- font-family: Helvetica Neue, Helvetica, sans-serif;
6
- font-size: 85%;
7
- margin: 0;
8
- padding: 0;
9
- background: white;
10
- color: black; }
11
-
12
- #wrapper {
13
- min-height: 100%;
14
- height: auto !important;
15
- height: 100%;
16
- margin: 0 auto -43px; }
17
-
18
- #footer-push {
19
- height: 43px; }
20
-
21
- div.header, #footer {
22
- background: #eee; }
23
-
24
- #footer {
25
- border-top: 1px solid silver;
26
- margin-top: 12px;
27
- padding: 0 2em;
28
- line-height: 30px;
29
- text-align: center;
30
- font-variant: small-caps;
31
- font-size: 95%; }
32
-
33
- .clearing:after {
34
- content: ".";
35
- visibility: hidden;
36
- height: 0;
37
- display: block;
38
- clear: both; }
39
- * html .clearing {
40
- height: 1px; }
41
- .clearing *:first-child + html {
42
- overflow: hidden; }
43
-
44
- h1, h2, h3, h4, h5, h6 {
45
- margin: 0;
46
- font-weight: normal; }
47
-
48
- a {
49
- color: #0b3e71; }
50
- a:hover {
51
- background: #336699;
52
- text-decoration: none;
53
- color: #eef; }
54
-
55
- #diagram img {
56
- border: 0; }
57
-
58
- #description a, .method .description a, .header a {
59
- color: #336699; }
60
- #description a:hover, .method .description a:hover, .header a:hover {
61
- color: #eee; }
62
- #description h1 a, #description h2 a, #description h3 a, #description h4 a, #description h5 a, #description h6 a, .method .description h1 a, .method .description h2 a, .method .description h3 a, .method .description h4 a, .method .description h5 a, .method .description h6 a, .header h1 a, .header h2 a, .header h3 a, .header h4 a, .header h5 a, .header h6 a {
63
- color: #0b3e71; }
64
-
65
- ol {
66
- margin: 0;
67
- padding: 0;
68
- list-style: none; }
69
- ol li {
70
- margin-left: 0;
71
- white-space: nowrap; }
72
- ol li.other {
73
- display: none; }
74
-
75
- ol.expanded li.other {
76
- display: list-item; }
77
-
78
- table {
79
- margin-bottom: 1em;
80
- font-size: 1em;
81
- border-collapse: collapse; }
82
- table td, table th {
83
- padding: .4em .8em; }
84
- table thead {
85
- background-color: #e8e8e8; }
86
- table thead th {
87
- font-variant: small-caps;
88
- color: #666666; }
89
- table tr {
90
- border-bottom: 1px solid silver; }
91
-
92
- #index a.show, div.header a.show {
93
- text-decoration: underline;
94
- font-style: italic;
95
- color: #666666; }
96
- #index a.show:after, div.header a.show:after {
97
- content: " ..."; }
98
- #index a.show:hover, div.header a.show:hover {
99
- color: black;
100
- background: #ffe; }
101
-
102
- #index {
103
- font: 85%/1.2 Helvetica neue, Helvetica, sans-serif; }
104
- #index a {
105
- text-decoration: none; }
106
- #index h1 {
107
- padding: .2em .5em .1em;
108
- background: #ccc;
109
- font: small-caps 1.2em Helvetica Neue, Helvetica, sans-serif;
110
- color: #333;
111
- border-bottom: 1px solid gray; }
112
- #index form {
113
- margin: 0;
114
- padding: 0; }
115
- #index form input {
116
- margin: .4em;
117
- margin-bottom: 0;
118
- width: 90%; }
119
- #index form #search.untouched {
120
- color: #777777; }
121
- #index ol {
122
- padding: .4em .5em; }
123
- #index ol li {
124
- white-space: nowrap; }
125
- #index #index-entries li a {
126
- padding: 1px 2px; }
127
- #index #index-entries.classes {
128
- font-size: 1.1em; }
129
- #index #index-entries.classes ol {
130
- padding: 0; }
131
- #index #index-entries.classes span.nodoc {
132
- display: none; }
133
- #index #index-entries.classes span.nodoc, #index #index-entries.classes a {
134
- font-weight: bold; }
135
- #index #index-entries.classes .parent {
136
- font-weight: normal; }
137
- #index #index-entries.methods li, #index #search-results.methods li {
138
- margin-bottom: 0.2em; }
139
- #index #index-entries.methods li a .method_name, #index #search-results.methods li a .method_name {
140
- margin-right: 0.25em; }
141
- #index #index-entries.methods li a .module_name, #index #search-results.methods li a .module_name {
142
- color: #666666; }
143
- #index #index-entries.methods li a:hover .module_name, #index #search-results.methods li a:hover .module_name {
144
- color: #ddd; }
145
-
146
- div.header {
147
- font-size: 80%;
148
- padding: .5em 2%;
149
- font-family: Helvetica, sans-serif;
150
- border-bottom: 1px solid silver; }
151
- div.header .name {
152
- font-size: 1.6em;
153
- font-family: Helvetica, sans-serif; }
154
- div.header .name .type {
155
- color: #666666;
156
- font-size: 80%;
157
- font-variant: small-caps; }
158
- div.header h1.name {
159
- font-size: 2.2em; }
160
- div.header .paths, div.header .last-update, div.header .parent {
161
- color: #666666; }
162
- div.header .last-update .datetime {
163
- color: #484848; }
164
- div.header .parent {
165
- margin-top: .3em; }
166
- div.header .parent strong {
167
- font-weight: normal;
168
- color: #484848; }
169
-
170
- #content {
171
- padding: 12px 2%; }
172
- div.class #content {
173
- position: relative;
174
- width: 72%; }
175
- #content pre, #content .method .synopsis {
176
- font: 14px Monaco, DejaVu Sans Mono , Bitstream Vera Sans Mono , Courier New , monospace; }
177
- #content pre {
178
- color: black;
179
- background: #eee;
180
- border: 1px solid silver;
181
- padding: .5em .8em;
182
- overflow: auto; }
183
- #content p code, #content p tt, #content li code, #content li tt, #content dl code, #content dl tt {
184
- font: 14px Monaco, DejaVu Sans Mono , Bitstream Vera Sans Mono , Courier New , monospace;
185
- background: #ffffe3;
186
- padding: 2px 3px;
187
- line-height: 1.4; }
188
- #content h1 code, #content h1 tt, #content h2 code, #content h2 tt, #content h3 code, #content h3 tt, #content h4 code, #content h4 tt, #content h5 code, #content h5 tt, #content h6 code, #content h6 tt {
189
- font-size: 1.1em; }
190
- #content #text {
191
- position: relative; }
192
- #content #description p {
193
- margin-top: .5em; }
194
- #content #description h1, #content #description h2, #content #description h3, #content #description h4, #content #description h5, #content #description h6 {
195
- font-family: Helvetica Neue, Helvetica, sans-serif; }
196
- #content #description h1 {
197
- font-size: 2.2em;
198
- margin-bottom: .2em;
199
- border-bottom: 3px double #d8d8d8;
200
- padding-bottom: .1em; }
201
- #content #description h2 {
202
- font-size: 1.8em;
203
- color: #0e3062;
204
- margin: .8em 0 .3em 0; }
205
- #content #description h3 {
206
- font-size: 1.6em;
207
- margin: .8em 0 .3em 0;
208
- color: #666666; }
209
- #content #description h4 {
210
- font-size: 1.4em;
211
- margin: .8em 0 .3em 0; }
212
- #content #description h5 {
213
- font-size: 1.2em;
214
- margin: .8em 0 .3em 0;
215
- color: #0e3062; }
216
- #content #description h6 {
217
- font-size: 1.0em;
218
- margin: .8em 0 .3em 0;
219
- color: #666666; }
220
- #content #description ul, #content #description ol, #content .method .description ul, #content .method .description ol {
221
- margin: .8em 0;
222
- padding-left: 1.5em; }
223
- #content #description ol, #content .method .description ol {
224
- list-style: decimal; }
225
- #content #description ol li, #content .method .description ol li {
226
- white-space: normal; }
227
-
228
- #method-list {
229
- position: absolute;
230
- top: 0px;
231
- right: -33%;
232
- width: 28%;
233
- background: #eee;
234
- border: 1px solid silver;
235
- padding: .4em 1%;
236
- overflow: hidden; }
237
- #method-list h2 {
238
- font-size: 1.3em; }
239
- #method-list h3 {
240
- font-variant: small-caps;
241
- text-transform: capitalize;
242
- font-family: Helvetica Neue, Helvetica, sans-serif;
243
- color: #666;
244
- font-size: 1.1em; }
245
- #method-list ol {
246
- padding: 0 0 .5em .5em; }
247
-
248
- #context {
249
- border-top: 1px dashed silver;
250
- margin-top: 1em;
251
- margin-bottom: 1em; }
252
-
253
- #context h2, #section h2 {
254
- font: small-caps 1.2em Helvetica Neue, Helvetica, sans-serif;
255
- color: #444;
256
- margin: 1em 0 .2em 0; }
257
-
258
- #methods .method {
259
- border: 1px solid silver;
260
- margin-top: .5em;
261
- background: #eee; }
262
- #methods .method .synopsis {
263
- color: black;
264
- background: silver;
265
- padding: .2em 1em; }
266
- #methods .method .synopsis .name {
267
- font-weight: bold; }
268
- #methods .method .synopsis a {
269
- text-decoration: none; }
270
- #methods .method .description {
271
- padding: 0 1em; }
272
- #methods .method .description pre {
273
- background: #f8f8f8; }
274
- #methods .method .source {
275
- margin: .5em 0; }
276
- #methods .method .source-toggle {
277
- font-size: 85%;
278
- margin-left: 1em; }
279
- #methods .public-class {
280
- background: #ffffe4; }
281
- #methods .public-instance .synopsis {
282
- color: #eee;
283
- background: #336699; }
284
-
285
- #content .method .source pre {
286
- font-size: 90%;
287
- background: #262626;
288
- color: #ffdead;
289
- margin: 1em;
290
- padding: 0.5em;
291
- border: 1px dashed #999;
292
- overflow: auto; }
293
- #content .method .source pre .ruby-constant {
294
- color: #7fffd4;
295
- background: transparent; }
296
- #content .method .source pre .ruby-keyword {
297
- color: #00ffff;
298
- background: transparent; }
299
- #content .method .source pre .ruby-ivar {
300
- color: #eedd82;
301
- background: transparent; }
302
- #content .method .source pre .ruby-operator {
303
- color: #00ffee;
304
- background: transparent; }
305
- #content .method .source pre .ruby-identifier {
306
- color: #ffdead;
307
- background: transparent; }
308
- #content .method .source pre .ruby-node {
309
- color: #ffa07a;
310
- background: transparent; }
311
- #content .method .source pre .ruby-comment {
312
- color: #b22222;
313
- font-weight: bold;
314
- background: transparent; }
315
- #content .method .source pre .ruby-regexp {
316
- color: #ffa07a;
317
- background: transparent; }
318
- #content .method .source pre .ruby-value {
319
- color: #7fffd4;
320
- background: transparent; }
@@ -1 +0,0 @@
1
- test:test_realm:fbab5e064c6fa79c414735bcdcf2ce4a