hugs 1.0.0 → 1.1.0
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.md +0 -1
- data/VERSION +1 -1
- data/hugs.gemspec +69 -0
- data/lib/hugs.rb +3 -3
- data/test/test_hugs.rb +11 -0
- metadata +4 -3
data/README.md
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.
|
1
|
+
1.1.0
|
data/hugs.gemspec
ADDED
@@ -0,0 +1,69 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = %q{hugs}
|
8
|
+
s.version = "1.1.0"
|
9
|
+
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = ["retr0h"]
|
12
|
+
s.date = %q{2010-12-12}
|
13
|
+
s.email = %q{john@dewey.ws}
|
14
|
+
s.extra_rdoc_files = [
|
15
|
+
"LICENSE",
|
16
|
+
"README.md"
|
17
|
+
]
|
18
|
+
s.files = [
|
19
|
+
".bundle/config",
|
20
|
+
".rvmrc",
|
21
|
+
"Gemfile",
|
22
|
+
"Gemfile.lock",
|
23
|
+
"LICENSE",
|
24
|
+
"README.md",
|
25
|
+
"Rakefile",
|
26
|
+
"VERSION",
|
27
|
+
"hugs.gemspec",
|
28
|
+
"lib/hugs.rb",
|
29
|
+
"test/support.rb",
|
30
|
+
"test/test_hugs.rb"
|
31
|
+
]
|
32
|
+
s.homepage = %q{http://github.com/retr0h/hugs}
|
33
|
+
s.require_paths = ["lib"]
|
34
|
+
s.rubygems_version = %q{1.3.7}
|
35
|
+
s.summary = %q{Hugs net-http-persistent with convenient get, delete, post, and put methods.}
|
36
|
+
s.test_files = [
|
37
|
+
"test/support.rb",
|
38
|
+
"test/test_hugs.rb"
|
39
|
+
]
|
40
|
+
|
41
|
+
if s.respond_to? :specification_version then
|
42
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
43
|
+
s.specification_version = 3
|
44
|
+
|
45
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
46
|
+
s.add_runtime_dependency(%q<yajl-ruby>, ["~> 0.7.8"])
|
47
|
+
s.add_runtime_dependency(%q<net-http-persistent>, ["~> 1.4.1"])
|
48
|
+
s.add_development_dependency(%q<rake>, [">= 0"])
|
49
|
+
s.add_development_dependency(%q<jeweler>, ["~> 1.5.1"])
|
50
|
+
s.add_development_dependency(%q<minitest>, ["~> 2.0.0"])
|
51
|
+
s.add_development_dependency(%q<mocha>, ["~> 0.9.10"])
|
52
|
+
else
|
53
|
+
s.add_dependency(%q<yajl-ruby>, ["~> 0.7.8"])
|
54
|
+
s.add_dependency(%q<net-http-persistent>, ["~> 1.4.1"])
|
55
|
+
s.add_dependency(%q<rake>, [">= 0"])
|
56
|
+
s.add_dependency(%q<jeweler>, ["~> 1.5.1"])
|
57
|
+
s.add_dependency(%q<minitest>, ["~> 2.0.0"])
|
58
|
+
s.add_dependency(%q<mocha>, ["~> 0.9.10"])
|
59
|
+
end
|
60
|
+
else
|
61
|
+
s.add_dependency(%q<yajl-ruby>, ["~> 0.7.8"])
|
62
|
+
s.add_dependency(%q<net-http-persistent>, ["~> 1.4.1"])
|
63
|
+
s.add_dependency(%q<rake>, [">= 0"])
|
64
|
+
s.add_dependency(%q<jeweler>, ["~> 1.5.1"])
|
65
|
+
s.add_dependency(%q<minitest>, ["~> 2.0.0"])
|
66
|
+
s.add_dependency(%q<mocha>, ["~> 0.9.10"])
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
data/lib/hugs.rb
CHANGED
@@ -8,10 +8,10 @@ class Hugs
|
|
8
8
|
|
9
9
|
##
|
10
10
|
# Required options:
|
11
|
-
# +user+: A String containing the username for use in HTTP Basic auth.
|
12
|
-
# +password+: A String containing the password for use in HTTP Basic auth.
|
13
11
|
# +host+: A String with the host to connect.
|
14
12
|
# Optional:
|
13
|
+
# +user+: A String containing the username for use in HTTP Basic auth.
|
14
|
+
# +password+: A String containing the password for use in HTTP Basic auth.
|
15
15
|
# +port+: An Integer containing the port to connect.
|
16
16
|
# +scheme+: A String containing the HTTP scheme.
|
17
17
|
|
@@ -73,7 +73,7 @@ private
|
|
73
73
|
end
|
74
74
|
|
75
75
|
def common_headers request
|
76
|
-
request.basic_auth
|
76
|
+
request.basic_auth(@user, @password) if @user && @password
|
77
77
|
case request.class.to_s
|
78
78
|
when Net::HTTP::Get.to_s, Net::HTTP::Delete.to_s
|
79
79
|
request.add_field "accept", Headers[:json]
|
data/test/test_hugs.rb
CHANGED
@@ -65,6 +65,17 @@ describe Hugs do
|
|
65
65
|
must_match %r{Basic #{Base64.encode64("#{@user}:#{@password}").delete("\r\n")}}
|
66
66
|
end
|
67
67
|
|
68
|
+
[:user, :password].each do |option|
|
69
|
+
it "doesn't authenticate when '#{option}' missing" do
|
70
|
+
invalid_options = @valid_options.reject { |k,v| k == option }
|
71
|
+
@instance = Hugs.new invalid_options
|
72
|
+
|
73
|
+
@instance.send :response_for, @request, "/", {}
|
74
|
+
|
75
|
+
@instance.instance_variable_get(:@request).get_fields("authorization").must_be_nil
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
68
79
|
[Net::HTTP::Post, Net::HTTP::Put].each do |clazz|
|
69
80
|
it "has content-type and accept for '#{clazz}'" do
|
70
81
|
@instance.send :response_for, clazz, "/", {}
|
metadata
CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
|
|
4
4
|
prerelease: false
|
5
5
|
segments:
|
6
6
|
- 1
|
7
|
+
- 1
|
7
8
|
- 0
|
8
|
-
|
9
|
-
version: 1.0.0
|
9
|
+
version: 1.1.0
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- retr0h
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-12-
|
17
|
+
date: 2010-12-12 00:00:00 -08:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
@@ -123,6 +123,7 @@ files:
|
|
123
123
|
- README.md
|
124
124
|
- Rakefile
|
125
125
|
- VERSION
|
126
|
+
- hugs.gemspec
|
126
127
|
- lib/hugs.rb
|
127
128
|
- test/support.rb
|
128
129
|
- test/test_hugs.rb
|