agree2 0.1.1 → 0.2.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/.gitignore +4 -0
- data/Rakefile +17 -44
- data/VERSION +1 -0
- data/agree2.gemspec +76 -0
- data/certs/sf_bundle.crt +77 -0
- data/lib/agree2.rb +19 -12
- data/lib/agree2/agreement.rb +17 -2
- data/lib/agree2/base.rb +29 -1
- data/lib/agree2/client.rb +14 -6
- data/lib/agree2/party.rb +10 -1
- data/lib/agree2/user.rb +10 -10
- data/spec/agreement_spec.rb +1 -1
- data/spec/client_spec.rb +2 -2
- data/spec/party_spec.rb +1 -1
- data/spec/user_spec.rb +7 -2
- metadata +26 -30
data/.gitignore
ADDED
data/Rakefile
CHANGED
@@ -40,50 +40,23 @@ namespace :spec do |ns|
|
|
40
40
|
end
|
41
41
|
end
|
42
42
|
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
43
|
+
begin
|
44
|
+
require 'jeweler'
|
45
|
+
Jeweler::Tasks.new do |gemspec|
|
46
|
+
gemspec.name = "agree2"
|
47
|
+
gemspec.summary = "Ruby client library for Agree2"
|
48
|
+
gemspec.description = "Ruby library for creating and managing agreements on Agree2"
|
49
|
+
gemspec.email = "support@agree2.com"
|
50
|
+
gemspec.homepage = "http://agree2.com"
|
51
|
+
gemspec.authors = ["Pelle Braendgaard"]
|
52
|
+
gemspec.add_dependency('oauth', '>= 0.3.5')
|
53
|
+
gemspec.add_dependency("json", [">= 1.1.3"])
|
54
|
+
gemspec.add_dependency("activesupport", [">= 2.0.2"])
|
55
|
+
|
56
|
+
gemspec.rubyforge_project = 'agree2'
|
47
57
|
end
|
48
|
-
|
49
|
-
|
50
|
-
pkg.need_tar = true
|
51
|
-
pkg.need_zip = true
|
52
|
-
end
|
53
|
-
|
54
|
-
desc 'Install the package as a gem.'
|
55
|
-
task :install => [:clean, :package] do
|
56
|
-
gem = Dir['pkg/*.gem'].first
|
57
|
-
sh "sudo gem install --local #{gem}"
|
58
|
-
end
|
59
|
-
|
60
|
-
|
61
|
-
desc 'Package and upload the release to rubyforge.'
|
62
|
-
task :release => [:clean, :package] do |t|
|
63
|
-
pkg = "pkg/#{name}-#{@version}"
|
64
|
-
|
65
|
-
if $DEBUG then
|
66
|
-
puts "release_id = rf.add_release #{rubyforge_name.inspect}, #{name.inspect}, #{@version.inspect}, \"#{pkg}.tgz\""
|
67
|
-
puts "rf.add_file #{rubyforge_name.inspect}, #{name.inspect}, release_id, \"#{pkg}.gem\""
|
68
|
-
end
|
69
|
-
|
70
|
-
rf = RubyForge.new.configure
|
71
|
-
puts "Logging in"
|
72
|
-
rf.login
|
73
|
-
|
74
|
-
# c = rf.userconfig
|
75
|
-
# c["release_notes"] = description if description
|
76
|
-
# c["release_changes"] = changes if changes
|
77
|
-
# c["preformatted"] = true
|
78
|
-
|
79
|
-
files = ["#{pkg}.tgz",
|
80
|
-
"#{pkg}.zip",
|
81
|
-
"#{pkg}.gem"].compact
|
82
|
-
|
83
|
-
puts "Releasing #{name} v. #{@version}"
|
84
|
-
rf.add_release rubyforge_name, name, @version, *files
|
85
|
-
end
|
86
|
-
|
58
|
+
rescue LoadError
|
59
|
+
puts "Jeweler not available. Install it with: sudo gem install technicalpickles-jeweler -s http://gems.github.com"
|
87
60
|
end
|
88
61
|
|
89
62
|
desc "Clean up all dirt"
|
@@ -94,4 +67,4 @@ task :clean => [ "rdoc:clobber_doc", "gem:clobber_package" ] do
|
|
94
67
|
end
|
95
68
|
end
|
96
69
|
|
97
|
-
task :default=>[:spec]
|
70
|
+
task :default=>["spec:spec"]
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.2.0
|
data/agree2.gemspec
ADDED
@@ -0,0 +1,76 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
Gem::Specification.new do |s|
|
4
|
+
s.name = %q{agree2}
|
5
|
+
s.version = "0.2.0"
|
6
|
+
|
7
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
8
|
+
s.authors = ["Pelle Braendgaard"]
|
9
|
+
s.date = %q{2009-07-31}
|
10
|
+
s.description = %q{Ruby library for creating and managing agreements on Agree2}
|
11
|
+
s.email = %q{support@agree2.com}
|
12
|
+
s.extra_rdoc_files = [
|
13
|
+
"README.rdoc"
|
14
|
+
]
|
15
|
+
s.files = [
|
16
|
+
".gitignore",
|
17
|
+
"History.txt",
|
18
|
+
"License.txt",
|
19
|
+
"README.rdoc",
|
20
|
+
"Rakefile",
|
21
|
+
"VERSION",
|
22
|
+
"agree2.gemspec",
|
23
|
+
"certs/sf_bundle.crt",
|
24
|
+
"lib/agree2.rb",
|
25
|
+
"lib/agree2/agreement.rb",
|
26
|
+
"lib/agree2/base.rb",
|
27
|
+
"lib/agree2/client.rb",
|
28
|
+
"lib/agree2/party.rb",
|
29
|
+
"lib/agree2/proxy_collection.rb",
|
30
|
+
"lib/agree2/template.rb",
|
31
|
+
"lib/agree2/user.rb",
|
32
|
+
"spec/agreement_spec.rb",
|
33
|
+
"spec/client_spec.rb",
|
34
|
+
"spec/fixtures/agreement.json",
|
35
|
+
"spec/fixtures/party.json",
|
36
|
+
"spec/party_spec.rb",
|
37
|
+
"spec/proxy_collection_spec.rb",
|
38
|
+
"spec/spec_helper.rb",
|
39
|
+
"spec/template_spec.rb",
|
40
|
+
"spec/user_spec.rb"
|
41
|
+
]
|
42
|
+
s.homepage = %q{http://agree2.com}
|
43
|
+
s.rdoc_options = ["--charset=UTF-8"]
|
44
|
+
s.require_paths = ["lib"]
|
45
|
+
s.rubyforge_project = %q{agree2}
|
46
|
+
s.rubygems_version = %q{1.3.5}
|
47
|
+
s.summary = %q{Ruby client library for Agree2}
|
48
|
+
s.test_files = [
|
49
|
+
"spec/agreement_spec.rb",
|
50
|
+
"spec/client_spec.rb",
|
51
|
+
"spec/party_spec.rb",
|
52
|
+
"spec/proxy_collection_spec.rb",
|
53
|
+
"spec/spec_helper.rb",
|
54
|
+
"spec/template_spec.rb",
|
55
|
+
"spec/user_spec.rb"
|
56
|
+
]
|
57
|
+
|
58
|
+
if s.respond_to? :specification_version then
|
59
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
60
|
+
s.specification_version = 3
|
61
|
+
|
62
|
+
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
63
|
+
s.add_runtime_dependency(%q<oauth>, [">= 0.3.5"])
|
64
|
+
s.add_runtime_dependency(%q<json>, [">= 1.1.3"])
|
65
|
+
s.add_runtime_dependency(%q<activesupport>, [">= 2.0.2"])
|
66
|
+
else
|
67
|
+
s.add_dependency(%q<oauth>, [">= 0.3.5"])
|
68
|
+
s.add_dependency(%q<json>, [">= 1.1.3"])
|
69
|
+
s.add_dependency(%q<activesupport>, [">= 2.0.2"])
|
70
|
+
end
|
71
|
+
else
|
72
|
+
s.add_dependency(%q<oauth>, [">= 0.3.5"])
|
73
|
+
s.add_dependency(%q<json>, [">= 1.1.3"])
|
74
|
+
s.add_dependency(%q<activesupport>, [">= 2.0.2"])
|
75
|
+
end
|
76
|
+
end
|
data/certs/sf_bundle.crt
ADDED
@@ -0,0 +1,77 @@
|
|
1
|
+
-----BEGIN CERTIFICATE-----
|
2
|
+
MIIFBzCCA++gAwIBAgICAgEwDQYJKoZIhvcNAQEFBQAwaDELMAkGA1UEBhMCVVMx
|
3
|
+
JTAjBgNVBAoTHFN0YXJmaWVsZCBUZWNobm9sb2dpZXMsIEluYy4xMjAwBgNVBAsT
|
4
|
+
KVN0YXJmaWVsZCBDbGFzcyAyIENlcnRpZmljYXRpb24gQXV0aG9yaXR5MB4XDTA2
|
5
|
+
MTExNjAxMTU0MFoXDTI2MTExNjAxMTU0MFowgdwxCzAJBgNVBAYTAlVTMRAwDgYD
|
6
|
+
VQQIEwdBcml6b25hMRMwEQYDVQQHEwpTY290dHNkYWxlMSUwIwYDVQQKExxTdGFy
|
7
|
+
ZmllbGQgVG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SEwHwYDVQQDExhodHRw
|
69
|
+
Oi8vd3d3LnZhbGljZXJ0LmNvbS8xIDAeBgkqhkiG9w0BCQEWEWluZm9AdmFsaWNl
|
70
|
+
cnQuY29tMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDOOnHK5avIWZJV16vY
|
71
|
+
dA757tn2VUdZZUcOBVXc65g2PFxTXdMwzzjsvUGJ7SVCCSRrCl6zfN1SLUzm1NZ9
|
72
|
+
WlmpZdRJEy0kTRxQb7XBhVQ7/nHk01xC+YDgkRoKWzk2Z/M/VXwbP7RfZHM047QS
|
73
|
+
v4dk+NoS/zcnwbNDu+97bi5p9wIDAQABMA0GCSqGSIb3DQEBBQUAA4GBADt/UG9v
|
74
|
+
UJSZSWI4OB9L+KXIPqeCgfYrx+jFzug6EILLGACOTb2oWH+heQC1u+mNr0HZDzTu
|
75
|
+
IYEZoDJJKPTEjlbVUjP9UNV+mWwD5MlM/Mtsq2azSiGM5bUMMj4QssxsodyamEwC
|
76
|
+
W/POuZ6lcg5Ktz885hZo+L7tdEy8W9ViH0Pd
|
77
|
+
-----END CERTIFICATE-----
|
data/lib/agree2.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
require 'net/https'
|
2
2
|
require 'rubygems'
|
3
|
-
gem 'oauth', ">= 0.
|
3
|
+
gem 'oauth', ">= 0.3.5"
|
4
4
|
require 'oauth'
|
5
5
|
gem 'json'
|
6
6
|
gem 'activesupport'
|
@@ -20,15 +20,22 @@ require 'agree2/party'
|
|
20
20
|
require 'agree2/template'
|
21
21
|
|
22
22
|
|
23
|
-
|
24
|
-
|
25
|
-
class OAuth::Consumer
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
23
|
+
if OAuth::VERSION=='0.3.5'
|
24
|
+
unless OAuth::Consumer.method_defined? :create_http_with_ca_file_option
|
25
|
+
class OAuth::Consumer
|
26
|
+
alias_method :create_http_without_ca_file_option, :create_http
|
27
|
+
# monkey patch with ca_file option from 0.3.6 to allow us to set the agree2 certs
|
28
|
+
def create_http_with_ca_file_option(_url = nil)
|
29
|
+
http_object = create_http_without_ca_file_option(_url)
|
30
|
+
if http_object.use_ssl && @options[:ca_file]
|
31
|
+
http_object.ca_file = @options[:ca_file]
|
32
|
+
http_object.verify_mode = OpenSSL::SSL::VERIFY_PEER
|
33
|
+
http_object.verify_depth = 5
|
34
|
+
end
|
35
|
+
|
36
|
+
http_object
|
37
|
+
end
|
38
|
+
alias_method :create_http, :create_http_with_ca_file_option
|
39
|
+
end
|
32
40
|
end
|
33
|
-
|
34
|
-
end
|
41
|
+
end
|
data/lib/agree2/agreement.rb
CHANGED
@@ -1,7 +1,10 @@
|
|
1
1
|
module Agree2
|
2
2
|
class Agreement<Base
|
3
3
|
attr_serializable :permalink,:title,:body,:created_at,:updated_at,:smart_fields,:state,:active_version,
|
4
|
-
:version,:digest,:finalized_at,:
|
4
|
+
:version,:digest,:finalized_at,:terminated_at,:activated_at,:valid_to
|
5
|
+
|
6
|
+
attr_read_only :permalink,:state,:created_at,:updated_at,:active_version,:version,
|
7
|
+
:digest,:finalized_at,:terminated_at,:activated_at
|
5
8
|
|
6
9
|
alias_method :fields,:smart_fields
|
7
10
|
# Returns the parties to the agreement
|
@@ -17,6 +20,17 @@ module Agree2
|
|
17
20
|
permalink
|
18
21
|
end
|
19
22
|
|
23
|
+
# state of the agreement
|
24
|
+
# draft, final, active, terminated
|
25
|
+
def state
|
26
|
+
@state||=load_state
|
27
|
+
end
|
28
|
+
|
29
|
+
# has agreement been signed by all parties?
|
30
|
+
def active?
|
31
|
+
state=='active'
|
32
|
+
end
|
33
|
+
|
20
34
|
def respond_to?(symbol, include_priv = false) #:nodoc:
|
21
35
|
return true if super symbol,include_priv
|
22
36
|
return false if fields.nil?||fields.empty?
|
@@ -40,7 +54,7 @@ module Agree2
|
|
40
54
|
|
41
55
|
def attributes_for_save #:nodoc:
|
42
56
|
if new_record?
|
43
|
-
|
57
|
+
super
|
44
58
|
else
|
45
59
|
{"fields"=>fields}
|
46
60
|
end
|
@@ -67,5 +81,6 @@ module Agree2
|
|
67
81
|
end
|
68
82
|
end
|
69
83
|
|
84
|
+
|
70
85
|
end
|
71
86
|
end
|
data/lib/agree2/base.rb
CHANGED
@@ -17,6 +17,19 @@ module Agree2
|
|
17
17
|
def serializable_attributes # :nodoc:
|
18
18
|
read_inheritable_attribute("serializable_attributes")
|
19
19
|
end
|
20
|
+
|
21
|
+
def attr_read_only(*attributes) #:nodoc:
|
22
|
+
attributes.map!{|a|a.to_sym}
|
23
|
+
write_inheritable_attribute("read_only_attributes",
|
24
|
+
Set.new(attributes) +
|
25
|
+
(read_only_attributes || []))
|
26
|
+
protected *attributes.collect{|a| "#{a.to_s}=".to_sym }
|
27
|
+
end
|
28
|
+
|
29
|
+
# Returns an array of all the attributes that have been made accessible to mass-assignment.
|
30
|
+
def read_only_attributes # :nodoc:
|
31
|
+
read_inheritable_attribute("read_only_attributes")
|
32
|
+
end
|
20
33
|
|
21
34
|
def collection_path #:nodoc:
|
22
35
|
"/#{collection_name}"
|
@@ -104,8 +117,17 @@ module Agree2
|
|
104
117
|
|
105
118
|
protected
|
106
119
|
|
120
|
+
# Get the primary attributes of an object as a hash
|
121
|
+
def savable_attributes #:nodoc:
|
122
|
+
(self.class.serializable_attributes-self.class.read_only_attributes).inject({}) do |h,field|
|
123
|
+
value=self.send(field)
|
124
|
+
h[field]=value if value
|
125
|
+
h
|
126
|
+
end
|
127
|
+
end
|
128
|
+
|
107
129
|
def attributes_for_save #:nodoc:
|
108
|
-
{self.class.singular_name=>
|
130
|
+
{self.class.singular_name=>savable_attributes}
|
109
131
|
end
|
110
132
|
|
111
133
|
def decode(element) #:nodoc:
|
@@ -128,6 +150,12 @@ module Agree2
|
|
128
150
|
@from_wire=true
|
129
151
|
load_attributes(JSON.parse(json))
|
130
152
|
end
|
153
|
+
|
154
|
+
# Loads the state of the object if supported. This is much quicker than downloading and parsing json
|
155
|
+
def load_state #:nodoc:
|
156
|
+
user.get(to_url+".state",{"Accept"=>"text/plain"})
|
157
|
+
end
|
158
|
+
|
131
159
|
# private
|
132
160
|
#
|
133
161
|
# def method_missing(method_symbol, *arguments) #:nodoc:
|
data/lib/agree2/client.rb
CHANGED
@@ -42,7 +42,7 @@ module Agree2
|
|
42
42
|
#
|
43
43
|
# To get these register your application at: https://agree2.com/client_applications
|
44
44
|
def initialize(key,secret)
|
45
|
-
@consumer=OAuth::Consumer.new(key,secret,{:site=>AGREE2_URL})
|
45
|
+
@consumer=OAuth::Consumer.new(key,secret,{:site=>AGREE2_URL,:ca_file=>File.join(File.dirname(__FILE__), '..','..','certs','sf_bundle.crt')})
|
46
46
|
end
|
47
47
|
|
48
48
|
# initialize a new user object with the given token and secret. The user object is what you use to do most of the work.
|
@@ -63,8 +63,13 @@ module Agree2
|
|
63
63
|
# @request_token = @client.get_request_token
|
64
64
|
# redirect_to @request_token.authorize_url
|
65
65
|
#
|
66
|
-
|
67
|
-
|
66
|
+
# If you want to pass a callback_url you should do so here.
|
67
|
+
#
|
68
|
+
# @request_token = @client.get_request_token :oauth_callback => "http://example.com/cb"
|
69
|
+
# redirect_to @request_token.authorize_url
|
70
|
+
#
|
71
|
+
def get_request_token(request_options = {})
|
72
|
+
consumer.get_request_token request_options
|
68
73
|
end
|
69
74
|
|
70
75
|
# Exchange an Authorized RequestToken for a working user object
|
@@ -72,13 +77,16 @@ module Agree2
|
|
72
77
|
# === Required Field
|
73
78
|
#
|
74
79
|
# * <tt>request_token</tt> The Request token created using get_request_token and authorized on Agree2 by your user
|
80
|
+
# * <tt>oauth_verifier</tt> The oauth_verifier passed to your callback url
|
75
81
|
#
|
76
82
|
# Example:
|
83
|
+
#
|
84
|
+
# @request_token = ClientRequestToken.find_by_token params[:oauth_token]
|
85
|
+
# @user_client = @client.user_from_request_token(@request_token,params[:oauth_verifier])
|
77
86
|
#
|
78
|
-
# @user_client = @client.user_from_request_token(@request_token)
|
79
87
|
#
|
80
|
-
def user_from_request_token(request_token)
|
81
|
-
access_token=request_token.get_access_token
|
88
|
+
def user_from_request_token(request_token,oauth_verifier)
|
89
|
+
access_token=request_token.get_access_token(:oauth_verifier=>oauth_verifier)
|
82
90
|
user(access_token.token,access_token.secret)
|
83
91
|
rescue Net::HTTPServerException=>e
|
84
92
|
if e.response.code=='401'
|
data/lib/agree2/party.rb
CHANGED
@@ -1,6 +1,8 @@
|
|
1
1
|
module Agree2
|
2
2
|
class Party<Base
|
3
|
-
attr_serializable :id,:role,:email,:first_name,:last_name,:created_at,:updated_at,:organization_name
|
3
|
+
attr_serializable :id,:role,:email,:first_name,:last_name,:created_at,:updated_at,:organization_name,:status
|
4
|
+
attr_read_only :id,:status,:created_at,:updated_at
|
5
|
+
|
4
6
|
alias_method :agreement,:container
|
5
7
|
|
6
8
|
# Creates a one time signed url to redirect your user to their acceptance page. This url is only valid once. Call again to
|
@@ -10,6 +12,13 @@ module Agree2
|
|
10
12
|
AGREE2_URL+user.client.consumer.create_signed_request(:get,path,user.access_token,{:scheme=>:query_string}).path
|
11
13
|
end
|
12
14
|
|
15
|
+
# Status of party
|
16
|
+
# new|invited|accepted|declined
|
17
|
+
def status
|
18
|
+
@status||=load_state
|
19
|
+
end
|
20
|
+
|
21
|
+
|
13
22
|
def self.validate_parties_hash(parties) #:nodoc:
|
14
23
|
parties&&parties.each{|r,p| validate_party_hash(p)}
|
15
24
|
true
|
data/lib/agree2/user.rb
CHANGED
@@ -15,24 +15,24 @@ module Agree2
|
|
15
15
|
@templates||=Agree2::ProxyCollection.new self,'/masters','Template'
|
16
16
|
end
|
17
17
|
|
18
|
-
def get(path)
|
19
|
-
handle_response @access_token.get(path,
|
18
|
+
def get(path,options={})
|
19
|
+
handle_response @access_token.get(path,{'Accept'=>'application/json'}.merge(options))
|
20
20
|
end
|
21
21
|
|
22
|
-
def head(path)
|
23
|
-
handle_response @access_token.head(path,
|
22
|
+
def head(path,options={})
|
23
|
+
handle_response @access_token.head(path,options)
|
24
24
|
end
|
25
25
|
|
26
|
-
def post(path,data=nil)
|
27
|
-
handle_response @access_token.post(path,(data ? data.to_json : nil),AGREE2_JSON_HEADERS)
|
26
|
+
def post(path,data=nil,options={})
|
27
|
+
handle_response @access_token.post(path,(data ? data.to_json : nil),AGREE2_JSON_HEADERS.merge(options))
|
28
28
|
end
|
29
29
|
|
30
|
-
def put(path,data=nil)
|
31
|
-
handle_response @access_token.put(path,(data ? data.to_json : nil),AGREE2_JSON_HEADERS )
|
30
|
+
def put(path,data=nil,options={})
|
31
|
+
handle_response @access_token.put(path,(data ? data.to_json : nil),AGREE2_JSON_HEADERS.merge(options) )
|
32
32
|
end
|
33
33
|
|
34
|
-
def delete(path)
|
35
|
-
handle_response @access_token.delete(path,
|
34
|
+
def delete(path,options={})
|
35
|
+
handle_response @access_token.delete(path,options)
|
36
36
|
end
|
37
37
|
|
38
38
|
# OAuth Stuff below here
|
data/spec/agreement_spec.rb
CHANGED
@@ -12,7 +12,7 @@ describe Agree2::Agreement do
|
|
12
12
|
end
|
13
13
|
|
14
14
|
it "should have attribute hash" do
|
15
|
-
@agreement.
|
15
|
+
@agreement.send(:savable_attributes).should=={:title=>"My Title",:body=>"My Body"}
|
16
16
|
end
|
17
17
|
|
18
18
|
it "should have a user" do
|
data/spec/client_spec.rb
CHANGED
@@ -38,8 +38,8 @@ describe Agree2::Client do
|
|
38
38
|
access_token=mock("access_token")
|
39
39
|
access_token.stub!(:token).and_return('token')
|
40
40
|
access_token.stub!(:secret).and_return('token_secret')
|
41
|
-
request_token.should_receive(:get_access_token).and_return(access_token)
|
42
|
-
user=@client.user_from_request_token(request_token)
|
41
|
+
request_token.should_receive(:get_access_token).with(:oauth_verifier=>"verifier").and_return(access_token)
|
42
|
+
user=@client.user_from_request_token(request_token,"verifier")
|
43
43
|
user.client.should==@client
|
44
44
|
user.access_token.consumer.should==@client.consumer
|
45
45
|
user.token.should=="token"
|
data/spec/party_spec.rb
CHANGED
@@ -107,7 +107,7 @@ describe Party do
|
|
107
107
|
describe "Save to Server" do
|
108
108
|
before(:each) do
|
109
109
|
@user.should_receive(:put).with("/agreements/hello/parties/1102",
|
110
|
-
{'party'=>@party.
|
110
|
+
{'party'=>@party.send(:savable_attributes)}).and_return(@json)
|
111
111
|
end
|
112
112
|
|
113
113
|
it "should save and return true" do
|
data/spec/user_spec.rb
CHANGED
@@ -39,9 +39,14 @@ describe Agree2::User do
|
|
39
39
|
@response.stub!(:body).and_return(@json)
|
40
40
|
end
|
41
41
|
|
42
|
-
|
42
|
+
it "should perform http get" do
|
43
|
+
@token.should_receive(:get).with("/test",{'Accept'=>'application/json'}).and_return(@response)
|
44
|
+
@user.send(:get,"/test").should==@json
|
45
|
+
end
|
46
|
+
|
47
|
+
[:head,:delete].each do |m|
|
43
48
|
it "should perform http #{m.to_s}" do
|
44
|
-
@token.should_receive(m).with("/test",{
|
49
|
+
@token.should_receive(m).with("/test",{}).and_return(@response)
|
45
50
|
@user.send(m,"/test").should==@json
|
46
51
|
end
|
47
52
|
end
|
metadata
CHANGED
@@ -1,28 +1,17 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: agree2
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Pelle Braendgaard
|
8
|
-
- Lau Taarnskov
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
11
|
|
13
|
-
date:
|
12
|
+
date: 2009-07-31 00:00:00 -04:00
|
14
13
|
default_executable:
|
15
14
|
dependencies:
|
16
|
-
- !ruby/object:Gem::Dependency
|
17
|
-
name: ruby-hmac
|
18
|
-
type: :runtime
|
19
|
-
version_requirement:
|
20
|
-
version_requirements: !ruby/object:Gem::Requirement
|
21
|
-
requirements:
|
22
|
-
- - ">="
|
23
|
-
- !ruby/object:Gem::Version
|
24
|
-
version: 0.3.1
|
25
|
-
version:
|
26
15
|
- !ruby/object:Gem::Dependency
|
27
16
|
name: oauth
|
28
17
|
type: :runtime
|
@@ -31,7 +20,7 @@ dependencies:
|
|
31
20
|
requirements:
|
32
21
|
- - ">="
|
33
22
|
- !ruby/object:Gem::Version
|
34
|
-
version: 0.
|
23
|
+
version: 0.3.5
|
35
24
|
version:
|
36
25
|
- !ruby/object:Gem::Dependency
|
37
26
|
name: json
|
@@ -53,38 +42,47 @@ dependencies:
|
|
53
42
|
- !ruby/object:Gem::Version
|
54
43
|
version: 2.0.2
|
55
44
|
version:
|
56
|
-
description:
|
57
|
-
email:
|
58
|
-
- support@agree2.com
|
45
|
+
description: Ruby library for creating and managing agreements on Agree2
|
46
|
+
email: support@agree2.com
|
59
47
|
executables: []
|
60
48
|
|
61
49
|
extensions: []
|
62
50
|
|
63
51
|
extra_rdoc_files:
|
64
|
-
- History.txt
|
65
|
-
- License.txt
|
66
52
|
- README.rdoc
|
67
53
|
files:
|
54
|
+
- .gitignore
|
68
55
|
- History.txt
|
69
56
|
- License.txt
|
70
57
|
- README.rdoc
|
71
58
|
- Rakefile
|
59
|
+
- VERSION
|
60
|
+
- agree2.gemspec
|
61
|
+
- certs/sf_bundle.crt
|
72
62
|
- lib/agree2.rb
|
63
|
+
- lib/agree2/agreement.rb
|
73
64
|
- lib/agree2/base.rb
|
74
65
|
- lib/agree2/client.rb
|
75
|
-
- lib/agree2/user.rb
|
76
|
-
- lib/agree2/agreement.rb
|
77
66
|
- lib/agree2/party.rb
|
78
67
|
- lib/agree2/proxy_collection.rb
|
79
68
|
- lib/agree2/template.rb
|
69
|
+
- lib/agree2/user.rb
|
70
|
+
- spec/agreement_spec.rb
|
71
|
+
- spec/client_spec.rb
|
72
|
+
- spec/fixtures/agreement.json
|
73
|
+
- spec/fixtures/party.json
|
74
|
+
- spec/party_spec.rb
|
75
|
+
- spec/proxy_collection_spec.rb
|
76
|
+
- spec/spec_helper.rb
|
77
|
+
- spec/template_spec.rb
|
78
|
+
- spec/user_spec.rb
|
80
79
|
has_rdoc: true
|
81
|
-
homepage: http://agree2.
|
80
|
+
homepage: http://agree2.com
|
82
81
|
licenses: []
|
83
82
|
|
84
83
|
post_install_message:
|
85
84
|
rdoc_options:
|
86
|
-
- --
|
87
|
-
- README.rdoc
|
85
|
+
- --charset=UTF-8
|
88
86
|
require_paths:
|
89
87
|
- lib
|
90
88
|
required_ruby_version: !ruby/object:Gem::Requirement
|
@@ -102,17 +100,15 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
102
100
|
requirements: []
|
103
101
|
|
104
102
|
rubyforge_project: agree2
|
105
|
-
rubygems_version: 1.3.
|
103
|
+
rubygems_version: 1.3.5
|
106
104
|
signing_key:
|
107
|
-
specification_version:
|
108
|
-
summary:
|
105
|
+
specification_version: 3
|
106
|
+
summary: Ruby client library for Agree2
|
109
107
|
test_files:
|
110
|
-
- spec/spec_helper.rb
|
111
108
|
- spec/agreement_spec.rb
|
112
109
|
- spec/client_spec.rb
|
113
110
|
- spec/party_spec.rb
|
114
111
|
- spec/proxy_collection_spec.rb
|
112
|
+
- spec/spec_helper.rb
|
115
113
|
- spec/template_spec.rb
|
116
114
|
- spec/user_spec.rb
|
117
|
-
- spec/fixtures/agreement.json
|
118
|
-
- spec/fixtures/party.json
|