From 6dda359db1aedf8ac571cbb817c752647055e6ff Mon Sep 17 00:00:00 2001 From: Akinori MUSHA Date: Sat, 23 Mar 2013 00:37:21 +0900 Subject: [PATCH] Improve rdoc. --- README.md | 15 ++++++++++++++- http-cookie.gemspec | 1 + lib/http/cookie.rb | 7 +++---- lib/http/cookie_jar/hash_store.rb | 2 ++ 4 files changed, 20 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 8a9aed7..1681c1e 100644 --- a/README.md +++ b/README.md @@ -111,6 +111,19 @@ equivalent using `HTTP::Cookie`: # after jar.save(file) +- `Mechanize::CookieJar#jar` + + There is no direct access to the internal hash in + `HTTP::CookieJar` since it has introduced an abstract storage + layer. If you want to tweak the internals of the hash storage, + try creating a new storage class referring to the default storage + class `HTTP::CookieJar::HashStore`. + + If you desperately need it you can access it by + `jar.store.instance_variable_get(:@jar)`, but there is no + guarantee that it will remain available in the future. + + `HTTP::Cookie`/`CookieJar` raise runtime errors to help migration, so after replacing the class names, try running your test code once to find out how to fix your code base. @@ -128,7 +141,7 @@ Trying to load a YAML file saved by `HTTP::CookieJar` with `Mechanize::CookieJar` will fail in runtime error. On the other hand, there has been (and will ever be) no change in the -cookies.txt format, so use it instead if compatibility is required. +cookies.txt format, so use it instead if compatibility is significant. ## Contributing diff --git a/http-cookie.gemspec b/http-cookie.gemspec index fabf3d6..236f8b5 100644 --- a/http-cookie.gemspec +++ b/http-cookie.gemspec @@ -21,6 +21,7 @@ Gem::Specification.new do |gem| gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) } gem.test_files = gem.files.grep(%r{^(test|spec|features)/}) gem.require_paths = ["lib"] + gem.extra_rdoc_files = ['README.md', 'LICENSE.txt'] gem.add_runtime_dependency("domain_name", ["~> 0.5"]) gem.add_development_dependency("bundler", [">= 1.2.0"]) diff --git a/lib/http/cookie.rb b/lib/http/cookie.rb index 72c018d..b6c2cf9 100644 --- a/lib/http/cookie.rb +++ b/lib/http/cookie.rb @@ -13,8 +13,7 @@ if RUBY_VERSION < "1.9.3" begin URI(URI('')) rescue - # :nodoc: - def URI(url) + def URI(url) # :nodoc: url.is_a?(URI) ? url : URI.parse(url) end end @@ -239,9 +238,9 @@ class HTTP::Cookie # * Order of parameters is a slightly different in # `HTTP::Cookie.parse`. Compare these: # - # Mechanize::Cookie.parse(uri, set_cookie[, log]) + # Mechanize::Cookie.parse(uri, set_cookie[, log]) # - # HTTP::Cookie.parse(set_cookie, :origin => uri[, :logger => # log]) + # HTTP::Cookie.parse(set_cookie, :origin => uri[, :logger => # log]) # # * `HTTP::Cookie.parse` does not yield nil nor include nil in an # returned array. It simply ignores unparsable parts. diff --git a/lib/http/cookie_jar/hash_store.rb b/lib/http/cookie_jar/hash_store.rb index 9d59801..87af8f0 100644 --- a/lib/http/cookie_jar/hash_store.rb +++ b/lib/http/cookie_jar/hash_store.rb @@ -1,10 +1,12 @@ require 'http/cookie_jar' +# :stopdoc: class Array def sort_by!(&block) replace(sort_by(&block)) end unless method_defined?(:sort_by!) end +# :startdoc: class HTTP::CookieJar class HashStore < AbstractStore