mwunsch-weary 0.3.0 → 0.3.1
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/lib/weary.rb +7 -2
- data/spec/weary_spec.rb +16 -5
- data/weary.gemspec +1 -1
- metadata +1 -1
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.3.
|
1
|
+
0.3.1
|
data/lib/weary.rb
CHANGED
@@ -71,13 +71,17 @@ module Weary
|
|
71
71
|
@password = password
|
72
72
|
return nil
|
73
73
|
end
|
74
|
+
|
75
|
+
def always_with(params)
|
76
|
+
@always_with = params
|
77
|
+
end
|
74
78
|
|
75
79
|
# Declare a resource. Use it with a block to setup the resource
|
76
80
|
#
|
77
81
|
# Methods that are understood are:
|
78
82
|
# [<tt>via</tt>] Get, Post, etc. Defaults to a GET request
|
79
|
-
# [<tt>with</tt>] An array of parameters that will be passed to the body or query of the request.
|
80
|
-
# [<tt>requires</tt>]
|
83
|
+
# [<tt>with</tt>] An array of parameters that will be passed to the body or query of the request. If you pass a hash, it will define default <tt>values</tt> for params <tt>keys</tt>
|
84
|
+
# [<tt>requires</tt>] Array of members of <tt>:with</tt> that are required by the resource.
|
81
85
|
# [<tt>authenticates</tt>] Boolean value; does the resource require authentication?
|
82
86
|
# [<tt>url</tt>] The url of the resource. You can use the same flags as #construct_url
|
83
87
|
# [<tt>format</tt>] The format you would like to request. Defaults to json
|
@@ -120,6 +124,7 @@ module Weary
|
|
120
124
|
preparation.format = (@default_format || :json)
|
121
125
|
preparation.domain = @domain
|
122
126
|
preparation.url = (@url_pattern || "<domain><resource>.<format>")
|
127
|
+
preparation.with = @always_with unless @always_with.nil?
|
123
128
|
return preparation
|
124
129
|
end
|
125
130
|
|
data/spec/weary_spec.rb
CHANGED
@@ -62,12 +62,23 @@ describe Weary do
|
|
62
62
|
end
|
63
63
|
|
64
64
|
describe "Common Request Paramaters" do
|
65
|
-
it "should define with params that every resource inherits"
|
66
|
-
|
67
|
-
|
65
|
+
it "should define with params that every resource inherits" do
|
66
|
+
@test.on_domain "http://foo.bar"
|
67
|
+
@test.always_with [:login, :token]
|
68
|
+
r = @test.get "resource"
|
69
|
+
r.with.should == [:login, :token]
|
70
|
+
r.requires = [:foobar]
|
71
|
+
r.with.should == [:login, :token, :foobar]
|
72
|
+
end
|
68
73
|
|
69
|
-
it "should be able to be a hash"
|
70
|
-
|
74
|
+
it "should be able to be a hash" do
|
75
|
+
@test.on_domain "http://foo.bar"
|
76
|
+
@test.always_with :foo => "Foo", :bar => "Bar"
|
77
|
+
r = @test.get "resource"
|
78
|
+
r.with.should == {:foo => "Foo", :bar => "Bar"}
|
79
|
+
r.requires = [:foobar]
|
80
|
+
r.with.should == {:foo => "Foo", :bar => "Bar", :foobar => nil}
|
81
|
+
end
|
71
82
|
end
|
72
83
|
|
73
84
|
describe 'Resource Declaration' do
|
data/weary.gemspec
CHANGED