prawn_cocktail 0.5.0 → 0.5.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,4 @@
1
+ language: ruby
2
+ rvm:
3
+ - 1.9.3
4
+ - rbx-19mode
data/README.md CHANGED
@@ -1,5 +1,7 @@
1
1
  # PrawnCocktail
2
2
 
3
+ [![Build status](https://secure.travis-ci.org/barsoom/prawn_cocktail.png)](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
  ![](http://upload.wikimedia.org/wikipedia/commons/f/f8/Cocktail_1_bg_060702.jpg)
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
@@ -1 +1,8 @@
1
1
  require "bundler/gem_tasks"
2
+ require "rake/testtask"
3
+
4
+ Rake::TestTask.new do |t|
5
+ t.pattern = "spec/*_spec.rb"
6
+ end
7
+
8
+ task :default => :test
@@ -1,5 +1,6 @@
1
1
  require "prawn"
2
2
  require "active_support/core_ext/class/attribute"
3
+ require "active_support/inflector"
3
4
 
4
5
  require_relative "renderer"
5
6
 
@@ -1,3 +1,3 @@
1
1
  module PrawnCocktail
2
- VERSION = "0.5.0"
2
+ VERSION = "0.5.1"
3
3
  end
@@ -18,4 +18,7 @@ Gem::Specification.new do |gem|
18
18
 
19
19
  gem.add_dependency "prawn"
20
20
  gem.add_dependency "activesupport"
21
+
22
+ gem.add_development_dependency "rake" # For Travis CI.
23
+ gem.add_development_dependency "pdf-inspector"
21
24
  end
@@ -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,6 @@
1
+ meta page_size: "A4"
2
+
3
+ content do |data|
4
+ text "Test document"
5
+ status_line data.status
6
+ 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.0
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: &70333264743560 !ruby/object:Gem::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: *70333264743560
24
+ version_requirements: *70216788921060
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: activesupport
27
- requirement: &70333264742900 !ruby/object:Gem::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: *70333264742900
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: