docusign 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +2 -0
- data/History.txt +3 -0
- data/Manifest.txt +18 -0
- data/README.txt +43 -0
- data/Rakefile +80 -0
- data/VERSION +1 -0
- data/bin/docusign +0 -0
- data/docusign.gemspec +82 -0
- data/lib/Credential.wsdl +183 -0
- data/lib/DocuSign3.0.10API.wsdl +2376 -0
- data/lib/docusign.rb +40 -0
- data/lib/docusign/anchor_tab.rb +5 -0
- data/lib/docusign/auth_header_handler.rb +36 -0
- data/lib/docusign/base.rb +46 -0
- data/lib/docusign/builder/anchor_builder.rb +7 -0
- data/lib/docusign/builder/base.rb +27 -0
- data/lib/docusign/builder/tab_builder.rb +26 -0
- data/lib/docusign/credential.rb +136 -0
- data/lib/docusign/credentialDriver.rb +65 -0
- data/lib/docusign/credentialMappingRegistry.rb +128 -0
- data/lib/docusign/document.rb +30 -0
- data/lib/docusign/docusign.rb +2624 -0
- data/lib/docusign/docusignDriver.rb +321 -0
- data/lib/docusign/docusignMappingRegistry.rb +2920 -0
- data/lib/docusign/extensions.rb +41 -0
- data/lib/docusign/tab.rb +26 -0
- data/lib/docusign/utilities.rb +8 -0
- data/spec/docusign/builder/anchor_builder_spec.rb +49 -0
- data/spec/docusign/builder/tab_builder_spec.rb +74 -0
- data/spec/docusign/document_spec.rb +51 -0
- data/spec/spec.opts +4 -0
- data/spec/spec_helper.rb +2 -0
- data/tasks/docusign_tasks.rake +30 -0
- data/test/test_docusign.rb +0 -0
- metadata +103 -0
@@ -0,0 +1,41 @@
|
|
1
|
+
# AutoCamelize
|
2
|
+
#
|
3
|
+
# This module enables a class to automatically map
|
4
|
+
# Ruby-esque snake_case method calls to the equivalent
|
5
|
+
# camelCase calls. If a method with a camelCase equivalent
|
6
|
+
# is found, we alias the snake_case method on the
|
7
|
+
# class, to avoid tripping method_missing for the same
|
8
|
+
# method in the future.
|
9
|
+
|
10
|
+
module AutoCamelize
|
11
|
+
def method_missing(method_name, *args, &block)
|
12
|
+
ds_name = ds_equivalent(method_name)
|
13
|
+
|
14
|
+
if ds_name && respond_to?(ds_name)
|
15
|
+
self.class.class_eval %Q{
|
16
|
+
alias :#{method_name} :#{ds_name}
|
17
|
+
}
|
18
|
+
|
19
|
+
send method_name, *args, &block
|
20
|
+
else
|
21
|
+
super
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
# Find the equivalent built-in method name, if there is one.
|
26
|
+
# Example:
|
27
|
+
# ds_equivalent('pdf_bytes') => 'pDFBytes'
|
28
|
+
|
29
|
+
def ds_equivalent(string)
|
30
|
+
string = string.to_s.camelize(:lower)
|
31
|
+
methods.find { |m| m.downcase == string.downcase }
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
Docusign.constants.each do |c|
|
36
|
+
constant = Docusign.const_get c
|
37
|
+
if constant.is_a? Class
|
38
|
+
constant.send :include, AutoCamelize
|
39
|
+
constant.extend AutoCamelize
|
40
|
+
end
|
41
|
+
end
|
data/lib/docusign/tab.rb
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
module Docusign
|
2
|
+
class Tab
|
3
|
+
def anchor(options = {}, &block)
|
4
|
+
returning anchor_builder.build(options, &block) do |a|
|
5
|
+
yield a if block_given?
|
6
|
+
self.anchor_tab_item = a
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
def anchor=(options = {})
|
11
|
+
anchor options
|
12
|
+
end
|
13
|
+
|
14
|
+
def anchor_builder
|
15
|
+
@anchor_builder ||= Docusign::Builder::AnchorBuilder.new
|
16
|
+
end
|
17
|
+
|
18
|
+
%w(recipient document).each do |attr|
|
19
|
+
class_eval %Q{
|
20
|
+
def #{attr}=(value)
|
21
|
+
self.#{attr}ID = value.id
|
22
|
+
end
|
23
|
+
}
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
require 'spec/spec_helper'
|
2
|
+
|
3
|
+
describe Docusign::Builder::AnchorBuilder do
|
4
|
+
describe "#initialize" do
|
5
|
+
it "should return a new AnchorBuilder" do
|
6
|
+
Docusign::Builder::AnchorBuilder.new.should be_an_instance_of(Docusign::Builder::AnchorBuilder)
|
7
|
+
end
|
8
|
+
|
9
|
+
describe "#build" do
|
10
|
+
before(:each) do
|
11
|
+
@ab = Docusign::Builder::AnchorBuilder.new
|
12
|
+
end
|
13
|
+
|
14
|
+
context "with no arguments" do
|
15
|
+
it "should return a new Docusign::AnchorTab" do
|
16
|
+
@ab.build.should be_an_instance_of(Docusign::AnchorTab)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
context "passing in attributes from a hash" do
|
21
|
+
before(:each) do
|
22
|
+
@anchor = @ab.build :x_offset => 2, :y_offset => 3, :anchor_tab_string => 'foo'
|
23
|
+
end
|
24
|
+
|
25
|
+
it "should set attributes from the passed-in hash" do
|
26
|
+
@anchor.x_offset.should == 2
|
27
|
+
@anchor.y_offset.should == 3
|
28
|
+
@anchor.anchor_tab_string.should == 'foo'
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
context "passing in attributes from a block" do
|
33
|
+
before(:each) do
|
34
|
+
@anchor = @ab.build do |a|
|
35
|
+
a.x_offset = 2
|
36
|
+
a.y_offset = 3
|
37
|
+
a.anchor_tab_string = 'foo'
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
it "should set attributes from the passed-in block" do
|
42
|
+
@anchor.x_offset.should == 2
|
43
|
+
@anchor.y_offset.should == 3
|
44
|
+
@anchor.anchor_tab_string.should == 'foo'
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
@@ -0,0 +1,74 @@
|
|
1
|
+
require 'spec/spec_helper'
|
2
|
+
|
3
|
+
describe Docusign::Builder::TabBuilder do
|
4
|
+
def init_tab_builder
|
5
|
+
@document = stub(:id => 1)
|
6
|
+
@recipient = stub(:id => 1)
|
7
|
+
@tb = Docusign::Builder::TabBuilder.new @document, @recipient
|
8
|
+
end
|
9
|
+
|
10
|
+
describe "#initialize" do
|
11
|
+
before(:each) do
|
12
|
+
init_tab_builder
|
13
|
+
end
|
14
|
+
|
15
|
+
it "should return an instance of itself" do
|
16
|
+
@tb.should be_an_instance_of(Docusign::Builder::TabBuilder)
|
17
|
+
end
|
18
|
+
|
19
|
+
it "should set the document" do
|
20
|
+
@tb.document.should == @document
|
21
|
+
end
|
22
|
+
|
23
|
+
it "should set the recipient if passed in" do
|
24
|
+
@tb.recipient.should == @recipient
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
describe "#build" do
|
29
|
+
before(:each) do
|
30
|
+
init_tab_builder
|
31
|
+
end
|
32
|
+
|
33
|
+
it "should return a new tab with no arguments" do
|
34
|
+
@tb.build.should be_an_instance_of(Docusign::Tab)
|
35
|
+
end
|
36
|
+
|
37
|
+
it "should set attributes passed in via options" do
|
38
|
+
tab = @tb.build :name => 'foo', :value => 'bar'
|
39
|
+
|
40
|
+
tab.name.should == 'foo'
|
41
|
+
tab.value.should == 'bar'
|
42
|
+
end
|
43
|
+
|
44
|
+
it "should set attributes via block" do
|
45
|
+
tab = @tb.build do |t|
|
46
|
+
t.name = 'foo'
|
47
|
+
t.value = 'bar'
|
48
|
+
end
|
49
|
+
|
50
|
+
tab.name.should == 'foo'
|
51
|
+
tab.value.should == 'bar'
|
52
|
+
end
|
53
|
+
|
54
|
+
it "should set the document and recipient" do
|
55
|
+
tab = @tb.build
|
56
|
+
tab.document_id.should == @document.id
|
57
|
+
tab.recipient_id.should == @recipient.id
|
58
|
+
end
|
59
|
+
|
60
|
+
context "overriding document and recipient" do
|
61
|
+
before(:each) do
|
62
|
+
@tab = @tb.build :document_id => 3, :recipient_id => 2
|
63
|
+
end
|
64
|
+
|
65
|
+
it "should not set a default document" do
|
66
|
+
@tab.document_id.should == 3
|
67
|
+
end
|
68
|
+
|
69
|
+
it "should not set a default recipient" do
|
70
|
+
@tab.recipient_id.should == 2
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
require 'spec/spec_helper'
|
2
|
+
|
3
|
+
describe Docusign::Document do
|
4
|
+
before(:each) do
|
5
|
+
@d = Docusign::Document.new
|
6
|
+
end
|
7
|
+
|
8
|
+
it "should create a new document" do
|
9
|
+
@d.should be_an_instance_of(Docusign::Document)
|
10
|
+
end
|
11
|
+
|
12
|
+
it "should respond to tabs" do
|
13
|
+
@d.should respond_to(:tabs)
|
14
|
+
end
|
15
|
+
|
16
|
+
describe "#tabs" do
|
17
|
+
context "with no arguments" do
|
18
|
+
it "should return an empty tab array" do
|
19
|
+
@d.tabs.should == Docusign::ArrayOfTab.new
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
context "with arguments" do
|
24
|
+
before(:each) do
|
25
|
+
@tabs = @d.tabs stub(:id => 1) do |d|
|
26
|
+
d.tab :name => 'tab_1', :value => 'foo'
|
27
|
+
d.tab :name => 'tab_2', :value => 'bar'
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
it "should build tabs" do
|
32
|
+
@tabs.all? { |t| t.is_a?(Docusign::Tab) }.should be_true
|
33
|
+
end
|
34
|
+
|
35
|
+
it "should build the appropriate number of tabs" do
|
36
|
+
@tabs.size.should == 2
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
describe "#tab" do
|
42
|
+
it "should build a tab" do
|
43
|
+
@d.tab.should be_an_instance_of(Docusign::Tab)
|
44
|
+
end
|
45
|
+
|
46
|
+
it "should pass in arguments" do
|
47
|
+
tab = @d.tab :document_id => 1
|
48
|
+
tab.document_id.should == 1
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
data/spec/spec.opts
ADDED
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
# Generates SOAP stubs for Salesforce Enterprise API.
|
2
|
+
# Requires a /config/salesforce/enterprise.wsdl.xml
|
3
|
+
|
4
|
+
require 'rubygems'
|
5
|
+
gem 'soap4r'
|
6
|
+
require 'wsdl/soap/wsdl2ruby'
|
7
|
+
|
8
|
+
namespace :docusign do
|
9
|
+
namespace :services do
|
10
|
+
desc "Generate SOAP stubs for Salesforce API"
|
11
|
+
task :generate => [:environment] do
|
12
|
+
wsdl_path = File.expand_path(File.dirname(__FILE__) + "/../lib/DocuSign3.0.10API.wsdl")
|
13
|
+
wsdl2ruby('docusign', 'Docusign', "file://#{wsdl_path}")
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
private
|
19
|
+
|
20
|
+
def wsdl2ruby(name, module_name, url)
|
21
|
+
g = WSDL::SOAP::WSDL2Ruby.new
|
22
|
+
g.location = url
|
23
|
+
g.basedir = File.expand_path(File.dirname(__FILE__) + "/../lib/")
|
24
|
+
g.opt['classdef'] = name
|
25
|
+
g.opt['driver'] = nil
|
26
|
+
g.opt['module_path'] = module_name
|
27
|
+
g.opt['mapping_registry'] = true
|
28
|
+
g.opt['force'] = true
|
29
|
+
g.run
|
30
|
+
end
|
File without changes
|
metadata
ADDED
@@ -0,0 +1,103 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: docusign
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 0
|
7
|
+
- 5
|
8
|
+
- 0
|
9
|
+
version: 0.5.0
|
10
|
+
platform: ruby
|
11
|
+
authors:
|
12
|
+
- Leigh Caplan
|
13
|
+
autorequire:
|
14
|
+
bindir: bin
|
15
|
+
cert_chain: []
|
16
|
+
|
17
|
+
date: 2010-03-20 00:00:00 -07:00
|
18
|
+
default_executable: docusign
|
19
|
+
dependencies: []
|
20
|
+
|
21
|
+
description: |
|
22
|
+
A library for working with the Docusign API and associated objects.
|
23
|
+
Provides SOAP4R-generated proxy classes, and extends many useful classes
|
24
|
+
with familiar Ruby-like syntax.
|
25
|
+
|
26
|
+
email: texel1@gmail.com
|
27
|
+
executables:
|
28
|
+
- docusign
|
29
|
+
extensions: []
|
30
|
+
|
31
|
+
extra_rdoc_files:
|
32
|
+
- README.txt
|
33
|
+
files:
|
34
|
+
- .gitignore
|
35
|
+
- History.txt
|
36
|
+
- Manifest.txt
|
37
|
+
- README.txt
|
38
|
+
- Rakefile
|
39
|
+
- VERSION
|
40
|
+
- bin/docusign
|
41
|
+
- docusign.gemspec
|
42
|
+
- lib/Credential.wsdl
|
43
|
+
- lib/DocuSign3.0.10API.wsdl
|
44
|
+
- lib/docusign.rb
|
45
|
+
- lib/docusign/anchor_tab.rb
|
46
|
+
- lib/docusign/auth_header_handler.rb
|
47
|
+
- lib/docusign/base.rb
|
48
|
+
- lib/docusign/builder/anchor_builder.rb
|
49
|
+
- lib/docusign/builder/base.rb
|
50
|
+
- lib/docusign/builder/tab_builder.rb
|
51
|
+
- lib/docusign/credential.rb
|
52
|
+
- lib/docusign/credentialDriver.rb
|
53
|
+
- lib/docusign/credentialMappingRegistry.rb
|
54
|
+
- lib/docusign/document.rb
|
55
|
+
- lib/docusign/docusign.rb
|
56
|
+
- lib/docusign/docusignDriver.rb
|
57
|
+
- lib/docusign/docusignMappingRegistry.rb
|
58
|
+
- lib/docusign/extensions.rb
|
59
|
+
- lib/docusign/tab.rb
|
60
|
+
- lib/docusign/utilities.rb
|
61
|
+
- spec/docusign/builder/anchor_builder_spec.rb
|
62
|
+
- spec/docusign/builder/tab_builder_spec.rb
|
63
|
+
- spec/docusign/document_spec.rb
|
64
|
+
- spec/spec.opts
|
65
|
+
- spec/spec_helper.rb
|
66
|
+
- tasks/docusign_tasks.rake
|
67
|
+
- test/test_docusign.rb
|
68
|
+
has_rdoc: true
|
69
|
+
homepage: http://github.com/texel/docusign
|
70
|
+
licenses: []
|
71
|
+
|
72
|
+
post_install_message:
|
73
|
+
rdoc_options:
|
74
|
+
- --charset=UTF-8
|
75
|
+
require_paths:
|
76
|
+
- lib
|
77
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
78
|
+
requirements:
|
79
|
+
- - ">="
|
80
|
+
- !ruby/object:Gem::Version
|
81
|
+
segments:
|
82
|
+
- 0
|
83
|
+
version: "0"
|
84
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
85
|
+
requirements:
|
86
|
+
- - ">="
|
87
|
+
- !ruby/object:Gem::Version
|
88
|
+
segments:
|
89
|
+
- 0
|
90
|
+
version: "0"
|
91
|
+
requirements: []
|
92
|
+
|
93
|
+
rubyforge_project:
|
94
|
+
rubygems_version: 1.3.6
|
95
|
+
signing_key:
|
96
|
+
specification_version: 3
|
97
|
+
summary: A library for working with the Docusign API and associated objects
|
98
|
+
test_files:
|
99
|
+
- spec/docusign/builder/anchor_builder_spec.rb
|
100
|
+
- spec/docusign/builder/tab_builder_spec.rb
|
101
|
+
- spec/docusign/document_spec.rb
|
102
|
+
- spec/spec_helper.rb
|
103
|
+
- test/test_docusign.rb
|