prawn_cocktail 0.5.0 → 0.5.1
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/.travis.yml +4 -0
- data/README.md +2 -8
- data/Rakefile +7 -0
- data/lib/prawn_cocktail/document.rb +1 -0
- data/lib/prawn_cocktail/version.rb +1 -1
- data/prawn_cocktail.gemspec +3 -0
- data/spec/fixtures/document.rb +20 -0
- data/spec/fixtures/test_document.pdf.rb +6 -0
- data/spec/integration_spec.rb +49 -0
- metadata +35 -6
data/.travis.yml
ADDED
data/README.md
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
# PrawnCocktail
|
2
2
|
|
3
|
+
[](https://travis-ci.org/#!/barsoom/prawn_cocktail/builds)
|
4
|
+
|
3
5
|
Simple documents, templates and helpers on top of Prawn.
|
4
6
|
|
5
7
|
Because writing Prawn documents PHP 4 style is no fun.
|
@@ -8,16 +10,8 @@ If you're using this with Ruby on Rails, get [`PrawnCocktailRails`](http://githu
|
|
8
10
|
|
9
11
|
Ruby 1.9 only since we use and love instance\_exec.
|
10
12
|
|
11
|
-
NOTE: Work in progress; well used but untested.
|
12
|
-
|
13
13
|

|
14
14
|
|
15
|
-
## TODO
|
16
|
-
|
17
|
-
* Tests.
|
18
|
-
* Syntax to declare page size shorthands?
|
19
|
-
* Include instead of inherit? Consider `class_attribute`.
|
20
|
-
|
21
15
|
## Usage
|
22
16
|
|
23
17
|
### Configuration
|
data/Rakefile
CHANGED
data/prawn_cocktail.gemspec
CHANGED
@@ -0,0 +1,20 @@
|
|
1
|
+
module TestDocumentHelper
|
2
|
+
def status_line(status)
|
3
|
+
text "Status: #{status}"
|
4
|
+
end
|
5
|
+
end
|
6
|
+
|
7
|
+
class TestDocument < PrawnCocktail::Document
|
8
|
+
helper TestDocumentHelper
|
9
|
+
initialize_document { text "Init works." }
|
10
|
+
|
11
|
+
def initialize(status)
|
12
|
+
@status = status
|
13
|
+
end
|
14
|
+
|
15
|
+
private
|
16
|
+
|
17
|
+
def data
|
18
|
+
{ status: @status }
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
require "minitest/autorun"
|
2
|
+
require "minitest/pride"
|
3
|
+
require "pdf/inspector"
|
4
|
+
|
5
|
+
require "prawn_cocktail"
|
6
|
+
|
7
|
+
PrawnCocktail.template_root = "spec/fixtures"
|
8
|
+
require_relative "fixtures/document"
|
9
|
+
|
10
|
+
describe PrawnCocktail do
|
11
|
+
describe "#render" do
|
12
|
+
it "works" do
|
13
|
+
data = TestDocument.new("success").render
|
14
|
+
assert_test_document data
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
describe "#render_file" do
|
19
|
+
it "works" do
|
20
|
+
TestDocument.new("success").render_file("/tmp/test_document.pdf")
|
21
|
+
data = File.read("/tmp/test_document.pdf")
|
22
|
+
assert_test_document data
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def assert_test_document(data)
|
28
|
+
assert_equal(
|
29
|
+
[ "Init works.", "Test document", "Status: success" ],
|
30
|
+
parse_strings(data)
|
31
|
+
)
|
32
|
+
|
33
|
+
assert_equal(
|
34
|
+
parse_geometry(data),
|
35
|
+
expected_geometry("A4")
|
36
|
+
)
|
37
|
+
end
|
38
|
+
|
39
|
+
def parse_strings(pdf_data)
|
40
|
+
PDF::Inspector::Text.analyze(pdf_data).strings
|
41
|
+
end
|
42
|
+
|
43
|
+
def parse_geometry(pdf_data)
|
44
|
+
PDF::Inspector::Page.analyze(pdf_data).pages.first[:size]
|
45
|
+
end
|
46
|
+
|
47
|
+
def expected_geometry(name)
|
48
|
+
Prawn::Document::PageGeometry::SIZES[name]
|
49
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: prawn_cocktail
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -13,7 +13,7 @@ date: 2013-02-23 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: prawn
|
16
|
-
requirement: &
|
16
|
+
requirement: &70216788921060 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70216788921060
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: activesupport
|
27
|
-
requirement: &
|
27
|
+
requirement: &70216788920580 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,7 +32,29 @@ dependencies:
|
|
32
32
|
version: '0'
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *70216788920580
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
name: rake
|
38
|
+
requirement: &70216776430360 !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
40
|
+
requirements:
|
41
|
+
- - ! '>='
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: '0'
|
44
|
+
type: :development
|
45
|
+
prerelease: false
|
46
|
+
version_requirements: *70216776430360
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: pdf-inspector
|
49
|
+
requirement: &70216776429880 !ruby/object:Gem::Requirement
|
50
|
+
none: false
|
51
|
+
requirements:
|
52
|
+
- - ! '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
type: :development
|
56
|
+
prerelease: false
|
57
|
+
version_requirements: *70216776429880
|
36
58
|
description:
|
37
59
|
email:
|
38
60
|
- henrik@barsoom.se
|
@@ -41,6 +63,7 @@ extensions: []
|
|
41
63
|
extra_rdoc_files: []
|
42
64
|
files:
|
43
65
|
- .gitignore
|
66
|
+
- .travis.yml
|
44
67
|
- Gemfile
|
45
68
|
- README.md
|
46
69
|
- Rakefile
|
@@ -50,6 +73,9 @@ files:
|
|
50
73
|
- lib/prawn_cocktail/renderer.rb
|
51
74
|
- lib/prawn_cocktail/version.rb
|
52
75
|
- prawn_cocktail.gemspec
|
76
|
+
- spec/fixtures/document.rb
|
77
|
+
- spec/fixtures/test_document.pdf.rb
|
78
|
+
- spec/integration_spec.rb
|
53
79
|
homepage: ''
|
54
80
|
licenses: []
|
55
81
|
post_install_message:
|
@@ -74,5 +100,8 @@ rubygems_version: 1.8.5
|
|
74
100
|
signing_key:
|
75
101
|
specification_version: 3
|
76
102
|
summary: Simple documents, templates and helpers on top of Prawn.
|
77
|
-
test_files:
|
103
|
+
test_files:
|
104
|
+
- spec/fixtures/document.rb
|
105
|
+
- spec/fixtures/test_document.pdf.rb
|
106
|
+
- spec/integration_spec.rb
|
78
107
|
has_rdoc:
|