prawn_cocktail_rails 0.1.0 → 0.2.0

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
+ - 2.0.0
4
+ - 1.9.3
data/README.md CHANGED
@@ -2,12 +2,6 @@
2
2
 
3
3
  Ruby on Rails integration for [PrawnCocktail](http://github.com/barsoom/prawn_cocktail).
4
4
 
5
- NOTE: Work in progress; well used but untested.
6
-
7
- ## TODO
8
-
9
- * Tests
10
-
11
5
  ## Usage
12
6
 
13
7
  Please see [PrawnCocktail](http://github.com/barsoom/prawn_cocktail).
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
@@ -6,5 +6,3 @@ require "prawn_cocktail"
6
6
  class ActionController::Base
7
7
  include PrawnCocktailRails::Controller
8
8
  end
9
-
10
- PrawnCocktail.template_root = "app/views/documents"
@@ -5,5 +5,9 @@ module PrawnCocktailRails
5
5
  initializer "prawn_cocktail.autoload", before: :set_autoload_paths do |app|
6
6
  app.config.autoload_paths << "#{app.config.root}/app/documents/helpers"
7
7
  end
8
+
9
+ initializer "prawn_cocktail.set_template_root" do |app|
10
+ PrawnCocktail.template_root = app.config.root.join("app/views/documents")
11
+ end
8
12
  end
9
13
  end
@@ -1,3 +1,3 @@
1
1
  module PrawnCocktailRails
2
- VERSION = "0.1.0"
2
+ VERSION = "0.2.0"
3
3
  end
@@ -8,7 +8,7 @@ Gem::Specification.new do |gem|
8
8
  gem.version = PrawnCocktailRails::VERSION
9
9
  gem.authors = ["Henrik Nyh"]
10
10
  gem.email = ["henrik@barsoom.se"]
11
- gem.summary = "PrawnCocktail on Rails."
11
+ gem.summary = "Simple documents, templates and helpers on top of Prawn. In Ruby on Rails."
12
12
  gem.homepage = ""
13
13
 
14
14
  gem.files = `git ls-files`.split($/)
@@ -18,4 +18,7 @@ Gem::Specification.new do |gem|
18
18
 
19
19
  gem.add_dependency "prawn_cocktail", ">=0.4.0"
20
20
  gem.add_dependency "rails"
21
+
22
+ gem.add_development_dependency "rake" # For Travis CI.
23
+ gem.add_development_dependency "pdf-inspector"
21
24
  end
@@ -0,0 +1 @@
1
+ log/*
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env rake
2
+ # Add your own tasks in files placed in lib/tasks ending in .rake,
3
+ # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
4
+
5
+ require File.expand_path('../config/application', __FILE__)
6
+ Dummy::Application.load_tasks
@@ -0,0 +1,3 @@
1
+ class ApplicationController < ActionController::Base
2
+ protect_from_forgery
3
+ end
@@ -0,0 +1,6 @@
1
+ class DummyController < ApplicationController
2
+ def show
3
+ document = TestDocument.new("test")
4
+ send_pdf document
5
+ end
6
+ end
@@ -0,0 +1,5 @@
1
+ module TestDocumentHelper
2
+ def helper_works
3
+ text "Helper works."
4
+ end
5
+ end
@@ -0,0 +1,17 @@
1
+ class TestDocument < PrawnCocktail::Document
2
+ helper TestDocumentHelper
3
+
4
+ def initialize(message)
5
+ @message = message
6
+ end
7
+
8
+ def filename
9
+ "test.pdf"
10
+ end
11
+
12
+ private
13
+
14
+ def data
15
+ { message: @message }
16
+ end
17
+ end
@@ -0,0 +1,6 @@
1
+ meta page_size: "A4"
2
+
3
+ content do |data|
4
+ helper_works
5
+ text "Message: #{data.message}."
6
+ end
@@ -0,0 +1,4 @@
1
+ # This file is used by Rack-based servers to start the application.
2
+
3
+ require ::File.expand_path('../config/environment', __FILE__)
4
+ run Dummy::Application
@@ -0,0 +1,16 @@
1
+ require File.expand_path('../boot', __FILE__)
2
+
3
+ # Pick the frameworks you want:
4
+ require "action_controller/railtie"
5
+ #require "action_mailer/railtie"
6
+ #require "active_resource/railtie"
7
+ #require "sprockets/railtie"
8
+ #require "rails/test_unit/railtie"
9
+
10
+ Bundler.require
11
+ require "prawn_cocktail_rails"
12
+
13
+ module Dummy
14
+ class Application < Rails::Application
15
+ end
16
+ end
@@ -0,0 +1,10 @@
1
+ require 'rubygems'
2
+ gemfile = File.expand_path('../../../../Gemfile', __FILE__)
3
+
4
+ if File.exist?(gemfile)
5
+ ENV['BUNDLE_GEMFILE'] = gemfile
6
+ require 'bundler'
7
+ Bundler.setup
8
+ end
9
+
10
+ $:.unshift File.expand_path('../../../../lib', __FILE__)
@@ -0,0 +1,5 @@
1
+ # Load the rails application
2
+ require File.expand_path('../application', __FILE__)
3
+
4
+ # Initialize the rails application
5
+ Dummy::Application.initialize!
@@ -0,0 +1,37 @@
1
+ Dummy::Application.configure do
2
+ # Settings specified here will take precedence over those in config/application.rb
3
+
4
+ # The test environment is used exclusively to run your application's
5
+ # test suite. You never need to work with it otherwise. Remember that
6
+ # your test database is "scratch space" for the test suite and is wiped
7
+ # and recreated between test runs. Don't rely on the data there!
8
+ config.cache_classes = true
9
+
10
+ # Configure static asset server for tests with Cache-Control for performance
11
+ config.serve_static_assets = true
12
+ config.static_cache_control = "public, max-age=3600"
13
+
14
+ # Log error messages when you accidentally call methods on nil
15
+ config.whiny_nils = true
16
+
17
+ # Show full error reports and disable caching
18
+ config.consider_all_requests_local = true
19
+ config.action_controller.perform_caching = false
20
+
21
+ # Raise exceptions instead of rendering exception templates
22
+ config.action_dispatch.show_exceptions = false
23
+
24
+ # Disable request forgery protection in test environment
25
+ config.action_controller.allow_forgery_protection = false
26
+
27
+ # Tell Action Mailer not to deliver emails to the real world.
28
+ # The :test delivery method accumulates sent emails in the
29
+ # ActionMailer::Base.deliveries array.
30
+ #config.action_mailer.delivery_method = :test
31
+
32
+ # Raise exception on mass assignment protection for Active Record models
33
+ #config.active_record.mass_assignment_sanitizer = :strict
34
+
35
+ # Print deprecation notices to the stderr
36
+ config.active_support.deprecation = :stderr
37
+ end
@@ -0,0 +1,7 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # Your secret key for verifying the integrity of signed cookies.
4
+ # If you change this key, all old signed cookies will become invalid!
5
+ # Make sure the secret is at least 30 characters and all random,
6
+ # no regular words or you'll be exposed to dictionary attacks.
7
+ Dummy::Application.config.secret_token = 'ecc1e4d2f3688465864a194ce713e2a958d94741c8a39741775b5fd5c001fcf279c2f32540d95139f3cb814718a25d36b23de65d8c7d8d5643e5da61ba86e5a9'
@@ -0,0 +1,3 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ Dummy::Application.config.session_store :cookie_store, key: '_dummy_session'
@@ -0,0 +1,5 @@
1
+ # Sample localization file for English. Add more files in this directory for other locales.
2
+ # See https://github.com/svenfuchs/rails-i18n/tree/master/rails%2Flocale for starting points.
3
+
4
+ en:
5
+ hello: "Hello world"
@@ -0,0 +1,3 @@
1
+ Dummy::Application.routes.draw do
2
+ get 'document' => 'dummy#show'
3
+ end
File without changes
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env ruby
2
+ # This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.
3
+
4
+ APP_PATH = File.expand_path('../../config/application', __FILE__)
5
+ require File.expand_path('../../config/boot', __FILE__)
6
+ require 'rails/commands'
@@ -0,0 +1,33 @@
1
+ # Load dummy Rails app.
2
+ ENV["RAILS_ENV"] ||= "test"
3
+ require_relative "dummy/config/environment.rb"
4
+ require "rails/test_help"
5
+
6
+ require "pdf/inspector"
7
+ require "minitest/pride"
8
+
9
+ class IntegrationTest < ActionController::TestCase
10
+ tests DummyController
11
+
12
+ def test_integration
13
+ get :show
14
+ assert_header "Content-Type", "application/pdf"
15
+ assert_header "Content-Disposition", 'attachment; filename="test.pdf"'
16
+ assert_pdf_strings [
17
+ "Helper works.",
18
+ "Message: test."
19
+ ]
20
+ end
21
+ end
22
+
23
+ def assert_header(name, value)
24
+ assert_equal value, response.headers[name]
25
+ end
26
+
27
+ def assert_pdf_strings(strings)
28
+ assert_equal strings, parse_strings(response.body)
29
+ end
30
+
31
+ def parse_strings(pdf_data)
32
+ PDF::Inspector::Text.analyze(pdf_data).strings
33
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: prawn_cocktail_rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-02-23 00:00:00.000000000 Z
12
+ date: 2013-03-02 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: prawn_cocktail
16
- requirement: &70330186124280 !ruby/object:Gem::Requirement
16
+ requirement: &70205053958180 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: 0.4.0
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70330186124280
24
+ version_requirements: *70205053958180
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: rails
27
- requirement: &70330186123660 !ruby/object:Gem::Requirement
27
+ requirement: &70205053957740 !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: *70330186123660
35
+ version_requirements: *70205053957740
36
+ - !ruby/object:Gem::Dependency
37
+ name: rake
38
+ requirement: &70205053957180 !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: *70205053957180
47
+ - !ruby/object:Gem::Dependency
48
+ name: pdf-inspector
49
+ requirement: &70205053956720 !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: *70205053956720
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
@@ -49,6 +72,25 @@ files:
49
72
  - lib/prawn_cocktail_rails/railtie.rb
50
73
  - lib/prawn_cocktail_rails/version.rb
51
74
  - prawn_cocktail.gemspec
75
+ - spec/dummy/.gitignore
76
+ - spec/dummy/Rakefile
77
+ - spec/dummy/app/controllers/application_controller.rb
78
+ - spec/dummy/app/controllers/dummy_controller.rb
79
+ - spec/dummy/app/documents/helpers/test_document_helper.rb
80
+ - spec/dummy/app/documents/test_document.rb
81
+ - spec/dummy/app/views/documents/test_document.pdf.rb
82
+ - spec/dummy/config.ru
83
+ - spec/dummy/config/application.rb
84
+ - spec/dummy/config/boot.rb
85
+ - spec/dummy/config/environment.rb
86
+ - spec/dummy/config/environments/test.rb
87
+ - spec/dummy/config/initializers/secret_token.rb
88
+ - spec/dummy/config/initializers/session_store.rb
89
+ - spec/dummy/config/locales/en.yml
90
+ - spec/dummy/config/routes.rb
91
+ - spec/dummy/lib/assets/.gitkeep
92
+ - spec/dummy/script/rails
93
+ - spec/integration_spec.rb
52
94
  homepage: ''
53
95
  licenses: []
54
96
  post_install_message:
@@ -72,6 +114,25 @@ rubyforge_project:
72
114
  rubygems_version: 1.8.5
73
115
  signing_key:
74
116
  specification_version: 3
75
- summary: PrawnCocktail on Rails.
76
- test_files: []
117
+ summary: Simple documents, templates and helpers on top of Prawn. In Ruby on Rails.
118
+ test_files:
119
+ - spec/dummy/.gitignore
120
+ - spec/dummy/Rakefile
121
+ - spec/dummy/app/controllers/application_controller.rb
122
+ - spec/dummy/app/controllers/dummy_controller.rb
123
+ - spec/dummy/app/documents/helpers/test_document_helper.rb
124
+ - spec/dummy/app/documents/test_document.rb
125
+ - spec/dummy/app/views/documents/test_document.pdf.rb
126
+ - spec/dummy/config.ru
127
+ - spec/dummy/config/application.rb
128
+ - spec/dummy/config/boot.rb
129
+ - spec/dummy/config/environment.rb
130
+ - spec/dummy/config/environments/test.rb
131
+ - spec/dummy/config/initializers/secret_token.rb
132
+ - spec/dummy/config/initializers/session_store.rb
133
+ - spec/dummy/config/locales/en.yml
134
+ - spec/dummy/config/routes.rb
135
+ - spec/dummy/lib/assets/.gitkeep
136
+ - spec/dummy/script/rails
137
+ - spec/integration_spec.rb
77
138
  has_rdoc: