postful 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/doc/classes/Postful/Letter.html +60 -60
- data/doc/classes/Postful/Letter.src/M000018.html +4 -4
- data/doc/classes/Postful/Letter.src/M000019.html +4 -4
- data/doc/classes/Postful/Letter.src/M000020.html +4 -4
- data/doc/classes/Postful/Letter.src/M000021.html +4 -4
- data/doc/classes/Postful/Letter.src/M000022.html +4 -4
- data/doc/classes/Postful/Letter.src/M000023.html +4 -4
- data/doc/classes/Postful/Letter.src/M000024.html +4 -4
- data/doc/classes/Postful/Letter.src/M000025.html +4 -4
- data/doc/classes/Postful/Letter.src/M000026.html +4 -4
- data/doc/classes/Postful/Letter.src/{M000016.html → M000027.html} +4 -4
- data/doc/classes/Postful/Letter.src/{M000017.html → M000028.html} +4 -4
- data/doc/classes/Postful/Letter.src/{M000015.html → M000029.html} +4 -4
- data/doc/classes/Postful/Postcard.html +222 -0
- data/doc/classes/Postful/{Service.src → Postcard.src}/M000011.html +4 -5
- data/doc/classes/Postful/Postcard.src/M000012.html +18 -0
- data/doc/classes/Postful/Postcard.src/M000013.html +18 -0
- data/doc/classes/Postful/Service.html +20 -20
- data/doc/classes/Postful/Service.src/M000014.html +5 -10
- data/doc/classes/Postful/Service.src/{M000012.html → M000015.html} +0 -0
- data/doc/classes/Postful/Service.src/{M000013.html → M000016.html} +0 -0
- data/doc/classes/Postful/Service.src/M000017.html +24 -0
- data/doc/created.rid +1 -1
- data/doc/files/README.html +42 -2
- data/doc/files/lib/postful/base_rb.html +1 -1
- data/doc/files/lib/postful/letter_rb.html +1 -1
- data/doc/files/lib/postful/postcard_rb.html +109 -0
- data/doc/files/lib/postful/service_rb.html +1 -1
- data/doc/files/lib/postful/util_rb.html +1 -1
- data/doc/files/lib/postful_rb.html +2 -1
- data/doc/fr_class_index.html +1 -0
- data/doc/fr_file_index.html +1 -0
- data/doc/fr_method_index.html +19 -16
- data/lib/postful.rb +2 -1
- data/lib/postful/base.rb +0 -1
- data/lib/postful/letter.rb +7 -3
- data/lib/postful/postcard.rb +162 -0
- data/lib/postful/util.rb +10 -7
- data/test/suite.rb +1 -0
- data/test/test_letter.rb +2 -2
- data/test/test_postcard.rb +104 -2
- metadata +15 -8
data/test/suite.rb
CHANGED
data/test/test_letter.rb
CHANGED
|
@@ -95,13 +95,13 @@ class TestLetter < Test::Unit::TestCase
|
|
|
95
95
|
end
|
|
96
96
|
|
|
97
97
|
def test_requires_document
|
|
98
|
-
@letter.add_international_address ['Buckingham Palace', 'London SW1A 1AA'], 'ENGLAND'
|
|
98
|
+
@letter.add_international_address ['The Queen', 'Buckingham Palace', 'London SW1A 1AA'], 'ENGLAND'
|
|
99
99
|
assert !@letter.valid?
|
|
100
100
|
assert_equal 'Requires at least one document', @letter.errors.first
|
|
101
101
|
end
|
|
102
102
|
|
|
103
103
|
def test_valid_with_letter_and_document
|
|
104
|
-
@letter.add_international_address ['Buckingham Palace', 'London SW1A 1AA'], 'ENGLAND'
|
|
104
|
+
@letter.add_international_address ['The Queen', 'Buckingham Palace', 'London SW1A 1AA'], 'ENGLAND'
|
|
105
105
|
@letter.add_pdf_document 'Example PDF Document'
|
|
106
106
|
assert @letter.send(:valid?)
|
|
107
107
|
end
|
data/test/test_postcard.rb
CHANGED
|
@@ -1,12 +1,114 @@
|
|
|
1
1
|
require 'test/unit'
|
|
2
2
|
require 'fake_web'
|
|
3
|
+
require 'lib/postful/postcard'
|
|
3
4
|
|
|
4
5
|
class TestPostcard < Test::Unit::TestCase
|
|
6
|
+
include Postful
|
|
5
7
|
def setup
|
|
6
|
-
|
|
8
|
+
@postcard = Postcard.new('email', 'password')
|
|
9
|
+
@valid_postcard = Postcard.new('email', 'password')
|
|
10
|
+
@valid_postcard.add_address :name => 'John Doe',
|
|
11
|
+
:address => '123 Main St',
|
|
12
|
+
:city => 'Anytown',
|
|
13
|
+
:state => 'AZ',
|
|
14
|
+
:postal_code => '10000'
|
|
15
|
+
FakeWeb.register_uri('https://www.postful.com/service/upload', :string => %(
|
|
16
|
+
<?xml version="1.0" encoding="UTF-8"?><upload><id>290797321.waltershandy.2</id></upload>))
|
|
7
17
|
end
|
|
8
18
|
|
|
9
|
-
def
|
|
19
|
+
def test_adding_border_chooses_fit
|
|
20
|
+
@postcard.add_border
|
|
21
|
+
assert_equal Postcard::FIT, @postcard.send(:choose_template)
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def test_adding_two_images_choose_images
|
|
25
|
+
@postcard.front_image = 'data'
|
|
26
|
+
@postcard.back_image = 'data'
|
|
27
|
+
assert_equal Postcard::IMAGES, @postcard.send(:choose_template)
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def test_adding_no_border_chooses_fill
|
|
31
|
+
@postcard.front_image = 'data'
|
|
32
|
+
assert_equal Postcard::FILL, @postcard.send(:choose_template)
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def test_valid
|
|
36
|
+
@valid_postcard.front_image = 'image'
|
|
37
|
+
@valid_postcard.back_text = 'text'
|
|
38
|
+
assert @valid_postcard.valid?
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
def test_back_image_and_text_invalid
|
|
42
|
+
@valid_postcard.back_text = 'text'
|
|
43
|
+
@valid_postcard.back_image = 'image'
|
|
44
|
+
assert !@valid_postcard.valid?
|
|
45
|
+
assert_equal "Cannot have both image and text on back", @valid_postcard.errors.first
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
def test_back_image_and_border_invalid
|
|
49
|
+
@valid_postcard.add_border
|
|
50
|
+
@valid_postcard.back_image = 'image'
|
|
51
|
+
assert !@valid_postcard.valid?
|
|
52
|
+
assert_equal "Cannot have both front border and image on back", @valid_postcard.errors.first
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
def test_requires_front
|
|
56
|
+
@valid_postcard.back_image = 'image'
|
|
57
|
+
assert !@valid_postcard.valid?
|
|
58
|
+
assert_equal "Must have image on front", @valid_postcard.errors.first
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
def test_requires_back
|
|
62
|
+
@valid_postcard.front_image = 'image'
|
|
63
|
+
assert !@valid_postcard.valid?
|
|
64
|
+
assert_equal "Must have either text or image on back", @valid_postcard.errors.first
|
|
65
|
+
end
|
|
10
66
|
|
|
67
|
+
def test_front_image_from_file
|
|
68
|
+
@valid_postcard.front_image_from_file = fixture('sample.txt')
|
|
69
|
+
assert_equal 'Hello, world!', @valid_postcard.front_image
|
|
11
70
|
end
|
|
71
|
+
|
|
72
|
+
def test_back_image_from_file
|
|
73
|
+
@valid_postcard.back_image_from_file = fixture('sample.txt')
|
|
74
|
+
assert_equal 'Hello, world!', @valid_postcard.back_image
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
def test_fit
|
|
78
|
+
@valid_postcard.add_border
|
|
79
|
+
@valid_postcard.front_image = 'image'
|
|
80
|
+
@valid_postcard.back_text = 'text'
|
|
81
|
+
assert @valid_postcard.valid?
|
|
82
|
+
assert_equal %(<mail><documents><document><template><source>gallery</source><name>Postcard: Image fit front</name></template><sections><section><name>Text</name><text>text</text></section><section><name>Image</name><attachment>290797321.waltershandy.2</attachment></section></sections></document></documents><addressees><addressee><name>John Doe</name><address>123 Main St</address><city>Anytown</city><state>AZ</state><postal-code>10000</postal-code></addressee></addressees></mail>),
|
|
83
|
+
build_request(@valid_postcard)
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
def test_fill
|
|
87
|
+
@valid_postcard.front_image = 'image'
|
|
88
|
+
@valid_postcard.back_text = 'text'
|
|
89
|
+
assert @valid_postcard.valid?
|
|
90
|
+
assert_equal %(<mail><documents><document><template><source>gallery</source><name>Postcard: Image fill front</name></template><sections><section><name>Text</name><text>text</text></section><section><name>Image</name><attachment>290797321.waltershandy.2</attachment></section></sections></document></documents><addressees><addressee><name>John Doe</name><address>123 Main St</address><city>Anytown</city><state>AZ</state><postal-code>10000</postal-code></addressee></addressees></mail>),
|
|
91
|
+
build_request(@valid_postcard)
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
def test_two_images
|
|
95
|
+
@valid_postcard.front_image = 'image'
|
|
96
|
+
@valid_postcard.back_image = 'image'
|
|
97
|
+
assert_equal %(<mail><documents><document><template><source>gallery</source><name>Postcard: Image front and back</name></template><sections><section><name>Back</name><attachment>290797321.waltershandy.2</attachment></section><section><name>Front</name><attachment>290797321.waltershandy.2</attachment></section></sections></document></documents><addressees><addressee><name>John Doe</name><address>123 Main St</address><city>Anytown</city><state>AZ</state><postal-code>10000</postal-code></addressee></addressees></mail>),
|
|
98
|
+
build_request(@valid_postcard)
|
|
99
|
+
end
|
|
100
|
+
|
|
101
|
+
private
|
|
102
|
+
|
|
103
|
+
def build_request(postcard)
|
|
104
|
+
postcard.send :build_sections
|
|
105
|
+
postcard.send :upload_attachments
|
|
106
|
+
postcard.send :build_template_document
|
|
107
|
+
postcard.send(:build_request)
|
|
108
|
+
end
|
|
109
|
+
|
|
110
|
+
def fixture(filename)
|
|
111
|
+
File.join(File.dirname(__FILE__), 'fixtures', filename)
|
|
112
|
+
end
|
|
113
|
+
|
|
12
114
|
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: postful
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.2.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Postful, Inc
|
|
@@ -9,7 +9,7 @@ autorequire:
|
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
11
|
|
|
12
|
-
date: 2008-08-
|
|
12
|
+
date: 2008-08-12 00:00:00 -07:00
|
|
13
13
|
default_executable:
|
|
14
14
|
dependencies:
|
|
15
15
|
- !ruby/object:Gem::Dependency
|
|
@@ -35,6 +35,7 @@ files:
|
|
|
35
35
|
- lib/postful/instance_exec_module.rb
|
|
36
36
|
- lib/postful/letter.rb
|
|
37
37
|
- lib/postful/order.rb
|
|
38
|
+
- lib/postful/postcard.rb
|
|
38
39
|
- lib/postful/service.rb
|
|
39
40
|
- lib/postful/util.rb
|
|
40
41
|
- lib/postful.rb
|
|
@@ -56,9 +57,6 @@ files:
|
|
|
56
57
|
- doc/classes/Postful/InternalServerError.html
|
|
57
58
|
- doc/classes/Postful/Letter.html
|
|
58
59
|
- doc/classes/Postful/Letter.src
|
|
59
|
-
- doc/classes/Postful/Letter.src/M000015.html
|
|
60
|
-
- doc/classes/Postful/Letter.src/M000016.html
|
|
61
|
-
- doc/classes/Postful/Letter.src/M000017.html
|
|
62
60
|
- doc/classes/Postful/Letter.src/M000018.html
|
|
63
61
|
- doc/classes/Postful/Letter.src/M000019.html
|
|
64
62
|
- doc/classes/Postful/Letter.src/M000020.html
|
|
@@ -68,6 +66,9 @@ files:
|
|
|
68
66
|
- doc/classes/Postful/Letter.src/M000024.html
|
|
69
67
|
- doc/classes/Postful/Letter.src/M000025.html
|
|
70
68
|
- doc/classes/Postful/Letter.src/M000026.html
|
|
69
|
+
- doc/classes/Postful/Letter.src/M000027.html
|
|
70
|
+
- doc/classes/Postful/Letter.src/M000028.html
|
|
71
|
+
- doc/classes/Postful/Letter.src/M000029.html
|
|
71
72
|
- doc/classes/Postful/NotFoundException.html
|
|
72
73
|
- doc/classes/Postful/Order.html
|
|
73
74
|
- doc/classes/Postful/Order.src
|
|
@@ -75,12 +76,17 @@ files:
|
|
|
75
76
|
- doc/classes/Postful/Order.src/M000008.html
|
|
76
77
|
- doc/classes/Postful/Order.src/M000009.html
|
|
77
78
|
- doc/classes/Postful/Order.src/M000010.html
|
|
79
|
+
- doc/classes/Postful/Postcard.html
|
|
80
|
+
- doc/classes/Postful/Postcard.src
|
|
81
|
+
- doc/classes/Postful/Postcard.src/M000011.html
|
|
82
|
+
- doc/classes/Postful/Postcard.src/M000012.html
|
|
83
|
+
- doc/classes/Postful/Postcard.src/M000013.html
|
|
78
84
|
- doc/classes/Postful/Service.html
|
|
79
85
|
- doc/classes/Postful/Service.src
|
|
80
|
-
- doc/classes/Postful/Service.src/M000011.html
|
|
81
|
-
- doc/classes/Postful/Service.src/M000012.html
|
|
82
|
-
- doc/classes/Postful/Service.src/M000013.html
|
|
83
86
|
- doc/classes/Postful/Service.src/M000014.html
|
|
87
|
+
- doc/classes/Postful/Service.src/M000015.html
|
|
88
|
+
- doc/classes/Postful/Service.src/M000016.html
|
|
89
|
+
- doc/classes/Postful/Service.src/M000017.html
|
|
84
90
|
- doc/classes/Postful/UnknownResponseException.html
|
|
85
91
|
- doc/classes/Postful/ValidationException.html
|
|
86
92
|
- doc/created.rid
|
|
@@ -88,6 +94,7 @@ files:
|
|
|
88
94
|
- doc/files/lib/postful/instance_exec_module_rb.html
|
|
89
95
|
- doc/files/lib/postful/letter_rb.html
|
|
90
96
|
- doc/files/lib/postful/order_rb.html
|
|
97
|
+
- doc/files/lib/postful/postcard_rb.html
|
|
91
98
|
- doc/files/lib/postful/service_rb.html
|
|
92
99
|
- doc/files/lib/postful/util_rb.html
|
|
93
100
|
- doc/files/lib/postful_rb.html
|