Skip to content

Commit 34c23b9

Browse files
committed
Merged
2 parents 43d7140 + aa1f319 commit 34c23b9

File tree

9 files changed

+52
-63
lines changed

9 files changed

+52
-63
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@
33
pkg
44
doc
55
.bundle
6+
Gemfile.lock

.rspec

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
--color
2+
-w

Gemfile

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,2 @@
1-
source "http://rubygems.org"
2-
# requires ruby >= 2.0
3-
1+
source 'https://rubygems.org'
42
gemspec

Rakefile

+12-12
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,15 @@
1+
require 'bundler/gem_tasks'
2+
13
require 'rake'
24

35
require 'rake/clean'
4-
require 'rake/packagetask'
56
require 'yard'
67
require 'yard/rake/yardoc_task'
78

8-
require 'fileutils'
9-
include FileUtils
10-
11-
# Default Rake task is to run all tests
12-
task :default => :test
139
CLEAN << Rake::FileList['doc/**', '.yardoc']
14-
#Yard
10+
# Yard
1511
YARD::Rake::YardocTask.new do |t|
16-
t.files = ['lib/**/*.rb'] # optional
12+
t.files = ['lib/**/*.rb'] # optional
1713
t.options = ['--title', 'CookieJar, a HTTP Client Cookie Parsing Library',
1814
'--main', 'README.markdown', '--files', 'LICENSE']
1915
end
@@ -22,10 +18,14 @@ begin
2218
require 'rspec/core/rake_task'
2319

2420
RSpec::Core::RakeTask.new do |t|
25-
# t.libs << 'lib'
26-
# t.pattern = 'test/**/*_test.rb'
21+
t.ruby_opts = %w(-w)
22+
t.pattern = 'spec/**/*_spec.rb'
2723
end
28-
task :test => :spec
24+
task test: :spec
2925
rescue LoadError
30-
puts "Warning: unable to load rspec tasks"
26+
puts 'Warning: unable to load rspec tasks'
3127
end
28+
task test: :spec
29+
30+
# Default Rake task is to run all tests
31+
task default: :test

cookiejar.gemspec

+20-39
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,26 @@
11
# -*- encoding: utf-8 -*-
22

3-
Gem::Specification.new do |s|
4-
s.name = "cookiejar"
5-
s.version = "0.3.2"
3+
lib = File.expand_path('../lib', __FILE__)
4+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5+
require 'cookiejar/version'
66

7-
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8-
s.authors = ["David Waite"]
9-
s.date = "2014-02-16"
10-
s.license = "BSD-2-Clause"
11-
s.description = "Allows for parsing and returning cookies in Ruby HTTP client code"
12-
s.email = "[email protected]"
13-
s.files = [
14-
"LICENSE",
15-
"README.markdown",
16-
"Rakefile",
17-
"contributors.json",
18-
"lib/cookiejar/cookie.rb",
19-
"lib/cookiejar/cookie_validation.rb",
20-
"lib/cookiejar/jar.rb",
21-
"lib/cookiejar.rb",
22-
"spec/cookie_spec.rb",
23-
"spec/cookie_validation_spec.rb",
24-
"spec/jar_spec.rb"
25-
]
26-
s.homepage = "https://alkaline-solutions.com"
27-
s.rdoc_options = ["--title", "CookieJar -- Client-side HTTP Cookies"]
28-
s.require_paths = ["lib"]
29-
s.rubygems_version = "2.1.10"
30-
s.summary = "Client-side HTTP Cookie library"
7+
Gem::Specification.new do |s|
8+
s.name = 'cookiejar'
9+
s.version = CookieJar::VERSION
10+
s.authors = ['David Waite']
11+
s.email = ['[email protected]']
12+
s.description = 'Allows for parsing and returning cookies in Ruby HTTP client code'
13+
s.summary = 'Client-side HTTP Cookie library'
14+
s.homepage = 'http://alkaline-solutions.com'
15+
s.date = '2014-02-01'
3116

32-
if s.respond_to? :specification_version then
33-
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
34-
s.specification_version = 3
17+
s.files = `git ls-files`.split($INPUT_RECORD_SEPARATOR)
18+
s.test_files = s.files.grep(%r{^(spec)/})
19+
s.rdoc_options = ['--title', 'CookieJar -- Client-side HTTP Cookies']
20+
s.require_paths = ['lib']
3521

36-
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
37-
else
38-
end
39-
else
40-
end
41-
s.add_development_dependency "rake", "~> 10.0"
42-
s.add_development_dependency "rspec-collection_matchers", "~> 1.0"
43-
s.add_development_dependency "rspec", "~> 3.0"
44-
s.add_development_dependency "yard", "~> 0.8", ">= 0.8.7"
22+
s.add_development_dependency 'rake', '~> 10.0'
23+
s.add_development_dependency 'rspec-collection_matchers', '~> 1.0'
24+
s.add_development_dependency 'rspec', '~> 3.0'
25+
s.add_development_dependency 'yard', '~> 0.8', '>= 0.8.7'
4526
end

lib/cookiejar.rb

+1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
require 'cookiejar/cookie'
22
require 'cookiejar/jar'
3+
require 'cookiejar/version'

lib/cookiejar/cookie_validation.rb

+10-9
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# frozen_string_literal: true
12
require 'cgi'
23
require 'uri'
34

@@ -266,7 +267,7 @@ def self.validate_cookie(request_uri, cookie)
266267
end
267268
end
268269

269-
raise InvalidCookieError, errors unless errors.empty?
270+
fail InvalidCookieError, errors unless errors.empty?
270271

271272
# Note: 'secure' is not explicitly defined as an SSL channel, and no
272273
# test is defined around validity and the 'secure' attribute
@@ -288,8 +289,8 @@ def self.parse_set_cookie(set_cookie_value)
288289
params.each do |param|
289290
result = PARAM1.match param
290291
unless result
291-
raise InvalidCookieError,
292-
"Invalid cookie parameter in cookie '#{set_cookie_value}'"
292+
fail InvalidCookieError,
293+
"Invalid cookie parameter in cookie '#{set_cookie_value}'"
293294
end
294295
key = result[1].downcase.to_sym
295296
keyvalue = result[2]
@@ -313,7 +314,7 @@ def self.parse_set_cookie(set_cookie_value)
313314
when :httponly
314315
args[:http_only] = true
315316
else
316-
raise InvalidCookieError, "Unknown cookie parameter '#{key}'"
317+
fail InvalidCookieError, "Unknown cookie parameter '#{key}'"
317318
end
318319
end
319320
end
@@ -354,8 +355,8 @@ def self.parse_set_cookie2(set_cookie_value)
354355
begin
355356
md = PARAM2.match set_cookie_value[index..-1]
356357
if md.nil? || md.offset(0).first != 0
357-
raise InvalidCookieError,
358-
"Invalid Set-Cookie2 header '#{set_cookie_value}'"
358+
fail InvalidCookieError,
359+
"Invalid Set-Cookie2 header '#{set_cookie_value}'"
359360
end
360361
index += md.offset(0)[1]
361362

@@ -383,14 +384,14 @@ def self.parse_set_cookie2(set_cookie_value)
383384
ports = keyvalue.split(/,\s*/)
384385
args[:ports] = ports.map(&:to_i)
385386
else
386-
raise InvalidCookieError, "Unknown cookie parameter '#{key}'"
387+
fail InvalidCookieError, "Unknown cookie parameter '#{key}'"
387388
end
388389
end
389390
end until md.post_match.empty?
390391
# if our last match in the scan failed
391392
if args[:version] != 1
392-
raise InvalidCookieError,
393-
'Set-Cookie2 declares a non RFC2965 version cookie'
393+
fail InvalidCookieError,
394+
'Set-Cookie2 declares a non RFC2965 version cookie'
394395
end
395396

396397
args

lib/cookiejar/version.rb

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# frozen_string_literal: true
2+
module CookieJar
3+
VERSION = '0.3.3'.freeze
4+
end

spec/cookie_spec.rb

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# frozen_string_literal: true
12
require 'spec_helper'
23

34
include CookieJar

0 commit comments

Comments
 (0)